Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: NixOS/nixpkgs
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 9e09e3d5da13
Choose a base ref
...
head repository: NixOS/nixpkgs
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 225a23071661
Choose a head ref
  • 2 commits
  • 2 files changed
  • 2 contributors

Commits on May 23, 2017

  1. nixos/cloudinit: add cloudinit test

    An iso containing metadatas is created and attached as a cdrom to the
    qemu VM used for this test.
    
    The cloudinit service is enabled. The test case ensures the root
    authorized_keys file is populated and the cloudinit write_file module is
    working well.
    nlewo committed May 23, 2017
    Copy the full SHA
    7b80f4c View commit details

Commits on Jun 5, 2017

  1. Merge pull request #23173 from nlewo/test/cloudinit

    Cloudinit test
    grahamc authored Jun 5, 2017
    Copy the full SHA
    225a230 View commit details
Showing with 48 additions and 0 deletions.
  1. +1 −0 nixos/release.nix
  2. +47 −0 nixos/tests/cloud-init.nix
1 change: 1 addition & 0 deletions nixos/release.nix
Original file line number Diff line number Diff line change
@@ -222,6 +222,7 @@ in rec {
tests.cadvisor = hydraJob (import tests/cadvisor.nix { system = "x86_64-linux"; });
tests.chromium = (callSubTests tests/chromium.nix { system = "x86_64-linux"; }).stable;
tests.cjdns = callTest tests/cjdns.nix {};
tests.cloud-init = callTest tests/cloud-init.nix {};
tests.containers-ipv4 = callTest tests/containers-ipv4.nix {};
tests.containers-ipv6 = callTest tests/containers-ipv6.nix {};
tests.containers-bridge = callTest tests/containers-bridge.nix {};
47 changes: 47 additions & 0 deletions nixos/tests/cloud-init.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
{ system ? builtins.currentSystem }:

with import ../lib/testing.nix { inherit system; };
with import ../lib/qemu-flags.nix;
with pkgs.lib;

let
metadataDrive = pkgs.stdenv.mkDerivation {
name = "metadata";
buildCommand = ''
mkdir -p $out/iso
cat << EOF > $out/iso/user-data
#cloud-config
write_files:
- content: |
cloudinit
path: /tmp/cloudinit-write-file
EOF
cat << EOF > $out/iso/meta-data
instance-id: iid-local01
local-hostname: "test"
public-keys:
- "should be a key!"
EOF
${pkgs.cdrkit}/bin/genisoimage -volid cidata -joliet -rock -o $out/metadata.iso $out/iso
'';
};
in makeTest {
meta = with pkgs.stdenv.lib.maintainers; {
maintainers = [ lewo ];
};
machine =
{ config, pkgs, ... }:
{
virtualisation.qemu.options = [ "-cdrom" "${metadataDrive}/metadata.iso" ];
services.cloud-init.enable = true;
};
testScript = ''
$machine->start;
$machine->waitForUnit("cloud-init.service");
$machine->succeed("cat /tmp/cloudinit-write-file | grep -q 'cloudinit'");
$machine->waitUntilSucceeds("cat /root/.ssh/authorized_keys | grep -q 'should be a key!'");
'';
}