forked from includeos/IncludeOS
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.py
More file actions
executable file
·62 lines (46 loc) · 1.62 KB
/
test.py
File metadata and controls
executable file
·62 lines (46 loc) · 1.62 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
#!/usr/bin/env python3
from __future__ import print_function
from future import standard_library
standard_library.install_aliases()
from builtins import str
import sys
import os
import subprocess
import _thread
import time
thread_timeout = 60
from vmrunner import vmrunner
iperf_cmd = "iperf3"
transmit_size = "100M"
nsname="server1"
def move_tap1(o):
subprocess.call(["./setup.sh", "--vmsetup"])
def clean():
subprocess.call(["sudo","pkill",iperf_cmd])
subprocess.call(["./setup.sh", "--clean"])
def iperf_server():
subprocess.Popen(["sudo","ip","netns","exec", nsname, iperf_cmd, "-s"],
stdout = subprocess.PIPE,
stdin = subprocess.PIPE,
stderr = subprocess.PIPE)
def iperf_client(o):
print("Starting iperf client. Iperf output: ")
print(subprocess.check_output([iperf_cmd,"-c","10.42.42.2","-n", transmit_size], timeout=thread_timeout))
vmrunner.vms[0].exit(0, "Test completed without errors")
return True
#clean anything hangig after a crash.. from previous test
subprocess.call(["./setup.sh", "--clean"])
subprocess.call("./setup.sh")
vm = vmrunner.vms[0]
# Move second interface to second bridge, right after boot
vm.on_output("Routing test", move_tap1)
# Start iperf server right away, client when vm is up
_thread.start_new_thread(iperf_server, ())
vm.on_output("Service ready", iperf_client)
# Clean
vm.on_exit(clean)
if len(sys.argv) > 1:
vm.boot(image_name=str(sys.argv[1]))
else:
# Boot the VM, taking a timeout as parameter
vm.boot(thread_timeout,image_name='net_router.elf.bin')