about summary refs log tree commit diff
path: root/nixos/tests/beanstalkd.nix
diff options
context:
space:
mode:
authoraanderse <aaron@fosslib.net>2019-02-22 08:10:02 -0500
committerzimbatm <zimbatm@zimbatm.com>2019-02-22 14:10:02 +0100
commite5405f9ae8b87c202a22438dd162defda1996a97 (patch)
tree1e449d0e15596582ca7930cb309471eaab23f5f5 /nixos/tests/beanstalkd.nix
parentb6c82183be6c1118fd52220887722601ed86bd76 (diff)
nixos/beanstalkd: new service for existing package (#55953)
Diffstat (limited to 'nixos/tests/beanstalkd.nix')
-rw-r--r--nixos/tests/beanstalkd.nix43
1 files changed, 43 insertions, 0 deletions
diff --git a/nixos/tests/beanstalkd.nix b/nixos/tests/beanstalkd.nix
new file mode 100644
index 0000000000000..9b7ac111a57b5
--- /dev/null
+++ b/nixos/tests/beanstalkd.nix
@@ -0,0 +1,43 @@
+import ./make-test.nix ({ pkgs, lib, ... }:
+
+let
+  produce = pkgs.writeScript "produce.py" ''
+    #!${pkgs.python2.withPackages (p: [p.beanstalkc])}/bin/python
+    import beanstalkc
+
+    queue = beanstalkc.Connection(host='localhost', port=11300, parse_yaml=False);
+    queue.put('this is a job')
+    queue.put('this is another job')
+  '';
+
+  consume = pkgs.writeScript "consume.py" ''
+    #!${pkgs.python2.withPackages (p: [p.beanstalkc])}/bin/python
+    import beanstalkc
+
+    queue = beanstalkc.Connection(host='localhost', port=11300, parse_yaml=False);
+
+    job = queue.reserve(timeout=0)
+    print job.body
+    job.delete()
+  '';
+
+in
+{
+  name = "beanstalkd";
+  meta.maintainers = [ lib.maintainers.aanderse ];
+
+  machine =
+    { ... }:
+    { services.beanstalkd.enable = true;
+    };
+
+  testScript = ''
+    startAll;
+
+    $machine->waitForUnit('beanstalkd.service');
+
+    $machine->succeed("${produce}");
+    $machine->succeed("${consume}") eq "this is a job\n" or die;
+    $machine->succeed("${consume}") eq "this is another job\n" or die;
+  '';
+})