blob: abea1657f3eadbcb02dcc9fa3a83a76c3dcf1f25 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
import ./make-test-python.nix ({ pkgs, ... }:
{
name = "redis";
meta = with pkgs.lib.maintainers; {
maintainers = [ flokli ];
};
nodes = {
machine =
{ pkgs, lib, ... }: with lib;
{
services.redis.servers."".enable = true;
services.redis.servers."test".enable = true;
users.users = listToAttrs (map (suffix: nameValuePair "member${suffix}" {
createHome = false;
description = "A member of the redis${suffix} group";
isNormalUser = true;
extraGroups = [ "redis${suffix}" ];
}) ["" "-test"]);
};
};
testScript = { nodes, ... }: let
inherit (nodes.machine.config.services) redis;
in ''
start_all()
machine.wait_for_unit("redis")
machine.wait_for_unit("redis-test")
# The unnamed Redis server still opens a port for backward-compatibility
machine.wait_for_open_port(6379)
machine.wait_for_file("${redis.servers."".unixSocket}")
machine.wait_for_file("${redis.servers."test".unixSocket}")
# The unix socket is accessible to the redis group
machine.succeed('su member -c "redis-cli ping | grep PONG"')
machine.succeed('su member-test -c "redis-cli ping | grep PONG"')
machine.succeed("redis-cli ping | grep PONG")
machine.succeed("redis-cli -s ${redis.servers."".unixSocket} ping | grep PONG")
machine.succeed("redis-cli -s ${redis.servers."test".unixSocket} ping | grep PONG")
'';
})
|