Example #1
0
func setUpDocker(c *check.C) {
	common.InstallSnap(c, "docker/edge")
	dockerVersion := common.GetCurrentVersion(c, "docker")
	dockerService := fmt.Sprintf("docker_docker-daemon_%s.service", dockerVersion)

	err := wait.ForActiveService(c, dockerService)
	c.Assert(err, check.IsNil, check.Commentf("Error waiting for service: %s", err))

	err = wait.ForCommand(c, `(?ms).*docker\.sock\s.*`, "ls", "/run")
	c.Assert(err, check.IsNil, check.Commentf("Expected nil error, got %s", err))

	cli.ExecCommand(c, "docker", "pull", baseContainer)
}
Example #2
0
func restartDocker(c *check.C) {
	dockerVersion := common.GetCurrentVersion(c, "docker")
	dockerService := fmt.Sprintf("docker_docker-daemon_%s.service", dockerVersion)

	cli.ExecCommand(c, "sudo", "systemctl", "restart", dockerService)

	// we need to wait until the socket is ready, an active systemctl status is not enough
	err := wait.ForActiveService(c, dockerService)
	c.Assert(err, check.IsNil, check.Commentf("Expected nil error, got %s", err))

	err = wait.ForCommand(c, `(?ms).*docker\.sock\s.*`, "ls", "/run")
	c.Assert(err, check.IsNil, check.Commentf("Expected nil error, got %s", err))
}
Example #3
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"))
	}
}
Example #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) {
	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"))
	}
}
Example #5
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"))
	}
}
Example #6
0
func isServiceRunning(c *check.C) bool {
	packageVersion := common.GetCurrentVersion(c, data.BasicServiceSnapName)
	service := fmt.Sprintf("%s_service_%s.service", data.BasicServiceSnapName, packageVersion)

	err := wait.ForActiveService(c, service)
	c.Assert(err, check.IsNil)

	statusOutput := cli.ExecCommand(c, "systemctl", "status", service)

	expected := "(?ms)" +
		fmt.Sprintf(".* %s_service_.*\\.service .*\n", data.BasicServiceSnapName) +
		".*Loaded: loaded .*\n" +
		".*Active: active \\(running\\) .*\n" +
		".*"

	matched, err := regexp.MatchString(expected, statusOutput)
	c.Assert(err, check.IsNil)
	return matched
}
Example #7
0
func dockerCfgFile(c *check.C) string {
	dockerVersion := common.GetCurrentVersion(c, "docker")
	return fmt.Sprintf("/var/snap/docker/%s/etc/docker.conf", dockerVersion)
}