Skip to content

pkg/term: refactor TestEscapeProxyRead#39800

Merged
tiborvass merged 1 commit intomoby:masterfrom
thaJeztah:refactor_TestEscapeProxyRead
Sep 6, 2019
Merged

pkg/term: refactor TestEscapeProxyRead#39800
tiborvass merged 1 commit intomoby:masterfrom
thaJeztah:refactor_TestEscapeProxyRead

Conversation

@thaJeztah
Copy link
Member

noticed this test while reviewing #39728, and did some refactoring

  • use subtests to make it clearer what the individual test-cases
    are, and to prevent tests from depending on values set by the
    previous test(s).
  • remove redundant messages in assert (gotest.tools already prints
    a useful message if assertions fail).

- use subtests to make it clearer what the individual test-cases
  are, and to prevent tests from depending on values set by the
  previous test(s).
- remove redundant messages in assert (gotest.tools already prints
  a useful message if assertions fail).

Signed-off-by: Sebastiaan van Stijn <[email protected]>
@thaJeztah
Copy link
Member Author

Windows RS1: https://ci.docker.com/public/blue/rest/organizations/jenkins/pipelines/moby/branches/PR-39800/runs/1/nodes/39/log/?start=0

[2019-08-27T14:21:03.998Z] FAIL: check_test.go:86: DockerSuite.OnTimeout
[2019-08-27T14:21:03.998Z] 
[2019-08-27T14:21:03.998Z] check_test.go:93:
[2019-08-27T14:21:03.998Z]     c.Fatalf("Failed to get daemon PID from %s\n", path)
[2019-08-27T14:21:03.998Z] ... Error: Failed to get daemon PID from docker.pid
[2019-08-27T14:21:03.998Z] 
[2019-08-27T14:21:03.998Z] 
[2019-08-27T14:21:03.998Z] --- FAIL: Test (604.63s)
[2019-08-27T14:21:03.998Z] panic: DockerSuite.TestAPIImagesSaveAndLoad test timed out after 10m0s [recovered]
[2019-08-27T14:21:03.998Z] 	panic: DockerSuite.TestAPIImagesSaveAndLoad test timed out after 10m0s
[2019-08-27T14:21:03.998Z] 
[2019-08-27T14:21:03.998Z] goroutine 42 [running]:
[2019-08-27T14:21:03.998Z] testing.tRunner.func1(0xc0004b8300)
[2019-08-27T14:21:03.998Z] 	d:/CI-1/CI-556d26c07/go/src/testing/testing.go:830 +0x399
[2019-08-27T14:21:03.998Z] panic(0x111f600, 0xc00014dfa0)
[2019-08-27T14:21:03.998Z] 	d:/CI-1/CI-556d26c07/go/src/runtime/panic.go:522 +0x1c3
[2019-08-27T14:21:03.998Z] github.com/docker/docker/vendor/github.com/go-check/check.(*suiteRunner).runTest(0xc00074e240, 0xc000298930, 0xc0007832c0)
[2019-08-27T14:21:03.998Z] 	d:/gopath/src/github.com/docker/docker/vendor/github.com/go-check/check/check.go:875 +0x2a5
[2019-08-27T14:21:03.998Z] github.com/docker/docker/vendor/github.com/go-check/check.(*suiteRunner).run(0xc00074e240, 0x1d22208)
[2019-08-27T14:21:03.998Z] 	d:/gopath/src/github.com/docker/docker/vendor/github.com/go-check/check/check.go:621 +0x105
[2019-08-27T14:21:03.998Z] github.com/docker/docker/vendor/github.com/go-check/check.Run(0x11f2280, 0x1d22208, 0xc00033e0a0, 0x1)
[2019-08-27T14:21:03.998Z] 	d:/gopath/src/github.com/docker/docker/vendor/github.com/go-check/check/run.go:100 +0x54
[2019-08-27T14:21:03.998Z] github.com/docker/docker/vendor/github.com/go-check/check.RunAll(0xc00033e0a0, 0x3)
[2019-08-27T14:21:03.998Z] 	d:/gopath/src/github.com/docker/docker/vendor/github.com/go-check/check/run.go:92 +0x9d
[2019-08-27T14:21:03.998Z] github.com/docker/docker/vendor/github.com/go-check/check.TestingT(0xc0004b8300)
[2019-08-27T14:21:03.998Z] 	d:/gopath/src/github.com/docker/docker/vendor/github.com/go-check/check/run.go:80 +0x378
[2019-08-27T14:21:03.998Z] github.com/docker/docker/integration-cli.Test(0xc0004b8300)
[2019-08-27T14:21:03.998Z] 	d:/gopath/src/github.com/docker/docker/integration-cli/check_test.go:76 +0x90
[2019-08-27T14:21:03.998Z] testing.tRunner(0xc0004b8300, 0x1264e28)
[2019-08-27T14:21:03.998Z] 	d:/CI-1/CI-556d26c07/go/src/testing/testing.go:865 +0xc7
[2019-08-27T14:21:03.998Z] created by testing.(*T).Run
[2019-08-27T14:21:03.998Z] 	d:/CI-1/CI-556d26c07/go/src/testing/testing.go:916 +0x361
[2019-08-27T14:21:03.998Z] exit status 2
[2019-08-27T14:21:03.998Z] FAIL	github.com/docker/docker/integration-cli	604.741s
[2019-08-27T14:21:03.998Z] 
[2019-08-27T14:21:03.998Z] 
[2019-08-27T14:21:03.998Z] ERROR: Failed 'ERROR: Integration CLI tests failed at 08/27/2019 14:21:00. Duration:00:10:16.6229173' at 08/27/2019 14:21:00
[2019-08-27T14:21:03.998Z] At D:\gopath\src\github.com\docker\docker\hack\ci\windows.ps1:858 char:17
[2019-08-27T14:21:03.998Z] + ...             Throw "ERROR: Integration CLI tests failed at $(Get-Date) ...
[2019-08-27T14:21:03.998Z] +    

Windows RS5:

This one may be racy; https://ci.docker.com/public/blue/rest/organizations/jenkins/pipelines/moby/branches/PR-39800/runs/1/nodes/192/log/?start=0

[2019-08-27T14:33:38.194Z] ----------------------------------------------------------------------
[2019-08-27T14:33:38.194Z] FAIL: docker_cli_ps_test.go:439: DockerSuite.TestPsListContainersFilterExited
[2019-08-27T14:33:38.194Z] 
[2019-08-27T14:33:38.194Z] docker_cli_ps_test.go:456:
[2019-08-27T14:33:38.194Z]     c.Assert(out, checker.Contains, strings.TrimSpace(secondZero))
[2019-08-27T14:33:38.194Z] ... obtained string = "" +
[2019-08-27T14:33:38.194Z] ...     "1653c525de732958df93c247ff529027e3bba44373c9a4840db4a6801005e74f\n" +
[2019-08-27T14:33:38.194Z] ...     "6b43aa06d28f9aa73f63a82c3bfbe10e9d7b71a60a689434d3bb6ffc20d6aebf\n"
[2019-08-27T14:33:38.194Z] ... substring string = "c33000f372ee52bd910d1d5862e2a53ae96c1786490f6a63b74bad1184e39fe8"

@thaJeztah
Copy link
Member Author

ping @kolyshkin @vdemeester PTAL 🤗

Copy link
Member

@vdemeester vdemeester left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@thaJeztah Nice ! 😉 we may even be able to use test tables to reduce a bit the duplication of code

@thaJeztah
Copy link
Member Author

we may even be able to use test tables to reduce a bit the duplication of code

that's what I tried at the start, but although they look very similar, there's quite some subtle differences between the tests, and writing a table for that resulted in a lot of if/else/elseif complexity, so I removed that again, and went for a simpler approach (at the cost of duplicating some steps)

assert.DeepEqual(t, keys, buf)
})

t.Run("ctrl-c,ctrl-z escape key, keys ctrl-c,ctrl-z", func(t *testing.T) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: in the test name I would use the ctrl-c,ctrl-z escape key, keys [ctrl-c],[ctrl-z] format, because the sequence of reads matters, for example on my PR I have a test for [ctrl-c,ctrl-z] (a single read with 2 bytes), which doesn't work with the current code.

I can as well change the format on my PR when I rebase.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, good suggestion; yes, perhaps ok to touch-up those as part of your PR

@thaJeztah
Copy link
Member Author

@kolyshkin @vdemeester LGTY?

Copy link
Member

@vdemeester vdemeester left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants