// This is the logic common to all the failover tests. Each of them has to call this method // with the snap that will be updated and the function that changes it to fail. func (s *failoverSuite) testUpdateToBrokenVersion(c *check.C, snap string, changeFunc updates.ChangeFakeUpdateSnap) { snapName := strings.Split(snap, ".")[0] currentVersion := common.GetCurrentVersion(c, snapName) if common.BeforeReboot() { common.SetSavedVersion(c, currentVersion) updates.CallFakeUpdate(c, snap, changeFunc) common.Reboot(c) } else if common.AfterReboot(c) { common.RemoveRebootMark(c) c.Assert(currentVersion, check.Equals, common.GetSavedVersion(c), check.Commentf("Rebooted to the wrong version")) } }
// This is the logic common to all the failover tests. Each of them has to call this method // with the snap that will be updated and the function that changes it to fail. func (s *failoverSuite) testUpdateToBrokenVersion(c *check.C, snap string, changeFunc updates.ChangeFakeUpdateSnap) { c.Skip("KNOWN BUG FIXME: https://bugs.launchpad.net/snappy/+bug/1534029") snapName := strings.Split(snap, ".")[0] currentVersion := common.GetCurrentVersion(c, snapName) if common.BeforeReboot() { common.SetSavedVersion(c, currentVersion) updates.CallFakeUpdate(c, snap, changeFunc) common.Reboot(c) } else if common.AfterReboot(c) { common.RemoveRebootMark(c) c.Assert(currentVersion, check.Equals, common.GetSavedVersion(c), check.Commentf("Rebooted to the wrong version")) } }
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)) } }
// This is the logic common to all the failover tests. Each of them has to call this method // with the snap that will be updated and the function that changes it to fail. func (s *failoverSuite) testUpdateToBrokenVersion(c *check.C, snap string, changeFunc updates.ChangeFakeUpdateSnap) { snapName := strings.Split(snap, ".")[0] c.Skip("FIXME: `snap refresh` is not compatible with the fake test store") // FIXME: remove once the OS snap is fixed and has a working // "snap booted" again cli.ExecCommand(c, "sudo", "snap", "booted") if common.BeforeReboot() { currentVersion := common.GetCurrentVersion(c, snapName) common.SetSavedVersion(c, currentVersion) updates.CallFakeUpdate(c, snap, changeFunc) common.Reboot(c) } else if common.AfterReboot(c) { currentVersion := common.GetCurrentVersion(c, snapName) common.RemoveRebootMark(c) c.Assert(currentVersion, check.Equals, common.GetSavedVersion(c), check.Commentf("Rebooted to the wrong version")) } }
// 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) }