Skip to content

Commit

Permalink
cleanup: CI tweaks
Browse files Browse the repository at this point in the history
This commit makes a few minor changes to the tests:
- allow the Jenkins tests to fail and continue with the rest of the pipeline;
- run GitHub actions when pull requests are created, in addition to pushes;
- run through all tests in GitHub actions, delaying failure to the end;
- log failed tests to the perform_build GitHub action stage summary;
- move the `testmisc` target to Jenkins for now, until it is fixed;
- flush stdout in assertions to avoid `SIGABRT` losing test output;
- switch to using the public onload repository for GitHub actions;
- improve skipping packetdrill tests for GitHub actions; and
- remove unused valgrind test wrappers.
  • Loading branch information
jfeather-amd committed Apr 24, 2024
1 parent 8f0ee66 commit 105e123
Show file tree
Hide file tree
Showing 6 changed files with 62 additions and 45 deletions.
19 changes: 10 additions & 9 deletions .github/workflows/perform_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@

name: "perform_build"

on: push
on:
push:
pull_request:
types: [opened]

jobs:
extract_branch_info:
Expand All @@ -29,7 +32,6 @@ jobs:
id: tcpdirectBranch
run: echo "branch=$(yq -r '.products.TCPDirect.version' < $GITHUB_WORKSPACE/tcpdirect/versions.yaml)" >> "$GITHUB_OUTPUT"


- name: Extract onload branch name
id: onloadBranch
run: echo "branch=$(yq -r '.products.Onload.version' < $GITHUB_WORKSPACE/tcpdirect/versions.yaml)" >> "$GITHUB_OUTPUT"
Expand All @@ -53,13 +55,13 @@ jobs:
- name: onload checkout
uses: actions/checkout@v4
with:
repository: ${{ github.repository_owner }}/onload_internal
path: onload_internal
ssh-key: ${{ secrets.ONLOAD_INTERNAL_PRIVATE_KEY }}
repository: ${{ github.repository_owner }}/onload
path: onload
ref: ${{ needs.extract_branch_info.outputs.onloadBranch }}

- name: packetdrill checkout
uses: actions/checkout@v4
continue-on-error: true
with:
repository: ${{ github.repository_owner }}/packetdrill-tcpdirect
path: packetdrill-tcpdirect
Expand All @@ -71,18 +73,17 @@ jobs:
sudo apt-get update
sudo apt-get install -y build-essential perl
- name: build
run: |
cd $GITHUB_WORKSPACE/tcpdirect
ONLOAD_TREE=$GITHUB_WORKSPACE/onload_internal NDEBUG=1 make -j $(nproc)
ONLOAD_TREE=$GITHUB_WORKSPACE/onload NDEBUG=1 make -j $(nproc)
- name: shim
run: |
cd $GITHUB_WORKSPACE/tcpdirect
ONLOAD_TREE=$GITHUB_WORKSPACE/onload_internal NDEBUG=1 ZF_DEVEL=1 TEST_THREAD_NAME=zf make -j $(nproc) shim
ONLOAD_TREE=$GITHUB_WORKSPACE/onload NDEBUG=1 ZF_DEVEL=1 TEST_THREAD_NAME=zf make -j $(nproc) shim
- name: tests
run: |
cd $GITHUB_WORKSPACE/tcpdirect
ONLOAD_TREE=$GITHUB_WORKSPACE/onload_internal NDEBUG=1 ZF_DEVEL=1 TEST_THREAD_NAME=zf make -j $(nproc) test
ONLOAD_TREE=$GITHUB_WORKSPACE/onload UT_OUTPUT=$GITHUB_STEP_SUMMARY NDEBUG=1 ZF_DEVEL=1 TEST_THREAD_NAME=zf make -j $(nproc) -k test
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ include src/tests/zf_apps/Makefile.inc
include src/tests/zf_internal/Makefile.inc

# We use packetdrill for some tests, but can cope without it if not present
ifneq ("$(wildcard ../packetdrill-tcpdirect)", "")
ifneq ("$(wildcard ../packetdrill-tcpdirect/Makefile.inc)", "")
include ../packetdrill-tcpdirect/Makefile.inc
endif

Expand Down
7 changes: 5 additions & 2 deletions ci/test.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -159,13 +159,16 @@ nm.slack_notify() {
dir('test-results') { // ensure folder exists
}
// Makefiles do not support gcov build yet
sh """#!/bin/bash
def rc = sh(script: """#!/bin/bash
export CC=${CC}
export ONLOAD_TREE=\$PWD/onload
export ZF_DEVEL=1
export TEST_THREAD_NAME=zf
make -k -C tcpdirect test_jenkins
"""
""", returnStatus: true)
if (rc != 0) {
unstable("not all tests passed")
}
}
},
)
Expand Down
3 changes: 3 additions & 0 deletions src/include/zf_internal/utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ struct zf_pool;
do { \
zf_log(NULL, "FAIL at %s:%d\n", __FILE__, __LINE__); \
zf_backtrace(); \
fflush(stdout); \
abort(); \
} while(0)

Expand Down Expand Up @@ -161,6 +162,7 @@ struct zf_pool;
fprintf(stderr, "ERROR: at %s:%d\n", __FILE__, __LINE__); \
fprintf(stderr, "ERROR: rc=%d errno=%d (%s)\n", \
__rc, errno, strerror(errno)); \
fflush(stdout); \
abort(); \
}; \
if(ZF_UNLIKELY( __rc < 0 )) { \
Expand All @@ -174,6 +176,7 @@ struct zf_pool;
auto __report = [&]() ZF_COLD ZF_NOINLINE { \
fprintf(stderr, "ERROR: %s: ZF_TEST(%s) failed\n", __func__, #x); \
fprintf(stderr, "ERROR: at %s:%d\n", __FILE__, __LINE__); \
fflush(stdout); \
abort(); \
}; \
if(ZF_UNLIKELY( ! (x) )) { \
Expand Down
42 changes: 10 additions & 32 deletions src/tests/zf_unit/Makefile.inc
Original file line number Diff line number Diff line change
Expand Up @@ -171,32 +171,9 @@ $(UT_SCRIPT_BINS): $(UT_BINDIR)/%: $(SRC_CURRENT)/%
# Notably it enforces copying the scripts everytime...
.PHONY: $(UT_SCRIPT_BINS)
$(UT_SCRIPT_BINS): zf_apps $(UT_BINDIR)/zftcppingpong2
ifdef UT_OUTPUT
UT_OUTPUT_DIR = $(UT_OUTPUT)

$(filter-out run_%,$(UT_ALL_TARGETS)): | $(UT_OUTPUT_DIR)

$(UT_OUTPUT_DIR):
mkdir -p $(UT_OUTPUT_DIR)/valgrind
#moved valgrind results to separate folder to avoid junit accesing them
rm -rf $(UT_OUTPUT)/valgrind/*.xml
rm -rf $(UT_OUTPUT)/*.xml
endif # UT_OUTPUT

ifdef VALGRIND
VALGRIND_FLAGS = valgrind --tool=memcheck --read-var-info=yes \
--fair-sched=yes --track-fds=yes --xml=yes \
--xml-file=$(UT_OUTPUT_DIR)/valgrind/$@_%p.xml\
--show-mismatched-frees=yes --trace-children=yes\
--undef-value-errors=yes --track-origins=yes \
--leak-check=full --show-leak-kinds=all
#As these are nightly tests given bit more time to avoid unnecessary timeouts.
HARNESS_TIME_OUT=10800
TEST_TIME_OUT=600
else

HARNESS_TIME_OUT=480
TEST_TIME_OUT=120
endif

$(call target_variants,testloop): $(UT_LOOP:%=$(UT_BINDIR)/%)
$(call target_variants,testloop2): $(UT_LOOP2:%=$(UT_BINDIR)/%)
Expand All @@ -211,7 +188,7 @@ $(call target_variants,testpacketdrill): $(filter %packetdrill.sh,$(UT_SCRIPT_BI

# for phony targets it does not matter whether dependencies are order-only or not
# However order-only dependencies are out of $^ which makes recipes simpler.
ifeq ("$(wildcard ../packetdrill-tcpdirect)", "")
ifeq ("$(wildcard ../packetdrill-tcpdirect/Makefile.inc)", "")
packetdrill: ;
endif
$(call target_explode,testpacketdrill): | shim packetdrill
Expand All @@ -228,22 +205,22 @@ buildattrs = ZF_ATTR="$(subst $(space),;,$(ATTR_LIST))"
$(call target_variants,$(UT_NONSCRIPT_LISTS)):
@echo "Test target: $@"
sudo env $(UT_ENV) $(ENV) $(call buildattrs) \
UT_OUTPUT=$(UT_OUTPUT) TEST_TIME_OUT=$(TEST_TIME_OUT) TEST_TARGET="$@" \
timeout $(HARNESS_TIME_OUT) \
prove --exec \
"timeout $(TEST_TIME_OUT) $(NETNS_SCRIPT) $(VALGRIND_FLAGS)" \
"$(NETNS_SCRIPT)" \
$(PROVE_FLAGS) \
$^ \
$(PROVE_REDIRECT)
$^

$(call target_variants,$(UT_SCRIPT_LISTS)):
@echo "Test target: $@"
sudo env $(UT_ENV) $(ENV) EXTRA_$(call buildattrs) \
UT_OUTPUT=$(UT_OUTPUT) TEST_TIME_OUT=$(TEST_TIME_OUT) \
timeout $(HARNESS_TIME_OUT) \
prove --exec \
"timeout $(TEST_TIME_OUT) $(NETNS_SCRIPT) $(VALGRIND_FLAGS)" \
"$(NETNS_SCRIPT)" \
$(PROVE_FLAGS) \
$^ \
$(PROVE_REDIRECT)
$^


# The targets need to run sequentieally as each uses huge pages and spins on CPUs
Expand All @@ -255,13 +232,14 @@ $(call target_variants,$(UT_SCRIPT_LISTS)):
# see we only use testdelegated_smallmtu
test: testloop \
testloop2_rx-x3 testloop2_x3 \
testloop_vlan testloop_txvi testmisc \
testloop_vlan testloop_txvi \
testb2bsb \
testdelegated_smallmtu \
testb2b testalts testalts_vlan testalts_txvi testpacketdrill

test_jenkins: testjenkins \
testscript_x3 \
testmisc \
testscript


Expand Down
34 changes: 33 additions & 1 deletion src/tests/zf_unit/netns.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,36 @@ echo 4096 > /proc/sys/vm/nr_hugepages
ifconfig lo up
shift

exec "$@"
output="$(timeout ${TEST_TIME_OUT:-120} $@)"
rc="$?"
echo "$output"
if [ "$rc" -ne 0 -a -n "$UT_OUTPUT" ]; then
if [ ! -f "$UT_OUTPUT" ]; then
output_dir="$(dirname $UT_OUTPUT)"
if [ -n "$output_dir" -a ! -d "$output_dir" ]; then
mkdir -p "$output_dir"
fi
touch "$UT_OUTPUT"
fi

echo "# Failed \`$(basename $@)\` in \`$TEST_TARGET\`" >> "$UT_OUTPUT"
if [ "$rc" -eq 124 ]; then
echo "Test timed out (rc=$rc)." >> "$UT_OUTPUT"
else
echo "Test returned $rc." >> "$UT_OUTPUT"
fi

echo "## Suggested Reproducer" >> "$UT_OUTPUT"
echo "\`\`\`" >> "$UT_OUTPUT"
echo "sudo env EF_VI_CTPIO_MODE=$EF_VI_CTPIO_MODE \\" >> "$UT_OUTPUT"
echo " ZF_ATTR=\"$ZF_ATTR\" \\" >> "$UT_OUTPUT"
echo " EXTRA_ZF_ATTR=\"$EXTRA_ZF_ATTR\" \\" >> "$UT_OUTPUT"
echo " $@" >> "$UT_OUTPUT"
echo "\`\`\`" >> "$UT_OUTPUT"

echo "## Test Log" >> "$UT_OUTPUT"
echo "\`\`\`" >> "$UT_OUTPUT"
echo "$output" >> "$UT_OUTPUT"
echo "\`\`\`" >> "$UT_OUTPUT"
fi
exit 0

0 comments on commit 105e123

Please sign in to comment.