Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix network worker smoke test #33

Merged
merged 3 commits into from
Dec 16, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 19 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"
erthalion marked this conversation as resolved.
Show resolved Hide resolved

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,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 &
Comment on lines +26 to +28
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nit] Launching in background ('&') does not guarantee the server will have completed initialization before bpftrace is started. This would require that berserker decides when to daemonize to give back control.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point, I'll add some mechanisms to make sure it's fully initialized.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And it's there.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not what I had imagined, but it is simple and should work. Thanks !


# 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
Expand All @@ -37,30 +51,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
Loading