-
Notifications
You must be signed in to change notification settings - Fork 947
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
test: refactor test package and add cases #331
test: refactor test package and add cases #331
Conversation
) | ||
|
||
// PruneAllImages deletes all images from pouchd. | ||
func PruneAllImages(apiClient client.ImageAPIClient) error { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why func PruneAllImages(apiClient client.ImageAPIClient) error
?
Not func (apiClient client.ImageAPIClient) PruneAllImages() error
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Original idea is that the PruneAllImages
is only used in test package. It comes from docker system prune
. If you need this in pouch, we can implement it in cli
package.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is not in pouch's first stage.
Maybe in the future, we will support this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Got it. Make senses
All test case fails with the stderr output:
|
I totally support this idea. |
@0x04C2 The CI is failed. You can debug your code in travis according to the following document. |
Hi @sunyuan3 and @allencloud , the CI is expected to be failed. I try to fix this issue in #345 |
#345 has been merged. Please rebase this. @0x04C2 |
Got it. Hold on a sec. |
Signed-off-by: Wei Fu <fhfuwei@163.com>
@allencloud , has been rebased. Please check it. |
// {name: "missing image name", args: ""}, | ||
} { | ||
res := command.PouchRun("create", tc.args) | ||
c.Assert(res.Error, check.NotNil, check.Commentf(tc.name)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I think we should use more c.Assert
in test cases. It is much better now. 👍
args := map[string]bool{ | ||
"": false, | ||
// getImageInfo is used to retrieve the information about image. | ||
func getImageInfo(apiClient client.ImageAPIClient, name string) (types.ImageInfo, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to add an API GET /images/{idOrName}/json
😄 I recorded this in issue #138
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On my plan. Haha
|
||
// running | ||
{ | ||
command.PouchRun("start", name).Assert(c, icmd.Success) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to use pouch run
to replace create
and start
, if issue #351 is solved. Just leave a comment to record this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think there is no need to use run
command, because I want to check the created
, running
and stopped
. If I use run
, I will miss the created
status. :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
make sense
"github.com/alibaba/pouch/test/environment" | ||
) | ||
|
||
// Get sends request to the default pouchd server with custom request options. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like this package 😄
@@ -507,6 +507,12 @@ | |||
"revision": "b5461758462b97cff258bf388ca42110f529d747", | |||
"revisionTime": "2017-11-07T15:27:38Z" | |||
}, | |||
{ | |||
"checksumSHA1": "jHOLsfeMPcX84YQB2MXBqXFntBg=", | |||
"path": "github.com/kr/pty", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This package is licensed under MIT.
Just comment to mark this.
In the future, we will list all the licenses of vendored package.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh. I don't realize this. Sorry about that.
It seems that we can do this without pr/tty
. I will try.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is all right. Maybe in the future. We need these test very much. I think we could merge this ASAP.
LGTM. Generally. While I have some tiny suggestion for this PR. These advices all help users could learn test easily.
All the points above is a record, not blocking this pr. We can handle this in follow-ups absolutely. /cc @sunyuan3 @Letty5411 WDYT? |
Thanks again for your contribution. I am going to merge this. 🍻 |
Signed-off-by: Wei Fu fhfuwei@163.com
1.Describe what this PR did
Refactor test package and add more tests
2.Does this pull request fix one issue?
none
3.Describe how you did it
runCmd
wrapsicmd
and does the same thing asicmd
. In order to make maintainer eaiser, I remove therunCmd
and createcommand
package intest
package.test
package not just test the cli command, but also test the pouch api. For this reason, I createrequest
package to handle the request. And then the host address is stable. We can do initailization work inrequest
package so that case doesn't need to do the duplicate work about initialization.Before this commit, the almost cases doesn't care the result. We need to inspect the result. In this commit, the trick one is
pouch start -a -i
. In order to testattach
andtty
, we can createpty
to write and read the content.4.Describe how to verify it
none
5.Special notes for reviews
During testing, I meets some issues:
The
pouch pull
requires thepty/tty
device as STDIN. [bug] pouch pull can't be run by using exec package #313The
pouch rm -f
cannot clear/var/lib/pouch/containers/{containerID}
folder. The reason is [bug] The phantom container's meta data #326The
pouch {command} ""
is valid. The""
is emtpy and invalid.pouch pull ""
should equalpouch pull
. Butpouch pull ""
runs sucessfully.Ping @Letty5411 @allencloud