forked from named-data/ndnd
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrunner.py
More file actions
75 lines (61 loc) · 1.91 KB
/
runner.py
File metadata and controls
75 lines (61 loc) · 1.91 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
import random
import os
import subprocess
import time
from pathlib import Path
from types import FunctionType
from mininet.log import setLogLevel, info
from minindn.minindn import Minindn
from minindn.util import MiniNDNCLI
import test_001
import test_002
import test_003
import test_004
import test_005
import test_006
def ensure_local_ndnd() -> None:
repo_root = Path(__file__).resolve().parent.parent
local_bin = repo_root / ".bin"
local_ndnd = local_bin / "ndnd"
local_bin.mkdir(parents=True, exist_ok=True)
if not local_ndnd.exists():
info("Building local ndnd binary for E2E scenarios\n")
subprocess.check_call(
["go", "build", "-o", str(local_ndnd), "./cmd/ndnd"],
cwd=repo_root,
)
os.environ["PATH"] = f"{local_bin}:{os.environ.get('PATH', '')}"
def run(scenario: FunctionType, **kwargs) -> None:
try:
random.seed(0)
info(f"===================================================\n")
start = time.time()
scenario(ndn, **kwargs)
info(f'Scenario completed in: {time.time()-start:.2f}s\n')
info(f"===================================================\n\n")
# MiniNDNCLI(ndn.net)
# Call all cleanups without stopping the network
# This ensures we don't recreate the network for each test
for cleanup in reversed(ndn.cleanups):
cleanup()
except Exception as e:
ndn.stop()
raise e
finally:
# kill everything we started just in case ...
os.system('pkill -9 ndnd')
os.system('pkill -9 nfd')
if __name__ == '__main__':
setLogLevel('info')
ensure_local_ndnd()
Minindn.cleanUp()
Minindn.verifyDependencies()
ndn = Minindn()
ndn.start()
run(test_001.scenario)
run(test_002.scenario)
run(test_003.scenario)
run(test_004.scenario)
run(test_005.scenario)
run(test_006.scenario)
ndn.stop()