From fc96f75c354d9772327ca78a6f23763df4cb4c72 Mon Sep 17 00:00:00 2001 From: Sven Dowideit Date: Mon, 30 Jan 2017 16:11:46 +1000 Subject: [PATCH] add upgrade with non-default console installed Signed-off-by: Sven Dowideit --- cmd/control/install.go | 9 ++++++--- tests/common_test.go | 6 +++--- tests/upgrade_test.go | 16 +++++++++++++--- 3 files changed, 22 insertions(+), 9 deletions(-) diff --git a/cmd/control/install.go b/cmd/control/install.go index 69119fec..232d8746 100755 --- a/cmd/control/install.go +++ b/cmd/control/install.go @@ -220,7 +220,7 @@ func runInstall(image, installType, cloudConfig, device, kappend string, force, if !isoinstallerloaded { log.Infof("start !isoinstallerloaded") - if _, err := os.Stat("/dist/initrd"); os.IsNotExist(err) { + if _, err := os.Stat("/dist/initrd-" + config.Version); os.IsNotExist(err) { if err = mountBootIso(); err != nil { log.Debugf("mountBootIso error %s", err) } else { @@ -237,8 +237,11 @@ func runInstall(image, installType, cloudConfig, device, kappend string, force, useIso = true // now use the installer image cfg := config.LoadConfig() - // TODO: fix the fullinstaller Dockerfile to use the ${VERSION}${SUFFIX} - image = cfg.Rancher.Upgrade.Image + "-installer" + ":latest" + + if image == cfg.Rancher.Upgrade.Image+":"+config.Version+config.Suffix { + // TODO: fix the fullinstaller Dockerfile to use the ${VERSION}${SUFFIX} + image = cfg.Rancher.Upgrade.Image + "-installer" + ":latest" + } } } // TODO: also poke around looking for the /boot/vmlinuz and initrd... diff --git a/tests/common_test.go b/tests/common_test.go index 0ae1b1c9..14fef530 100755 --- a/tests/common_test.go +++ b/tests/common_test.go @@ -185,13 +185,13 @@ func (s *QemuSuite) LoadInstallerImage(c *C) { c.Assert(cmd.Run(), IsNil) } -func (s *QemuSuite) PullAndLoadInstallerImage(c *C, tag string) { - cmd := exec.Command("sh", "-c", fmt.Sprintf("docker pull rancher/os:%s", tag)) +func (s *QemuSuite) PullAndLoadInstallerImage(c *C, image string) { + cmd := exec.Command("sh", "-c", fmt.Sprintf("docker pull %s", image)) cmd.Stdout = os.Stdout cmd.Stderr = os.Stderr c.Assert(cmd.Run(), IsNil) - cmd = exec.Command("sh", "-c", fmt.Sprintf("docker save rancher/os:%s | ../scripts/ssh --qemu sudo system-docker load", tag)) + cmd = exec.Command("sh", "-c", fmt.Sprintf("docker save %s | ../scripts/ssh --qemu sudo system-docker load", image)) cmd.Stdout = os.Stdout cmd.Stderr = os.Stderr c.Assert(cmd.Run(), IsNil) diff --git a/tests/upgrade_test.go b/tests/upgrade_test.go index 2a21f05d..2b7cc384 100755 --- a/tests/upgrade_test.go +++ b/tests/upgrade_test.go @@ -40,7 +40,9 @@ func (s *QemuSuite) commonTestCode(c *C, startWithVersion, console string) { c.Assert(Version, Equals, version) fmt.Printf("installing %s", startWithVersion) - s.PullAndLoadInstallerImage(c, startWithVersion) + s.PullAndLoadInstallerImage(c, fmt.Sprintf("rancher/os:%s", startWithVersion)) + + //ADD a custom append line and make sure its kept in the upgraded version too s.CheckCall(c, fmt.Sprintf(` echo "---------------------------------- generic" @@ -48,9 +50,8 @@ set -ex echo "ssh_authorized_keys:" > config.yml echo " - $(cat /home/rancher/.ssh/authorized_keys)" >> config.yml sudo ros install --force --no-reboot --device /dev/vda -c config.yml --append rancher.password=rancher -i rancher/os:%s -sudo ros console enable %s sync - `, startWithVersion, console)) + `, startWithVersion)) time.Sleep(500 * time.Millisecond) s.Stop(c) } @@ -63,6 +64,15 @@ sync s.CheckOutput(c, "ros version "+startWithVersion+"\n", Equals, "sudo ros -v") + if console != "default" { + // Can't preload the startWithVersion console image, as some don't exist by that name - not sure how to approach that + //s.PullAndLoadInstallerImage(c, fmt.Sprintf("rancher/os-%sconsole:%s", console, startWithVersion)) + // TODO: ouch. probably need to tag the dev / master version as latest cos this won't work + // Need to pull the image here - if we do it at boot, then the test will fail. + s.PullAndLoadInstallerImage(c, fmt.Sprintf("rancher/os-%sconsole:%s", console, "v0.8.0-rc3")) + s.CheckCall(c, fmt.Sprintf("sudo ros console enable %s", console)) + } + s.LoadInstallerImage(c) s.CheckCall(c, fmt.Sprintf("sudo ros os upgrade --no-reboot -i rancher/os:%s%s --force", Version, Suffix))