Skip to content

Commit

Permalink
Fix network worker smoke test
Browse files Browse the repository at this point in the history
Don't bother with stopping every process one by one, correct
endpoints gathering from logs and test configuration.
  • Loading branch information
erthalion committed Dec 9, 2024
1 parent 7db7f65 commit 1e48e23
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 17 deletions.
26 changes: 12 additions & 14 deletions tests/workers/network/smoke.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions tests/workers/network/workload.client.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion tests/workers/network/workload.server.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 1e48e23

Please sign in to comment.