Skip to content
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: add test to images quiet flag #203

Closed
wants to merge 1 commit into from
Closed

test: add test to images quiet flag #203

wants to merge 1 commit into from

Conversation

fuweid
Copy link
Contributor

@fuweid fuweid commented Nov 30, 2017

Signed-off-by: Wei Fu fhfuwei@163.com

1.Describe what this PR did

Add test case for pouch images -q|--quiet.

2.Does this pull request fix one issue?
NONE

3.Describe how you did it
NONE

4.Describe how to verify it
NONE

5.Special notes for reviews
For now, we're missing pouch rm functionality. In local testing, I did hack-thing to rm -rf /var/lib/pouch/containers to make the clean env. It's killing me.

I think the hack/make.sh can run pouchd in other scope before we have pouch rm functionality.

Signed-off-by: Wei Fu <fhfuwei@163.com>
c.Assert(err, check.IsNil)

c.Assert(qOut, check.Equals, quietOut)
if match, _ := regexp.MatchString("^[0-9a-f]+\n$", qOut); !match {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I tried these code by using

Desktop $ cat main.go
package main

import (
	"regexp"
	"fmt"
)

func main(){
	qOut := "123456789"
	if match, _ := regexp.MatchString("^[0-9a-f]+\n$", qOut); !match {
 		fmt.Println("should return numeric ID, but got")
		fmt.Println(qOut)
	}
}

Desktop $ go run main.go
should return numeric ID, but got
123456789

I think 123456789 is a valid image ID, but the regexp will not pass.
Am I wrong?

Copy link
Contributor Author

@fuweid fuweid Nov 30, 2017

Choose a reason for hiding this comment

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

The ID is valid.

But the cli uses fmt.Println to print so that each ID will have the Carriage char at the end.
For the case, the qOut will contains the \n. That is why I put the \n before the $ in the regrex.

Copy link
Collaborator

Choose a reason for hiding this comment

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

In this case, can we make pouchd pull an image in advance in the integration test of travisCI?
@sunyuan3 @Letty5411

Copy link
Contributor Author

@fuweid fuweid Nov 30, 2017

Choose a reason for hiding this comment

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

BTW, the Windows uses \r\n as Carriage char. I don't have env to test that. 😢 The case maybe fail in Windows...

Copy link
Collaborator

Choose a reason for hiding this comment

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

I am afraid no. But we have not planned running on Windows.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OK! 👍

Copy link
Contributor

Choose a reason for hiding this comment

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

@allencloud Yes, I can pull an image in advance in the integration test of travisCI.

c.Assert(err, check.IsNil)

c.Assert(qOut, check.Equals, quietOut)
if match, _ := regexp.MatchString("^[0-9a-f]+\n$", qOut); !match {
Copy link
Contributor

Choose a reason for hiding this comment

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

^[0-9a-f] : this may be changed to ^[0-9] as image ID only contains number.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hi @Letty5411 , the ID is short for SHA256-Digest which is hexadecimal. ID can contains the a-f.

@Letty5411
Copy link
Contributor

@allencloud @sunyuan3 Currently, test has pulled testImage(busybox) in SetUpSuite function:

 func (suite *PouchImagesSuite) SetUpSuite(c *check.C) {
 	SkipIfFalse(c, IsLinux)
 
 	// Pull test image
 	cmd := exec.Command("pouch", "pull", testImage)
 	cmd.Run()

@allencloud
Copy link
Collaborator

If we need to support --quiet flag testing, I am afraid we need to support pouch image inspect command to get image ID of image first. Then, use the ID to check whether --quiet testing result is correct. @0x04C2 WDYT?

@fuweid
Copy link
Contributor Author

fuweid commented Dec 4, 2017

Hi @allencloud ,

I have question before this PR. How to check the image information? Should we need to send a request to containerd to get information?

If not, I think pouch image inspect is good choice.

@skoowoo
Copy link
Contributor

skoowoo commented Dec 12, 2017

yes, We need a API to get image information and "pouch image inspect". @0x04C2

@fuweid
Copy link
Contributor Author

fuweid commented Dec 12, 2017

@skoo87 Got it. Thanks!

@fuweid
Copy link
Contributor Author

fuweid commented Dec 13, 2017

I close this PR and do it in other PR.

@fuweid fuweid closed this Dec 13, 2017
@fuweid fuweid deleted the test_images_quiet_flag branch August 3, 2018 02:51
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.

None yet

6 participants