aboutgitcodebugslistschat
path: root/test/lib/test
diff options
context:
space:
mode:
authorDavid Gibson <david@gibson.dropbear.id.au>2022-09-02 12:04:32 +1000
committerStefano Brivio <sbrivio@redhat.com>2022-09-07 11:01:22 +0200
commit5c13b511d9e97ae24cfa7bb87a1e23648c8d8249 (patch)
treef75b5548081a6158796b6e045fdfab7c37137272 /test/lib/test
parent55679a16af441344eacc95ae8d5e952aae2313b0 (diff)
downloadpasst-5c13b511d9e97ae24cfa7bb87a1e23648c8d8249.tar
passt-5c13b511d9e97ae24cfa7bb87a1e23648c8d8249.tar.gz
passt-5c13b511d9e97ae24cfa7bb87a1e23648c8d8249.tar.bz2
passt-5c13b511d9e97ae24cfa7bb87a1e23648c8d8249.tar.lz
passt-5c13b511d9e97ae24cfa7bb87a1e23648c8d8249.tar.xz
passt-5c13b511d9e97ae24cfa7bb87a1e23648c8d8249.tar.zst
passt-5c13b511d9e97ae24cfa7bb87a1e23648c8d8249.zip
test: Combine iperf3c and iperf3s into a single DSL command
These two commands in the DSL to run an iperf client and server are always used together, and some of the parameters must match between them. The iperf3s must also be run more or less immediately after iperf3c, since iperf3c will run a client in the background after a sleep and requires a server to be running before it will work. A bunch of things can be made cleaner if we make a single DSL command that runs both sides of the test. For now make the combined command work exactly like the two commands together did, warts and all. This does lose the ability for the DSL scripts to give additional options to the iperf3 server, but we weren't using that anyway. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Diffstat (limited to 'test/lib/test')
-rwxr-xr-xtest/lib/test90
1 files changed, 43 insertions, 47 deletions
diff --git a/test/lib/test b/test/lib/test
index e5a8632..600399b 100755
--- a/test/lib/test
+++ b/test/lib/test
@@ -13,74 +13,73 @@
# Copyright (c) 2021 Red Hat GmbH
# Author: Stefano Brivio <sbrivio@redhat.com>
-# test_iperf3() - Ugly helper for iperf3c/iperf3s directives
-# $1: Role: client or server
-# $2: Pane name, can be lowercase
-# $3: Destination name or address for client
-# $4: Port number, ${i} is translated to process index
-# $5: Number of processes to run in parallel
-# $@: Options
+# test_iperf3() - Ugly helper for iperf3 directive
+# $1: Variable name: to put the measure bandwidth into
+# $2: Source/client pane name, can be lowercase
+# $3: Destination/server pane name, can be lowercase
+# $4: Destination name or address for client
+# $5: Port number, ${i} is translated to process index
+# $6: Number of processes to run in parallel
+# $@: Client options
test_iperf3() {
- __role="${1}"; shift
- __pane="$(echo "${1}" | tr [a-z] [A-Z])"; shift
- [ "${__role}" = "client" ] && __dest="${1}" && shift || __dest=""
+ __var="${1}"; shift
+ __cpane="$(echo "${1}" | tr [a-z] [A-Z])"; shift
+ __spane="$(echo "${1}" | tr [a-z] [A-Z])"; shift
+ __dest="${1}"; shift
__port="${1}"; shift
__procs="$((${1} - 1))"; shift
- [ "${__role}" = "server" ] && __role_opt="-c" || __role_opt="-s1J"
+ pane_run "${__spane}" 'for i in $(seq 0 '${__procs}'); do' \
+ ':> s${i}.bw; done'
+ pane_status "${__spane}"
+
+ __udp=0
+ for __opt in ${@}; do
+ [ "${__opt}" = "-u" ] && __udp=1
+ done
- if [ ${__role} = "client" ]; then
- UDP_CLIENT=0
- for __opt in ${@}; do
- [ "${__opt}" = "-u" ] && UDP_CLIENT=1
- done
-
- (
+ (
sleep 2
- pane_run "${__pane}" 'for i in $(seq 0 '${__procs}');' \
- 'do ( iperf3 -c '"${__dest}"' -p '"${__port}" \
- "${@}" ' -T s${i} & echo $! > c${i}.pid & ); done'
+ pane_run "${__cpane}" 'for i in $(seq 0 '${__procs}');' \
+ 'do ( iperf3 -c '"${__dest}"' -p '"${__port}" \
+ "${@}" ' -T s${i} & echo $! > c${i}.pid & ); done'
sleep 40
- pane_run "${__pane}" 'for i in $(seq 0 '${__procs}'); do'\
+ pane_run "${__cpane}" 'for i in $(seq 0 '${__procs}'); do'\
'kill -INT $(cat c${i}.pid) 2>/dev/null; done'
- ) &
- return
- fi
+ ) &
- pane_run "${__pane}" 'for i in $(seq 0 '${__procs}'); do' \
- ':> s${i}.bw; done'
- pane_status "${__pane}"
-
- if [ ${UDP_CLIENT} -eq 0 ]; then
- pane_run "${__pane}" 'for i in $(seq 0 '${__procs}');' \
- 'do ( ( iperf3 -s1J -p '"${__port} ${@}" \
+ 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 "${__pane}" 'for i in $(seq 0 '${__procs}');' \
- 'do ( ( iperf3 -s1J -i 30 -p '"${__port} ${@}" \
+ pane_run "${__spane}" 'for i in $(seq 0 '${__procs}');' \
+ 'do ( ( iperf3 -s1J -i 30 -p '"${__port}" \
'& echo $! > s${i}.pid ) 2>/dev/null' \
'| jq -rM ".intervals[0].sum.bits_per_second"' \
'> s${i}.bw & );' \
'done'
fi
- pane_status "${__pane}"
+ pane_status "${__spane}"
sleep 45
- pane_run "${__pane}" 'for i in $(seq 0 '${__procs}'); do' \
+ pane_run "${__spane}" 'for i in $(seq 0 '${__procs}'); do' \
'kill -INT $(cat s${i}.pid) 2>/dev/null; done'
sleep 4
- pane_wait "${__pane}"
- pane_run "${__pane}" '(cat s*.bw |' \
+ pane_wait "${__spane}"
+ pane_run "${__spane}" '(cat s*.bw |' \
'sed '"'"'s/\(.*\)/\1\+/g'"'"' |' \
'tr -d "\n"; echo 0) | bc -l'
- pane_wait "${__pane}"
- pane_parse "${__pane}"
- pane_run "${__pane}" 'for i in $(seq 0 '${__procs}'); do' \
+ 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_status "${__pane}"
+ pane_status "${__spane}"
+
+ TEST_ONE_subs="$(list_add_pair "${TEST_ONE_subs}" "__${__var}__" "${__bw}" )"
}
test_one_line() {
@@ -323,11 +322,8 @@ test_one_line() {
"lat")
table_value_latency ${__arg} || TEST_ONE_perf_nok=1
;;
- "iperf3c")
- test_iperf3 client ${__arg}
- ;;
- "iperf3s")
- TEST_ONE_subs="$(list_add_pair "${TEST_ONE_subs}" "__${__arg%% *}__" "$(test_iperf3 server ${__arg#* })" )"
+ "iperf3")
+ test_iperf3 ${__arg}
;;
"set")
TEST_ONE_subs="$(list_add_pair "${TEST_ONE_subs}" "__${__arg%% *}__" "${__arg#* }")"