1 { system ? builtins.currentSystem,
3 pkgs ? import ../.. { inherit system config; }
6 with import ../lib/testing-python.nix { inherit system pkgs; };
9 with import common/ec2.nix { inherit makeTest pkgs; };
12 image = (import ../lib/eval-config.nix {
15 ../maintainers/scripts/openstack/openstack-image.nix
16 ../modules/testing/test-instrumentation.nix
17 ../modules/profiles/qemu-guest.nix
19 # Needed by nixos-rebuild due to lack of network access.
20 system.extraDependencies = with pkgs; [
25 }).config.system.build.openstackImage + "/nixos.qcow2";
27 sshKeys = import ./ssh-keys.nix pkgs;
28 snakeOilPrivateKey = sshKeys.snakeOilPrivateKey.text;
29 snakeOilPrivateKeyFile = pkgs.writeText "private-key" snakeOilPrivateKey;
30 snakeOilPublicKey = sshKeys.snakeOilPublicKey;
33 metadata = makeEc2Test {
34 name = "openstack-ec2-metadata";
36 sshPublicKey = snakeOilPublicKey;
38 SSH_HOST_ED25519_KEY_PUB:${snakeOilPublicKey}
39 SSH_HOST_ED25519_KEY:${replaceStrings ["\n"] ["|"] snakeOilPrivateKey}
43 machine.wait_for_file("/etc/ec2-metadata/user-data")
44 machine.wait_for_unit("sshd.service")
46 machine.succeed("grep unknown /etc/ec2-metadata/ami-manifest-path")
48 # We have no keys configured on the client side yet, so this should fail
49 machine.fail("ssh -o BatchMode=yes localhost exit")
51 # Let's install our client private key
52 machine.succeed("mkdir -p ~/.ssh")
54 machine.copy_from_host_via_shell(
55 "${snakeOilPrivateKeyFile}", "~/.ssh/id_ed25519"
57 machine.succeed("chmod 600 ~/.ssh/id_ed25519")
59 # We haven't configured the host key yet, so this should still fail
60 machine.fail("ssh -o BatchMode=yes localhost exit")
62 # Add the host key; ssh should finally succeed
64 "echo localhost,127.0.0.1 ${snakeOilPublicKey} > ~/.ssh/known_hosts"
66 machine.succeed("ssh -o BatchMode=yes localhost exit")
68 # Just to make sure resizing is idempotent.
71 machine.wait_for_file("/etc/ec2-metadata/user-data")
75 userdata = makeEc2Test {
76 name = "openstack-ec2-metadata";
78 sshPublicKey = snakeOilPublicKey;
83 <nixpkgs/nixos/modules/virtualisation/openstack-config.nix>
84 <nixpkgs/nixos/modules/testing/test-instrumentation.nix>
85 <nixpkgs/nixos/modules/profiles/qemu-guest.nix>
87 environment.etc.testFile = {
94 machine.wait_for_file("/etc/testFile")
95 assert "whoa" in machine.succeed("cat /etc/testFile")