1 import ./make-test-python.nix ({ pkgs, ...} : {
2 name = "ocsinventory-agent";
4 nodes.machine = { pkgs, ... }: {
5 services.ocsinventory-agent = {
9 local = "/var/lib/ocsinventory-agent/reports";
10 tag = "MY_INVENTORY_TAG";
16 path = "/var/lib/ocsinventory-agent/reports"
18 # Run the agent to generate the inventory file in offline mode
20 machine.succeed("mkdir -p {}".format(path))
21 machine.wait_for_unit("ocsinventory-agent.service")
22 machine.wait_until_succeeds("journalctl -u ocsinventory-agent.service | grep 'Inventory saved in'")
24 # Fetch the path to the generated inventory file
25 report_file = machine.succeed("find {}/*.ocs -type f | head -n1".format(path))
27 with subtest("Check the tag value"):
28 tag = machine.succeed(
29 "${pkgs.libxml2}/bin/xmllint --xpath 'string(/REQUEST/CONTENT/ACCOUNTINFO/KEYVALUE)' {}".format(report_file)
31 assert tag == "MY_INVENTORY_TAG", f"tag is not valid, was '{tag}'"