2023-05-24 13:37:59 +00:00
|
|
|
import ./make-test-python.nix ({ pkgs, lib, ... }:
|
2021-01-15 22:18:51 +00:00
|
|
|
{
|
2020-04-24 23:36:52 +00:00
|
|
|
name = "redis";
|
2023-05-24 13:37:59 +00:00
|
|
|
meta.maintainers = with lib.maintainers; [ flokli ];
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
nodes = {
|
|
|
|
machine =
|
2023-05-24 13:37:59 +00:00
|
|
|
{ pkgs, lib, ... }:
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
{
|
2021-12-19 01:06:50 +00:00
|
|
|
services.redis.servers."".enable = true;
|
|
|
|
services.redis.servers."test".enable = true;
|
2021-01-15 22:18:51 +00:00
|
|
|
|
2023-05-24 13:37:59 +00:00
|
|
|
users.users = lib.listToAttrs (map (suffix: lib.nameValuePair "member${suffix}" {
|
2021-01-15 22:18:51 +00:00
|
|
|
createHome = false;
|
2021-12-19 01:06:50 +00:00
|
|
|
description = "A member of the redis${suffix} group";
|
2021-04-15 00:37:46 +00:00
|
|
|
isNormalUser = true;
|
2021-12-19 01:06:50 +00:00
|
|
|
extraGroups = [ "redis${suffix}" ];
|
|
|
|
}) ["" "-test"]);
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2021-12-19 01:06:50 +00:00
|
|
|
testScript = { nodes, ... }: let
|
|
|
|
inherit (nodes.machine.config.services) redis;
|
|
|
|
in ''
|
2020-04-24 23:36:52 +00:00
|
|
|
start_all()
|
|
|
|
machine.wait_for_unit("redis")
|
2021-12-19 01:06:50 +00:00
|
|
|
machine.wait_for_unit("redis-test")
|
|
|
|
|
|
|
|
# The unnamed Redis server still opens a port for backward-compatibility
|
2022-06-16 17:23:12 +00:00
|
|
|
machine.wait_for_open_port(6379)
|
2021-01-15 22:18:51 +00:00
|
|
|
|
2021-12-19 01:06:50 +00:00
|
|
|
machine.wait_for_file("${redis.servers."".unixSocket}")
|
|
|
|
machine.wait_for_file("${redis.servers."test".unixSocket}")
|
|
|
|
|
2021-01-15 22:18:51 +00:00
|
|
|
# The unix socket is accessible to the redis group
|
|
|
|
machine.succeed('su member -c "redis-cli ping | grep PONG"')
|
2021-12-19 01:06:50 +00:00
|
|
|
machine.succeed('su member-test -c "redis-cli ping | grep PONG"')
|
2021-01-15 22:18:51 +00:00
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
machine.succeed("redis-cli ping | grep PONG")
|
2021-12-19 01:06:50 +00:00
|
|
|
machine.succeed("redis-cli -s ${redis.servers."".unixSocket} ping | grep PONG")
|
|
|
|
machine.succeed("redis-cli -s ${redis.servers."test".unixSocket} ping | grep PONG")
|
2020-04-24 23:36:52 +00:00
|
|
|
'';
|
|
|
|
})
|