From bc79c2562f999e9d49b2dd8eecc5e61e0f5f6d7e Mon Sep 17 00:00:00 2001 From: Paul Spooren Date: Fri, 25 Jul 2025 07:05:21 +0200 Subject: [PATCH] tests: add lan/wan testing and wan_port feature Signed-off-by: Paul Spooren --- .gitignore | 4 ++++ targets/bananapi_bpi-r4.yaml | 2 ++ targets/bananapi_bpi-r64.yaml | 1 + targets/cznic_turris-omnia.yaml | 1 + targets/genexis_pulse-ex400.yaml | 1 + targets/glinet_gl-mt1300.yaml | 1 + targets/glinet_gl-mt6000.yaml | 1 + targets/linksys_e8450.yaml | 1 + targets/openwrt_one.yaml | 1 + targets/qemu-armsr-armv8.yaml | 3 +++ targets/qemu-malta-be.yaml | 3 +++ targets/qemu-x86-64.yaml | 3 +++ targets/tplink_tl-wdr3600-v1.yaml | 1 + targets/tplink_tl-wdr4300-v1.yaml | 1 + targets/tplink_tl-wr1043nd-v3.yaml | 1 + targets/tplink_tl-wr842n-v3.yaml | 1 + tests/conftest.py | 6 ++++++ tests/test_lan.py | 12 ++++++++++++ tests/test_wan.py | 12 ++++++++++++ 19 files changed, 56 insertions(+) diff --git a/.gitignore b/.gitignore index 211aae01d..e50b7ccd3 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,7 @@ __pycache__ console_* results.json alluredir/ +allure3 +ansible/host_vars +env +firmware diff --git a/targets/bananapi_bpi-r4.yaml b/targets/bananapi_bpi-r4.yaml index 47a1a8837..8449f884e 100644 --- a/targets/bananapi_bpi-r4.yaml +++ b/targets/bananapi_bpi-r4.yaml @@ -1,5 +1,7 @@ targets: main: + features: + - wan_port resources: RemotePlace: name: !template "$LG_PLACE" diff --git a/targets/bananapi_bpi-r64.yaml b/targets/bananapi_bpi-r64.yaml index dc1c79431..9bf0ce1da 100644 --- a/targets/bananapi_bpi-r64.yaml +++ b/targets/bananapi_bpi-r64.yaml @@ -1,6 +1,7 @@ targets: main: features: + - wan_port - wifi resources: RemotePlace: diff --git a/targets/cznic_turris-omnia.yaml b/targets/cznic_turris-omnia.yaml index 62224bf3d..5aa3f96c7 100644 --- a/targets/cznic_turris-omnia.yaml +++ b/targets/cznic_turris-omnia.yaml @@ -1,6 +1,7 @@ targets: main: features: + - wan_port - wifi resources: RemotePlace: diff --git a/targets/genexis_pulse-ex400.yaml b/targets/genexis_pulse-ex400.yaml index 63f538b63..ded67a5e2 100644 --- a/targets/genexis_pulse-ex400.yaml +++ b/targets/genexis_pulse-ex400.yaml @@ -1,6 +1,7 @@ targets: main: features: + - wan_port - wifi resources: RemotePlace: diff --git a/targets/glinet_gl-mt1300.yaml b/targets/glinet_gl-mt1300.yaml index 954fc3aba..fd800539f 100644 --- a/targets/glinet_gl-mt1300.yaml +++ b/targets/glinet_gl-mt1300.yaml @@ -1,6 +1,7 @@ targets: main: features: + - wan_port - wifi resources: RemotePlace: diff --git a/targets/glinet_gl-mt6000.yaml b/targets/glinet_gl-mt6000.yaml index 9b74c5b4e..3459227ae 100644 --- a/targets/glinet_gl-mt6000.yaml +++ b/targets/glinet_gl-mt6000.yaml @@ -1,6 +1,7 @@ targets: main: features: + - wan_port - wifi resources: RemotePlace: diff --git a/targets/linksys_e8450.yaml b/targets/linksys_e8450.yaml index 4b9da6669..09e1f61ca 100644 --- a/targets/linksys_e8450.yaml +++ b/targets/linksys_e8450.yaml @@ -1,6 +1,7 @@ targets: main: features: + - wan_port - wifi resources: RemotePlace: diff --git a/targets/openwrt_one.yaml b/targets/openwrt_one.yaml index 4cda7d688..4e51341c6 100644 --- a/targets/openwrt_one.yaml +++ b/targets/openwrt_one.yaml @@ -1,6 +1,7 @@ targets: main: features: + - wan_port - wifi resources: RemotePlace: diff --git a/targets/qemu-armsr-armv8.yaml b/targets/qemu-armsr-armv8.yaml index f4fd4dd74..e00175440 100644 --- a/targets/qemu-armsr-armv8.yaml +++ b/targets/qemu-armsr-armv8.yaml @@ -1,5 +1,8 @@ targets: main: + features: + - wan_port + resources: - NetworkService: # The actual address will be filled in by the strategy diff --git a/targets/qemu-malta-be.yaml b/targets/qemu-malta-be.yaml index b26e622ba..6a62fe092 100644 --- a/targets/qemu-malta-be.yaml +++ b/targets/qemu-malta-be.yaml @@ -1,5 +1,8 @@ targets: main: + features: + - wan_port + resources: - NetworkService: # The actual address will be filled in by the strategy diff --git a/targets/qemu-x86-64.yaml b/targets/qemu-x86-64.yaml index 86ab04568..86d889988 100644 --- a/targets/qemu-x86-64.yaml +++ b/targets/qemu-x86-64.yaml @@ -1,5 +1,8 @@ targets: main: + features: + - wan_port + resources: - NetworkService: # The actual address will be filled in by the strategy diff --git a/targets/tplink_tl-wdr3600-v1.yaml b/targets/tplink_tl-wdr3600-v1.yaml index 1f7bbf9f3..523e61638 100644 --- a/targets/tplink_tl-wdr3600-v1.yaml +++ b/targets/tplink_tl-wdr3600-v1.yaml @@ -1,6 +1,7 @@ targets: main: features: + - wan_port - wifi resources: RemotePlace: diff --git a/targets/tplink_tl-wdr4300-v1.yaml b/targets/tplink_tl-wdr4300-v1.yaml index dfacbc1b2..fb43377cc 100644 --- a/targets/tplink_tl-wdr4300-v1.yaml +++ b/targets/tplink_tl-wdr4300-v1.yaml @@ -1,6 +1,7 @@ targets: main: features: + - wan_port - wifi resources: RemotePlace: diff --git a/targets/tplink_tl-wr1043nd-v3.yaml b/targets/tplink_tl-wr1043nd-v3.yaml index a8bc3a9c4..759a5526c 100644 --- a/targets/tplink_tl-wr1043nd-v3.yaml +++ b/targets/tplink_tl-wr1043nd-v3.yaml @@ -1,6 +1,7 @@ targets: main: features: + - wan_port - wifi resources: RemotePlace: diff --git a/targets/tplink_tl-wr842n-v3.yaml b/targets/tplink_tl-wr842n-v3.yaml index 2c83ff286..bf728dc87 100644 --- a/targets/tplink_tl-wr842n-v3.yaml +++ b/targets/tplink_tl-wr842n-v3.yaml @@ -1,6 +1,7 @@ targets: main: features: + - wan_port - wifi resources: RemotePlace: diff --git a/tests/conftest.py b/tests/conftest.py index f76ed53e5..5cf73288e 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -39,6 +39,12 @@ def pytest_addoption(parser): parser.addoption("--firmware", action="store", default="firmware.bin") +def pytest_configure(config): + config._metadata = getattr(config, "_metadata", {}) + config._metadata["version"] = "12.3.4" + config._metadata["environment"] = "staging" + + def pytest_sessionfinish(session): """Gather all results and save them to a JSON file.""" diff --git a/tests/test_lan.py b/tests/test_lan.py index 416fb637c..8cff138da 100644 --- a/tests/test_lan.py +++ b/tests/test_lan.py @@ -1,5 +1,17 @@ from ipaddress import IPv4Interface +from conftest import ubus_call + + +def test_lan_wait_for_network(shell_command): + for _ in range(60): + if ubus_call(shell_command, "network.interface.lan", "status").get( + "ipv4-address" + ): + return + + assert False, "LAN interface did not come up within 60 seconds" + def test_lan_interface_address(shell_command): assert shell_command.get_ip_addresses("br-lan")[0] == IPv4Interface( diff --git a/tests/test_wan.py b/tests/test_wan.py index af24f481a..87357693c 100644 --- a/tests/test_wan.py +++ b/tests/test_wan.py @@ -1,4 +1,5 @@ import pytest +from conftest import ubus_call def check_download( @@ -41,6 +42,17 @@ def check_download( command.run(f"rm {filename}") +@pytest.mark.lg_feature("wan_port") +def test_wan_wait_for_network(shell_command): + for i in range(60): + if ubus_call(shell_command, "network.interface.wan", "status").get( + "ipv4-address" + ): + return + + assert False, "WAN interface did not come up within 60 seconds" + + @pytest.mark.lg_feature("online") def test_https_download(ssh_command): check_download(