2021-01-03 18:20:02 +00:00
|
|
|
import ./make-test-python.nix ({ pkgs, ... }:
|
|
|
|
{
|
2019-08-31 18:17:33 +00:00
|
|
|
name = "redis";
|
2021-01-10 19:08:30 +00:00
|
|
|
meta = with pkgs.lib.maintainers; {
|
2019-08-31 18:17:33 +00:00
|
|
|
maintainers = [ flokli ];
|
|
|
|
};
|
|
|
|
|
|
|
|
nodes = {
|
|
|
|
machine =
|
2021-10-23 03:44:07 +00:00
|
|
|
{ pkgs, lib, ... }: with lib;
|
2019-08-31 18:17:33 +00:00
|
|
|
|
|
|
|
{
|
2021-10-23 03:44:07 +00:00
|
|
|
services.redis.servers."".enable = true;
|
|
|
|
services.redis.servers."test".enable = true;
|
2021-01-03 18:20:02 +00:00
|
|
|
|
2021-10-23 03:44:07 +00:00
|
|
|
users.users = listToAttrs (map (suffix: nameValuePair "member${suffix}" {
|
2021-01-03 18:20:02 +00:00
|
|
|
createHome = false;
|
2021-10-23 03:44:07 +00:00
|
|
|
description = "A member of the redis${suffix} group";
|
2021-03-07 13:54:00 +00:00
|
|
|
isNormalUser = true;
|
2021-10-23 03:44:07 +00:00
|
|
|
extraGroups = [ "redis${suffix}" ];
|
|
|
|
}) ["" "-test"]);
|
2019-08-31 18:17:33 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2021-10-23 03:44:07 +00:00
|
|
|
testScript = { nodes, ... }: let
|
|
|
|
inherit (nodes.machine.config.services) redis;
|
|
|
|
in ''
|
2019-11-06 14:57:56 +00:00
|
|
|
start_all()
|
|
|
|
machine.wait_for_unit("redis")
|
2021-10-23 03:44:07 +00:00
|
|
|
machine.wait_for_unit("redis-test")
|
|
|
|
|
|
|
|
# The unnamed Redis server still opens a port for backward-compatibility
|
2022-06-11 12:22:53 +00:00
|
|
|
machine.wait_for_open_port(6379)
|
2021-01-03 18:20:02 +00:00
|
|
|
|
2021-10-23 03:44:07 +00:00
|
|
|
machine.wait_for_file("${redis.servers."".unixSocket}")
|
|
|
|
machine.wait_for_file("${redis.servers."test".unixSocket}")
|
|
|
|
|
2021-01-03 18:20:02 +00:00
|
|
|
# The unix socket is accessible to the redis group
|
|
|
|
machine.succeed('su member -c "redis-cli ping | grep PONG"')
|
2021-10-23 03:44:07 +00:00
|
|
|
machine.succeed('su member-test -c "redis-cli ping | grep PONG"')
|
2021-01-03 18:20:02 +00:00
|
|
|
|
2019-11-06 14:57:56 +00:00
|
|
|
machine.succeed("redis-cli ping | grep PONG")
|
2021-10-23 03:44:07 +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")
|
2019-08-31 18:17:33 +00:00
|
|
|
'';
|
|
|
|
})
|