From bd857716a3fb62c27e5a74bf22c654cb94b24f07 Mon Sep 17 00:00:00 2001 From: Sven Dowideit Date: Fri, 26 May 2017 13:31:09 +1000 Subject: [PATCH] Add a cloud-config based install test Signed-off-by: Sven Dowideit --- scripts/run | 2 +- .../cloud-config.yml | 27 +++++++++++++ tests/cloud_config_install_test.go | 39 +++++++++++++++++++ 3 files changed, 67 insertions(+), 1 deletion(-) create mode 100644 tests/assets/cloud_config_install_test/cloud-config.yml create mode 100644 tests/cloud_config_install_test.go diff --git a/scripts/run b/scripts/run index 9cb504c7..bd230448 100755 --- a/scripts/run +++ b/scripts/run @@ -255,7 +255,7 @@ if [ "$CONSOLEDISPLAY" == "1" ]; then DISPLAY_OPTS="-curses" else # default - DISPLAY_OPTS="-nographic -serial stdio -display none" + DISPLAY_OPTS="-nographic -serial mon:stdio -display none" fi if [ "$QEMU" == "1" ]; then diff --git a/tests/assets/cloud_config_install_test/cloud-config.yml b/tests/assets/cloud_config_install_test/cloud-config.yml new file mode 100644 index 00000000..7e1ad184 --- /dev/null +++ b/tests/assets/cloud_config_install_test/cloud-config.yml @@ -0,0 +1,27 @@ +#cloud-config +write_files: +- path: /opt/install + permissions: "0755" + content: | + #!/bin/sh + set -ex + echo "running" > /var/log/ros-install.log + system-docker exec console ros install -i rancher/os:v1.0.1 -d /dev/vda --append "rancher.password=rancher" -f --no-reboot --debug >> /var/log/install.log 2>&1 + echo "done" > /var/log/ros-install.log +ssh_authorized_keys: + - ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC85w9stZyiLQp/DkVO6fqwiShYcj1ClKdtCqgHtf+PLpJkFReSFu8y21y+ev09gsSMRRrjF7yt0pUHV6zncQhVeqsZtgc5WbELY2DOYUGmRn/CCvPbXovoBrQjSorqlBmpuPwsStYLr92Xn+VVsMNSUIegHY22DphGbDKG85vrKB8HxUxGIDxFBds/uE8FhSy+xsoyT/jUZDK6pgq2HnGl6D81ViIlKecpOpWlW3B+fea99ADNyZNVvDzbHE5pcI3VRw8u59WmpWOUgT6qacNVACl8GqpBvQk8sw7O/X9DSZHCKafeD9G5k+GYbAUz92fKWrx/lOXfUXPS3+c8dRIF +rancher: + services: + ros-install: + image: alpine + entrypoint: /usr/bin/ros entrypoint + command: /opt/install + labels: + io.rancher.os.scope: system + io.rancher.os.after: console + uts: host + privileged: true + volumes: + - /var/log:/var/log + volumes_from: + - all-volumes diff --git a/tests/cloud_config_install_test.go b/tests/cloud_config_install_test.go new file mode 100644 index 00000000..2d0f0aff --- /dev/null +++ b/tests/cloud_config_install_test.go @@ -0,0 +1,39 @@ +package integration + +import ( + "time" + + . "gopkg.in/check.v1" +) + +func (s *QemuSuite) TestCloudConfigInstall(c *C) { + s.RunQemu(c, + "--iso", + "--fresh", + "--no-format", + "--cloud-config", "./tests/assets/cloud_config_install_test/cloud-config.yml") + + //check we have a particular version, from iso + s.CheckOutput(c, " Backing Filesystem: tmpfs\n", Equals, "sudo system-docker info | grep Filesystem") + //and no persistence yet + //s.CheckOutput(c, "\n", Equals, "sudo blkid") + // TODO: need some way to wait for install to complete. + time.Sleep(time.Second) + for { + result, _ := s.MakeCall("cat", "/var/log/ros-install.log") + if result == "done\n" { + break + } + time.Sleep(time.Second * 3) + } + //check we have persistence and that ros-install completed ok + s.CheckOutput(c, "/dev/vda1:\n", Equals, "sudo blkid | grep RANCHER_STATE | cut -d ' ' -f 1") + s.CheckOutput(c, "LABEL=\"RANCHER_STATE\"\n", Equals, "sudo blkid | grep vda1 | cut -d ' ' -f 2") + + //reboot, and check we're using the new non-iso install + s.Stop(c) + s.RunQemuWith(c, "--qemu", "--boothd", "--no-rm-usr") + s.CheckOutput(c, "/dev/vda1:\n", Equals, "sudo blkid | grep RANCHER_STATE | cut -d ' ' -f 1") + s.CheckOutput(c, "LABEL=\"RANCHER_STATE\"\n", Equals, "sudo blkid | grep vda1 | cut -d ' ' -f 2") + s.CheckOutput(c, " Backing Filesystem: extfs\n", Equals, "sudo system-docker info | grep Filesystem") +}