blob: 6c84701c9c0a98faad7569842c296f71f73cff7f (
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
|
{
system ? builtins.currentSystem,
config ? { },
pkgs ? import ../../.. { inherit system config; },
lib ? pkgs.lib,
}:
let
makeTest = import ./make-test-python.nix;
mkTestName =
pkg: "${pkg.pname}_${builtins.replaceStrings [ "." ] [ "" ] (lib.versions.majorMinor pkg.version)}";
redisPackages = {
inherit (pkgs) redis keydb;
};
makeRedisTest =
{
package,
name ? mkTestName package,
}:
makeTest {
inherit name;
meta.maintainers = [
lib.maintainers.flokli
lib.teams.helsinki-systems.members
];
nodes = {
machine =
{ lib, ... }:
{
services = {
redis = {
inherit package;
servers."".enable = true;
servers."test".enable = true;
};
};
users.users = lib.listToAttrs (
map
(
suffix:
lib.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.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 "${pkgs.redis}/bin/redis-cli ping | grep PONG"')
machine.succeed('su member-test -c "${pkgs.redis}/bin/redis-cli ping | grep PONG"')
machine.succeed("${pkgs.redis}/bin/redis-cli ping | grep PONG")
machine.succeed("${pkgs.redis}/bin/redis-cli -s ${redis.servers."".unixSocket} ping | grep PONG")
machine.succeed("${pkgs.redis}/bin/redis-cli -s ${
redis.servers."test".unixSocket
} ping | grep PONG")
'';
};
in
lib.mapAttrs (_: package: makeRedisTest { inherit package; }) redisPackages
|