From c90e35bcb96bae04a9ae9b4663bc5b5237b89a97 Mon Sep 17 00:00:00 2001 From: Albrecht Lohofener Date: Wed, 2 Oct 2024 20:45:54 +0200 Subject: [PATCH] Add LAN_IF=host test, some minor fixes --- test/requirements.txt | 2 +- test/tests/openwrt_docker_test.py | 24 +++++++++--------------- 2 files changed, 10 insertions(+), 16 deletions(-) diff --git a/test/requirements.txt b/test/requirements.txt index 8b16ed7..64c80d8 100644 --- a/test/requirements.txt +++ b/test/requirements.txt @@ -4,4 +4,4 @@ pytest-docker requests[security] pyyaml pytest-html -paramiko \ No newline at end of file +paramiko[all] \ No newline at end of file diff --git a/test/tests/openwrt_docker_test.py b/test/tests/openwrt_docker_test.py index 85bd244..7aa55a9 100644 --- a/test/tests/openwrt_docker_test.py +++ b/test/tests/openwrt_docker_test.py @@ -236,8 +236,8 @@ def test_openwrt_booted(docker_services): @pytest.mark.parametrize("parameter", - [('LAN_IF','veth'),('LAN_IF','ens5'),('LAN_IF','')], indirect=True, - ids=['LAN_IF=veth', 'LAN_IF=ens5', 'LAN_IF=""']) + [('LAN_IF','veth'),('LAN_IF','ens5'),('LAN_IF',''),('LAN_IF','host')], indirect=True, + ids=['LAN_IF=veth', 'LAN_IF=ens5', 'LAN_IF=""', 'LAN_IF="host"']) def test_openwrt_lan(docker_services, parameter): wait_for_openwrt_startup(docker_services) @@ -249,14 +249,14 @@ def test_openwrt_lan(docker_services, parameter): assert True, 'ping timeout' return - case "": - response = run_openwrt_shell_command("ip", "addr") + case '' | 'host': + response = run_openwrt_shell_command("ip", "addr", "add", "192.168.1.15/24", "dev", "br-lan") assert response['exitcode'] == 0 - # Look for eth0 - assert ('eth0' in response['out-data']) == True + response = run_openwrt_shell_command("ping", "-c1", "-W2", "-w2", "192.168.1.2") + assert response['exitcode'] == 0 return - + case _: # Usage of real Ethernet interface e.g. 'eth0' # This test is most likely only working in a github action environment because multiple VM are necessary to test it. See the action file, please. # Try to ping LAN-VM @@ -274,18 +274,12 @@ def test_openwrt_wan(docker_services, parameter): wait_for_openwrt_startup(docker_services) match parameter[1]: - case 'host': + case '' | 'host': # For some reason ping is not working at github actions, so use nslookup to test internet connection response = run_openwrt_shell_command("nslookup", "google.com") assert response['exitcode'] == 0 return - case '': - # For some reason ping is not working at github actions, so use nslookup to test internet connection - response = run_openwrt_shell_command("nslookup", "google.com") - assert response['exitcode'] == 0 - return - case 'none': # We are looking for eth1. It should not existing response = run_openwrt_shell_command("ip", "addr") @@ -457,7 +451,7 @@ def test_api_get_factory_reset(docker_services): def test_mdns(docker_services): wait_for_openwrt_startup(docker_services) try: - polling2.poll(lambda: os.system("ping -c 1 openwrt.local >/dev/null") == 0, step=1, timeout=240) + polling2.poll(lambda: os.system("ping -c 1 openwrt.local >/dev/null 2>/dev/null") == 0, step=1, timeout=240) except polling2.TimeoutException: assert True, 'ping timeout' return