Skip to content
This repository has been archived by the owner on Nov 27, 2023. It is now read-only.

Commit

Permalink
Merge pull request #203 from docker/fix_TestKillChild
Browse files Browse the repository at this point in the history
Fix flaky test (subject to running tests in //)
  • Loading branch information
gtardif authored Jun 11, 2020
2 parents 3ad1e69 + 9d4eed2 commit d9b4564
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
2 changes: 1 addition & 1 deletion tests/framework/suite.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ func (s *Suite) ListProcessesCommand() *CmdContext {
if IsWindows() {
return s.NewCommand("tasklist")
}
return s.NewCommand("ps")
return s.NewCommand("ps", "-x")
}

// NewCommand creates a command context.
Expand Down
11 changes: 6 additions & 5 deletions tests/skip-win-ci-e2e/skip_win_ci_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,30 +50,31 @@ type NonWinCIE2eSuite struct {

func (s *NonWinCIE2eSuite) TestKillChildOnCancel() {
It("should kill docker-classic if parent command is cancelled", func() {
imageName := "test-sleep-image"
out := s.ListProcessesCommand().ExecOrDie()
Expect(out).NotTo(ContainSubstring("docker-classic"))
Expect(out).NotTo(ContainSubstring(imageName))

dir := s.ConfigDir
Expect(ioutil.WriteFile(filepath.Join(dir, "Dockerfile"), []byte(`FROM alpine:3.10
RUN sleep 100`), 0644)).To(Succeed())
shutdown := make(chan time.Time)
errs := make(chan error)
ctx := s.NewDockerCommand("build", "--no-cache", "-t", "test-sleep-image", ".").WithinDirectory(dir).WithTimeout(shutdown)
ctx := s.NewDockerCommand("build", "--no-cache", "-t", imageName, ".").WithinDirectory(dir).WithTimeout(shutdown)
go func() {
_, err := ctx.Exec()
errs <- err
}()
err := WaitFor(time.Second, 10*time.Second, errs, func() bool {
out := s.ListProcessesCommand().ExecOrDie()
return strings.Contains(out, "docker-classic")
return strings.Contains(out, imageName)
})
Expect(err).NotTo(HaveOccurred())
log.Println("Killing docker process")

close(shutdown)
err = WaitFor(time.Second, 12*time.Second, nil, func() bool {
out := s.ListProcessesCommand().ExecOrDie()
return !strings.Contains(out, "docker-classic")
return !strings.Contains(out, imageName)
})
Expect(err).NotTo(HaveOccurred())
})
Expand Down Expand Up @@ -108,7 +109,7 @@ func (s *NonWinCIE2eSuite) getGrpcServerAndCLientAddress() (string, string) {
return socketName, socketName
}

func TestE2e(t *testing.T) {
func TestNonWinCIE2(t *testing.T) {
suite.Run(t, new(NonWinCIE2eSuite))
}

Expand Down

0 comments on commit d9b4564

Please sign in to comment.