diff options
author | Anthony Roussel <anthony@roussel.dev> | 2023-11-02 01:28:20 +0100 |
---|---|---|
committer | Anthony Roussel <anthony@roussel.dev> | 2023-11-02 14:20:46 +0100 |
commit | c72a44718c5aca8c42763dc61ff1197e7bde7738 (patch) | |
tree | bf967f6c7b348c23e5ae5e427fb7d4ef471bbfea /nixos/tests/ocsinventory-agent.nix | |
parent | efdbdab8b511f8cf1e361938f36246709acd6d2f (diff) |
nixosTests.ocsinventory-agent: init
Diffstat (limited to 'nixos/tests/ocsinventory-agent.nix')
-rw-r--r-- | nixos/tests/ocsinventory-agent.nix | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/nixos/tests/ocsinventory-agent.nix b/nixos/tests/ocsinventory-agent.nix new file mode 100644 index 0000000000000..67b0c8c911036 --- /dev/null +++ b/nixos/tests/ocsinventory-agent.nix @@ -0,0 +1,33 @@ +import ./make-test-python.nix ({ pkgs, ...} : { + name = "ocsinventory-agent"; + + nodes.machine = { pkgs, ... }: { + services.ocsinventory-agent = { + enable = true; + settings = { + debug = true; + local = "/var/lib/ocsinventory-agent/reports"; + tag = "MY_INVENTORY_TAG"; + }; + }; + }; + + testScript = '' + path = "/var/lib/ocsinventory-agent/reports" + + # Run the agent to generate the inventory file in offline mode + start_all() + machine.succeed("mkdir -p {}".format(path)) + machine.wait_for_unit("ocsinventory-agent.service") + machine.wait_until_succeeds("journalctl -u ocsinventory-agent.service | grep 'Inventory saved in'") + + # Fetch the path to the generated inventory file + report_file = machine.succeed("find {}/*.ocs -type f | head -n1".format(path)) + + with subtest("Check the tag value"): + tag = machine.succeed( + "${pkgs.libxml2}/bin/xmllint --xpath 'string(/REQUEST/CONTENT/ACCOUNTINFO/KEYVALUE)' {}".format(report_file) + ).rstrip() + assert tag == "MY_INVENTORY_TAG", f"tag is not valid, was '{tag}'" + ''; +}) |