fix(node): clarify wireless enrollment and restore active K1 after upgrade
This commit is contained in:
@@ -165,6 +165,8 @@ def test_node_scan_real_service_preserves_operation_identity_and_replay(
|
||||
"action": "scan", "parameters": {},
|
||||
}
|
||||
result = await device.deliver(command)
|
||||
if not radio_failure:
|
||||
assert scanner.capture_discovered_device("AA:BB:CC:DD:EE:FF") is not None
|
||||
repeated = await device.deliver(command)
|
||||
assert len(calls) == 1
|
||||
assert result["discovery_generation"] == 1
|
||||
@@ -307,6 +309,21 @@ def test_networkmanager_ssids_are_not_split_at_escaped_colons():
|
||||
assert nm_fields(r"field\:network\\name:88:WPA2") == ["field:network\\name", "88", "WPA2"]
|
||||
|
||||
|
||||
def test_wired_board_bridge_does_not_require_host_wifi_association(tmp_path, monkeypatch):
|
||||
from k1link.device_plugins.xgrids_k1 import linux_host
|
||||
|
||||
(tmp_path / "enp1s0").mkdir()
|
||||
|
||||
def forbidden(*_args, **_kwargs):
|
||||
raise AssertionError("Ethernet must not request Wi-Fi association")
|
||||
|
||||
monkeypatch.setattr(linux_host, "_run", forbidden)
|
||||
value = linux_host.LinuxWifiAssociationProbe(tmp_path).observe(interface_name="enp1s0")
|
||||
assert value["association_state"] == "not-wifi"
|
||||
assert value["continuity_proven"] is True
|
||||
assert value["reason_code"] is None
|
||||
|
||||
|
||||
def test_linux_kernel_route_is_matched_route_not_resolved_host(monkeypatch):
|
||||
from k1link.device_plugins.xgrids_k1 import linux_host
|
||||
from k1link.device_plugins.xgrids_k1.facade import _classify_host_route
|
||||
|
||||
@@ -0,0 +1,56 @@
|
||||
"""Execute the real maintainer scripts with isolated OS paths and commands."""
|
||||
|
||||
import os
|
||||
import subprocess
|
||||
from pathlib import Path
|
||||
|
||||
import pytest
|
||||
|
||||
PACKAGING = Path(__file__).resolve().parents[1] / "apps/node-agent/packaging"
|
||||
|
||||
|
||||
@pytest.mark.parametrize("active,configured", [(True, True), (False, True), (True, False)])
|
||||
def test_node_update_restores_only_previously_running_configured_plugin(
|
||||
tmp_path, active, configured,
|
||||
):
|
||||
binary = tmp_path / "bin"
|
||||
binary.mkdir()
|
||||
run = tmp_path / "run"
|
||||
(run / "systemd/system").mkdir(parents=True)
|
||||
release = tmp_path / "os-release"
|
||||
release.write_text("ID=ubuntu\nVERSION_ID=24.04\n")
|
||||
state = tmp_path / "active"
|
||||
if active:
|
||||
state.touch()
|
||||
events = tmp_path / "events"
|
||||
systemctl = binary / "systemctl"
|
||||
systemctl.write_text('''#!/bin/sh
|
||||
printf '%s\\n' "$*" >> "$TEST_EVENTS"
|
||||
case "$1" in
|
||||
is-active) [ -f "$TEST_ACTIVE" ]; exit $? ;;
|
||||
show) echo inactive ;;
|
||||
stop) rm -f "$TEST_ACTIVE" ;;
|
||||
start) touch "$TEST_ACTIVE" ;;
|
||||
esac
|
||||
''')
|
||||
(binary / "getent").write_text("#!/bin/sh\nexit 0\n")
|
||||
(binary / "dpkg-query").write_text(
|
||||
"#!/bin/sh\necho 'install ok " + ("installed" if configured else "unpacked") + "'\n"
|
||||
)
|
||||
for file in binary.iterdir():
|
||||
file.chmod(0o700)
|
||||
env = dict(os.environ, PATH=str(binary) + os.pathsep + os.environ["PATH"],
|
||||
TEST_EVENTS=str(events), TEST_ACTIVE=str(state))
|
||||
for name, args in [("preinst", ["upgrade", "0.8.2"]), ("postinst", ["configure", "0.8.2"])]:
|
||||
script = tmp_path / name
|
||||
script.write_text((PACKAGING / name).read_text()
|
||||
.replace("/run/", str(run) + "/")
|
||||
.replace("/etc/os-release", str(release)))
|
||||
subprocess.run(["/bin/sh", str(script), *args], env=env, check=True,
|
||||
capture_output=True, text=True)
|
||||
if name == "preinst":
|
||||
assert not state.exists()
|
||||
calls = events.read_text().splitlines()
|
||||
assert ("start mission-core-k1.service" in calls) is (active and configured)
|
||||
assert state.exists() is (active and configured)
|
||||
assert not (run / "mission-core-node-k1-upgrade-active").exists()
|
||||
Reference in New Issue
Block a user