selftests: rds: refactor and expand rds selftests test
Subsystems (5)
Allison Henderson
maintainercover selftests: rds: refactor and expand rds selftests test
Hi all,
This series aims to improve the current rds selftests. The first patch refactors the existing test.py such that the networking set up can be reused as general purpose infrastructure for other tests. The existing send and receive code is hoisted into a separate rds_basic.py. The next patch adds a new rds_stress.py that exercises RDS via the external rds-stress tool from the rds-tools package if it is available on the host. We add two new flags to test.py, -b and -s to select rds_basic or rds_stress respectively. The intent is to make the RDS selftests more modular and extensible. Let me know what you all think.
Questions, comments, suggestions appreciated!
Thanks!
Allison
v1:
- fixed pylint warnings
Allison Henderson (2):
selftests: rds: Refactor test.py
selftests: rds: Add rds_stress.py
tools/testing/selftests/net/rds/Makefile | 2 + tools/testing/selftests/net/rds/rds_basic.py | 183 +++++++++++++++++ tools/testing/selftests/net/rds/rds_stress.py | 58 ++++++ tools/testing/selftests/net/rds/run.sh | 42 +++- tools/testing/selftests/net/rds/test.py | 184 +++--------------- 5 files changed, 308 insertions(+), 161 deletions(-) create mode 100755 tools/testing/selftests/net/rds/rds_basic.py create mode 100644 tools/testing/selftests/net/rds/rds_stress.py
Signature · 1 line
2.43.0
Allison Henderson
maintainerPATCH 1/2 selftests: rds: Refactor test.py
From: Allison Henderson <[email protected]>
This patch hoists the send and recv logic from test.py into a helper module rds_basic.py, keeping the namespace and networking configurations in the calling test.py script. This will allow us to reuse the test.py infrastructure to add additional rds tests. No functional changes are added in this initial refactor.
--- tools/testing/selftests/net/rds/Makefile | 1 + tools/testing/selftests/net/rds/rds_basic.py | 183 +++++++++++++++++++ tools/testing/selftests/net/rds/test.py | 169 +---------------- 3 files changed, 191 insertions(+), 162 deletions(-)
tools/testing/selftests/net/rds/Makefile +1 -0
@@ -8,6 +8,7 @@ TEST_PROGS := run.sh TEST_FILES := \ include.sh \ test.py \ + rds_basic.py \ # end of TEST_FILES EXTRA_CLEAN := \
tools/testing/selftests/net/rds/rds_basic.py new file +183 -0
183 lines not on this page · raw message
tools/testing/selftests/net/rds/test.py +7 -162
208 lines not on this page · raw message
Signature · 1 line
2.43.0
Allison Henderson
maintainerPATCH 2/2 selftests: rds: Add rds_stress.py
In reply to Allison HendersonFrom: Allison Henderson <[email protected]>
This patch adds a new rds stress test to the rds selftests suite. rds_stress is available through the rds-tools package, and can be run in the selftests infrastructure if it is installed on the host. We also add new test flags --rds_stress and --rds_basic to the calling test.py script to run one or both of the tests.
--- tools/testing/selftests/net/rds/Makefile | 1 + tools/testing/selftests/net/rds/rds_stress.py | 58 +++++++++++++++++++ tools/testing/selftests/net/rds/run.sh | 42 ++++++++++++-- tools/testing/selftests/net/rds/test.py | 27 ++++++++- 4 files changed, 123 insertions(+), 5 deletions(-)
tools/testing/selftests/net/rds/Makefile +1 -0
@@ -9,6 +9,7 @@ TEST_FILES := \ include.sh \ test.py \ rds_basic.py \ + rds_stress.py \ # end of TEST_FILES EXTRA_CLEAN := \
tools/testing/selftests/net/rds/rds_stress.py new file +58 -0
58 lines not on this page · raw message
tools/testing/selftests/net/rds/run.sh +38 -4
68 lines not on this page · raw message
tools/testing/selftests/net/rds/test.py +26 -1
@@ -9,6 +9,7 @@ import sys from pwd import getpwuid from os import stat import rds_basic +import rds_stress # Allow utils module to be imported from different directory this_dir = os.path.dirname(os.path.realpath(__file__))
@@ -21,6 +22,20 @@ net1 = 'net1' veth0 = 'veth0' veth1 = 'veth1' +def increment_ports(addrs, inc): + """Increment port numbers in the addrs list by inc. + Use between tests to make the port numbers unique + + addrs: list of (ip, port) tuples + inc: int + """ + new_addrs = [] + + for addr, port in addrs: + new_addrs.append((addr, port + inc)) + + return new_addrs + def signal_handler(sig, frame): print('Test timed out') sys.exit(1)
@@ -31,6 +46,10 @@ parser = argparse.ArgumentParser(description="init script args", formatter_class=argparse.ArgumentDefaultsHelpFormatter) parser.add_argument("-d", "--logdir", action="store", help="directory to store logs", default="/tmp") +parser.add_argument("-b", "--rds_basic", action="store_true", + help="Run rds basic tests") +parser.add_argument("-s", "--rds_stress", action="store_true", + help="Run rds stress tests") parser.add_argument('--timeout', help="timeout to terminate hung test", type=int, default=0) parser.add_argument('-l', '--loss', help="Simulate tcp packet loss",
@@ -102,7 +121,13 @@ env = { 'netns': [net0, net1], } -ret = rds_basic.run_test(env) +ret = 0 +if args.rds_basic: + ret = rds_basic.run_test(env) + +if ret == 0 and args.rds_stress: + env['addrs'] = increment_ports(env['addrs'], 1000) + ret = rds_stress.run_test(env) print("Stopping network packet captures") subprocess.check_call(['killall', '-q', 'tcpdump'])
Signature · 1 line
2.43.0
Jakub Kicinski
maintainerQuoted 11 lines · On Sun, 1 Mar 2026 22:55:16 -0700 Allison Henderson wrote:
This series aims to improve the current rds selftests. The first patch refactors the existing
test.pysuch that the networking set up can be reused as general purpose infrastructure for other tests. The existing send and receive code is hoisted into a separaterds_basic.py. The next patch adds a newrds_stress.pythat exercises RDS via the external rds-stress tool from the rds-tools package if it is available on the host. We add two new flags totest.py, -b and -s to selectrds_basicorrds_stressrespectively. The intent is to make the RDS selftests more modular and extensible. Let me know what you all think.Questions, comments, suggestions appreciated!
IDK Allison. I tried to integrate the remaining tests with Netdev CI this weekend. The two groups of networking tests which can't be run like all the other selftests are vsock and RDS. I get vsock being different. vsock is used to communicate between VMs and host, setting up the vms with the locally built kernel makes it different.
But I'm not exactly sure what makes RDS different. Would you mind explaining the challenges with fitting RDS into the ksft framework?
Quoted 13 lines · Jakub Kicinski
Quoted 11 lines · On Sun, 1 Mar 2026 22:55:16 -0700 Allison Henderson wrote:
This series aims to improve the current rds selftests. The first patch refactors the existing
test.pysuch that the networking set up can be reused as general purpose infrastructure for other tests. The existing send and receive code is hoisted into a separaterds_basic.py. The next patch adds a newrds_stress.pythat exercises RDS via the external rds-stress tool from the rds-tools package if it is available on the host. We add two new flags totest.py, -b and -s to selectrds_basicorrds_stressrespectively. The intent is to make the RDS selftests more modular and extensible. Let me know what you all think.Questions, comments, suggestions appreciated!
Quoted 8 lines
IDK Allison. I tried to integrate the remaining tests with Netdev CI this weekend. The two groups of networking tests which can't be run like all the other selftests are vsock and RDS. I get vsock being different. vsock is used to communicate between VMs and host, setting up the vms with the locally built kernel makes it different.
But I'm not exactly sure what makes RDS different. Would you mind explaining the challenges with fitting RDS into the ksft framework?
Hi Jakub,
I didnt know it was causing you grief, but I am happy to work with you to adapt it. RDS is a little unique in that the network topology defines the underlying transport it uses. If you were to run it with just a pair of veth interfaces on a single host or vm, then you will only be using the loop back transport in rds.ko. In order to get it to load and test rds_tcp.ko, we need the endpoints to be in separate network namespaces so that the destination IP isn't seen as local. So the test case does this by forking server/client processes across name spaces. There really isnt a rush on this series, so if you think we should do some refactoring/cleanup for ksft first that is fine. Let me know your thoughts.
Thanks,
Allison
Jakub Kicinski
maintainerQuoted 11 lines · On Wed, 4 Mar 2026 02:50:34 +0000 Allison Henderson wrote:
I didnt know it was causing you grief, but I am happy to work with you to adapt it. RDS is a little unique in that the network topology defines the underlying transport it uses. If you were to run it with just a pair of veth interfaces on a single host or vm, then you will only be using the loop back transport in rds.ko. In order to get it to load and test rds_tcp.ko, we need the endpoints to be in separate network namespaces so that the destination IP isn't seen as local. So the test case does this by forking server/client processes across name spaces. There really isnt a rush on this series, so if you think we should do some refactoring/cleanup for ksft first that is fine. Let me know your thoughts.
IIUC the need to set up a veth + 2 name spaces topology is very common. We have bash "libraries" / helpers in various lib.sh files to do it. Python libs also have some support (tho the default linking there is by pairing two netdevsim devices).
Well, maybe to be clear I should say that we _even_ have support in libraries for this. Not really strongly opposed to you rolling your own way of setting up the namespaces at this point. I primarily care about us being able to execute all your tests in our CI, with standard ksft commands. Maybe I did something wrong but
make -C tools/testing/selftests TARGETS=net/rds run_tests
did not work for me.
Quoted 24 lines · Jakub Kicinski
Quoted 11 lines · On Wed, 4 Mar 2026 02:50:34 +0000 Allison Henderson wrote:
I didnt know it was causing you grief, but I am happy to work with you to adapt it. RDS is a little unique in that the network topology defines the underlying transport it uses. If you were to run it with just a pair of veth interfaces on a single host or vm, then you will only be using the loop back transport in rds.ko. In order to get it to load and test rds_tcp.ko, we need the endpoints to be in separate network namespaces so that the destination IP isn't seen as local. So the test case does this by forking server/client processes across name spaces. There really isnt a rush on this series, so if you think we should do some refactoring/cleanup for ksft first that is fine. Let me know your thoughts.
IIUC the need to set up a veth + 2 name spaces topology is very common. We have bash "libraries" / helpers in various
lib.shfiles to do it. Python libs also have some support (tho the default linking there is by pairing two netdevsim devices).Well, maybe to be clear I should say that we _even_ have support in libraries for this. Not really strongly opposed to you rolling your own way of setting up the namespaces at this point. I primarily care about us being able to execute all your tests in our CI, with standard ksft commands. Maybe I did something wrong but
Quoted 3 lines
make -C
tools/testing/selftestsTARGETS=net/rdsrun_testsdid not work for me.
Sure, lets get this fixed first then. Usually when I run the test, I just run the one rds test directly like this:
vng --build --config .config; vng -v --rwdir ./ --run . --user root --cpus 16 -- "export PYTHONPATH=tools/testing/selftests/net/; tools/testing/selftests/net/rds/run.sh" 2>&1 | tee outfile.txt;
I believe the way you run it would have it run directly on the host though. Which can work but it would have to be built and configured correctly for rds. Also I think when run it through make run_tests, ksft may have other lib includes that get inherited by the child processes which can affect how they run. But I'd like to see your output to confirm. Could you include the output you are seeing? Then I'll see if I can recreate and address what you're seeing on my end.
Thank you!
Allison
Jakub Kicinski
maintainerQuoted 31 lines · On Fri, 6 Mar 2026 07:43:56 +0000 Allison Henderson wrote:
Quoted 24 lines · Jakub Kicinski
Quoted 11 lines · On Wed, 4 Mar 2026 02:50:34 +0000 Allison Henderson wrote:
I didnt know it was causing you grief, but I am happy to work with you to adapt it. RDS is a little unique in that the network topology defines the underlying transport it uses. If you were to run it with just a pair of veth interfaces on a single host or vm, then you will only be using the loop back transport in rds.ko. In order to get it to load and test rds_tcp.ko, we need the endpoints to be in separate network namespaces so that the destination IP isn't seen as local. So the test case does this by forking server/client processes across name spaces. There really isnt a rush on this series, so if you think we should do some refactoring/cleanup for ksft first that is fine. Let me know your thoughts.
IIUC the need to set up a veth + 2 name spaces topology is very common. We have bash "libraries" / helpers in various
lib.shfiles to do it. Python libs also have some support (tho the default linking there is by pairing two netdevsim devices).Well, maybe to be clear I should say that we _even_ have support in libraries for this. Not really strongly opposed to you rolling your own way of setting up the namespaces at this point. I primarily care about us being able to execute all your tests in our CI, with standard ksft commands. Maybe I did something wrong but
Quoted 3 lines
make -C
tools/testing/selftestsTARGETS=net/rdsrun_testsdid not work for me.
Sure, lets get this fixed first then. Usually when I run the test, I just run the one rds test directly like this:
Quoted 8 lines
vng --build --config .config; vng -v --rwdir ./ --run . --user root --cpus 16 -- "export PYTHONPATH=tools/testing/selftests/net/;
tools/testing/selftests/net/rds/run.sh" 2>&1 | tee outfile.txt;I believe the way you run it would have it run directly on the host though. Which can work but it would have to be built and configured correctly for rds. Also I think when run it through make
run_tests, ksft may have other lib includes that get inherited by the child processes which can affect how they run. But I'd like to see your output to confirm. Could you include the output you are seeing? Then I'll see if I can recreate and address what you're seeing on my end.
This is how we run:
https://github.com/linux-netdev/nipa/wiki/How-to-run-netdev-selftests-CI-style
Base system is Fedora 43 (since we use vng that's what the "VM" is effectively also using). Please re-ask the questions that are still relevant after you go thru the link above? I'm not sure what "run directly on the host" means exactly ;)