summaryrefslogtreecommitdiffstats
path: root/test/vpp_iperf.py
diff options
context:
space:
mode:
authorNaveen Joy <najoy@cisco.com>2023-02-02 13:56:59 -0800
committerDave Wallace <dwallacelf@gmail.com>2023-02-10 02:14:44 +0000
commit25b6e44424e3945eb37226d214baf38735730121 (patch)
tree08035aed62d62ddf179ee72ef4359a7a8f47e4f3 /test/vpp_iperf.py
parentffa3f60290499bdacc37a97c49f2e794b5e1f18c (diff)
tests: use iperf3 for running interface tests on the host
Type: improvement Change-Id: I7123591932d51ce0c5b372893454945bbd3913b2 Signed-off-by: Naveen Joy <najoy@cisco.com>
Diffstat (limited to 'test/vpp_iperf.py')
-rw-r--r--test/vpp_iperf.py21
1 files changed, 20 insertions, 1 deletions
diff --git a/test/vpp_iperf.py b/test/vpp_iperf.py
index 42b5ea8a523..8fe0d749a4b 100644
--- a/test/vpp_iperf.py
+++ b/test/vpp_iperf.py
@@ -36,7 +36,7 @@ class VppIperf:
self.server_args = ""
self.logger = logger
# Set the iperf executable
- self.iperf = os.path.join(os.getenv("TEST_DATA_DIR") or "/", "usr/bin/iperf")
+ self.iperf = self.get_iperf()
def ensure_init(self):
if self.server_ns and self.client_ns and self.server_ip:
@@ -46,6 +46,24 @@ class VppIperf:
"Error: Cannot Start." "iPerf object has not been initialized"
)
+ def get_iperf(self):
+ """Return the iperf executable for running tests.
+
+ Look for the iperf executable in the following order
+ 1. ${TEST_DATA_DIR}/usr/bin/iperf # running tests inside the VM
+ 2. /usr/bin/iperf3 # running tests on the host
+ """
+ vm_test_dir = os.getenv("TEST_DATA_DIR", "/tmp/vpp-vm-tests")
+ if os.path.isdir(vm_test_dir):
+ iperf = os.path.join(vm_test_dir, "/usr/bin/iperf")
+ else:
+ iperf = "/usr/bin/iperf3"
+ if os.path.exists(iperf):
+ return iperf
+ else:
+ self.logger.error(f"Could not find an iperf executable for running tests")
+ sys.exit(1)
+
def start_iperf_server(self):
args = [
"ip",
@@ -58,6 +76,7 @@ class VppIperf:
]
args.extend(self.server_args.split())
args = " ".join(args)
+ self.logger.debug(f"Starting iperf server: {args}")
try:
return subprocess.run(
args,