-
-
Notifications
You must be signed in to change notification settings - Fork 14.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
119 changed files
with
2,269 additions
and
1,907 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,44 +1,87 @@ | ||
import ./make-test-python.nix ({ pkgs, lib, ... }: | ||
{ | ||
name = "redis"; | ||
meta.maintainers = with lib.maintainers; [ flokli ]; | ||
|
||
nodes = { | ||
machine = | ||
{ pkgs, lib, ... }: | ||
|
||
{ | ||
services.redis.servers."".enable = true; | ||
services.redis.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"]); | ||
}; | ||
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.config.services) redis; | ||
in '' | ||
start_all() | ||
machine.wait_for_unit("redis") | ||
machine.wait_for_unit("redis-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) | ||
# 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}") | ||
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"') | ||
# 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("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") | ||
''; | ||
}) | ||
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.