Esempio n. 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)
}
Esempio n. 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))
}
Esempio n. 3
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
}