func (s *rollbackSuite) TestRollbackMustRebootToOtherVersion(c *check.C) { if common.BeforeReboot() { // here we upgrade updates.CallFakeOSUpdate(c) common.Reboot(c) } else if common.CheckRebootMark(c.TestName()) { // after the first reboot we check that it actually booted // a newer version than before common.RemoveRebootMark(c) currentVersion := common.GetCurrentUbuntuCoreVersion(c) savedVersion := common.GetSavedVersion(c) c.Assert(snappy.VersionCompare(currentVersion, savedVersion), check.Equals, 1, check.Commentf("First reboot to the wrong version: %s <= %s", currentVersion, savedVersion)) // now we rollback to the previous version cli.ExecCommand(c, "sudo", "snappy", "rollback", partition.OSSnapName(c), common.GetSavedVersion(c)) common.RebootWithMark(c, c.TestName()+"-rollback") } else if common.CheckRebootMark(c.TestName() + "-rollback") { // and on the second reboot we check that the rollback // did indeed rolled us back to the previous version common.RemoveRebootMark(c) currentVersion := common.GetCurrentUbuntuCoreVersion(c) savedVersion := common.GetSavedVersion(c) c.Assert(currentVersion, check.Equals, savedVersion, check.Commentf("Second reboot to the wrong version: %s != %s", currentVersion, savedVersion)) } }
func (s *updateRollbackSuite) SetUpTest(c *check.C) { s.SnappySuite.SetUpTest(c) err := os.MkdirAll(basePath, 0777) c.Assert(err, check.IsNil) currentVersion := common.GetCurrentUbuntuCoreVersion(c) s.cm, err = newCycleManager(currentVersion) c.Assert(err, check.IsNil, check.Commentf("Error creating manager: %v", err)) }
func (s *rollbackSuite) TestRollbackMustRebootToOtherVersion(c *check.C) { if common.BeforeReboot() { common.CallFakeUpdate(c) common.Reboot(c) } else if common.CheckRebootMark(c.TestName()) { common.RemoveRebootMark(c) currentVersion := common.GetCurrentUbuntuCoreVersion(c) c.Assert(currentVersion > common.GetSavedVersion(c), check.Equals, true, check.Commentf("Rebooted to the wrong version: %d", currentVersion)) cli.ExecCommand(c, "sudo", "snappy", "rollback", "ubuntu-core", strconv.Itoa(common.GetSavedVersion(c))) common.SetSavedVersion(c, currentVersion) common.RebootWithMark(c, c.TestName()+"-rollback") } else if common.CheckRebootMark(c.TestName() + "-rollback") { common.RemoveRebootMark(c) currentVersion := common.GetCurrentUbuntuCoreVersion(c) c.Assert(currentVersion < common.GetSavedVersion(c), check.Equals, true, check.Commentf("Rebooted to the wrong version: %d", currentVersion)) } }
func (s *rollbackSuite) TestRollbackMustRebootToOtherVersion(c *check.C) { c.Skip("KNOWN BUG FIXME: https://bugs.launchpad.net/snappy/+bug/1534029") if common.BeforeReboot() { updates.CallFakeOSUpdate(c) common.Reboot(c) } else if common.CheckRebootMark(c.TestName()) { common.RemoveRebootMark(c) currentVersion := common.GetCurrentUbuntuCoreVersion(c) c.Assert(snappy.VersionCompare(currentVersion, common.GetSavedVersion(c)), check.Equals, -1, check.Commentf("Rebooted to the wrong version: %s", currentVersion)) cli.ExecCommand(c, "sudo", "snappy", "rollback", partition.OSSnapName(c), common.GetSavedVersion(c)) common.RebootWithMark(c, c.TestName()+"-rollback") } else if common.CheckRebootMark(c.TestName() + "-rollback") { common.RemoveRebootMark(c) currentVersion := common.GetCurrentUbuntuCoreVersion(c) c.Assert(snappy.VersionCompare(currentVersion, common.GetSavedVersion(c)), check.Equals, 0, check.Commentf("Rebooted to the wrong version: %s", currentVersion)) } }
// Test that the update to the same release and channel must install a newer // version. If there is no update available, the channel version will be // modified to fake an update. If there is a version available, the image will // be up-to-date after running this test. func (s *updateSuite) TestUpdateToSameReleaseAndChannel(c *check.C) { if common.BeforeReboot() { updateOutput := common.CallFakeUpdate(c) expected := "(?ms)" + ".*" + "^Reboot to use .*ubuntu-core.\n" c.Assert(updateOutput, check.Matches, expected) s.assertBootDirContents(c) common.Reboot(c) } else if common.AfterReboot(c) { common.RemoveRebootMark(c) currentVersion := common.GetCurrentUbuntuCoreVersion(c) c.Assert(currentVersion > common.GetSavedVersion(c), check.Equals, true, check.Commentf("Rebooted to the wrong version: %d", currentVersion)) } }
// Test that the ubuntu-core update to the same release and channel must install a newer // version. If there is no update available, the channel version will be // modified to fake an update. If there is a version available, the image will // be up-to-date after running this test. func (s *updateOSSuite) TestUpdateToSameReleaseAndChannel(c *check.C) { if common.BeforeReboot() { updateOutput := updates.CallFakeOSUpdate(c) expected := "(?ms)" + ".*" + fmt.Sprintf("^Reboot to use %s version .*\\.\n", partition.OSSnapName(c)) c.Assert(updateOutput, check.Matches, expected) s.assertBootDirContents(c) common.Reboot(c) } else if common.AfterReboot(c) { common.RemoveRebootMark(c) currentVersion := common.GetCurrentUbuntuCoreVersion(c) c.Assert(snappy.VersionCompare(currentVersion, common.GetSavedVersion(c)), check.Equals, 1, check.Commentf("Rebooted to the wrong version: %d", currentVersion)) } }
// CallFakeOSUpdate calls snappy update after faking a new version available for the OS snap. func CallFakeOSUpdate(c *check.C) string { currentVersion := common.GetCurrentUbuntuCoreVersion(c) common.SetSavedVersion(c, currentVersion) return CallFakeUpdate(c, partition.OSSnapName(c)+".canonical", NoOp) }