Пример #1
0
func (s *serviceSuite) TestServiceMustBeStartedAfterReboot(c *check.C) {
	if common.BeforeReboot() {
		installSnapWithService(c)
		common.Reboot(c)
	} else if common.AfterReboot(c) {
		common.RemoveRebootMark(c)
		c.Assert(isServiceRunning(c), check.Equals, true, check.Commentf("Service is not running"))
	}
}
Пример #2
0
// 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"))
	}
}
func (s *initRAMFSSuite) TestFreeSpaceWithResize(c *check.C) {
	if common.BeforeReboot() {
		bootDir := getCurrentBootDir(c)
		writablePercent := "85"
		cli.ExecCommand(
			c, "sh", "-x", "integration-tests/scripts/install-test-initramfs", bootDir, writablePercent)
		common.Reboot(c)
	} else if common.AfterReboot(c) {
		common.RemoveRebootMark(c)
		freeSpace := getFreeSpacePercent(c)
		c.Assert(freeSpace < 10, check.Equals, true,
			check.Commentf("The writable partition was not resized"))
	}
}
Пример #4
0
// 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"))
	}
}
Пример #5
0
// 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))
	}
}
Пример #6
0
// 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))
	}
}
Пример #7
0
// 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"))
	}
}