浏览代码

improve TestServiceLogs for the goroutine issue #28915

Signed-off-by: Akihiro Suda <suda.akihiro@lab.ntt.co.jp>
Akihiro Suda 8 年之前
父节点
当前提交
f8a93d0c9d
共有 1 个文件被更改,包括 20 次插入10 次删除
  1. 20 10
      integration-cli/docker_cli_service_logs_experimental_test.go

+ 20 - 10
integration-cli/docker_cli_service_logs_experimental_test.go

@@ -23,19 +23,29 @@ func (s *DockerSwarmSuite) TestServiceLogs(c *check.C) {
 
 	d := s.AddDaemon(c, true, true)
 
-	name := "TestServiceLogs"
+	// we have multiple services here for detecting the goroutine issue #28915
+	services := map[string]string{
+		"TestServiceLogs1": "hello1",
+		"TestServiceLogs2": "hello2",
+	}
 
-	out, err := d.Cmd("service", "create", "--name", name, "--restart-condition", "none", "busybox", "sh", "-c", "echo hello world")
-	c.Assert(err, checker.IsNil)
-	c.Assert(strings.TrimSpace(out), checker.Not(checker.Equals), "")
+	for name, message := range services {
+		out, err := d.Cmd("service", "create", "--name", name, "busybox",
+			"sh", "-c", fmt.Sprintf("echo %s; tail -f /dev/null", message))
+		c.Assert(err, checker.IsNil)
+		c.Assert(strings.TrimSpace(out), checker.Not(checker.Equals), "")
+	}
 
 	// make sure task has been deployed.
-	waitAndAssert(c, defaultReconciliationTimeout, d.checkActiveContainerCount, checker.Equals, 1)
-
-	out, err = d.Cmd("service", "logs", name)
-	fmt.Println(out)
-	c.Assert(err, checker.IsNil)
-	c.Assert(out, checker.Contains, "hello world")
+	waitAndAssert(c, defaultReconciliationTimeout,
+		d.checkActiveContainerCount, checker.Equals, len(services))
+
+	for name, message := range services {
+		out, err := d.Cmd("service", "logs", name)
+		c.Assert(err, checker.IsNil)
+		c.Logf("log for %q: %q", name, out)
+		c.Assert(out, checker.Contains, message)
+	}
 }
 
 func (s *DockerSwarmSuite) TestServiceLogsFollow(c *check.C) {