Skip to content

Commit a4c9bea

Browse files
committed
Tc
1 parent 3647804 commit a4c9bea

File tree

2 files changed

+27
-21
lines changed

2 files changed

+27
-21
lines changed

test/cni/Makefile

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ _check_perf_gso:
107107
$(QUIET) echo "Adjusting GSO (DISABLE_GSO=$(DISABLE_GSO))..."
108108
$(QUIET) $(MAKE) _adjust_gso
109109
$(QUIET) echo "Launching $(CMD) tests..."
110-
$(QUIET) DISABLE_GSO=$(DISABLE_GSO) DEBUG=1 NETNS=client python3 perf/check_perf.py $(CMD)
110+
$(QUIET) DISABLE_GSO=$(DISABLE_GSO) DEBUG=1 NETNS=client sudo -E python3 perf/check_perf.py $(CMD)
111111

112112
_gen_perf_reports:
113113
$(QUIET) python3 perf/gen_report.py .$(REPORT)_report_nogso.json "$(REPORT) tests (TSO/GSO=off)"
@@ -140,13 +140,19 @@ check_perf_iperf: _wait_up _wait_running
140140
$(QUIET) $(MAKE) _deploy
141141
$(QUIET) $(MAKE) _gen_perf_reports REPORT=iperf
142142

143-
_check_perf_mtu:
144-
$(QUIET) echo "Adjusting GSO (DISABLE_GSO=$(DISABLE_GSO))..."
145-
$(QUIET) $(MAKE) _adjust_gso
146-
$(QUIET) echo "Launching iperf tests..."
147-
$(QUIET) sudo ip netns exec client wget DISABLE_GSO=$(DISABLE_GSO) DEBUG=1 NETNS=client python3 perf/check_perf.py
148-
149143
check_perf_requests: _wait_up _wait_running
144+
$(QUIET) echo "Checking perf with GSO..."
145+
$(QUIET) DISABLE_GSO=0 $(MAKE) _check_perf_gso CMD=requests
146+
$(QUIET) echo "Checking perf without GSO..."
147+
$(QUIET) DISABLE_GSO=1 $(MAKE) _check_perf_gso CMD=requests
148+
$(QUIET) echo "Unloading NDEBUG sfunnel in NS..."
149+
$(QUIET) $(MAKE) _unload
150+
$(QUIET) echo "Loading DEBUG sfunnel in NS..."
151+
$(QUIET) $(MAKE) _load
152+
$(QUIET) echo "Restoring nginx..."
153+
$(QUIET) $(MAKE) _deploy
154+
$(QUIET) $(MAKE) _gen_perf_reports REPORT=requests
155+
exit 11
150156
$(QUIET) echo "Unloading DEBUG sfunnel in NS..."
151157
$(QUIET) $(MAKE) _unload
152158
$(QUIET) echo "Loading NDEBUG sfunnel in NS..."
@@ -167,14 +173,3 @@ check_perf_requests: _wait_up _wait_running
167173
done;
168174
$(QUIET) echo "Workaround lingering old conntrack (metallb/kubeproxy bug?)..."
169175
$(QUIET) for NODE in $$(minikube node list | awk '{print $$1}'); do minikube ssh -n $${NODE} "sudo conntrack -F"; done;
170-
$(QUIET) echo "Checking perf with GSO..."
171-
$(QUIET) DISABLE_GSO=0 $(MAKE) _check_perf_gso CMD=wget
172-
$(QUIET) echo "Checking perf without GSO..."
173-
$(QUIET) DISABLE_GSO=1 $(MAKE) _check_perf_gso CMD=wget
174-
$(QUIET) echo "Unloading NDEBUG sfunnel in NS..."
175-
$(QUIET) $(MAKE) _unload
176-
$(QUIET) echo "Loading DEBUG sfunnel in NS..."
177-
$(QUIET) $(MAKE) _load
178-
$(QUIET) echo "Restoring nginx..."
179-
$(QUIET) $(MAKE) _deploy
180-
$(QUIET) $(MAKE) _gen_perf_reports REPORT=wget

test/cni/perf/check_perf.py

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,19 @@
11
import argparse
22
import json
33
import os
4+
from pyroute2 import netns
45
import re
56
import requests
67
import subprocess
78
import sys
89
import time
910

11+
def set_ns():
12+
ns_name = os.getenv('NETNS')
13+
if not ns_name:
14+
return
15+
netns.setns(ns_name)
16+
1017
def get_lb_ip():
1118
return subprocess.getoutput(
1219
"minikube kubectl -- get service my-loadbalancer-service -o jsonpath='{.status.loadBalancer.ingress[0].ip}'"
@@ -25,8 +32,6 @@ def check_perf_iperf(test_name, fqdn, results, target_ports, src_ips=[]):
2532
debug = int(os.getenv('DEBUG', 0)) == 1
2633
mss = 1500 - 40 - 20 #IP+TCP overhead + funneling TCP overhead
2734
CMD = f"iperf --mss {mss} -f m"
28-
if os.getenv('NETNS'):
29-
CMD = f"sudo ip netns exec {os.getenv('NETNS')} " + CMD
3035
total_throughput = 0
3136
print(f"[{test_name}] Starting {N_WORKERS} workers against '{fqdn}' with target_ports='{target_ports}', src_ips='{src_ips}'")
3237

@@ -64,12 +69,15 @@ def check_perf_iperf(test_name, fqdn, results, target_ports, src_ips=[]):
6469

6570
def check_perf_requests(test_name, fqdn, results, port):
6671
fqdn = "http://"+fqdn+":"+str(port)+"/testfile.bin"
72+
73+
print(f"{fqdn}")
74+
6775
start = time.time()
6876
r = requests.get(fqdn, stream=True)
6977
total = sum(len(chunk) for chunk in r.iter_content(8192))
7078
elapsed = time.time() - start
71-
throughput = (total * 8) / 1e6 / elapsed
7279

80+
throughput = (total * 8) / 1e6 / elapsed
7381
results[test_name] = {
7482
'number_of_workers': 1,
7583
'total_throughput': throughput,
@@ -87,6 +95,9 @@ def main():
8795
LB_IP = get_lb_ip()
8896
results = {}
8997

98+
# Enter the right NS first
99+
set_ns()
100+
90101
if args.command == "iperf":
91102
results = check_perf_iperf("test_port_80 (calibration)", LB_IP, results, [80])
92103
results = check_perf_iperf("test_port_8080", LB_IP, results, [8080])

0 commit comments

Comments
 (0)