mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Merge pull request #28974 from AkihiroSuda/test-service-logs
improve TestServiceLogs for the goroutine issue #28915
This commit is contained in:
commit
08f0100d50
1 changed files with 19 additions and 9 deletions
|
@ -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")
|
||||
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)
|
||||
waitAndAssert(c, defaultReconciliationTimeout,
|
||||
d.checkActiveContainerCount, checker.Equals, len(services))
|
||||
|
||||
out, err = d.Cmd("service", "logs", name)
|
||||
fmt.Println(out)
|
||||
for name, message := range services {
|
||||
out, err := d.Cmd("service", "logs", name)
|
||||
c.Assert(err, checker.IsNil)
|
||||
c.Assert(out, checker.Contains, "hello world")
|
||||
c.Logf("log for %q: %q", name, out)
|
||||
c.Assert(out, checker.Contains, message)
|
||||
}
|
||||
}
|
||||
|
||||
func (s *DockerSwarmSuite) TestServiceLogsFollow(c *check.C) {
|
||||
|
|
Loading…
Reference in a new issue