Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 4 commits into from
Oct 29, 2024

Commits on Oct 27, 2024

  1. cups: add 'cups-pdf' vm test to passthru.tests

    While aimed at the cups-pdf printing package,
    this vm tests also serves as a test for
    the cups printing module in general.
    Yarny0 committed Oct 27, 2024
    Configuration menu
    Copy the full SHA
    377cbbd View commit details
    Browse the repository at this point in the history
  2. nixos/tests/printing: fix race of lpstat and ensure-printers

    There is a nasty race condition in the cups tests.
    To understand what is going on, one must first note that
    printers are installed in the vms with ensure-printers.service,
    which is started as part of multi-user.target.
    ensure-printers.service in turn triggers a start of
    cups.service as it needs to connect to the local cups daemon.
    
    This is what happens when the test runs:
    1  the test waits for cups.socket or cups.service to start up
       (subtest "Make sure that cups is up on both sides...")
    2  after cups.service started
       (it starts even in the "socket" case,
       triggered by ensure-printers.service),
       ensure-printers.service is started
    3  the test tries to connect to the cups daemons via curl
       (subtest "HTTP server is available too")
    4  the test verifies the required printers are installed
       ("lpstat -a" called by subtest "LP status checks")
    
    Usually, 3 needs some time, so ensure-printers.service
    already installed all printers that are required by 4.
    But if 3 is too fast, or if ensure-printers.service is too slow,
    4 fails to find the printers it is looking for.
    
    One can provoke the problem by adding
    
    > systemd.services.ensure-printers.serviceConfig.ExecStartPre = "/run/current-system/sw/bin/sleep 10";
    
    to the `nodes.client` configuration.
    
    The commit at hand fixes the problem by changing 1:
    Instead of waiting for cups,
    it now waits for ensure-printers.service
    (which in turn waits for cups.service and cups.socket).
    This is also in accordance with the
    subtest description in the code that promises to
    "Make sure that cups is up [...] and printers are set up".
    Yarny0 committed Oct 27, 2024
    Configuration menu
    Copy the full SHA
    1693e1a View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    2e48883 View commit details
    Browse the repository at this point in the history
  4. nixos/tests/printing: test cases for domain socket only config

    Add two new vm tests for the printing configuration that
    test `listenAddresses = []`, i.e., the situation where cups
    only listens on the unix domain socket `/run/cups/cups.sock`.
    
    This helps catching bugs like this:
    
    OpenPrinting/cups#985
    NixOS#337748
    Yarny0 committed Oct 27, 2024
    Configuration menu
    Copy the full SHA
    9bca428 View commit details
    Browse the repository at this point in the history