nixpkgs/nixos/tests/zookeeper.nix

47 lines
1.3 KiB
Nix
Raw Normal View History

import ./make-test-python.nix ({ pkgs, ...} :
let
perlEnv = pkgs.perl.withPackages (p: [p.NetZooKeeper]);
in {
2017-11-02 20:59:10 +03:00
name = "zookeeper";
meta = with pkgs.lib.maintainers; {
maintainers = [ nequissimus ztzg ];
2017-11-02 20:59:10 +03:00
};
nodes = {
server = { ... }: {
2017-11-02 20:59:10 +03:00
services.zookeeper = {
enable = true;
};
networking.firewall.allowedTCPPorts = [ 2181 ];
};
};
testScript = ''
2019-11-06 09:54:37 +03:00
start_all()
2017-11-02 20:59:10 +03:00
2019-11-06 09:54:37 +03:00
server.wait_for_unit("zookeeper")
server.wait_for_unit("network.target")
server.wait_for_open_port(2181)
2017-11-02 20:59:10 +03:00
2019-11-06 09:54:37 +03:00
server.wait_until_succeeds(
"${pkgs.zookeeper}/bin/zkCli.sh -server localhost:2181 create /foo bar"
)
server.wait_until_succeeds(
"${pkgs.zookeeper}/bin/zkCli.sh -server localhost:2181 set /foo hello"
)
server.wait_until_succeeds(
"${pkgs.zookeeper}/bin/zkCli.sh -server localhost:2181 get /foo | grep hello"
)
server.wait_until_succeeds(
"${perlEnv}/bin/perl -E 'use Net::ZooKeeper qw(:acls); $z=Net::ZooKeeper->new(q(localhost:2181)); $z->create(qw(/perl foo acl), ZOO_OPEN_ACL_UNSAFE) || die $z->get_error()'"
)
server.wait_until_succeeds(
"${perlEnv}/bin/perl -E 'use Net::ZooKeeper qw(:acls); $z=Net::ZooKeeper->new(q(localhost:2181)); $z->get(qw(/perl)) eq qw(foo) || die $z->get_error()'"
)
2017-11-02 20:59:10 +03:00
'';
})