示例#1
0
func (s *snapdTestSuite) SetUpTest(c *check.C) {
	s.SnappySuite.SetUpTest(c)
	s.cmd = exec.Command("sudo", "env", "PATH="+os.Getenv("PATH"),
		"/lib/systemd/systemd-activate",
		"-l", "0.0.0.0:"+port, "snapd")

	s.cmd.Start()

	intPort, _ := strconv.Atoi(port)
	err := wait.ForServerOnPort(c, "tcp", intPort)
	c.Assert(err, check.IsNil)
}
示例#2
0
func (s *pythonWebserverExampleSuite) TestNetworkingServiceMustBeStarted(c *check.C) {
	baseAppName := "xkcd-webserver"
	appName := baseAppName + ".canonical"
	common.InstallSnap(c, appName+"/edge")
	defer common.RemoveSnap(c, appName)

	err := wait.ForServerOnPort(c, "tcp", 80)
	c.Assert(err, check.IsNil, check.Commentf("Error waiting for server: %s", err))

	resp, err := http.Get("http://localhost")
	c.Assert(err, check.IsNil, check.Commentf("Error getting the http resource: %s", err))
	c.Check(resp.Status, check.Equals, "200 OK", check.Commentf("Wrong reply status"))
	c.Assert(resp.Proto, check.Equals, "HTTP/1.0", check.Commentf("Wrong reply protocol"))
}
示例#3
0
func (s *goWebserverExampleSuite) TestGetRootPathMustPrintMessage(c *check.C) {
	appName := "go-example-webserver"
	common.InstallSnap(c, appName+"/edge")
	defer common.RemoveSnap(c, appName)

	err := wait.ForServerOnPort(c, "tcp6", 8081)
	c.Assert(err, check.IsNil, check.Commentf("Error waiting for server: %s", err))

	resp, err := http.Get("http://localhost:8081/")
	defer resp.Body.Close()
	c.Assert(err, check.IsNil, check.Commentf("Error getting the http resource: %s", err))
	c.Check(resp.Status, check.Equals, "200 OK", check.Commentf("Wrong reply status"))
	body, err := ioutil.ReadAll(resp.Body)
	c.Assert(err, check.IsNil, check.Commentf("Error reading the reply body: %s", err))
	c.Assert(string(body), check.Equals, "Hello World\n", check.Commentf("Wrong reply body"))
}
示例#4
0
func (s *snapPythonWebserverExampleSuite) TestNetworkingServiceMustBeStarted(c *check.C) {
	c.Skip("FIXME: re-enable when new-security supports auto-connect")

	baseAppName := "xkcd-webserver"
	appName := baseAppName + ".canonical"
	installSnap(c, appName)
	defer removeSnap(c, appName)

	err := wait.ForServerOnPort(c, "tcp", 80)
	c.Assert(err, check.IsNil, check.Commentf("Error waiting for server: %s", err))

	resp, err := http.Get("http://localhost")
	c.Assert(err, check.IsNil, check.Commentf("Error getting the http resource: %s", err))
	c.Check(resp.Status, check.Equals, "200 OK", check.Commentf("Wrong reply status"))
	c.Assert(resp.Proto, check.Equals, "HTTP/1.0", check.Commentf("Wrong reply protocol"))
}
示例#5
0
func (s *snapGoWebserverExampleSuite) TestGetRootPathMustPrintMessage(c *check.C) {
	c.Skip("FIXME: re-enable when new-security supports auto-connect")

	appName := "go-example-webserver"
	output := installSnap(c, appName)
	defer removeSnap(c, appName)
	c.Assert(output, testutil.Contains, "go-example-webserver")

	err := wait.ForServerOnPort(c, "tcp6", 8081)
	c.Assert(err, check.IsNil, check.Commentf("Error waiting for server: %s", err))

	resp, err := http.Get("http://localhost:8081/")
	defer resp.Body.Close()
	c.Assert(err, check.IsNil, check.Commentf("Error getting the http resource: %s", err))
	c.Check(resp.Status, check.Equals, "200 OK", check.Commentf("Wrong reply status"))
	body, err := ioutil.ReadAll(resp.Body)
	c.Assert(err, check.IsNil, check.Commentf("Error reading the reply body: %s", err))
	c.Assert(string(body), check.Equals, "Hello World\n", check.Commentf("Wrong reply body"))
}