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
·69 lines (58 loc) · 1.83 KB
/
test.py
File metadata and controls
executable file
·69 lines (58 loc) · 1.83 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
#!/usr/bin/env python3
from __future__ import print_function
from future import standard_library
standard_library.install_aliases()
from builtins import str
import os
import signal
import sys
import subprocess
import _thread
import time
import atexit
includeos_src = os.environ.get('INCLUDEOS_SRC',
os.path.realpath(os.path.join(os.getcwd(), os.path.dirname(__file__))).split('/test')[0])
sys.path.insert(0,includeos_src)
from vmrunner import vmrunner
import requests
expected_string = "#" * 1024 * 1024 * 50
def validateRequest(addr):
response = requests.get('https://10.0.0.68:443', verify=False, timeout=5)
#print len(response.content)
return (response.content) == str(addr) + expected_string
# start nodeJS
pro = subprocess.Popen(["node", "server.js"], stdout=subprocess.PIPE)
requests_completed = False
def startBenchmark(line):
print("<test.py> starting test ")
assert validateRequest(6001)
assert validateRequest(6002)
assert validateRequest(6003)
assert validateRequest(6004)
assert validateRequest(6001)
assert validateRequest(6002)
assert validateRequest(6003)
assert validateRequest(6004)
print("Waiting for TCP MSL end...")
global requests_completed
requests_completed = True
return True
def mslEnded(line):
if requests_completed:
vm._on_success("SUCCESS")
return True
@atexit.register
def cleanup():
print("<test.py> Stopping node server")
# stop nodeJS
pro.kill()
# Get an auto-created VM from the vmrunner
vm = vmrunner.vms[0]
# Add custom event for testing server
vm.on_output("MicroLB ready for test", startBenchmark)
vm.on_output("TCP MSL ended", mslEnded)
if len(sys.argv) > 1:
vm.boot(image_name=str(sys.argv[1]))
else:
# Boot the VM, taking a timeout as parameter
vm.boot(20,image_name='net_microLB.elf.bin')