aboutsummaryrefslogtreecommitdiff
path: root/tests/remote-builds.nix
diff options
context:
space:
mode:
authorJohn Ericson <John.Ericson@Obsidian.Systems>2021-02-25 20:35:11 +0000
committerJohn Ericson <John.Ericson@Obsidian.Systems>2021-02-25 21:51:05 +0000
commitca0994819d68aee26a2906c37a47ae609ac46c4c (patch)
treec96805c008c22926b1eaadc340a99323d53be532 /tests/remote-builds.nix
parent10e81bf871551901ff0383bdede0f79325e93867 (diff)
parentc189031e8be0530d73a817571ad7f81ad5eedce6 (diff)
Merge remote-tracking branch 'upstream/master' into path-info
Diffstat (limited to 'tests/remote-builds.nix')
-rw-r--r--tests/remote-builds.nix85
1 files changed, 44 insertions, 41 deletions
diff --git a/tests/remote-builds.nix b/tests/remote-builds.nix
index 153956619..b9e7352c0 100644
--- a/tests/remote-builds.nix
+++ b/tests/remote-builds.nix
@@ -2,7 +2,7 @@
{ nixpkgs, system, overlay }:
-with import (nixpkgs + "/nixos/lib/testing.nix") {
+with import (nixpkgs + "/nixos/lib/testing-python.nix") {
inherit system;
extraConfigurations = [ { nixpkgs.overlays = [ overlay ]; } ];
};
@@ -36,6 +36,7 @@ let
in
{
+ name = "remote-builds";
nodes =
{ builder1 = builder;
@@ -66,44 +67,46 @@ in
};
};
- testScript = { nodes }:
- ''
- startAll;
-
- # Create an SSH key on the client.
- my $key = `${pkgs.openssh}/bin/ssh-keygen -t ed25519 -f key -N ""`;
- $client->succeed("mkdir -p -m 700 /root/.ssh");
- $client->copyFileFromHost("key", "/root/.ssh/id_ed25519");
- $client->succeed("chmod 600 /root/.ssh/id_ed25519");
-
- # Install the SSH key on the builders.
- $client->waitForUnit("network.target");
- foreach my $builder ($builder1, $builder2) {
- $builder->succeed("mkdir -p -m 700 /root/.ssh");
- $builder->copyFileFromHost("key.pub", "/root/.ssh/authorized_keys");
- $builder->waitForUnit("sshd");
- $client->succeed("ssh -o StrictHostKeyChecking=no " . $builder->name() . " 'echo hello world'");
- }
-
- # Perform a build and check that it was performed on the builder.
- my $out = $client->succeed(
- "nix-build ${expr nodes.client.config 1} 2> build-output",
- "grep -q Hello build-output"
- );
- $builder1->succeed("test -e $out");
-
- # And a parallel build.
- my ($out1, $out2) = split /\s/,
- $client->succeed('nix-store -r $(nix-instantiate ${expr nodes.client.config 2})\!out $(nix-instantiate ${expr nodes.client.config 3})\!out');
- $builder1->succeed("test -e $out1 -o -e $out2");
- $builder2->succeed("test -e $out1 -o -e $out2");
-
- # And a failing build.
- $client->fail("nix-build ${expr nodes.client.config 5}");
-
- # Test whether the build hook automatically skips unavailable builders.
- $builder1->block;
- $client->succeed("nix-build ${expr nodes.client.config 4}");
- '';
-
+ testScript = { nodes }: ''
+ # fmt: off
+ import subprocess
+
+ start_all()
+
+ # Create an SSH key on the client.
+ subprocess.run([
+ "${pkgs.openssh}/bin/ssh-keygen", "-t", "ed25519", "-f", "key", "-N", ""
+ ], capture_output=True, check=True)
+ client.succeed("mkdir -p -m 700 /root/.ssh")
+ client.copy_from_host("key", "/root/.ssh/id_ed25519")
+ client.succeed("chmod 600 /root/.ssh/id_ed25519")
+
+ # Install the SSH key on the builders.
+ client.wait_for_unit("network.target")
+ for builder in [builder1, builder2]:
+ builder.succeed("mkdir -p -m 700 /root/.ssh")
+ builder.copy_from_host("key.pub", "/root/.ssh/authorized_keys")
+ builder.wait_for_unit("sshd")
+ client.succeed(f"ssh -o StrictHostKeyChecking=no {builder.name} 'echo hello world'")
+
+ # Perform a build and check that it was performed on the builder.
+ out = client.succeed(
+ "nix-build ${expr nodes.client.config 1} 2> build-output",
+ "grep -q Hello build-output"
+ )
+ builder1.succeed(f"test -e {out}")
+
+ # And a parallel build.
+ paths = client.succeed(r'nix-store -r $(nix-instantiate ${expr nodes.client.config 2})\!out $(nix-instantiate ${expr nodes.client.config 3})\!out')
+ out1, out2 = paths.split()
+ builder1.succeed(f"test -e {out1} -o -e {out2}")
+ builder2.succeed(f"test -e {out1} -o -e {out2}")
+
+ # And a failing build.
+ client.fail("nix-build ${expr nodes.client.config 5}")
+
+ # Test whether the build hook automatically skips unavailable builders.
+ builder1.block()
+ client.succeed("nix-build ${expr nodes.client.config 4}")
+ '';
})