From be150023f7c379c61bdef5f8bbfbd48c12ee90ad Mon Sep 17 00:00:00 2001 From: Martin Weinelt Date: Fri, 30 Aug 2024 03:39:38 +0200 Subject: [PATCH] nixos/tests/home-assistant: fix reload expectations When sending SIGHUP to hass it will exit with code 100, which is the codified exit code to trigger a restart. This is useful, because it can allow triggering a restart from within the frontend. It was previously assumed that it would result in a reload, which would keep the same interpreter process intact. That is not the case and so the assumption that the PID would stay the same was flawed and only succeeded due to race conditions. --- nixos/tests/home-assistant.nix | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/nixos/tests/home-assistant.nix b/nixos/tests/home-assistant.nix index 47902fa4e134..5ff142b08d7a 100644 --- a/nixos/tests/home-assistant.nix +++ b/nixos/tests/home-assistant.nix @@ -206,21 +206,21 @@ in { with subtest("Check extra components are considered in systemd unit hardening"): hass.succeed("systemctl show -p DeviceAllow home-assistant.service | grep -q char-ttyUSB") - with subtest("Check service reloads when configuration changes"): + with subtest("Check service restart from SIGHUP"): pid = hass.succeed("systemctl show --property=MainPID home-assistant.service") cursor = get_journal_cursor() hass.succeed("${system}/specialisation/differentName/bin/switch-to-configuration test") - new_pid = hass.succeed("systemctl show --property=MainPID home-assistant.service") - assert pid == new_pid, "The PID of the process should not change between process reloads" wait_for_homeassistant(cursor) + new_pid = hass.succeed("systemctl show --property=MainPID home-assistant.service") + assert pid != new_pid, "The PID of the process must change after sending SIGHUP" with subtest("Check service restarts when dependencies change"): pid = new_pid cursor = get_journal_cursor() hass.succeed("${system}/specialisation/newFeature/bin/switch-to-configuration test") - new_pid = hass.succeed("systemctl show --property=MainPID home-assistant.service") - assert pid != new_pid, "The PID of the process should change when its PYTHONPATH changess" wait_for_homeassistant(cursor) + new_pid = hass.succeed("systemctl show --property=MainPID home-assistant.service") + assert pid != new_pid, "The PID of the process must change when its PYTHONPATH changess" with subtest("Check that new components get setup after restart"): journal = get_journal_since(cursor)