Skip to content

Commit 38effb3

Browse files
committed
tests_hw: Introduce networking tests for bu585
Includes new basic test group for testing ocre container network passthrough on hardware. The test plan is the confirm the webserver-complex container works and is able to successfully increment the counter. This should show that the container is able to send and receive packets successfully. These tests are implemented alongside other supervisor tests in the workflow. Signed-off-by: Matthew Gee <mgee@iol.unh.edu>
1 parent 740519f commit 38effb3

6 files changed

Lines changed: 157 additions & 4 deletions

File tree

.github/workflows/hardware-bu585.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ jobs:
247247
- name: Build and Flash Supervisor
248248
run: |
249249
. /opt/zephyr-venv/bin/activate
250-
west build -p always -b b_u585i_iot02a ocre-runtime/src/samples/supervisor/zephyr -- "-DOCRE_SDK_PRELOADED_IMAGES=hello-world.wasm"
250+
west build -p always -b b_u585i_iot02a --shield wiznet_w5500 ocre-runtime/src/samples/supervisor/zephyr -- "-DOCRE_SDK_PRELOADED_IMAGES=hello-world.wasm;webserver-complex.wasm"
251251
west flash --extload=/usr/local/STMicroelectronics/STM32Cube/STM32CubeProgrammer/bin/ExternalLoader/MX25LM51245G_STM32U585I-IOT02A.stldr --hex-file build/zephyr/merged.hex
252252
253253
supervisor-test-set-1:
@@ -260,6 +260,8 @@ jobs:
260260
test:
261261
- name: Hello-World
262262
group: supervisor-helloWorld
263+
- name: Webserver-Complex
264+
group: supervisor-webserverComplex
263265

264266
steps:
265267
- name: Checkout
@@ -269,6 +271,6 @@ jobs:
269271
run: |
270272
cd tests_hw && bash beginTests.sh ${{ matrix.test.group }}
271273
272-
- name: Print Hello-World Test Case Logs
274+
- name: Print ${{ matrix.test.name }} Testcase Logs
273275
if: always()
274276
run: cat /tmp/${{ matrix.test.group }}.log
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#!/usr/bin/env python3
2+
# @copyright Copyright (c) contributors to Project Ocre,
3+
# which has been established as Project Ocre a Series of LF Projects, LLC
4+
#
5+
# SPDX-License-Identifier: Apache-2.0
6+
7+
import sys
8+
sys.path.append("../..")
9+
10+
import testlib # noqa: E402
11+
import pexpect # noqa: E402
12+
import time # noqa: E402
13+
14+
15+
def main():
16+
serial_conn, pex = testlib.setup('/dev/ttyACM0')
17+
18+
print("Cleaning up container webserver-complex")
19+
serial_conn.send_break()
20+
expect_index = pex.expect(["ocre:~$", pexpect.TIMEOUT], 30)
21+
if (expect_index == 1):
22+
print("Zephyr runtime failed to come back up after a break")
23+
testlib.full_exit(serial_conn, 1)
24+
25+
pex.write(b'net iface\n')
26+
runtime_output = bytes(pex.before).decode(errors='ignore')
27+
if ("DHCP preferred" not in runtime_output): # Listed under IPv4 address if one exists
28+
pex.write(b'net dhcpv4 client start 1\n')
29+
time.sleep(5)
30+
31+
testlib.format_runtime_output(runtime_output, "Cleanup")
32+
testlib.full_exit(serial_conn, 0)
33+
34+
35+
if __name__ == "__main__":
36+
main()
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
{
2+
"name": "Supervisor Sample - Webserver Complex",
3+
"description": "Test webserver complex container on within the supervisor sample",
4+
"setup": [
5+
{
6+
"name": "Create Webserver Complex Container",
7+
"exec": "./setup.py"
8+
}
9+
],
10+
"test_suites": [
11+
{
12+
"name": "Test Container Output and Connectivity",
13+
"description": "Reads output from container to make sure it successfully ran",
14+
"test_cases": [
15+
{
16+
"name": "Check Runtime Webserver Complex",
17+
"exec": "./testcase.py"
18+
}
19+
]
20+
}
21+
],
22+
"cleanup": [
23+
{
24+
"name": "Remove Webserver Complex Container",
25+
"exec": "./clean.py"
26+
}
27+
]
28+
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
#!/usr/bin/env python3
2+
# @copyright Copyright (c) contributors to Project Ocre,
3+
# which has been established as Project Ocre a Series of LF Projects, LLC
4+
#
5+
# SPDX-License-Identifier: Apache-2.0
6+
7+
import sys
8+
sys.path.append("../..")
9+
10+
import testlib # noqa: E402
11+
import pexpect # noqa: E402
12+
13+
14+
def main():
15+
serial_conn, pex = testlib.setup('/dev/ttyACM0')
16+
17+
print("Creating container on board off of webserver-complex.wasm")
18+
pex.write(
19+
b'ocre run -n webserver-complex -k ocre:api -k networking webserver-complex.wasm\n')
20+
expect_index = pex.expect(["Minimal resource usage", pexpect.TIMEOUT], 30)
21+
runtime_output = bytes(pex.before).decode(errors='ignore')
22+
runtime_output += bytes(pex.after).decode(errors='ignore')
23+
24+
if (expect_index == 1):
25+
print("Container failed to create container in given timeout")
26+
serial_conn.send_break()
27+
testlib.format_runtime_output(runtime_output, "Failed")
28+
testlib.full_exit(serial_conn, 1)
29+
30+
if ("Failed to create container" in runtime_output) or ("Server Status: ONLINE" not in runtime_output):
31+
print("Failed to create container")
32+
testlib.format_runtime_output(runtime_output, "Failed")
33+
testlib.full_exit(serial_conn, 1)
34+
35+
testlib.format_runtime_output(runtime_output, "Setup")
36+
testlib.full_exit(serial_conn, 0)
37+
38+
39+
if __name__ == "__main__":
40+
main()
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
#!/usr/bin/env python3
2+
# @copyright Copyright (c) contributors to Project Ocre,
3+
# which has been established as Project Ocre a Series of LF Projects, LLC
4+
#
5+
# SPDX-License-Identifier: Apache-2.0
6+
7+
import sys
8+
sys.path.append("../..")
9+
10+
import requests # noqa: E402
11+
import testlib # noqa: E402
12+
13+
"""
14+
This testcase is to be used following the flashing of the supervisor sample to a board with the hello-world container put up.
15+
16+
The testcase forms a serial connection to the board, runs the hello-world container
17+
and checks the string "powered by Ocre" appears in the output of the container.
18+
"""
19+
20+
21+
def main():
22+
http_response1 = requests.get(f'{testlib.bu585_base_url}/api/counter')
23+
24+
if (http_response1.status_code != 200):
25+
print(f"Unable to reach container webserver, got status code {\
26+
http_response1.status_code}")
27+
28+
sys.exit(1)
29+
30+
requests.get(f'{testlib.bu585_base_url}/increment')
31+
http_response2 = requests.get(f'{testlib.bu585_base_url}/inapi/counter')
32+
33+
if (http_response2 != 200):
34+
print(f"Unable to reach container webserver, got status code {\
35+
http_response2.status_code}")
36+
sys.exit(1)
37+
38+
if (http_response2.json().get('counter') < http_response1.json().get('counter')):
39+
print(f"Remote server did not increment counter correctly, went from {\
40+
http_response1.json().get('counter')} to {http_response2.json().get('counter')}")
41+
sys.exit(1)
42+
43+
sys.exit(0)
44+
45+
46+
if __name__ == "__main__":
47+
main()

tests_hw/testlib.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,21 +10,21 @@
1010
from typing import Tuple
1111

1212
shell_prompt = "ocre:~$"
13+
bu585_base_url = "http://ocre-b-u585i.lfedge.iol.unh.edu:8000"
1314

1415

1516
def setup(device_filepath: str) -> Tuple[serial.Serial, pexpect.fdpexpect.fdspawn]:
1617
conn = serial.Serial(device_filepath, 115200, timeout=10)
1718
conn.reset_input_buffer()
1819
conn.reset_output_buffer()
19-
conn.flush()
2020
pex = pexpect.fdpexpect.fdspawn(conn.fileno())
21+
2122
return (conn, pex)
2223

2324

2425
def full_exit(conn: serial.Serial, status: int):
2526
conn.reset_input_buffer()
2627
conn.reset_output_buffer()
27-
conn.flush()
2828
conn.close()
2929
sys.exit(status)
3030

0 commit comments

Comments
 (0)