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

This commit is contained in:
Aleksana 2024-10-29 18:56:19 +08:00 committed by GitHub
commit 91d052e89a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 18 additions and 7 deletions

View File

@ -828,8 +828,10 @@ in {
predictable-interface-names = handleTest ./predictable-interface-names.nix {};
pretalx = runTest ./web-apps/pretalx.nix;
pretix = runTest ./web-apps/pretix.nix;
printing-socket = handleTest ./printing.nix { socket = true; };
printing-service = handleTest ./printing.nix { socket = false; };
printing-socket = handleTest ./printing.nix { socket = true; listenTcp = true; };
printing-service = handleTest ./printing.nix { socket = false; listenTcp = true; };
printing-socket-notcp = handleTest ./printing.nix { socket = true; listenTcp = false; };
printing-service-notcp = handleTest ./printing.nix { socket = false; listenTcp = false; };
private-gpt = handleTest ./private-gpt.nix {};
privatebin = runTest ./privatebin.nix;
privoxy = handleTest ./privoxy.nix {};

View File

@ -3,12 +3,17 @@
import ./make-test-python.nix (
{ pkgs
, socket ? true # whether to use socket activation
, listenTcp ? true # whether to open port 631 on client
, ...
}:
let
inherit (pkgs) lib;
in
{
name = "printing";
meta = with pkgs.lib.maintainers; {
meta = with lib.maintainers; {
maintainers = [ domenkozar matthewbauer ];
};
@ -35,9 +40,10 @@ import ./make-test-python.nix (
}];
};
nodes.client = { ... }: {
nodes.client = { lib, ... }: {
services.printing.enable = true;
services.printing.startWhenNeeded = socket;
services.printing.listenAddresses = lib.mkIf (!listenTcp) [];
# Add printer to the client as well, via IPP.
hardware.printers.ensurePrinters = [{
name = "DeskjetRemote";
@ -54,8 +60,8 @@ import ./make-test-python.nix (
start_all()
with subtest("Make sure that cups is up on both sides and printers are set up"):
server.wait_for_unit("cups.${if socket then "socket" else "service"}")
client.wait_for_unit("cups.${if socket then "socket" else "service"}")
server.wait_for_unit("ensure-printers.service")
client.wait_for_unit("ensure-printers.service")
assert "scheduler is running" in client.succeed("lpstat -r")
@ -63,7 +69,7 @@ import ./make-test-python.nix (
assert "/var/run/cups/cups.sock" in client.succeed("lpstat -H")
with subtest("HTTP server is available too"):
client.succeed("curl --fail http://localhost:631/")
${lib.optionalString listenTcp ''client.succeed("curl --fail http://localhost:631/")''}
client.succeed(f"curl --fail http://{server.name}:631/")
server.fail(f"curl --fail --connect-timeout 2 http://{client.name}:631/")

View File

@ -138,8 +138,11 @@ stdenv.mkDerivation rec {
passthru.tests = {
inherit (nixosTests)
cups-pdf
printing-service
printing-socket
printing-service-notcp
printing-socket-notcp
;
};