From dc3df2d066f6e064638d9592aca56c21f746c9da Mon Sep 17 00:00:00 2001 From: Piotr Kwiecinski <2151333+piotrkwiecinski@users.noreply.github.com> Date: Tue, 1 Apr 2025 23:13:43 +0200 Subject: [PATCH] nixosTests.beanstalkd: migrate to runTest Part of #386873 --- nixos/tests/all-tests.nix | 2 +- nixos/tests/beanstalkd.nix | 80 +++++++++++++++++++------------------- 2 files changed, 40 insertions(+), 42 deletions(-) diff --git a/nixos/tests/all-tests.nix b/nixos/tests/all-tests.nix index 754f97cec858..31a4aa7ee60d 100644 --- a/nixos/tests/all-tests.nix +++ b/nixos/tests/all-tests.nix @@ -228,7 +228,7 @@ in babeld = runTest ./babeld.nix; bazarr = runTest ./bazarr.nix; bcachefs = runTestOn [ "x86_64-linux" "aarch64-linux" ] ./bcachefs.nix; - beanstalkd = handleTest ./beanstalkd.nix { }; + beanstalkd = runTest ./beanstalkd.nix; bees = handleTest ./bees.nix { }; benchexec = handleTest ./benchexec.nix { }; binary-cache = handleTest ./binary-cache.nix { compression = "zstd"; }; diff --git a/nixos/tests/beanstalkd.nix b/nixos/tests/beanstalkd.nix index a04b2396aae1..587c4c6638b2 100644 --- a/nixos/tests/beanstalkd.nix +++ b/nixos/tests/beanstalkd.nix @@ -1,52 +1,50 @@ -import ./make-test-python.nix ( - { pkgs, lib, ... }: +{ pkgs, lib, ... }: - let - pythonEnv = pkgs.python3.withPackages (p: [ p.beanstalkc ]); +let + pythonEnv = pkgs.python3.withPackages (p: [ p.beanstalkc ]); - produce = pkgs.writeScript "produce.py" '' - #!${pythonEnv.interpreter} - import beanstalkc + produce = pkgs.writeScript "produce.py" '' + #!${pythonEnv.interpreter} + import beanstalkc - queue = beanstalkc.Connection(host='localhost', port=11300, parse_yaml=False); - queue.put(b'this is a job') - queue.put(b'this is another job') - ''; + queue = beanstalkc.Connection(host='localhost', port=11300, parse_yaml=False); + queue.put(b'this is a job') + queue.put(b'this is another job') + ''; - consume = pkgs.writeScript "consume.py" '' - #!${pythonEnv.interpreter} - import beanstalkc + consume = pkgs.writeScript "consume.py" '' + #!${pythonEnv.interpreter} + import beanstalkc - queue = beanstalkc.Connection(host='localhost', port=11300, parse_yaml=False); + queue = beanstalkc.Connection(host='localhost', port=11300, parse_yaml=False); - job = queue.reserve(timeout=0) - print(job.body.decode('utf-8')) - job.delete() - ''; + job = queue.reserve(timeout=0) + print(job.body.decode('utf-8')) + job.delete() + ''; - in - { - name = "beanstalkd"; - meta.maintainers = [ lib.maintainers.aanderse ]; +in +{ + name = "beanstalkd"; + meta.maintainers = [ lib.maintainers.aanderse ]; - nodes.machine = - { ... }: - { - services.beanstalkd.enable = true; - }; + nodes.machine = + { ... }: + { + services.beanstalkd.enable = true; + }; - testScript = '' - start_all() + testScript = '' + start_all() - machine.wait_for_unit("beanstalkd.service") + machine.wait_for_unit("beanstalkd.service") - machine.succeed("${produce}") - assert "this is a job\n" == machine.succeed( - "${consume}" - ) - assert "this is another job\n" == machine.succeed( - "${consume}" - ) - ''; - } -) + machine.succeed("${produce}") + assert "this is a job\n" == machine.succeed( + "${consume}" + ) + assert "this is another job\n" == machine.succeed( + "${consume}" + ) + ''; +}