From 9d4eed23567462da4c546a4861851d158ab6712c Mon Sep 17 00:00:00 2001 From: Guillaume Tardif Date: Thu, 11 Jun 2020 15:01:43 +0200 Subject: [PATCH] Fix flaky test (subject to running tests in //) --- tests/framework/suite.go | 2 +- tests/skip-win-ci-e2e/skip_win_ci_test.go | 11 ++++++----- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/tests/framework/suite.go b/tests/framework/suite.go index 91b7e3d2a..b7e688483 100644 --- a/tests/framework/suite.go +++ b/tests/framework/suite.go @@ -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. diff --git a/tests/skip-win-ci-e2e/skip_win_ci_test.go b/tests/skip-win-ci-e2e/skip_win_ci_test.go index cf055464c..53a6ed5cb 100644 --- a/tests/skip-win-ci-e2e/skip_win_ci_test.go +++ b/tests/skip-win-ci-e2e/skip_win_ci_test.go @@ -50,22 +50,23 @@ 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") @@ -73,7 +74,7 @@ RUN sleep 100`), 0644)).To(Succeed()) 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()) }) @@ -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)) }