Skip to content

Migrate volumes tests in integration-cli to api tests#36292

Merged
vdemeester merged 1 commit into
moby:masterfrom
yongtang:0212-2018-volumes-tests
Feb 27, 2018
Merged

Migrate volumes tests in integration-cli to api tests#36292
vdemeester merged 1 commit into
moby:masterfrom
yongtang:0212-2018-volumes-tests

Conversation

@yongtang
Copy link
Copy Markdown
Member

This fix migrates volumes tests in integration-cli to api tests in integration/

Signed-off-by: Yong Tang yong.tang.github@outlook.com

Copy link
Copy Markdown
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 🦁

Comment thread integration/volume/volume_test.go Outdated
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We could create an helper for that one (because I think it's gonna be use quite a lot)

container.Run(t, ctx, client, WithVolume("source:target"), WithVolume("another:one"))

@yongtang @dnephin wdyt ?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

There are actually two formats. One is source:target which is added to c.HostConfig.Binds. Another is path (without :) which is added to c.Config.Volumes. Maybe one WithBind() and another one WithVolume()?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

WithBind(src, target string) WithVolume(name string) SGTM

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Updated. Thanks.

@yongtang yongtang force-pushed the 0212-2018-volumes-tests branch from fe70d54 to 3efbed4 Compare February 13, 2018 17:17
@yongtang
Copy link
Copy Markdown
Member Author

Thanks @vdemeester @dnephin for the review. The PR has been updated. Please take a look.

Copy link
Copy Markdown
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.

Thanks, a few comments

Comment thread integration/volume/volume_test.go Outdated
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Checking the list contains a specific name is a pretty weak assertion.

Can we use a label and filter so that we can use assert.Equal() ?
Can we compare the entire struct instead of just names?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Thanks @dnephin. I updated the PR so that now all elements (except for create time) is compared against.

Comment thread integration/volume/volume_test.go Outdated
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Does this need to create a container? Could we use the volume create API instead? It should be much faster and lets us test the volume system independently from containers.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Thanks @dnephin. I think it make sense to not create the container. I updated the PR. Also I merged TestVolumesCreate and TestVolumesList into TestVolumesCreateAndList.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I still see it creating a conatiner here. Is that change not pushed?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looks like it's needed to get a "volume in use" error below

Likely the container doesn't have to be started though, only created (which would make the test faster to run and cleanup)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

@thaJeztah @dnephin Thanks. The PR has been updated. Now the container is created but not started.

Comment thread integration/volume/volume_test.go Outdated
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Could this assert.Equal() the entire struct instead of just the mountpoint?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Done. It is now compared against the whole Volume struct.

Comment thread integration/volume/volume_test.go Outdated
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

In this case I guess the container is necessary to test the "in use" case. It would be great if this could be done with a unit test instead, because it would be easier to set up that state without involving the container subsystem.

I guess it's ok like this.

Comment thread integration/volume/volume_test.go Outdated
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

https://godoc.org/github.com/gotestyourself/gotestyourself/assert/cmp#DeepEqual should make this type of comparison a lot cleaner. I hope we can use it soon.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

@dnephin Thanks. It seems that a vendor update is needed. I will take a look and create a follow up PR for that.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Don't worry about using it just yet. I have an automated migration that we can use to convert things all at once. I'll open a PR for it soon.

@yongtang
Copy link
Copy Markdown
Member Author

@dnephin Thanks for the review. The PR has been updated. I will create a follow up PR to try to utilize DeepEqual. Please take a look.

@vdemeester
Copy link
Copy Markdown
Member

@yongtang hum, janky failed

00:14:11 --- FAIL: TestVolumesCreateAndList (0.02s)
00:14:11 	assertions.go:226: 
                          
	Error Trace:	volume_test.go:45
00:14:11 		
	Error:      	Not equal: 
00:14:11 		
	            	expected: 2
00:14:11 		
	            	received: 1

@yongtang yongtang force-pushed the 0212-2018-volumes-tests branch 2 times, most recently from 19b79bf to 2559ad9 Compare February 14, 2018 12:06
@yongtang
Copy link
Copy Markdown
Member Author

Think there might be some leftover from previous tests. I added additional logging to take a look.

@yongtang yongtang force-pushed the 0212-2018-volumes-tests branch 2 times, most recently from edd0ae8 to bb4efdb Compare February 14, 2018 12:45
@yongtang
Copy link
Copy Markdown
Member Author

The build failure is caused by additional volume somevolume, seems to be left from docker-py test?

12:39:53 --- FAIL: TestVolumesCreateAndList (0.02s)
12:39:53 	volume_test.go:46: Volume[0]: {CreatedAt:2018-02-14T12:33:51Z Driver:local Labels:map[] Mountpoint:/var/lib/docker/volumes/somevolume/_data Name:somevolume Options:map[] Scope:local Status:map[] UsageData:<nil>}

@yongtang
Copy link
Copy Markdown
Member Author

Opened a PR docker/docker-py#1909 in docker-py to remove somevolume during test teardown.

yongtang added a commit to yongtang/docker that referenced this pull request Feb 15, 2018
This fix updates docker-py:
```
-ENV DOCKER_PY_COMMIT 1d6b5b203222ba5df7dedfcd1ee061a452f99c8a
+ENV DOCKER_PY_COMMIT 5e28dcaace5f7b70cbe44c313b7a3b288fa38916
```

The updated docker-py includes docker/docker-py#1909
which is required to have moby#36292 pass the tests.

Full diff is in docker/docker-py@1d6b5b2...5e28dca.

Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
@yongtang
Copy link
Copy Markdown
Member Author

docker/docker-py#1909 has been merged. Created a PR #36318 to update the docker-py.

@yongtang yongtang force-pushed the 0212-2018-volumes-tests branch from bfc676f to 2f33c0c Compare February 22, 2018 01:13
@codecov
Copy link
Copy Markdown

codecov Bot commented Feb 22, 2018

Codecov Report

❗ No coverage uploaded for pull request base (master@6004757). Click here to learn what that means.
The diff coverage is n/a.

@@            Coverage Diff            @@
##             master   #36292   +/-   ##
=========================================
  Coverage          ?   34.64%           
=========================================
  Files             ?      612           
  Lines             ?    45297           
  Branches          ?        0           
=========================================
  Hits              ?    15695           
  Misses            ?    27544           
  Partials          ?     2058

@thaJeztah
Copy link
Copy Markdown
Member

Looks like there's some failures;

03:25:08 === RUN   TestVolumesCreateAndList
03:25:08 --- FAIL: TestVolumesCreateAndList (0.02s)
03:25:08 	volume_test.go:46: Volume[0]: {CreatedAt:2018-02-22T03:17:44Z Driver:local Labels:map[] Mountpoint:/var/lib/docker/volumes/fd3e13663271fafcf7366b3bf595c1dfd1c6aaa4e34c04997dfc23d332d72dac/_data Name:fd3e13663271fafcf7366b3bf595c1dfd1c6aaa4e34c04997dfc23d332d72dac Options:map[] Scope:local Status:map[] UsageData:<nil>}
03:25:08 	volume_test.go:46: Volume[1]: {CreatedAt:2018-02-22T03:17:42Z Driver:local Labels:map[] Mountpoint:/var/lib/docker/volumes/somevolume/_data Name:somevolume Options:map[] Scope:local Status:map[] UsageData:<nil>}
03:25:08 	volume_test.go:46: Volume[2]: {CreatedAt:2018-02-22T03:25:08Z Driver:local Labels:map[] Mountpoint:/var/lib/docker/volumes/test/_data Name:test Options:map[] Scope:local Status:map[] UsageData:<nil>}
03:25:08 	volume_test.go:46: Volume[3]: {CreatedAt:2018-02-22T03:17:42Z Driver:local Labels:map[] Mountpoint:/var/lib/docker/volumes/1ed15ecbfbe0c65bcfdbd1b19901fe0f1ec312a8f9269699e7e133e8a3ae298d/_data Name:1ed15ecbfbe0c65bcfdbd1b19901fe0f1ec312a8f9269699e7e133e8a3ae298d Options:map[] Scope:local Status:map[] UsageData:<nil>}
03:25:08 	volume_test.go:46: Volume[4]: {CreatedAt:2018-02-22T03:17:45Z Driver:local Labels:map[] Mountpoint:/var/lib/docker/volumes/dc5ef5e600853abc6b2ac97d8c68353e6b06ed4dd58553f79a315cfe10e92b60/_data Name:dc5ef5e600853abc6b2ac97d8c68353e6b06ed4dd58553f79a315cfe10e92b60 Options:map[] Scope:local Status:map[] UsageData:<nil>}
03:25:08 	volume_test.go:46: Volume[5]: {CreatedAt:2018-02-22T03:17:42Z Driver:local Labels:map[] Mountpoint:/var/lib/docker/volumes/f324b219c9599d0a33c5ff2cc546a459c07d0a4d138abed91c2cc0313a1c70b5/_data Name:f324b219c9599d0a33c5ff2cc546a459c07d0a4d138abed91c2cc0313a1c70b5 Options:map[] Scope:local Status:map[] UsageData:<nil>}
03:25:08 	assertions.go:226: 
                          
	Error Trace:	volume_test.go:49
03:25:08 		
	Error:      	Not equal: 
03:25:08 		
	            	expected: 6
03:25:08 		
	            	received: 1
03:25:08 	assertions.go:226: 
                          
	Error Trace:	volume_test.go:51
03:25:08 		
	Error:      	Not equal: 
03:25:08 		
	            	expected: types.Volume{CreatedAt:"2018-02-22T03:17:44Z", Driver:"local", Labels:map[string]string(nil), Mountpoint:"/var/lib/docker/volumes/fd3e13663271fafcf7366b3bf595c1dfd1c6aaa4e34c04997dfc23d332d72dac/_data", Name:"fd3e13663271fafcf7366b3bf595c1dfd1c6aaa4e34c04997dfc23d332d72dac", Options:map[string]string{}, Scope:"local", Status:map[string]interface {}(nil), UsageData:(*types.VolumeUsageData)(nil)}
03:25:08 		
	            	received: types.Volume{CreatedAt:"2018-02-22T03:25:08Z", Driver:"local", Labels:map[string]string(nil), Mountpoint:"/var/lib/docker/volumes/test/_data", Name:"test", Options:map[string]string{}, Scope:"local", Status:map[string]interface {}(nil), UsageData:(*types.VolumeUsageData)(nil)}
03:25:08 		
	            	
03:25:08 		
	            	Diff:
03:25:08 		
	            	--- Expected
03:25:08 		
	            	+++ Actual
03:25:08 		
	            	@@ -1,7 +1,7 @@
03:25:08 		
	            	 (types.Volume) {
03:25:08 		
	            	- CreatedAt: (string) (len=20) "2018-02-22T03:17:44Z",
03:25:08 		
	            	+ CreatedAt: (string) (len=20) "2018-02-22T03:25:08Z",
03:25:08 		
	            	  Driver: (string) (len=5) "local",
03:25:08 		
	            	  Labels: (map[string]string) <nil>,
03:25:08 		
	            	- Mountpoint: (string) (len=94) "/var/lib/docker/volumes/fd3e13663271fafcf7366b3bf595c1dfd1c6aaa4e34c04997dfc23d332d72dac/_data",
03:25:08 		
	            	- Name: (string) (len=64) "fd3e13663271fafcf7366b3bf595c1dfd1c6aaa4e34c04997dfc23d332d72dac",
03:25:08 		
	            	+ Mountpoint: (string) (len=34) "/var/lib/docker/volumes/test/_data",
03:25:08 		
	            	+ Name: (string) (len=4) "test",
03:25:08 		
	            	  Options: (map[string]string) {

Once addressed, can you also squash commits? I think it's clearer if the test "remove" and "move" are in a single commit

@yongtang
Copy link
Copy Markdown
Member Author

@thaJeztah Thanks. I am still trying to figure out where the volumes comes from. Might be from docker-py but I am not so sure. May still need to play with the Jenkins build around. Will squash once I figure it out.

@yongtang yongtang force-pushed the 0212-2018-volumes-tests branch 3 times, most recently from 9f0ee2f to 056156a Compare February 22, 2018 22:15
@yongtang
Copy link
Copy Markdown
Member Author

Added a PR in docker-py docker/docker-py#1922

@yongtang
Copy link
Copy Markdown
Member Author

@thaJeztah The PR has been updated. Please take a look.

Copy link
Copy Markdown
Member

@thaJeztah thaJeztah left a comment

Choose a reason for hiding this comment

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

Left some suggestions 🤗

Comment thread integration/internal/container/ops.go Outdated
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Doc doesn't match the function? 😅

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Thanks @thaJeztah. Done.

Comment thread integration/volume/volume_test.go Outdated
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I know this was discussed in some other PR's; should this be a unique name (to allow tests running in parallel?). Could use t.Name() as part of the volume-name to make it unique, or just a random name

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Done.

Comment thread integration/volume/volume_test.go Outdated
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Same here with the name. In this case, I don't think we need a name at all (as we can reference the container by it's ID, correct?)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Done.

Comment thread integration/volume/volume_test.go Outdated
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Same here 🤗

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Done.

@yongtang yongtang force-pushed the 0212-2018-volumes-tests branch from af955d1 to be78e25 Compare February 26, 2018 19:31
@yongtang
Copy link
Copy Markdown
Member Author

Thanks @thaJeztah for the review. The PR has been updated.

This fix migrates volumes tests in integration-cli to api tests
in integration/

Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
Copy link
Copy Markdown
Member

@thaJeztah thaJeztah left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!

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