nixosTests.beanstalkd: migrate to runTest

Part of #386873
This commit is contained in:
Piotr Kwiecinski 2025-04-01 23:13:43 +02:00
parent 28a81fbea8
commit dc3df2d066
No known key found for this signature in database
GPG Key ID: EC0DE1CB9D5258B4
2 changed files with 40 additions and 42 deletions

View File

@ -228,7 +228,7 @@ in
babeld = runTest ./babeld.nix; babeld = runTest ./babeld.nix;
bazarr = runTest ./bazarr.nix; bazarr = runTest ./bazarr.nix;
bcachefs = runTestOn [ "x86_64-linux" "aarch64-linux" ] ./bcachefs.nix; bcachefs = runTestOn [ "x86_64-linux" "aarch64-linux" ] ./bcachefs.nix;
beanstalkd = handleTest ./beanstalkd.nix { }; beanstalkd = runTest ./beanstalkd.nix;
bees = handleTest ./bees.nix { }; bees = handleTest ./bees.nix { };
benchexec = handleTest ./benchexec.nix { }; benchexec = handleTest ./benchexec.nix { };
binary-cache = handleTest ./binary-cache.nix { compression = "zstd"; }; binary-cache = handleTest ./binary-cache.nix { compression = "zstd"; };

View File

@ -1,52 +1,50 @@
import ./make-test-python.nix ( { pkgs, lib, ... }:
{ pkgs, lib, ... }:
let let
pythonEnv = pkgs.python3.withPackages (p: [ p.beanstalkc ]); pythonEnv = pkgs.python3.withPackages (p: [ p.beanstalkc ]);
produce = pkgs.writeScript "produce.py" '' produce = pkgs.writeScript "produce.py" ''
#!${pythonEnv.interpreter} #!${pythonEnv.interpreter}
import beanstalkc import beanstalkc
queue = beanstalkc.Connection(host='localhost', port=11300, parse_yaml=False); queue = beanstalkc.Connection(host='localhost', port=11300, parse_yaml=False);
queue.put(b'this is a job') queue.put(b'this is a job')
queue.put(b'this is another job') queue.put(b'this is another job')
''; '';
consume = pkgs.writeScript "consume.py" '' consume = pkgs.writeScript "consume.py" ''
#!${pythonEnv.interpreter} #!${pythonEnv.interpreter}
import beanstalkc 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) job = queue.reserve(timeout=0)
print(job.body.decode('utf-8')) print(job.body.decode('utf-8'))
job.delete() job.delete()
''; '';
in in
{ {
name = "beanstalkd"; name = "beanstalkd";
meta.maintainers = [ lib.maintainers.aanderse ]; meta.maintainers = [ lib.maintainers.aanderse ];
nodes.machine = nodes.machine =
{ ... }: { ... }:
{ {
services.beanstalkd.enable = true; services.beanstalkd.enable = true;
}; };
testScript = '' testScript = ''
start_all() start_all()
machine.wait_for_unit("beanstalkd.service") machine.wait_for_unit("beanstalkd.service")
machine.succeed("${produce}") machine.succeed("${produce}")
assert "this is a job\n" == machine.succeed( assert "this is a job\n" == machine.succeed(
"${consume}" "${consume}"
) )
assert "this is another job\n" == machine.succeed( assert "this is another job\n" == machine.succeed(
"${consume}" "${consume}"
) )
''; '';
} }
)