diff --git a/tests/workers/network/smoke.sh b/tests/workers/network/smoke.sh index c984d38..77a8d02 100755 --- a/tests/workers/network/smoke.sh +++ b/tests/workers/network/smoke.sh @@ -6,6 +6,8 @@ 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" +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" @@ -18,9 +20,22 @@ 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 & + +# 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 & -export BPFTRACE_PID=$! # let bpftrace attach probes attempts=0 @@ -37,30 +52,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