diff options
author | Andreas Rammhold <andreas@rammhold.de> | 2021-12-18 23:01:33 +0100 |
---|---|---|
committer | Martin Weinelt <hexa@darmstadt.ccc.de> | 2022-06-22 16:20:11 +0200 |
commit | cfbcf381c27f0494f86f97056f43d1101ada715a (patch) | |
tree | a4d69fc77574d2d4f667109d208995067121fdce /nixos/tests/home-assistant.nix | |
parent | e1e08fe28bf0588a41cd556eac40b98d2793da99 (diff) |
nixos/home-assistant: reload the daemon when configuration changed
Reload the service when configuration changes. This means that we don't have a potentially slow startup for every small configuration change.
Diffstat (limited to 'nixos/tests/home-assistant.nix')
-rw-r--r-- | nixos/tests/home-assistant.nix | 32 |
1 files changed, 31 insertions, 1 deletions
diff --git a/nixos/tests/home-assistant.nix b/nixos/tests/home-assistant.nix index f7b9d283e4572..341374e636aed 100644 --- a/nixos/tests/home-assistant.nix +++ b/nixos/tests/home-assistant.nix @@ -98,9 +98,26 @@ in { }; lovelaceConfigWritable = true; }; + + # Cause a configuration change inside `configuration.yml` and verify that the process is being reloaded. + specialisation.differentName = { + inheritParentConfig = true; + configuration.services.home-assistant.config.homeassistant.name = lib.mkForce "Test Home"; + }; + + # Cause a configuration change that requires a service restart as we added a new runtime dependency + specialisation.newFeature = { + inheritParentConfig = true; + configuration.services.home-assistant.config.device_tracker = [ + { platform = "bluetooth_tracker"; } + ]; + }; }; - testScript = '' + testScript = { nodes, ... }: let + system = nodes.hass.config.system.build.toplevel; + in + '' import re start_all() @@ -142,6 +159,19 @@ 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"): + # store the old pid of the process + pid = hass.succeed("systemctl show --property=MainPID home-assistant.service") + 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" + + with subtest("check service restarts when package changes"): + pid = new_pid + 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 shoudl change when the HA binary changes" + with subtest("Print log to ease debugging"): output_log = hass.succeed("cat ${configDir}/home-assistant.log") print("\n### home-assistant.log ###\n") |