forked from Fediversity/Fediversity
split tests to allow running the faster ssh test separately
This commit is contained in:
parent
80e2a9b909
commit
cc66348444
14 changed files with 112 additions and 25 deletions
|
@ -57,11 +57,17 @@ jobs:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
- run: nix build .#checks.x86_64-linux.deployment-panel -L
|
- run: nix build .#checks.x86_64-linux.deployment-panel -L
|
||||||
|
|
||||||
check-deployment-model:
|
check-deployment-model-ssh:
|
||||||
runs-on: native
|
runs-on: native
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
- run: nix build .#checks.x86_64-linux.deployment-model -L
|
- run: nix build .#checks.x86_64-linux.deployment-model-ssh -L
|
||||||
|
|
||||||
|
check-deployment-model-nixops4:
|
||||||
|
runs-on: native
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
- run: nix build .#checks.x86_64-linux.deployment-model-nixops4 -L
|
||||||
|
|
||||||
## NOTE: NixOps4 does not provide a good “dry run” mode, so we instead check
|
## NOTE: NixOps4 does not provide a good “dry run” mode, so we instead check
|
||||||
## proxies for resources, namely whether their `.#vmOptions.<machine>` and
|
## proxies for resources, namely whether their `.#vmOptions.<machine>` and
|
||||||
|
|
|
@ -10,5 +10,10 @@ runNixOSTest {
|
||||||
./nixosTest.nix
|
./nixosTest.nix
|
||||||
];
|
];
|
||||||
_module.args = { inherit inputs sources; };
|
_module.args = { inherit inputs sources; };
|
||||||
inherit (import ./constants.nix) targetMachines pathToRoot pathFromRoot;
|
inherit (import ./constants.nix)
|
||||||
|
targetMachines
|
||||||
|
pathToRoot
|
||||||
|
pathFromRoot
|
||||||
|
useFlake
|
||||||
|
;
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,5 +15,6 @@ runNixOSTest {
|
||||||
pathToRoot
|
pathToRoot
|
||||||
pathFromRoot
|
pathFromRoot
|
||||||
enableAcme
|
enableAcme
|
||||||
|
useFlake
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
|
|
@ -163,7 +163,7 @@ in
|
||||||
'')}
|
'')}
|
||||||
|
|
||||||
${
|
${
|
||||||
if true then
|
if config.useFlake then
|
||||||
''
|
''
|
||||||
## NOTE: This is super slow. It could probably be optimised in Nix, for
|
## NOTE: This is super slow. It could probably be optimised in Nix, for
|
||||||
## instance by allowing to grab things directly from the host's store.
|
## instance by allowing to grab things directly from the host's store.
|
||||||
|
|
9
deployment/check/data-model-nixops4/constants.nix
Normal file
9
deployment/check/data-model-nixops4/constants.nix
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
{
|
||||||
|
targetMachines = [
|
||||||
|
"nixops4"
|
||||||
|
];
|
||||||
|
pathToRoot = ../../..;
|
||||||
|
pathFromRoot = ./.;
|
||||||
|
enableAcme = true;
|
||||||
|
useFlake = true;
|
||||||
|
}
|
22
deployment/check/data-model-nixops4/default.nix
Normal file
22
deployment/check/data-model-nixops4/default.nix
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
{
|
||||||
|
runNixOSTest,
|
||||||
|
inputs,
|
||||||
|
sources,
|
||||||
|
}:
|
||||||
|
|
||||||
|
runNixOSTest {
|
||||||
|
imports = [
|
||||||
|
../../data-model.nix
|
||||||
|
../../function.nix
|
||||||
|
../common/nixosTest.nix
|
||||||
|
./nixosTest.nix
|
||||||
|
];
|
||||||
|
_module.args = { inherit inputs sources; };
|
||||||
|
inherit (import ./constants.nix)
|
||||||
|
targetMachines
|
||||||
|
pathToRoot
|
||||||
|
pathFromRoot
|
||||||
|
enableAcme
|
||||||
|
useFlake
|
||||||
|
;
|
||||||
|
}
|
|
@ -20,7 +20,7 @@
|
||||||
(import ./deployment/check/common/data-model.nix {
|
(import ./deployment/check/common/data-model.nix {
|
||||||
inherit system inputs;
|
inherit system inputs;
|
||||||
config = {
|
config = {
|
||||||
inherit (import ./deployment/check/data-model/constants.nix) pathToRoot pathFromRoot;
|
inherit (import ./deployment/check/data-model-nixops4/constants.nix) pathToRoot pathFromRoot;
|
||||||
nodeName = "nixops4";
|
nodeName = "nixops4";
|
||||||
};
|
};
|
||||||
})."nixops4-deployment".nixops4;
|
})."nixops4-deployment".nixops4;
|
52
deployment/check/data-model-nixops4/nixosTest.nix
Normal file
52
deployment/check/data-model-nixops4/nixosTest.nix
Normal file
|
@ -0,0 +1,52 @@
|
||||||
|
{
|
||||||
|
lib,
|
||||||
|
config,
|
||||||
|
inputs,
|
||||||
|
...
|
||||||
|
}:
|
||||||
|
{
|
||||||
|
_class = "nixosTest";
|
||||||
|
imports = [
|
||||||
|
../common/data-model-options.nix
|
||||||
|
];
|
||||||
|
|
||||||
|
name = "deployment-model";
|
||||||
|
sourceFileset = lib.fileset.unions [
|
||||||
|
../../data-model.nix
|
||||||
|
../../function.nix
|
||||||
|
../common/data-model.nix
|
||||||
|
../common/data-model-options.nix
|
||||||
|
./constants.nix
|
||||||
|
(config.pathToCwd + "/flake-under-test.nix")
|
||||||
|
];
|
||||||
|
|
||||||
|
nodes.deployer =
|
||||||
|
{ pkgs, ... }:
|
||||||
|
{
|
||||||
|
environment.systemPackages = with pkgs; [
|
||||||
|
inputs.nixops4.packages.${system}.default
|
||||||
|
jq
|
||||||
|
];
|
||||||
|
|
||||||
|
# FIXME: sad times
|
||||||
|
system.extraDependencies = with pkgs; [
|
||||||
|
jq
|
||||||
|
jq.inputDerivation
|
||||||
|
];
|
||||||
|
|
||||||
|
system.extraDependenciesFromModule =
|
||||||
|
{ pkgs, ... }:
|
||||||
|
{
|
||||||
|
environment.systemPackages = with pkgs; [
|
||||||
|
hello
|
||||||
|
];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
extraTestScript = ''
|
||||||
|
with subtest("nixops4"):
|
||||||
|
nixops4.fail("hello 1>&2")
|
||||||
|
deployer.succeed("nixops4 apply check-deployment-model --show-trace --verbose --no-interactive 1>&2")
|
||||||
|
nixops4.succeed("su - operator -c hello 1>&2")
|
||||||
|
'';
|
||||||
|
}
|
|
@ -1,7 +1,6 @@
|
||||||
{
|
{
|
||||||
targetMachines = [
|
targetMachines = [
|
||||||
"ssh"
|
"ssh"
|
||||||
"nixops4"
|
|
||||||
];
|
];
|
||||||
pathToRoot = ../../..;
|
pathToRoot = ../../..;
|
||||||
pathFromRoot = ./.;
|
pathFromRoot = ./.;
|
|
@ -6,18 +6,18 @@
|
||||||
...
|
...
|
||||||
}:
|
}:
|
||||||
let
|
let
|
||||||
inherit (import ./constants.nix) pathToRoot;
|
inherit (import ./constants.nix) pathToRoot pathFromRoot;
|
||||||
|
inherit (pkgs) system;
|
||||||
escapedJson = v: lib.replaceStrings [ "\"" ] [ "\\\\\"" ] (lib.strings.toJSON v);
|
escapedJson = v: lib.replaceStrings [ "\"" ] [ "\\\\\"" ] (lib.strings.toJSON v);
|
||||||
deployment-config = {
|
deployment-config = {
|
||||||
inherit (import ./constants.nix) pathToRoot pathFromRoot;
|
inherit pathToRoot pathFromRoot;
|
||||||
inherit (config) enableAcme;
|
inherit (config) enableAcme;
|
||||||
acmeNodeIP = if config.enableAcme then config.nodes.acme.networking.primaryIPAddress else null;
|
acmeNodeIP = if config.enableAcme then config.nodes.acme.networking.primaryIPAddress else null;
|
||||||
nodeName = "ssh";
|
nodeName = "ssh";
|
||||||
};
|
};
|
||||||
inherit
|
inherit
|
||||||
((import ../common/data-model.nix {
|
((import ../common/data-model.nix {
|
||||||
inherit (pkgs) system;
|
inherit system inputs;
|
||||||
inherit inputs;
|
|
||||||
config = deployment-config;
|
config = deployment-config;
|
||||||
})."ssh-deployment".ssh-host.ssh
|
})."ssh-deployment".ssh-host.ssh
|
||||||
)
|
)
|
||||||
|
@ -39,23 +39,15 @@ in
|
||||||
../common/data-model.nix
|
../common/data-model.nix
|
||||||
../common/data-model-options.nix
|
../common/data-model-options.nix
|
||||||
./constants.nix
|
./constants.nix
|
||||||
(config.pathToCwd + "/flake-under-test.nix")
|
|
||||||
];
|
];
|
||||||
|
|
||||||
nodes.deployer =
|
nodes.deployer =
|
||||||
{ pkgs, ... }:
|
{ pkgs, ... }:
|
||||||
{
|
{
|
||||||
environment.systemPackages = with pkgs; [
|
environment.systemPackages = with pkgs; [
|
||||||
inputs.nixops4.packages.${system}.default
|
|
||||||
jq
|
jq
|
||||||
];
|
];
|
||||||
|
|
||||||
# FIXME: sad times
|
|
||||||
system.extraDependencies = with pkgs; [
|
|
||||||
jq
|
|
||||||
jq.inputDerivation
|
|
||||||
];
|
|
||||||
|
|
||||||
system.extraDependenciesFromModule =
|
system.extraDependenciesFromModule =
|
||||||
{ pkgs, ... }:
|
{ pkgs, ... }:
|
||||||
{
|
{
|
||||||
|
@ -66,11 +58,6 @@ in
|
||||||
};
|
};
|
||||||
|
|
||||||
extraTestScript = ''
|
extraTestScript = ''
|
||||||
with subtest("nixops4"):
|
|
||||||
nixops4.fail("hello 1>&2")
|
|
||||||
deployer.succeed("nixops4 apply check-deployment-model --show-trace --verbose --no-interactive 1>&2")
|
|
||||||
nixops4.succeed("su - operator -c hello 1>&2")
|
|
||||||
|
|
||||||
with subtest("ssh: Check the status before deployment"):
|
with subtest("ssh: Check the status before deployment"):
|
||||||
ssh.fail("hello 1>&2")
|
ssh.fail("hello 1>&2")
|
||||||
|
|
|
@ -15,5 +15,6 @@ runNixOSTest {
|
||||||
pathToRoot
|
pathToRoot
|
||||||
pathFromRoot
|
pathFromRoot
|
||||||
enableAcme
|
enableAcme
|
||||||
|
useFlake
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
|
|
@ -70,7 +70,7 @@ let
|
||||||
};
|
};
|
||||||
deployment-type = attrTag {
|
deployment-type = attrTag {
|
||||||
ssh-host = mkOption {
|
ssh-host = mkOption {
|
||||||
description = "A Terraform deployment by SSH to update a single existing NixOS host.";
|
description = "A deployment by SSH to update a single existing NixOS host.";
|
||||||
type = submodule {
|
type = submodule {
|
||||||
options = {
|
options = {
|
||||||
inherit nixos-configuration;
|
inherit nixos-configuration;
|
||||||
|
|
|
@ -22,7 +22,12 @@
|
||||||
inherit inputs sources;
|
inherit inputs sources;
|
||||||
};
|
};
|
||||||
|
|
||||||
deployment-model = import ./check/data-model {
|
deployment-model-ssh = import ./check/data-model-ssh {
|
||||||
|
inherit (pkgs.testers) runNixOSTest;
|
||||||
|
inherit inputs sources;
|
||||||
|
};
|
||||||
|
|
||||||
|
deployment-model-nixops4 = import ./check/data-model-nixops4 {
|
||||||
inherit (pkgs.testers) runNixOSTest;
|
inherit (pkgs.testers) runNixOSTest;
|
||||||
inherit inputs sources;
|
inherit inputs sources;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Reference in a new issue