diff options
author | Markus Hihn <markus.hihn@dcso.de> | 2017-12-20 21:38:35 +0100 |
---|---|---|
committer | Markus Hihn <markus.hihn@dcso.de> | 2017-12-20 21:38:35 +0100 |
commit | 03fde41b6c223e65363df43a26e735459a3cf92a (patch) | |
tree | 9c7e4d6cc9444c3fff936bcc21c4580d53c5fcab /krebs | |
parent | b1983327610628028021374e519baa27dc63d9bf (diff) | |
parent | a5d7056ccba9fb5f3495390ad1213e133e44fa78 (diff) |
Merge branch 'master' of prism.r:stockholm
Diffstat (limited to 'krebs')
-rw-r--r-- | krebs/3modules/lass/default.nix | 2 | ||||
-rw-r--r-- | krebs/6tests/data/test-config.nix | 22 | ||||
-rw-r--r-- | krebs/6tests/data/test-source.nix | 12 | ||||
-rw-r--r-- | krebs/6tests/deploy.nix | 110 |
4 files changed, 145 insertions, 1 deletions
diff --git a/krebs/3modules/lass/default.nix b/krebs/3modules/lass/default.nix index ba6d85e7a..0567d58ba 100644 --- a/krebs/3modules/lass/default.nix +++ b/krebs/3modules/lass/default.nix @@ -44,7 +44,7 @@ with import <stockholm/lib>; cores = 2; nets = rec { internet = { - ip4.addr = "45.62.226.163"; + ip4.addr = "64.137.242.41"; aliases = [ "echelon.i" ]; diff --git a/krebs/6tests/data/test-config.nix b/krebs/6tests/data/test-config.nix new file mode 100644 index 000000000..f0927ddd9 --- /dev/null +++ b/krebs/6tests/data/test-config.nix @@ -0,0 +1,22 @@ +{ config, lib, pkgs, ... }: + +{ + imports = [ + <stockholm/krebs> + <nixpkgs/nixos/modules/virtualisation/qemu-vm.nix> + <nixpkgs/nixos/modules/testing/test-instrumentation.nix> + ]; + + krebs.hosts.minimal = { + cores = 1; + secure = false; + }; + + boot.loader.grub.enable = false; + boot.loader.systemd-boot.enable = true; + + krebs.build = { + host = config.krebs.hosts.minimal; + user = config.krebs.users.krebs; + }; +} diff --git a/krebs/6tests/data/test-source.nix b/krebs/6tests/data/test-source.nix new file mode 100644 index 000000000..dfc6b3297 --- /dev/null +++ b/krebs/6tests/data/test-source.nix @@ -0,0 +1,12 @@ +with import <stockholm/lib>; +evalSource "" [{ + nixos-config = { + symlink.target = toString ./test-config; + }; + nixpkgs = { + symlink.target = toString <nixpkgs>; + }; + stockholm = { + symlink.target = toString <stockholm>; + }; +}] diff --git a/krebs/6tests/deploy.nix b/krebs/6tests/deploy.nix new file mode 100644 index 000000000..842bbc22a --- /dev/null +++ b/krebs/6tests/deploy.nix @@ -0,0 +1,110 @@ +with import <stockholm/lib>; +import <nixpkgs/nixos/tests/make-test.nix> ({ pkgs, ... }: + +let + test-config = <stockholm/krebs/6tests/data/test-config.nix>; + privKey = '' + -----BEGIN OPENSSH PRIVATE KEY----- + b3BlbnNzaC1rZXktdjEAAAAABG5vbmUAAAAEbm9uZQAAAAAAAAABAAAAMwAAAAtzc2gtZW + QyNTUxOQAAACD1tYD8r6Fcd7bq3Z0nvo5483nXQ8c4LFh0fcw8rOCQtQAAAJBTNHK6UzRy + ugAAAAtzc2gtZWQyNTUxOQAAACD1tYD8r6Fcd7bq3Z0nvo5483nXQ8c4LFh0fcw8rOCQtQ + AAAECK2ZlEIofZyGbh7rXlUq5lUsUyotamtp9QrlvoS3qgePW1gPyvoVx3turdnSe+jnjz + eddDxzgsWHR9zDys4JC1AAAACWxhc3NAbW9ycwECAwQ= + -----END OPENSSH PRIVATE KEY----- + ''; + pubKey = '' + ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIPW1gPyvoVx3turdnSe+jnjzeddDxzgsWHR9zDys4JC1 + ''; + + ssh-config = pkgs.writeText "ssh-config" '' + Host server + StrictHostKeyChecking no + UserKnownHostsFile=/dev/null + ''; + + populate-source = { + nixos-config = { + symlink.target = test-config; + type = "symlink"; + }; + nixpkgs = { + symlink.target = <nixpkgs>; + type = "symlink"; + }; + stockholm = { + symlink.target = <stockholm>; + type = "symlink"; + }; + }; + + test-deploy = pkgs.writeDash "test-deploy" '' + cd ${<stockholm>} + export NIX_PATH=stockholm=${<stockholm>}:nixpkgs=${<nixpkgs>}:$NIX_PATH + exec >&2 + : ${minimalSystem} + source=${pkgs.writeJSON "source.json" populate-source} + cat > /tmp/derp <<EOF + builtins.fromJSON (builtins.readFile "$source") + EOF + LOGNAME=krebs ${pkgs.populate}/bin/populate --force root@server:22/var/src/ < "$source" + #LOGNAME=krebs ${pkgs.stockholm}/bin/deploy \ + # --force-populate \ + # --source=/tmp/derp \ + # --system=server \ + ''; + minimalSystem = (import <nixpkgs/nixos/lib/eval-config.nix> { + modules = [ + test-config + ]; + }).config.system.build.toplevel; + +in { + name = "deploy"; + + nodes = { + + server = + { config, pkgs, ... }: + + { + imports = [ test-config ]; + environment.variables = { + NIX_PATH = mkForce "nixpkgs=${<nixpkgs>}"; + #LOL = minimalSystem; + }; + services.openssh.enable = true; + users.extraUsers.root.openssh.authorizedKeys.keys = [ + pubKey + ]; + #virtualisation.writableStore = true; + virtualisation.pathsInNixDB = [ + minimalSystem + pkgs.stockholm + ]; + }; + + client = + { config, pkgs, ... }: { }; + + }; + + testScript = '' + startAll; + + $server->waitForUnit("sshd"); + + $client->succeed("mkdir -p -m 700 /root/.ssh"); + $client->succeed("echo '${privKey}' > /root/.ssh/id_ed25519"); + $client->succeed("cp ${ssh-config} /root/.ssh/config"); + $client->succeed("chmod 600 /root/.ssh/id_ed25519"); + + $server->waitForUnit("network.target"); + $server->succeed("ip route show 1>&2"); + $client->waitForUnit("network.target"); + $client->succeed("${test-deploy}"); + $server->succeed("nixos-rebuild -I /var/src switch"); + + $client->shutdown; + $server->shutdown; + ''; +}) |