Esempio n. 1
0
// This is the logic common to all the failover tests. Each of them has define a
// type implementing the failer interface and call this function with an instance
// of it
func commonFailoverTest(c *check.C, f failer) {
	currentVersion := common.GetCurrentUbuntuCoreVersion(c)

	if common.AfterReboot(c) {
		common.RemoveRebootMark(c)
		f.unset(c)
		c.Assert(common.GetSavedVersion(c), check.Equals, currentVersion,
			check.Commentf("Rebooted to the wrong version"))
	} else {
		common.SetSavedVersion(c, currentVersion-1)
		common.CallFakeUpdate(c)
		f.set(c)
		common.Reboot(c)
	}
}
Esempio n. 2
0
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))
	}
}