[PATCH mptcp-next 4/4] selftests: mptcp: join: add io thread tests

Geliang Tang posted 4 patches 3 months ago
[PATCH mptcp-next 4/4] selftests: mptcp: join: add io thread tests
Posted by Geliang Tang 3 months ago
From: Geliang Tang <tanggeliang@kylinos.cn>

This io thread mode is used in BPF selftests bpf_tcp_ca and MPTCP, and
it is not very stable for MPTCP sched tests. This patch adds them into
mptcp_join tests (-T) to make sure this scene is also covered.

These tests only run in ns1 for 100 times. The failed output looks like:

 001 io thread tests
 recv 2884500 expected 10485760
 send 8005500 expected 10485760
 Failed in thread_ret -11
 Test no. 12 failed.
       syn                        [FAIL] got 12 JOIN[s] syn expected 100
       synack                     [ OK ]
       ack                        [FAIL] got 12 JOIN[s] ack expected 100

Signed-off-by: Geliang Tang <tanggeliang@kylinos.cn>
---
 .../testing/selftests/net/mptcp/mptcp_join.sh | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/tools/testing/selftests/net/mptcp/mptcp_join.sh b/tools/testing/selftests/net/mptcp/mptcp_join.sh
index 01c1e0871aca..ecba07aac776 100755
--- a/tools/testing/selftests/net/mptcp/mptcp_join.sh
+++ b/tools/testing/selftests/net/mptcp/mptcp_join.sh
@@ -3663,6 +3663,24 @@ endpoint_tests()
 	fi
 }
 
+io_thread_tests()
+{
+	if reset "io thread tests"; then
+		local nr=0 max=100
+		mptcp_lib_pm_nl_set_limits $ns1 8 8
+		mptcp_lib_pm_nl_add_endpoint $ns1 10.0.2.1 flags subflow
+		while [ $nr -lt $max ]; do
+			nr=$((nr + 1))
+			ip netns exec $ns1 ./mptcp_connect -l 10.0.1.1 -m "thread" -O 3000
+			if [ $? -ne 0 ]; then
+				echo "Test no. $nr failed."
+				break;
+			fi
+		done
+		chk_join_nr $max 0 $max
+	fi
+}
+
 # [$1: error message]
 usage()
 {
@@ -3711,6 +3729,7 @@ all_tests_sorted=(
 	F@fail_tests
 	u@userspace_tests
 	I@endpoint_tests
+	T@io_thread_tests
 )
 
 all_tests_args=""
-- 
2.43.0
Re: [PATCH mptcp-next 4/4] selftests: mptcp: join: add io thread tests
Posted by Matthieu Baerts 3 months ago
Hi Geliang,

On 01/08/2024 11:21, Geliang Tang wrote:
> From: Geliang Tang <tanggeliang@kylinos.cn>
> 
> This io thread mode is used in BPF selftests bpf_tcp_ca and MPTCP, and
> it is not very stable for MPTCP sched tests. This patch adds them into
> mptcp_join tests (-T) to make sure this scene is also covered.

Do you need to have multiple subflows to reproduce the issue? Can we not
have this test in mptcp_connect.sh instead?

For example, would it help to modify the CI to run:

  ./mptcp_connect.sh -m thread


> 
> These tests only run in ns1 for 100 times. The failed output looks like:
> 
>  001 io thread tests
>  recv 2884500 expected 10485760
>  send 8005500 expected 10485760
>  Failed in thread_ret -11
>  Test no. 12 failed.
>        syn                        [FAIL] got 12 JOIN[s] syn expected 100
>        synack                     [ OK ]
>        ack                        [FAIL] got 12 JOIN[s] ack expected 100
> 
> Signed-off-by: Geliang Tang <tanggeliang@kylinos.cn>
> ---
>  .../testing/selftests/net/mptcp/mptcp_join.sh | 19 +++++++++++++++++++
>  1 file changed, 19 insertions(+)
> 
> diff --git a/tools/testing/selftests/net/mptcp/mptcp_join.sh b/tools/testing/selftests/net/mptcp/mptcp_join.sh
> index 01c1e0871aca..ecba07aac776 100755
> --- a/tools/testing/selftests/net/mptcp/mptcp_join.sh
> +++ b/tools/testing/selftests/net/mptcp/mptcp_join.sh
> @@ -3663,6 +3663,24 @@ endpoint_tests()
>  	fi
>  }
>  
> +io_thread_tests()
> +{
> +	if reset "io thread tests"; then
> +		local nr=0 max=100
> +		mptcp_lib_pm_nl_set_limits $ns1 8 8
> +		mptcp_lib_pm_nl_add_endpoint $ns1 10.0.2.1 flags subflow
> +		while [ $nr -lt $max ]; do
> +			nr=$((nr + 1))
> +			ip netns exec $ns1 ./mptcp_connect -l 10.0.1.1 -m "thread" -O 3000

When you read this, it doesn't look obvious it is going to send and
receive data with itself. Can we not have a client and server? If not,
at least an explicit option, not making '-m "thread"' doing that.

> +			if [ $? -ne 0 ]; then

Shellcheck will not like that I guess:

  if ! ip netns exec (...); then

> +				echo "Test no. $nr failed."
> +				break;
> +			fi
> +		done
> +		chk_join_nr $max 0 $max
> +	fi
> +}
> +
>  # [$1: error message]
>  usage()
>  {
> @@ -3711,6 +3729,7 @@ all_tests_sorted=(
>  	F@fail_tests
>  	u@userspace_tests
>  	I@endpoint_tests
> +	T@io_thread_tests
>  )
>  
>  all_tests_args=""

Cheers,
Matt
-- 
Sponsored by the NGI0 Core fund.