From 1e48e23dad1afa18920c607e33f5715a01f8e516 Mon Sep 17 00:00:00 2001 From: Dmitrii Dolgov <9erthalion6@gmail.com> Date: Mon, 9 Dec 2024 16:51:47 +0100 Subject: [PATCH 1/3] Fix network worker smoke test Don't bother with stopping every process one by one, correct endpoints gathering from logs and test configuration. --- tests/workers/network/smoke.sh | 26 ++++++++++------------ tests/workers/network/workload.client.toml | 4 ++-- tests/workers/network/workload.server.toml | 2 +- 3 files changed, 15 insertions(+), 17 deletions(-) diff --git a/tests/workers/network/smoke.sh b/tests/workers/network/smoke.sh index c984d38..e20f524 100755 --- a/tests/workers/network/smoke.sh +++ b/tests/workers/network/smoke.sh @@ -6,6 +6,7 @@ stop() { echo "$*" 1>&2 ; exit 1; } which bpftrace &>/dev/null || stop "Don't have bpftrace" which bpftool &>/dev/null || stop "Don't have bpftool" which berserker &>/dev/null || stop "Don't have berserker" +which pkill &>/dev/null || stop "Don't have pkill" if [ ! -d "tests/workers/network/" ]; then echo "Can't find test directory. Smoke tests have to be run from the project root directory" @@ -18,9 +19,15 @@ rm -f /tmp/tcpaccept.log # in case if it's still running from a previous run pkill berserker || true +# make berserkers verbose +#export RUST_LOG=trace + +# start the server before bpftrace, to skip first accept +echo "Starting the server..." +berserker tests/workers/network/workload.server.toml &> /tmp/server.log & + echo "Starting bpftrace..." bpftrace tests/workers/network/sys_accept.bt &> /tmp/tcpaccept.log & -export BPFTRACE_PID=$! # let bpftrace attach probes attempts=0 @@ -37,30 +44,21 @@ do sleep 0.5; done -echo "Starting the server..." -berserker tests/workers/network/workload.server.toml &> /tmp/server.log & -export SERVER_PID=$! - echo "Starting the client..." berserker tests/workers/network/workload.client.toml &> /tmp/client.log & -export CLIENT_PID=$! # let it do some work sleep 5; echo "Stopping..." -kill "${CLIENT_PID}" || { echo 'Can't stop the client ; exit 1; } -kill "${SERVER_PID}" || { echo 'Can't stop the server ; exit 1; } -kill "${BPFTRACE_PID}" || { echo 'Can't stop the bpftrace ; exit 1; } +pkill berserker || true +pkill bpftrace || true echo "Verifying the results..." -ENDPOINTS=$(cat /tmp/tcpaccept.log |\ - grep hit |\ - awk '{print $4 " " $5}' |\ - sort | uniq -c | wc -l) +ENDPOINTS=$(cat /tmp/tcpaccept.log | grep hit | wc -l || echo "") if (( $ENDPOINTS > 0 )); then - echo "PASS" + echo "PASS (${ENDPOINTS} seen connections)" rm -f /tmp/server.log rm -f /tmp/client.log diff --git a/tests/workers/network/workload.client.toml b/tests/workers/network/workload.client.toml index 5c03bc0..04c71fd 100644 --- a/tests/workers/network/workload.client.toml +++ b/tests/workers/network/workload.client.toml @@ -5,8 +5,8 @@ workers = 1 [workload] type = "network" server = false -address = [192, 168, 0, 1] +address = [10, 0, 0, 1] target_port = 8081 -arrival_rate = 1000 +arrival_rate = 100 departure_rate = 1 nconnections = 10 diff --git a/tests/workers/network/workload.server.toml b/tests/workers/network/workload.server.toml index 8bd8b2b..c6e8292 100644 --- a/tests/workers/network/workload.server.toml +++ b/tests/workers/network/workload.server.toml @@ -5,7 +5,7 @@ workers = 1 [workload] type = "network" server = true -address = [192, 168, 0, 1] +address = [10, 0, 0, 1] target_port = 8081 arrival_rate = 0.1 departure_rate = 0.1 From 6ca076b37e6d1338e6b7d2afcb14bbcfe3d2cd67 Mon Sep 17 00:00:00 2001 From: Dmitrii Dolgov <9erthalion6@gmail.com> Date: Tue, 10 Dec 2024 10:54:06 +0100 Subject: [PATCH 2/3] Wait until the server has been started --- tests/workers/network/smoke.sh | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tests/workers/network/smoke.sh b/tests/workers/network/smoke.sh index e20f524..b24fdc2 100755 --- a/tests/workers/network/smoke.sh +++ b/tests/workers/network/smoke.sh @@ -26,6 +26,13 @@ pkill berserker || true echo "Starting the server..." berserker tests/workers/network/workload.server.toml &> /tmp/server.log & +# wait until it's accepting connections +while ! echo test | socat stdio tcp4-connect:10.0.0.1:8081 ; +do + echo "Wait for server"; + sleep 0.5; +done + echo "Starting bpftrace..." bpftrace tests/workers/network/sys_accept.bt &> /tmp/tcpaccept.log & From 9543e3682584757b58c1b78416a1b4c7a7007de0 Mon Sep 17 00:00:00 2001 From: Dmitrii Dolgov <9erthalion6@gmail.com> Date: Mon, 16 Dec 2024 10:13:52 +0100 Subject: [PATCH 3/3] Test socat presense Co-authored-by: Olivier Valentin --- tests/workers/network/smoke.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/workers/network/smoke.sh b/tests/workers/network/smoke.sh index b24fdc2..77a8d02 100755 --- a/tests/workers/network/smoke.sh +++ b/tests/workers/network/smoke.sh @@ -7,6 +7,7 @@ which bpftrace &>/dev/null || stop "Don't have bpftrace" which bpftool &>/dev/null || stop "Don't have bpftool" which berserker &>/dev/null || stop "Don't have berserker" which pkill &>/dev/null || stop "Don't have pkill" +which socat &>/dev/null || stop "Don't have socat" if [ ! -d "tests/workers/network/" ]; then echo "Can't find test directory. Smoke tests have to be run from the project root directory"