Skip to contentSkip to conversation

selftests: mptcp: add time per subtests in TAP output

PATCH In review Matthieu Baerts (NGI0) 3 participants 7 messages Aug 21, 2024 – Aug 24, 2024

Subsystems (3)
lore
Share & tools
lore

Matthieu Baerts (NGI0)

author maintainer
#0 lore raw

cover selftests: mptcp: add time per subtests in TAP output

Patches here add 'time=<N>ms' in the diagnostic data of the TAP output, e.g.

ok 1 - pm_netlink: defaults addr list # time=9ms

This addition is useful to quickly identify which subtests are taking a longer time than the others, or more than expected.

---
Matthieu Baerts (NGI0) (3):
selftests: mptcp: lib: add time per subtests in TAP output
sefltests: mptcp: connect: remote time in TAP output
selftests: mptcp: reset the last TS before the first test

 tools/testing/selftests/net/mptcp/mptcp_connect.sh |  3 ++-
 tools/testing/selftests/net/mptcp/mptcp_join.sh    |  3 ++-
 tools/testing/selftests/net/mptcp/mptcp_lib.sh     | 17 ++++++++++++++++-
 tools/testing/selftests/net/mptcp/mptcp_sockopt.sh |  1 +
 tools/testing/selftests/net/mptcp/pm_netlink.sh    |  2 ++
 tools/testing/selftests/net/mptcp/simult_flows.sh  |  1 +
 tools/testing/selftests/net/mptcp/userspace_pm.sh  |  1 +
 7 files changed, 25 insertions(+), 3 deletions(-)

---
base-commit: 624d90dc5dcaee846a57aa0985789623f7c64f2e
change-id: 20240821-mptcp-ksft-time-db492f4ec4da

Best regards,

Signature · 1 line
Matthieu Baerts (NGI0) <[email protected]>
author maintainer
#1 lore raw

PATCH 1/3 selftests: mptcp: lib: add time per subtests in TAP output

It adds 'time=<N>ms' in the diagnostic data of the TAP output, e.g.

ok 1 - pm_netlink: defaults addr list # time=9ms

This addition is useful to quickly identify which subtests are taking a longer time than the others, or more than expected.

Note that there are no specific formats to follow to show this time according to the TAP 13 [1], TAP 14 [2] and KTAP [3] specifications. Let's then define this one here.

---
 tools/testing/selftests/net/mptcp/mptcp_lib.sh | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)
tools/testing/selftests/net/mptcp/mptcp_lib.sh +16 -1
index 438280e68434..871720da04c4 100644
@@ -25,6 +25,7 @@ declare -rx MPTCP_LIB_AF_INET6=10
 MPTCP_LIB_SUBTESTS=()
 MPTCP_LIB_SUBTESTS_DUPLICATED=0
 MPTCP_LIB_SUBTEST_FLAKY=0
+MPTCP_LIB_SUBTESTS_LAST_TS_MS=
 MPTCP_LIB_TEST_COUNTER=0
 MPTCP_LIB_TEST_FORMAT="%02u %-50s"
 MPTCP_LIB_IP_MPTCP=0
@@ -201,6 +202,11 @@ mptcp_lib_kversion_ge() {
 	mptcp_lib_fail_if_expected_feature "kernel version ${1} lower than ${v}"
 }
 
+mptcp_lib_subtests_last_ts_reset() {
+	MPTCP_LIB_SUBTESTS_LAST_TS_MS="$(date +%s%3N)"
+}
+mptcp_lib_subtests_last_ts_reset
+
 __mptcp_lib_result_check_duplicated() {
 	local subtest
 
@@ -215,13 +221,22 @@ __mptcp_lib_result_check_duplicated() {
 
 __mptcp_lib_result_add() {
 	local result="${1}"
+	local time="time="
+	local ts_prev_ms
 	shift
 
 	local id=$((${#MPTCP_LIB_SUBTESTS[@]} + 1))
 
 	__mptcp_lib_result_check_duplicated "${*}"
 
-	MPTCP_LIB_SUBTESTS+=("${result} ${id} - ${KSFT_TEST}: ${*}")
+	# not to add two '#'
+	[[ "${*}" != *"#"* ]] && time="# ${time}"
+
+	ts_prev_ms="${MPTCP_LIB_SUBTESTS_LAST_TS_MS}"
+	mptcp_lib_subtests_last_ts_reset
+	time+="$((MPTCP_LIB_SUBTESTS_LAST_TS_MS - ts_prev_ms))ms"
+
+	MPTCP_LIB_SUBTESTS+=("${result} ${id} - ${KSFT_TEST}: ${*} ${time}")
 }
 
 # $1: test name
Signature · 1 line
2.45.2
author maintainer
#2 lore raw

PATCH 2/3 sefltests: mptcp: connect: remote time in TAP output

In reply to Matthieu Baerts (NGI0)

It is now added by the MPTCP lib automatically, see the parent commit.

The time in the TAP output might be sligly different from the one displayed before, but that's OK.

---
 tools/testing/selftests/net/mptcp/mptcp_connect.sh | 1 -
 1 file changed, 1 deletion(-)
tools/testing/selftests/net/mptcp/mptcp_connect.sh +0 -1
index b77fb7065bfb..f61e2f5870ea 100755
@@ -431,7 +431,6 @@ do_transfer()
 
 	local duration
 	duration=$((stop-start))
-	result_msg+=" # time=${duration}ms"
 	printf "(duration %05sms) " "${duration}"
 	if [ ${rets} -ne 0 ] || [ ${retc} -ne 0 ]; then
 		mptcp_lib_pr_fail "client exit code $retc, server $rets"
Signature · 1 line
2.45.2
author maintainer
#3 lore raw

PATCH 3/3 selftests: mptcp: reset the last TS before the first test

In reply to Matthieu Baerts (NGI0)

Just to slightly improve the precision of the duration of the first test.

In mptcp_join.sh, the last append_prev_results is now done as soon as the last test is over: this will add the last result in the list, and get a more precise time for this last test.

---
 tools/testing/selftests/net/mptcp/mptcp_connect.sh | 2 ++
 tools/testing/selftests/net/mptcp/mptcp_join.sh    | 3 ++-
 tools/testing/selftests/net/mptcp/mptcp_sockopt.sh | 1 +
 tools/testing/selftests/net/mptcp/pm_netlink.sh    | 2 ++
 tools/testing/selftests/net/mptcp/simult_flows.sh  | 1 +
 tools/testing/selftests/net/mptcp/userspace_pm.sh  | 1 +
 6 files changed, 9 insertions(+), 1 deletion(-)
tools/testing/selftests/net/mptcp/mptcp_connect.sh +2 -0
index f61e2f5870ea..49d90c4dbc01 100755
@@ -847,6 +847,8 @@ stop_if_error()
 make_file "$cin" "client"
 make_file "$sin" "server"
 
+mptcp_lib_subtests_last_ts_reset
+
 check_mptcp_disabled
 
 stop_if_error "The kernel configuration is not valid for MPTCP"
tools/testing/selftests/net/mptcp/mptcp_join.sh +2 -1
index dc089bba113f..24d74054b0c1 100755
@@ -3868,9 +3868,11 @@ if [ ${#tests[@]} -eq 0 ]; then
 	tests=("${all_tests_names[@]}")
 fi
 
+mptcp_lib_subtests_last_ts_reset
 for subtests in "${tests[@]}"; do
 	"${subtests}"
 done
+append_prev_results
 
 if [ ${ret} -ne 0 ]; then
 	echo
@@ -3881,7 +3883,6 @@ if [ ${ret} -ne 0 ]; then
 	echo
 fi
 
-append_prev_results
 mptcp_lib_result_print_all_tap
 
 exit $ret
tools/testing/selftests/net/mptcp/mptcp_sockopt.sh +1 -0
index 68899a303a1a..5e8d5b83e2d0 100755
@@ -349,6 +349,7 @@ init
 make_file "$cin" "client" 1
 make_file "$sin" "server" 1
 trap cleanup EXIT
+mptcp_lib_subtests_last_ts_reset
 
 run_tests $ns1 $ns2 10.0.1.1
 run_tests $ns1 $ns2 dead:beef:1::1
tools/testing/selftests/net/mptcp/pm_netlink.sh +2 -0
index 2757378b1b13..2e6648a2b2c0 100755
@@ -137,6 +137,8 @@ check()
 	fi
 }
 
+mptcp_lib_subtests_last_ts_reset
+
 check "show_endpoints" "" "defaults addr list"
 
 default_limits="$(get_limits)"
tools/testing/selftests/net/mptcp/simult_flows.sh +1 -0
index f74e1c3c126d..8fa77c8e9b65 100755
@@ -286,6 +286,7 @@ while getopts "bcdhi" option;do
 done
 
 setup
+mptcp_lib_subtests_last_ts_reset
 run_test 10 10 0 0 "balanced bwidth"
 run_test 10 10 1 25 "balanced bwidth with unbalanced delay"
 
tools/testing/selftests/net/mptcp/userspace_pm.sh +1 -0
index 9cb05978269d..3651f73451cf 100755
@@ -150,6 +150,7 @@ mptcp_lib_events "${ns2}" "${client_evts}" client_evts_pid
 server_evts=$(mktemp)
 mptcp_lib_events "${ns1}" "${server_evts}" server_evts_pid
 sleep 0.5
+mptcp_lib_subtests_last_ts_reset
 
 print_title "Init"
 print_test "Created network namespaces ns1, ns2"
Signature · 1 line
2.45.2
#4 lore raw
In reply to Matthieu Baerts (NGI0)

Hi Matthieu,

Thank you for your modifications, that's great!

Our CI did some validations and here is its report:

- KVM Validation: normal: Success! ✅
- KVM Validation: debug: Success! ✅
- KVM Validation: btf (only bpftest_all): Success! ✅
- Task: https://github.com/multipath-tcp/mptcp_net-next/actions/runs/10489178247

Initiator: Patchew Applier
Commits: https://github.com/multipath-tcp/mptcp_net-next/commits/e69c1c7d48b1
Patchwork: https://patchwork.kernel.org/project/mptcp/list/?series=881720

If there are some issues, you can reproduce them using the same environment as the one used by the CI thanks to a docker image, e.g.:

    $ cd [kernel source code]
    $ docker run -v "${PWD}:${PWD}:rw" -w "${PWD}" --privileged --rm -it \
        --pull always mptcp/mptcp-upstream-virtme-docker:latest \
        auto-normal

For more details:

https://github.com/multipath-tcp/mptcp-upstream-virtme-docker

Please note that despite all the efforts that have been already done to have a stable tests suite when executed on a public CI like here, it is possible some reported issues are not due to your modifications. Still, do not hesitate to help us improve that ;-)

Cheers,
MPTCP GH Action bot
Bot operated by Matthieu Baerts (NGI0 Core)

maintainer Reviewed-by on the v1 series
#5 lore raw
In reply to Matthieu Baerts (NGI0)
Quoted 8 lines · On Wed, 21 Aug 2024, Matthieu Baerts (NGI0) wrote:

Patches here add 'time=<N>ms' in the diagnostic data of the TAP output, e.g.

ok 1 - pm_netlink: defaults addr list # time=9ms

This addition is useful to quickly identify which subtests are taking a longer time than the others, or more than expected.

Quoted 7 lines

---
Matthieu Baerts (NGI0) (3):
selftests: mptcp: lib: add time per subtests in TAP output
sefltests: mptcp: connect: remote time in TAP output
selftests: mptcp: reset the last TS before the first test

Matthieu -

Series LGTM, thanks!

author maintainer
#6 lore raw

Hi Mat,

Quoted 18 lines · Mat Martineau
Quoted 8 lines · On Wed, 21 Aug 2024, Matthieu Baerts (NGI0) wrote:

Patches here add 'time=<N>ms' in the diagnostic data of the TAP output, e.g.

 ok 1 - pm_netlink: defaults addr list # time=9ms

This addition is useful to quickly identify which subtests are taking a longer time than the others, or more than expected.

Quoted 7 lines

---
Matthieu Baerts (NGI0) (3):
     selftests: mptcp: lib: add time per subtests in TAP output
     sefltests: mptcp: connect: remote time in TAP output
     selftests: mptcp: reset the last TS before the first test

Quoted 5 lines

Matthieu -

Series LGTM, thanks!

Thank you for the review!

New patches for t/upstream:
- 61eb92f67b13: selftests: mptcp: lib: add time per subtests in TAP output
- 301490f2d642: sefltests: mptcp: connect: remote time in TAP output
- 789ba8f8b57f: selftests: mptcp: reset the last TS before the first test
- Results: c94cd4e2e8ed..6b5502abeca5 (export)

Tests are now in progress:

- export:
https://github.com/multipath-tcp/mptcp_net-next/commit/9038dda10acf21b8021574e26927de82080d8394/checks

Cheers,
Matt

Signature · 1 line
Sponsored by the NGI0 Core fund.