From: David Gibson <david@gibson.dropbear.id.au>
To: passt-dev@passt.top
Subject: [PATCH 4/4] test: Rewrite test_iperf3
Date: Thu, 01 Sep 2022 23:08:05 +1000 [thread overview]
Message-ID: <20220901130805.3938040-5-david@gibson.dropbear.id.au> (raw)
In-Reply-To: <20220901130805.3938040-1-david@gibson.dropbear.id.au>
[-- Attachment #1: Type: text/plain, Size: 4984 bytes --]
test_iperf3() is a pretty inscrutable mess of nested background processes.
It has a number of magic sleeps whose value needs to match the durations of
the tests which are given in the DSL test files.
Rewrite it to be cleaner:
* Use the construct (a & b & wait) to run 'a' and 'b' in parallel, but
then wait for them both to complete before continuing
* This allows us to wait for both the server and client to finish, rather
than having arbitrary sleeps and kills
* Use jq to do all the math we need to get the final result, rather than
jq followed by some complicated 'bc' mangling
Signed-off-by: David Gibson <david(a)gibson.dropbear.id.au>
---
.gitignore | 1 +
test/lib/test | 68 ++++++++++++++++++---------------------------
test/perf/passt_tcp | 4 +--
test/perf/pasta_tcp | 2 +-
4 files changed, 31 insertions(+), 44 deletions(-)
diff --git a/.gitignore b/.gitignore
index 9b17f12..80967f3 100644
--- a/.gitignore
+++ b/.gitignore
@@ -7,4 +7,5 @@
/pasta.1
/seccomp.h
/*.pid
+/s*.json
README.plain.md
diff --git a/test/lib/test b/test/lib/test
index 8eb1ee5..d4357b7 100755
--- a/test/lib/test
+++ b/test/lib/test
@@ -30,54 +30,40 @@ test_iperf3() {
__procs="$((${1} - 1))"; shift
__time="${1}"; shift
- pane_run "${__spane}" 'for i in $(seq 0 '${__procs}'); do' \
- ':> s${i}.bw; done'
+ pane_run "${__spane}" \
+ '(' \
+ ' for i in $(seq 0 '${__procs}'); do' \
+ ' iperf3 -s1J -p'${__port}' -i'${__time} \
+ ' > s${i}.json &' \
+ ' done;' \
+ ' wait' \
+ ')'
+
+ pane_run "${__cpane}" \
+ '(' \
+ ' for i in $(seq 0 '${__procs}'); do' \
+ ' iperf3 -c '${__dest}' -p '${__port} \
+ ' -t'${__time}' -T s${i} '"${@}"' &' \
+ ' done;' \
+ ' wait' \
+ ')'
+
+ pane_status "${__cpane}"
pane_status "${__spane}"
- __udp=0
+ __jval=".end.sum_received.bits_per_second"
for __opt in ${@}; do
- [ "${__opt}" = "-u" ] && __udp=1
+ # UDP test
+ [ "${__opt}" = "-u" ] && __jval=".intervals[0].sum.bits_per_second"
done
- (
- sleep 2
- pane_run "${__cpane}" 'for i in $(seq 0 '${__procs}');' \
- 'do ( iperf3 -c '"${__dest}"' -p '"${__port}" \
- '-t'${__time} "${@}" ' -T s${i} & echo $! > c${i}.pid & ); done'
- sleep $(echo ${__time} + 10 | bc -l)
- pane_run "${__cpane}" 'for i in $(seq 0 '${__procs}'); do'\
- 'kill -INT $(cat c${i}.pid) 2>/dev/null; done'
- ) &
-
- if [ ${__udp} -eq 0 ]; then
- pane_run "${__spane}" 'for i in $(seq 0 '${__procs}');' \
- 'do ( ( iperf3 -s1J -p '"${__port}" \
- '& echo $! > s${i}.pid ) 2>/dev/null' \
- '| jq -rM ".end.sum_received.bits_per_second"' \
- '> s${i}.bw & );' \
- 'done'
- else
- pane_run "${__spane}" 'for i in $(seq 0 '${__procs}');' \
- 'do ( ( iperf3 -s1J -i '${__time}' -p '"${__port}" \
- '& echo $! > s${i}.pid ) 2>/dev/null' \
- '| jq -rM ".intervals[0].sum.bits_per_second"' \
- '> s${i}.bw & );' \
- 'done'
- fi
-
- pane_status "${__spane}"
- sleep $(echo ${__time} + 15 | bc -l)
- pane_run "${__spane}" 'for i in $(seq 0 '${__procs}'); do' \
- 'kill -INT $(cat s${i}.pid) 2>/dev/null; done'
- sleep 4
- pane_wait "${__spane}"
- pane_run "${__spane}" '(cat s*.bw |' \
- 'sed '"'"'s/\(.*\)/\1\+/g'"'"' |' \
- 'tr -d "\n"; echo 0) | bc -l'
+ pane_run "${__spane}" \
+ 'cat s*.json | jq -rMs "map('${__jval}') | add"'
pane_wait "${__spane}"
__bw="$(pane_parse "${__spane}")"
- pane_run "${__spane}" 'for i in $(seq 0 '${__procs}'); do' \
- 'rm -f [cs]${i}.bw [cs]${i}.pid; done'
+
+ pane_run "${__spane}" \
+ 'for i in $(seq 0 '${__procs}'); do rm s${i}.json; done'
pane_status "${__spane}"
TEST_ONE_subs="$(list_add_pair "${TEST_ONE_subs}" "__${__var}__" "${__bw}" )"
diff --git a/test/perf/passt_tcp b/test/perf/passt_tcp
index a960341..45095b6 100644
--- a/test/perf/passt_tcp
+++ b/test/perf/passt_tcp
@@ -11,8 +11,8 @@
# Copyright (c) 2021 Red Hat GmbH
# Author: Stefano Brivio <sbrivio(a)redhat.com>
-gtools sysctl ip jq nproc seq sleep bc iperf3 tcp_rr tcp_crr # From neper
-nstools sysctl ip jq nproc seq sleep bc iperf3 tcp_rr tcp_crr
+gtools sysctl ip jq nproc seq sleep iperf3 tcp_rr tcp_crr # From neper
+nstools sysctl ip jq nproc seq sleep iperf3 tcp_rr tcp_crr
htools bc head sed seq
# In this setup, virtio_net TX queue sometimes hangs, still under investigation
diff --git a/test/perf/pasta_tcp b/test/perf/pasta_tcp
index d607029..fc9e408 100644
--- a/test/perf/pasta_tcp
+++ b/test/perf/pasta_tcp
@@ -12,7 +12,7 @@
# Author: Stefano Brivio <sbrivio(a)redhat.com>
htools head ip seq bc sleep iperf3 tcp_rr tcp_crr jq sed
-nstools sysctl nproc ip seq bc sleep iperf3 tcp_rr tcp_crr jq sed
+nstools sysctl nproc ip seq sleep iperf3 tcp_rr tcp_crr jq sed
test pasta: throughput and latency (local connections)
--
@@ -12,7 +12,7 @@
# Author: Stefano Brivio <sbrivio(a)redhat.com>
htools head ip seq bc sleep iperf3 tcp_rr tcp_crr jq sed
-nstools sysctl nproc ip seq bc sleep iperf3 tcp_rr tcp_crr jq sed
+nstools sysctl nproc ip seq sleep iperf3 tcp_rr tcp_crr jq sed
test pasta: throughput and latency (local connections)
--
2.37.2
prev parent reply other threads:[~2022-09-01 13:08 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-09-01 13:08 [PATCH 0/4] Cleanups to performance tests David Gibson
2022-09-01 13:08 ` [PATCH 1/4] gitignore pidfiles other than passt.pid David Gibson
2022-09-01 13:08 ` [PATCH 2/4] test: Combine iperf3c and iperf3s into a single DSL command David Gibson
2022-09-01 13:08 ` [PATCH 3/4] test: Parameterize run time for throughput performance tests David Gibson
2022-09-01 13:08 ` David Gibson [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220901130805.3938040-5-david@gibson.dropbear.id.au \
--to=david@gibson.dropbear.id.au \
--cc=passt-dev@passt.top \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://passt.top/passt
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for IMAP folder(s).