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