Skip to content

Commit b16f158

Browse files
committed
nixos/hydra: switch to runTest, refactor
1 parent ab2a3d7 commit b16f158

File tree

4 files changed

+42
-64
lines changed

4 files changed

+42
-64
lines changed

nixos/tests/all-tests.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -611,7 +611,7 @@ in
611611
hostname = handleTest ./hostname.nix { };
612612
hound = handleTest ./hound.nix { };
613613
hub = handleTest ./git/hub.nix { };
614-
hydra = handleTest ./hydra { };
614+
hydra = runTest ./hydra;
615615
i3wm = handleTest ./i3wm.nix { };
616616
icingaweb2 = runTest ./icingaweb2.nix;
617617
ifm = handleTest ./ifm.nix { };

nixos/tests/hydra/common.nix

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
1-
{ system, ... }:
21
{
32
baseConfig =
43
{ pkgs, ... }:
54
let
65
trivialJob = pkgs.writeTextDir "trivial.nix" ''
76
{ trivial = builtins.derivation {
87
name = "trivial";
9-
system = "${system}";
8+
system = "${pkgs.stdenv.hostPlatform.system}";
109
builder = "/bin/sh";
1110
allowSubstitutes = false;
1211
preferLocalBuild = true;

nixos/tests/hydra/default.nix

Lines changed: 39 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -1,65 +1,44 @@
1-
{
2-
system ? builtins.currentSystem,
3-
config ? { },
4-
pkgs ? import ../../.. { inherit system config; },
5-
}:
6-
7-
with import ../../lib/testing-python.nix { inherit system pkgs; };
8-
with pkgs.lib;
9-
1+
{ pkgs, ... }:
102
let
11-
12-
inherit (import ./common.nix { inherit system; }) baseConfig;
13-
14-
hydraPkgs = {
15-
inherit (pkgs) hydra;
3+
inherit (import ./common.nix) baseConfig;
4+
in
5+
{
6+
name = "hydra";
7+
meta = with pkgs.lib.maintainers; {
8+
maintainers = [ lewo ];
169
};
1710

18-
makeHydraTest =
19-
with pkgs.lib;
20-
name: package:
21-
makeTest {
22-
name = "hydra-${name}";
23-
meta = with pkgs.lib.maintainers; {
24-
maintainers = [ lewo ];
25-
};
26-
27-
nodes.machine =
28-
{ pkgs, lib, ... }:
29-
{
30-
imports = [ baseConfig ];
31-
services.hydra = { inherit package; };
32-
};
33-
34-
testScript = ''
35-
# let the system boot up
36-
machine.wait_for_unit("multi-user.target")
37-
# test whether the database is running
38-
machine.wait_for_unit("postgresql.service")
39-
# test whether the actual hydra daemons are running
40-
machine.wait_for_unit("hydra-init.service")
41-
machine.require_unit_state("hydra-queue-runner.service")
42-
machine.require_unit_state("hydra-evaluator.service")
43-
machine.require_unit_state("hydra-notify.service")
44-
45-
machine.succeed("hydra-create-user admin --role admin --password admin")
46-
47-
# create a project with a trivial job
48-
machine.wait_for_open_port(3000)
49-
50-
# make sure the build as been successfully built
51-
machine.succeed("create-trivial-project.sh")
52-
53-
machine.wait_until_succeeds(
54-
'curl -L -s http://localhost:3000/build/1 -H "Accept: application/json" | jq .buildstatus | xargs test 0 -eq'
55-
)
56-
57-
machine.wait_until_succeeds(
58-
'journalctl -eu hydra-notify.service -o cat | grep -q "sending mail notification to hydra@localhost"'
59-
)
60-
'';
11+
nodes.machine =
12+
{ pkgs, lib, ... }:
13+
{
14+
imports = [ baseConfig ];
6115
};
6216

63-
in
64-
65-
mapAttrs makeHydraTest hydraPkgs
17+
testScript = ''
18+
# let the system boot up
19+
machine.wait_for_unit("multi-user.target")
20+
# test whether the database is running
21+
machine.wait_for_unit("postgresql.service")
22+
# test whether the actual hydra daemons are running
23+
machine.wait_for_unit("hydra-init.service")
24+
machine.require_unit_state("hydra-queue-runner.service")
25+
machine.require_unit_state("hydra-evaluator.service")
26+
machine.require_unit_state("hydra-notify.service")
27+
28+
machine.succeed("hydra-create-user admin --role admin --password admin")
29+
30+
# create a project with a trivial job
31+
machine.wait_for_open_port(3000)
32+
33+
# make sure the build as been successfully built
34+
machine.succeed("create-trivial-project.sh")
35+
36+
machine.wait_until_succeeds(
37+
'curl -L -s http://localhost:3000/build/1 -H "Accept: application/json" | jq .buildstatus | xargs test 0 -eq'
38+
)
39+
40+
machine.wait_until_succeeds(
41+
'journalctl -eu hydra-notify.service -o cat | grep -q "sending mail notification to hydra@localhost"'
42+
)
43+
'';
44+
}

pkgs/by-name/hy/hydra/package.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ stdenv.mkDerivation (finalAttrs: {
265265

266266
passthru = {
267267
inherit nix perlDeps;
268-
tests.basic = nixosTests.hydra.hydra;
268+
tests = { inherit (nixosTests) hydra; };
269269
updateScript = unstableGitUpdater { };
270270
};
271271

0 commit comments

Comments
 (0)