nixpkgs/nixos/tests/beanstalkd.nix

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

50 lines
1.1 KiB
Nix
Raw Normal View History

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