diff options
author | Martin Weinelt <hexa@darmstadt.ccc.de> | 2021-07-27 15:14:24 +0200 |
---|---|---|
committer | Martin Weinelt <hexa@darmstadt.ccc.de> | 2022-11-21 22:40:15 +0100 |
commit | 005233baa29a7da3aa2e76ce0bd36bf286aaac4f (patch) | |
tree | b5e9d566f7cabf5d3f75f917af7ee1f5d0c86218 | |
parent | 36f58b687c48494e6f849f0bb816b5d4fcdc30f4 (diff) |
nixos/tests/evcc: init
-rw-r--r-- | nixos/tests/all-tests.nix | 1 | ||||
-rw-r--r-- | nixos/tests/evcc.nix | 96 | ||||
-rw-r--r-- | pkgs/servers/home-automation/evcc/default.nix | 4 |
3 files changed, 101 insertions, 0 deletions
diff --git a/nixos/tests/all-tests.nix b/nixos/tests/all-tests.nix index d3dc8b9ca08a4..7b1006ba60156 100644 --- a/nixos/tests/all-tests.nix +++ b/nixos/tests/all-tests.nix @@ -198,6 +198,7 @@ in { etebase-server = handleTest ./etebase-server.nix {}; etesync-dav = handleTest ./etesync-dav.nix {}; extra-python-packages = handleTest ./extra-python-packages.nix {}; + evcc = handleTest ./evcc.nix {}; fancontrol = handleTest ./fancontrol.nix {}; fcitx = handleTest ./fcitx {}; fenics = handleTest ./fenics.nix {}; diff --git a/nixos/tests/evcc.nix b/nixos/tests/evcc.nix new file mode 100644 index 0000000000000..0fc261142f787 --- /dev/null +++ b/nixos/tests/evcc.nix @@ -0,0 +1,96 @@ +import ./make-test-python.nix ({ pkgs, lib, ...} : + +{ + name = "evcc"; + meta.maintainers = with lib.maintainers; [ hexa ]; + + nodes = { + machine = { config, ... }: { + services.evcc = { + enable = true; + settings = { + network = { + schema = "http"; + host = "localhost"; + port = 7070; + }; + + log = "info"; + + site = { + title = "NixOS Test"; + meters = { + grid = "grid"; + pv = "pv"; + }; + }; + + meters = [ { + type = "custom"; + name = "grid"; + power = { + source = "script"; + cmd = "/bin/sh -c 'echo -4500'"; + }; + } { + type = "custom"; + name = "pv"; + power = { + source = "script"; + cmd = "/bin/sh -c 'echo 7500'"; + }; + } ]; + + chargers = [ { + name = "dummy-charger"; + type = "custom"; + status = { + source = "script"; + cmd = "/bin/sh -c 'echo charger status F'"; + }; + enabled = { + source = "script"; + cmd = "/bin/sh -c 'echo charger enabled state false'"; + }; + enable = { + source = "script"; + cmd = "/bin/sh -c 'echo set charger enabled state true'"; + }; + maxcurrent = { + source = "script"; + cmd = "/bin/sh -c 'echo set charger max current 7200'"; + }; + } ]; + + loadpoints = [ { + title = "Dummy"; + charger = "dummy-charger"; + } ]; + }; + }; + }; + }; + + testScript = '' + start_all() + + machine.wait_for_unit("evcc.service") + machine.wait_for_open_port(7070) + + with subtest("Check package version propagates into frontend"): + machine.fail( + "curl --fail http://localhost:7070 | grep '0.0.1-alpha'" + ) + machine.succeed( + "curl --fail http://localhost:7070 | grep '${pkgs.evcc.version}'" + ) + + with subtest("Check journal for errors"): + _, output = machine.execute("journalctl -o cat -u evcc.service") + assert "ERROR" not in output + + with subtest("Check systemd hardening"): + _, output = machine.execute("systemd-analyze security evcc.service | grep -v '✓'") + machine.log(output) + ''; +}) diff --git a/pkgs/servers/home-automation/evcc/default.nix b/pkgs/servers/home-automation/evcc/default.nix index feb0180cc4cbf..a242f9d1cc3a1 100644 --- a/pkgs/servers/home-automation/evcc/default.nix +++ b/pkgs/servers/home-automation/evcc/default.nix @@ -10,6 +10,7 @@ , nodejs , npmHooks , nix-update-script +, nixosTests , stdenv }: @@ -77,6 +78,9 @@ buildGoModule rec { ''; passthru = { + tests = { + inherit (nixosTests) evcc; + }; updateScript = nix-update-script { attrPath = pname; }; |