at master 1.2 kB view raw
1import ./make-test-python.nix ( 2 { pkgs, ... }: 3 { 4 name = "ocsinventory-agent"; 5 6 nodes.machine = 7 { pkgs, ... }: 8 { 9 services.ocsinventory-agent = { 10 enable = true; 11 settings = { 12 debug = true; 13 local = "/var/lib/ocsinventory-agent/reports"; 14 tag = "MY_INVENTORY_TAG"; 15 }; 16 }; 17 }; 18 19 testScript = '' 20 path = "/var/lib/ocsinventory-agent/reports" 21 22 # Run the agent to generate the inventory file in offline mode 23 start_all() 24 machine.succeed("mkdir -p {}".format(path)) 25 machine.wait_for_unit("ocsinventory-agent.service") 26 machine.wait_until_succeeds("journalctl -u ocsinventory-agent.service | grep 'Inventory saved in'") 27 28 # Fetch the path to the generated inventory file 29 report_file = machine.succeed("find {}/*.ocs -type f | head -n1".format(path)) 30 31 with subtest("Check the tag value"): 32 tag = machine.succeed( 33 "${pkgs.libxml2}/bin/xmllint --xpath 'string(/REQUEST/CONTENT/ACCOUNTINFO/KEYVALUE)' {}".format(report_file) 34 ).rstrip() 35 assert tag == "MY_INVENTORY_TAG", f"tag is not valid, was '{tag}'" 36 ''; 37 } 38)