diff options
Diffstat (limited to 'nixos/tests/beanstalkd.nix')
-rw-r--r-- | nixos/tests/beanstalkd.nix | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/nixos/tests/beanstalkd.nix b/nixos/tests/beanstalkd.nix new file mode 100644 index 00000000000..4f4a454fb47 --- /dev/null +++ b/nixos/tests/beanstalkd.nix @@ -0,0 +1,49 @@ +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 ]; + + machine = + { ... }: + { services.beanstalkd.enable = true; + }; + + testScript = '' + start_all() + + 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}" + ) + ''; +}) |