at 24.11-pre 1.1 kB view raw
1import ./make-test-python.nix ({ pkgs, ...} : { 2 name = "ocsinventory-agent"; 3 4 nodes.machine = { pkgs, ... }: { 5 services.ocsinventory-agent = { 6 enable = true; 7 settings = { 8 debug = true; 9 local = "/var/lib/ocsinventory-agent/reports"; 10 tag = "MY_INVENTORY_TAG"; 11 }; 12 }; 13 }; 14 15 testScript = '' 16 path = "/var/lib/ocsinventory-agent/reports" 17 18 # Run the agent to generate the inventory file in offline mode 19 start_all() 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'") 23 24 # Fetch the path to the generated inventory file 25 report_file = machine.succeed("find {}/*.ocs -type f | head -n1".format(path)) 26 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) 30 ).rstrip() 31 assert tag == "MY_INVENTORY_TAG", f"tag is not valid, was '{tag}'" 32 ''; 33})