Skip to content

Migrate some kill integration cli test to api tests#36140

Merged
yongtang merged 3 commits intomoby:masterfrom
vdemeester:integration-container-kill
Feb 8, 2018
Merged

Migrate some kill integration cli test to api tests#36140
yongtang merged 3 commits intomoby:masterfrom
vdemeester:integration-container-kill

Conversation

@vdemeester
Copy link
Member

Signed-off-by: Vincent Demeester vincent@sbr.pm

client/client.go Outdated
Copy link
Member Author

Choose a reason for hiding this comment

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

These changes on client are not strictly required (and might be better off discussed in a separate PR)

Copy link
Member

Choose a reason for hiding this comment

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

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 from NewEnvClient (except the ops addition) to FromEnv()
  • create NewClientWithOpts() (or something like that) which creates a client from ops, but has no other inline setup.
  • remove ops from NewEnvClient and deprecate it. Replace the implementation with NewClientWithOpts(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.

Copy link
Member Author

Choose a reason for hiding this comment

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

sounds very good to me 👼

@vdemeester vdemeester changed the title Migration some kill integration cli test to api tests Migrate some kill integration cli test to api tests Jan 29, 2018
Copy link
Member Author

Choose a reason for hiding this comment

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

This one shouldn't be hard to port either

@vdemeester vdemeester force-pushed the integration-container-kill branch from ddde382 to 3ddcea8 Compare January 29, 2018 22:56
client/client.go Outdated
Copy link
Member

Choose a reason for hiding this comment

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

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 from NewEnvClient (except the ops addition) to FromEnv()
  • create NewClientWithOpts() (or something like that) which creates a client from ops, but has no other inline setup.
  • remove ops from NewEnvClient and deprecate it. Replace the implementation with NewClientWithOpts(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.

Copy link
Member

@dnephin dnephin Jan 30, 2018

Choose a reason for hiding this comment

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

Instead of a comment this can be the last arg to skip.If() so that we see it in the test output. (same below).

Copy link
Member Author

Choose a reason for hiding this comment

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

good point 🙃

@vdemeester vdemeester force-pushed the integration-container-kill branch 4 times, most recently from 6ceb6d9 to 42d9145 Compare January 31, 2018 21:10
Copy link
Member

@dnephin dnephin left a comment

Choose a reason for hiding this comment

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

looks like lint failures, and one comment, otherwise LGTM

Copy link
Member

Choose a reason for hiding this comment

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

I think this already exists as containerIsInState in this package.

@vdemeester vdemeester force-pushed the integration-container-kill branch 3 times, most recently from 2d5f616 to 04abc4a Compare January 31, 2018 23:48
Copy link
Member

@dnephin dnephin left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Member

Choose a reason for hiding this comment

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

looks like this test failed

Cannot connect to the Docker daemon at unix:///tmp/docker-integration/df6a1d02502f7.sock

@yongtang
Copy link
Member

yongtang commented Feb 5, 2018

Overall LGTM. Though powerpc build keeps panicking. Not sure if it is related (or it exposes some other unrelated issue).

Copy link
Member

@cpuguy83 cpuguy83 left a comment

Choose a reason for hiding this comment

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

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.

Copy link
Member

Choose a reason for hiding this comment

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

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.

Copy link
Member

@dnephin dnephin Feb 5, 2018

Choose a reason for hiding this comment

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

Good catch. Although we don't actually use -parallel right now so these t.Parallel() don't do anything I believe.

Copy link
Member

Choose a reason for hiding this comment

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

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.

Copy link
Member

Choose a reason for hiding this comment

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

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.

Copy link
Member

Choose a reason for hiding this comment

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

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.

Copy link
Member

Choose a reason for hiding this comment

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

May need to convert them to random generated names to avoid collision.

Where possible we should just capture the container ID that's returned

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, I think we'd need to have the client automatically namespace objects or something then the defer could cleanup just the namespaces resources.

Copy link
Member

Choose a reason for hiding this comment

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

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).

Copy link
Member

Choose a reason for hiding this comment

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

Funny, just found #36147

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>
@vdemeester vdemeester force-pushed the integration-container-kill branch from 57fd33e to b1af229 Compare February 8, 2018 14:27
@vdemeester
Copy link
Member Author

@cpuguy83 updated by removing t.Parallel() for now.

Copy link
Member

@cpuguy83 cpuguy83 left a comment

Choose a reason for hiding this comment

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

LGTM

@yongtang
Copy link
Member

yongtang commented Feb 8, 2018

@vdemeester I think there was an usage of NewClientForHost in secret_test.go which causes the build failure. Can you take a look?

@vdemeester
Copy link
Member Author

@yongtang yep, I will 😉

Signed-off-by: Vincent Demeester <vincent@sbr.pm>
@vdemeester vdemeester force-pushed the integration-container-kill branch from b1af229 to 6977f46 Compare February 8, 2018 15:22
Copy link
Member

@yongtang yongtang 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.

6 participants