Migrate some kill integration cli test to api tests#36140
Migrate some kill integration cli test to api tests#36140yongtang merged 3 commits intomoby:masterfrom
Conversation
client/client.go
Outdated
There was a problem hiding this comment.
These changes on client are not strictly required (and might be better off discussed in a separate PR)
There was a problem hiding this comment.
I think we've wanted to make this change for a while. What do you think about something like this:
- create a
func FromEnv(*Client)and move all the code fromNewEnvClient(except theopsaddition) toFromEnv() - create
NewClientWithOpts()(or something like that) which creates a client from ops, but has no other inline setup. - remove
opsfromNewEnvClientand deprecate it. Replace the implementation withNewClientWithOpts(FromEnv).
That way the new interface would create a bare client{} and we can apply any ops onto it. If there are required fields (host and client?) maybe it would also validate that.
There was a problem hiding this comment.
sounds very good to me 👼
There was a problem hiding this comment.
This one shouldn't be hard to port either
ddde382 to
3ddcea8
Compare
client/client.go
Outdated
There was a problem hiding this comment.
I think we've wanted to make this change for a while. What do you think about something like this:
- create a
func FromEnv(*Client)and move all the code fromNewEnvClient(except theopsaddition) toFromEnv() - create
NewClientWithOpts()(or something like that) which creates a client from ops, but has no other inline setup. - remove
opsfromNewEnvClientand deprecate it. Replace the implementation withNewClientWithOpts(FromEnv).
That way the new interface would create a bare client{} and we can apply any ops onto it. If there are required fields (host and client?) maybe it would also validate that.
integration/container/kill_test.go
Outdated
There was a problem hiding this comment.
Instead of a comment this can be the last arg to skip.If() so that we see it in the test output. (same below).
6ceb6d9 to
42d9145
Compare
dnephin
left a comment
There was a problem hiding this comment.
looks like lint failures, and one comment, otherwise LGTM
integration/container/kill_test.go
Outdated
There was a problem hiding this comment.
I think this already exists as containerIsInState in this package.
2d5f616 to
04abc4a
Compare
integration/network/inspect_test.go
Outdated
There was a problem hiding this comment.
looks like this test failed
Cannot connect to the Docker daemon at unix:///tmp/docker-integration/df6a1d02502f7.sock
04abc4a to
8979f0e
Compare
8979f0e to
fe79ee0
Compare
|
Overall LGTM. Though powerpc build keeps panicking. Not sure if it is related (or it exposes some other unrelated issue). |
cpuguy83
left a comment
There was a problem hiding this comment.
Seems mostly ok, the only thing is I don't think we can use defer setupTest(t)() with t.Parallel()... and I think we should opt for t.Parallel() over the cleanup helper.
integration/container/kill_test.go
Outdated
There was a problem hiding this comment.
I don't think this works with t.Parallel()
For what it's worth, the auto-cleanup is probably not needed as it's simple to cleanup manually.
There was a problem hiding this comment.
Good catch. Although we don't actually use -parallel right now so these t.Parallel() don't do anything I believe.
There was a problem hiding this comment.
I think we should make the extra effort to have these run parallel correctly, as we move stuff over it will be a huge help to test run times.
There was a problem hiding this comment.
While trying to migrate some integration-cli tests to integration api tests, I noticed some of the tests rely on fixed "name" of containers, like foo, server, etc.. I think that may not work well with parallel. May need to convert them to random generated names to avoid collision.
There was a problem hiding this comment.
Ya, I'm not against trying to get things running in parallel, but it is a lot more work than just adding t.Parallel().
It's a lot easier to get the cleanup wrong if we don't have an easy way to label everything with the test name.
There was a problem hiding this comment.
May need to convert them to random generated names to avoid collision.
Where possible we should just capture the container ID that's returned
There was a problem hiding this comment.
Yeah, I think we'd need to have the client automatically namespace objects or something then the defer could cleanup just the namespaces resources.
integration/container/kill_test.go
Outdated
There was a problem hiding this comment.
Just a performance concern here.. could this start up a "wait" goroutine earlier on for the case of it being stopped? (side thought, would be nice if the API let us wait for a container to be running).
fe79ee0 to
57fd33e
Compare
This allows to create a client with default values and override those
using functors. As an example, `NewEnvClient()` becomes
`NewClientWithOpts(FromEnv)` ; and if you want a different api version
for this client : `NewClientWithOpts(FromEnv, WithVersion("1.35"))`
Signed-off-by: Vincent Demeester <vincent@sbr.pm>
Signed-off-by: Vincent Demeester <vincent@sbr.pm>
57fd33e to
b1af229
Compare
|
@cpuguy83 updated by removing |
|
@vdemeester I think there was an usage of |
|
@yongtang yep, I will 😉 |
Signed-off-by: Vincent Demeester <vincent@sbr.pm>
b1af229 to
6977f46
Compare
Signed-off-by: Vincent Demeester vincent@sbr.pm