cups vm tests: fix race condition, add more tests (#338193)

authored by Aleksana and committed by GitHub 91d052e8 ea1bc25f

+18 -7
+4 -2
nixos/tests/all-tests.nix
··· 828 predictable-interface-names = handleTest ./predictable-interface-names.nix {}; 829 pretalx = runTest ./web-apps/pretalx.nix; 830 pretix = runTest ./web-apps/pretix.nix; 831 - printing-socket = handleTest ./printing.nix { socket = true; }; 832 - printing-service = handleTest ./printing.nix { socket = false; }; 833 private-gpt = handleTest ./private-gpt.nix {}; 834 privatebin = runTest ./privatebin.nix; 835 privoxy = handleTest ./privoxy.nix {};
··· 828 predictable-interface-names = handleTest ./predictable-interface-names.nix {}; 829 pretalx = runTest ./web-apps/pretalx.nix; 830 pretix = runTest ./web-apps/pretix.nix; 831 + printing-socket = handleTest ./printing.nix { socket = true; listenTcp = true; }; 832 + printing-service = handleTest ./printing.nix { socket = false; listenTcp = true; }; 833 + printing-socket-notcp = handleTest ./printing.nix { socket = true; listenTcp = false; }; 834 + printing-service-notcp = handleTest ./printing.nix { socket = false; listenTcp = false; }; 835 private-gpt = handleTest ./private-gpt.nix {}; 836 privatebin = runTest ./privatebin.nix; 837 privoxy = handleTest ./privoxy.nix {};
+11 -5
nixos/tests/printing.nix
··· 3 import ./make-test-python.nix ( 4 { pkgs 5 , socket ? true # whether to use socket activation 6 , ... 7 }: 8 9 { 10 name = "printing"; 11 - meta = with pkgs.lib.maintainers; { 12 maintainers = [ domenkozar matthewbauer ]; 13 }; 14 ··· 35 }]; 36 }; 37 38 - nodes.client = { ... }: { 39 services.printing.enable = true; 40 services.printing.startWhenNeeded = socket; 41 # Add printer to the client as well, via IPP. 42 hardware.printers.ensurePrinters = [{ 43 name = "DeskjetRemote"; ··· 54 start_all() 55 56 with subtest("Make sure that cups is up on both sides and printers are set up"): 57 - server.wait_for_unit("cups.${if socket then "socket" else "service"}") 58 - client.wait_for_unit("cups.${if socket then "socket" else "service"}") 59 60 assert "scheduler is running" in client.succeed("lpstat -r") 61 ··· 63 assert "/var/run/cups/cups.sock" in client.succeed("lpstat -H") 64 65 with subtest("HTTP server is available too"): 66 - client.succeed("curl --fail http://localhost:631/") 67 client.succeed(f"curl --fail http://{server.name}:631/") 68 server.fail(f"curl --fail --connect-timeout 2 http://{client.name}:631/") 69
··· 3 import ./make-test-python.nix ( 4 { pkgs 5 , socket ? true # whether to use socket activation 6 + , listenTcp ? true # whether to open port 631 on client 7 , ... 8 }: 9 10 + let 11 + inherit (pkgs) lib; 12 + in 13 + 14 { 15 name = "printing"; 16 + meta = with lib.maintainers; { 17 maintainers = [ domenkozar matthewbauer ]; 18 }; 19 ··· 40 }]; 41 }; 42 43 + nodes.client = { lib, ... }: { 44 services.printing.enable = true; 45 services.printing.startWhenNeeded = socket; 46 + services.printing.listenAddresses = lib.mkIf (!listenTcp) []; 47 # Add printer to the client as well, via IPP. 48 hardware.printers.ensurePrinters = [{ 49 name = "DeskjetRemote"; ··· 60 start_all() 61 62 with subtest("Make sure that cups is up on both sides and printers are set up"): 63 + server.wait_for_unit("ensure-printers.service") 64 + client.wait_for_unit("ensure-printers.service") 65 66 assert "scheduler is running" in client.succeed("lpstat -r") 67 ··· 69 assert "/var/run/cups/cups.sock" in client.succeed("lpstat -H") 70 71 with subtest("HTTP server is available too"): 72 + ${lib.optionalString listenTcp ''client.succeed("curl --fail http://localhost:631/")''} 73 client.succeed(f"curl --fail http://{server.name}:631/") 74 server.fail(f"curl --fail --connect-timeout 2 http://{client.name}:631/") 75
+3
pkgs/misc/cups/default.nix
··· 138 139 passthru.tests = { 140 inherit (nixosTests) 141 printing-service 142 printing-socket 143 ; 144 }; 145
··· 138 139 passthru.tests = { 140 inherit (nixosTests) 141 + cups-pdf 142 printing-service 143 printing-socket 144 + printing-service-notcp 145 + printing-socket-notcp 146 ; 147 }; 148