Browse Source

Recreate bench network after calibration to clear NAT and conntrack state

master
evgeny 1 day ago
parent
commit
5084670820
  1. 5
      tests/stream_netns/network.py
  2. 9
      tests/stream_netns/run.py

5
tests/stream_netns/network.py

@ -57,13 +57,14 @@ class Network:
self.namespaces = {}
self.children = []
self.serial = 0
self.log = (self.directory / "network.jsonl").open("w", buffering=1)
self.log = (self.directory / "network.jsonl").open("a", buffering=1)
def command(self, name, arguments, *, input=None, check=True):
prefix = self.prefix(name)
started = time.monotonic()
result = subprocess.run(prefix + list(arguments), input=input, text=True, capture_output=True, timeout=20)
self.log.write(json.dumps({"time": started, "namespace": name, "argv": list(arguments),
inode = self.namespaces[name][1] if name else self.controller
self.log.write(json.dumps({"time": started, "namespace": name, "inode": inode, "argv": list(arguments),
"rc": result.returncode, "stdout": result.stdout, "stderr": result.stderr}) + "\n")
if check and result.returncode:
raise RuntimeError(f"{name}: {' '.join(arguments)}: {result.stderr.strip() or result.stdout.strip()}")

9
tests/stream_netns/run.py

@ -49,7 +49,7 @@ def inside(args):
try:
print("Creating 25 isolated network namespaces (16 nodes, 3 routers, 6 NAT gateways)", flush=True)
network.build()
network.snapshot("initial")
network.snapshot("calibration-initial")
print("Calibrating WAN RTT and all 10 NAT clients", flush=True)
probes.start()
calibration = probes.calibrate()
@ -59,6 +59,13 @@ def inside(args):
if args.network_only:
result["pass"] = True
else:
# Пробы не оставляют открытых mappings/conntrack для настоящих процессов uTun.
network.snapshot("calibrated")
network.close()
print("Recreating network with empty NAT mappings and conntrack", flush=True)
network = Network(directory, args.seed, args.host_netns)
network.build()
network.snapshot("initial")
scenario = Scenario(network, args)
result = scenario.run()
except BaseException as error:

Loading…
Cancel
Save