integration-tests: Make it easier to override pkgs and colmena

This commit is contained in:
Zhaofeng Li 2021-12-07 23:13:31 -08:00
parent 31fc98cfa7
commit 372de58dff
9 changed files with 38 additions and 22 deletions

View file

@ -1,5 +1,7 @@
{ pkgs ? import ../nixpkgs.nix }:
let let
tools = import ../tools.nix { tools = pkgs.callPackage ../tools.nix {
targets = []; targets = [];
prebuiltTarget = "deployer"; prebuiltTarget = "deployer";
}; };

View file

@ -1,5 +1,7 @@
{ pkgs ? import ../nixpkgs.nix }:
let let
tools = import ../tools.nix {}; tools = pkgs.callPackage ../tools.nix {};
in tools.makeTest { in tools.makeTest {
name = "colmena-apply"; name = "colmena-apply";

View file

@ -22,9 +22,8 @@ with subtest("Check that activation messages were logged correctly"):
assert "must appear during activation" in logs assert "must appear during activation" in logs
with subtest("Check that we can still connect to the target nodes"): with subtest("Check that we can still connect to the target nodes"):
deployer.succeed("ssh alpha true") for node in targets:
deployer.succeed("ssh beta true") deployer.succeed(f"ssh {node.name} true")
deployer.succeed("ssh gamma true")
with subtest("Check that the new configurations are indeed applied"): with subtest("Check that the new configurations are indeed applied"):
for node in targets: for node in targets:

View file

@ -1,7 +1,7 @@
{ {
apply = import ./apply; apply = import ./apply {};
apply-local = import ./apply-local; apply-local = import ./apply-local {};
exec = import ./exec; exec = import ./exec {};
flakes = import ./flakes; flakes = import ./flakes {};
parallel = import ./parallel; parallel = import ./parallel {};
} }

View file

@ -1,5 +1,7 @@
{ pkgs ? import ../nixpkgs.nix }:
let let
tools = import ../tools.nix {}; tools = pkgs.callPackage ../tools.nix {};
in tools.makeTest { in tools.makeTest {
name = "colmena-exec"; name = "colmena-exec";

View file

@ -1,5 +1,7 @@
{ pkgs ? import ../nixpkgs.nix }:
let let
tools = import ../tools.nix { tools = pkgs.callPackage ../tools.nix {
targets = [ "alpha" ]; targets = [ "alpha" ];
}; };
in tools.makeTest { in tools.makeTest {

View file

@ -0,0 +1,13 @@
let
lock = builtins.fromJSON (builtins.readFile ../flake.lock);
pinned = fetchTarball {
url = "https://github.com/NixOS/nixpkgs/archive/${lock.nodes.nixpkgs.locked.rev}.tar.gz";
sha256 = lock.nodes.nixpkgs.locked.narHash;
};
in import pinned {
overlays = [
(final: prev: {
colmena = final.callPackage ../default.nix { };
})
];
}

View file

@ -1,5 +1,7 @@
{ pkgs ? import ../nixpkgs.nix }:
let let
tools = import ../tools.nix {}; tools = pkgs.callPackage ../tools.nix {};
in tools.makeTest { in tools.makeTest {
name = "colmena-parallel"; name = "colmena-parallel";

View file

@ -11,6 +11,9 @@
, deployers ? [ "deployer" ] # Nodes configured as deployers (with Colmena and pre-built system closure) , deployers ? [ "deployer" ] # Nodes configured as deployers (with Colmena and pre-built system closure)
, targets ? [ "alpha" "beta" "gamma" ] # Nodes configured as targets (minimal config) , targets ? [ "alpha" "beta" "gamma" ] # Nodes configured as targets (minimal config)
, prebuiltTarget ? "alpha" # Target node to prebuild system closure for, or null , prebuiltTarget ? "alpha" # Target node to prebuild system closure for, or null
, pkgs ? if insideVm then import <nixpkgs> {} else throw "Must specify pkgs"
, colmena ? if !insideVm then pkgs.colmena else throw "Cannot eval inside VM"
}: }:
with builtins; with builtins;
@ -18,17 +21,8 @@ with builtins;
assert elem "deployer" deployers; assert elem "deployer" deployers;
let let
lock = builtins.fromJSON (builtins.readFile ../flake.lock);
pinned = if insideVm then <nixpkgs> else fetchTarball {
url = "https://github.com/NixOS/nixpkgs/archive/${lock.nodes.nixpkgs.locked.rev}.tar.gz";
sha256 = lock.nodes.nixpkgs.locked.narHash;
};
pkgs = import pinned {};
inherit (pkgs) lib; inherit (pkgs) lib;
colmena =
if !insideVm then import ../default.nix { inherit pkgs; }
else throw "Cannot be used inside the VM";
colmenaExec = "${colmena}/bin/colmena"; colmenaExec = "${colmena}/bin/colmena";
sshKeys = import (pkgs.path + "/nixos/tests/ssh-keys.nix") pkgs; sshKeys = import (pkgs.path + "/nixos/tests/ssh-keys.nix") pkgs;