Skip to content

Commit

Permalink
Merge pull request #943 from Letty5411/0322
Browse files Browse the repository at this point in the history
test: use stable image tag
  • Loading branch information
HusterWan authored Mar 28, 2018
2 parents 8c443ac + 23215af commit 2f15bb9
Show file tree
Hide file tree
Showing 39 changed files with 229 additions and 102 deletions.
2 changes: 1 addition & 1 deletion hack/make.sh
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ function target()
fi
done

pouch pull registry.hub.docker.com/library/busybox:latest >/dev/null
pouch pull registry.hub.docker.com/library/busybox:1.28 >/dev/null

echo "verify pouch version"
pouch version
Expand Down
4 changes: 1 addition & 3 deletions test/api_container_attach_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,10 @@ package main
import (
"net/url"

"github.com/alibaba/pouch/test/command"
"github.com/alibaba/pouch/test/environment"
"github.com/alibaba/pouch/test/request"

"github.com/go-check/check"
"github.com/gotestyourself/gotestyourself/icmd"
)

// APIContainerAttachSuite is the test suite for container attach API.
Expand All @@ -22,7 +20,7 @@ func init() {
func (suite *APIContainerAttachSuite) SetUpTest(c *check.C) {
SkipIfFalse(c, environment.IsLinux)

command.PouchRun("pull", busyboxImage).Assert(c, icmd.Success)
PullImage(c, busyboxImage)
}

// TestContainerAttachStdin tests attaching stdin is OK.
Expand Down
4 changes: 1 addition & 3 deletions test/api_container_create_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,10 @@ import (
"net/url"

"github.com/alibaba/pouch/apis/types"
"github.com/alibaba/pouch/test/command"
"github.com/alibaba/pouch/test/environment"
"github.com/alibaba/pouch/test/request"

"github.com/go-check/check"
"github.com/gotestyourself/gotestyourself/icmd"
)

// APIContainerCreateSuite is the test suite for container create API.
Expand All @@ -22,7 +20,7 @@ func init() {
// SetUpTest does common setup in the beginning of each test.
func (suite *APIContainerCreateSuite) SetUpTest(c *check.C) {
SkipIfFalse(c, environment.IsLinux)
command.PouchRun("pull", busyboxImage).Assert(c, icmd.Success)
PullImage(c, busyboxImage)
}

// TestCreateOk test create api is ok with default parameters.
Expand Down
4 changes: 1 addition & 3 deletions test/api_container_delete_test.go
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
package main

import (
"github.com/alibaba/pouch/test/command"
"github.com/alibaba/pouch/test/environment"
"github.com/alibaba/pouch/test/request"

"github.com/go-check/check"
"github.com/gotestyourself/gotestyourself/icmd"
)

// APIContainerDeleteSuite is the test suite for container delete API.
Expand All @@ -19,7 +17,7 @@ func init() {
// SetUpTest does common setup in the beginning of each test.
func (suite *APIContainerDeleteSuite) SetUpTest(c *check.C) {
SkipIfFalse(c, environment.IsLinux)
command.PouchRun("pull", busyboxImage).Assert(c, icmd.Success)
PullImage(c, busyboxImage)
}

// TestDeleteNonExisting tests deleting a non-existing container return error.
Expand Down
4 changes: 1 addition & 3 deletions test/api_container_exec_start_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,10 @@ import (
"io"
"net"

"github.com/alibaba/pouch/test/command"
"github.com/alibaba/pouch/test/environment"
"github.com/alibaba/pouch/test/request"

"github.com/go-check/check"
"github.com/gotestyourself/gotestyourself/icmd"
)

// APIContainerExecStartSuite is the test suite for container exec start API.
Expand All @@ -23,7 +21,7 @@ func init() {
// SetUpTest does common setup in the beginning of each test.
func (suite *APIContainerExecStartSuite) SetUpTest(c *check.C) {
SkipIfFalse(c, environment.IsLinux)
command.PouchRun("pull", busyboxImage).Assert(c, icmd.Success)
PullImage(c, busyboxImage)
}

func checkEchoSuccess(c *check.C, conn net.Conn, br *bufio.Reader, exp string) {
Expand Down
4 changes: 1 addition & 3 deletions test/api_container_exec_test.go
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
package main

import (
"github.com/alibaba/pouch/test/command"
"github.com/alibaba/pouch/test/environment"
"github.com/alibaba/pouch/test/request"

"github.com/go-check/check"
"github.com/gotestyourself/gotestyourself/icmd"
)

// APIContainerExecSuite is the test suite for container exec API.
Expand All @@ -19,7 +17,7 @@ func init() {
// SetUpTest does common setup in the beginning of each test.
func (suite *APIContainerExecSuite) SetUpTest(c *check.C) {
SkipIfFalse(c, environment.IsLinux)
command.PouchRun("pull", busyboxImage).Assert(c, icmd.Success)
PullImage(c, busyboxImage)
}

// TestContainerCreateExecOk tests execing containers is OK.
Expand Down
4 changes: 1 addition & 3 deletions test/api_container_inspect_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,10 @@ package main

import (
"github.com/alibaba/pouch/apis/types"
"github.com/alibaba/pouch/test/command"
"github.com/alibaba/pouch/test/environment"
"github.com/alibaba/pouch/test/request"

"github.com/go-check/check"
"github.com/gotestyourself/gotestyourself/icmd"
)

// APIContainerInspectSuite is the test suite for container inspect API.
Expand All @@ -20,7 +18,7 @@ func init() {
// SetUpTest does common setup in the beginning of each test.
func (suite *APIContainerInspectSuite) SetUpTest(c *check.C) {
SkipIfFalse(c, environment.IsLinux)
command.PouchRun("pull", busyboxImage).Assert(c, icmd.Success)
PullImage(c, busyboxImage)
}

// TestInspectNoSuchContainer tests inspecting a container that doesn't exits return error.
Expand Down
4 changes: 1 addition & 3 deletions test/api_container_list_test.go
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
package main

import (
"github.com/alibaba/pouch/test/command"
"github.com/alibaba/pouch/test/environment"
"github.com/alibaba/pouch/test/request"

"github.com/go-check/check"
"github.com/gotestyourself/gotestyourself/icmd"
)

// APIContainerListSuite is the test suite for container list API.
Expand All @@ -19,7 +17,7 @@ func init() {
// SetUpTest does common setup in the beginning of each test.
func (suite *APIContainerListSuite) SetUpTest(c *check.C) {
SkipIfFalse(c, environment.IsLinux)
command.PouchRun("pull", busyboxImage).Assert(c, icmd.Success)
PullImage(c, busyboxImage)
}

// TestListOk test api is ok with default parameters.
Expand Down
4 changes: 1 addition & 3 deletions test/api_container_pause_test.go
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
package main

import (
"github.com/alibaba/pouch/test/command"
"github.com/alibaba/pouch/test/environment"
"github.com/alibaba/pouch/test/request"

"github.com/go-check/check"
"github.com/gotestyourself/gotestyourself/icmd"
)

// APIContainerPauseSuite is the test suite for container pause/unpause API.
Expand All @@ -19,7 +17,7 @@ func init() {
// SetUpTest does common setup in the beginning of each test.
func (suite *APIContainerPauseSuite) SetUpTest(c *check.C) {
SkipIfFalse(c, environment.IsLinux)
command.PouchRun("pull", busyboxImage).Assert(c, icmd.Success)
PullImage(c, busyboxImage)
}

// TestPauseUnpauseOk tests a running container could be paused and unpaused.
Expand Down
4 changes: 1 addition & 3 deletions test/api_container_rename_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,10 @@ package main
import (
"net/url"

"github.com/alibaba/pouch/test/command"
"github.com/alibaba/pouch/test/environment"
"github.com/alibaba/pouch/test/request"

"github.com/go-check/check"
"github.com/gotestyourself/gotestyourself/icmd"
)

// APIContainerRenameSuite is the test suite for container create API.
Expand All @@ -21,7 +19,7 @@ func init() {
// SetUpTest does common setup in the beginning of each test.
func (suite *APIContainerRenameSuite) SetUpTest(c *check.C) {
SkipIfFalse(c, environment.IsLinux)
command.PouchRun("pull", busyboxImage).Assert(c, icmd.Success)
PullImage(c, busyboxImage)
}

// TestRenameOk test create api is ok with default parameters.
Expand Down
1 change: 1 addition & 0 deletions test/api_container_resize.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ func init() {
func (suite *APIContainerResizeSuite) SetUpTest(c *check.C) {
SkipIfFalse(c, environment.IsLinux)

PullImage(c, busyboxImage)
}

// TestContainerResizeOk is to verify resize container.
Expand Down
4 changes: 1 addition & 3 deletions test/api_container_start_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,10 @@ package main
import (
"net/url"

"github.com/alibaba/pouch/test/command"
"github.com/alibaba/pouch/test/environment"
"github.com/alibaba/pouch/test/request"

"github.com/go-check/check"
"github.com/gotestyourself/gotestyourself/icmd"
)

// APIContainerStartSuite is the test suite for container pause/unpause API.
Expand All @@ -21,7 +19,7 @@ func init() {
// SetUpTest does common setup in the beginning of each test.
func (suite *APIContainerStartSuite) SetUpTest(c *check.C) {
SkipIfFalse(c, environment.IsLinux)
command.PouchRun("pull", busyboxImage).Assert(c, icmd.Success)
PullImage(c, busyboxImage)
}

// TestStartOk tests starting container could work.
Expand Down
4 changes: 1 addition & 3 deletions test/api_container_stop_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,10 @@ package main
import (
"net/url"

"github.com/alibaba/pouch/test/command"
"github.com/alibaba/pouch/test/environment"
"github.com/alibaba/pouch/test/request"

"github.com/go-check/check"
"github.com/gotestyourself/gotestyourself/icmd"
)

// APIContainerStopSuite is the test suite for container stop API.
Expand All @@ -21,7 +19,7 @@ func init() {
// SetUpTest does common setup in the beginning of each test.
func (suite *APIContainerStopSuite) SetUpTest(c *check.C) {
SkipIfFalse(c, environment.IsLinux)
command.PouchRun("pull", busyboxImage).Assert(c, icmd.Success)
PullImage(c, busyboxImage)
}

// TestStopOk tests a running container could be stopped.
Expand Down
10 changes: 5 additions & 5 deletions test/api_image_create_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ func (suite *APIImageCreateSuite) SetUpTest(c *check.C) {
// TestImageCreateOk tests creating an image is OK.
func (suite *APIImageCreateSuite) TestImageCreateOk(c *check.C) {
q := url.Values{}
q.Add("fromImage", helloworldImage)
q.Add("tag", "latest")
q.Add("fromImage", environment.HelloworldRepo)
q.Add("tag", "linux")
query := request.WithQuery(q)
resp, err := request.Post("/images/create", query)
c.Assert(err, check.IsNil)
Expand All @@ -36,7 +36,7 @@ func (suite *APIImageCreateSuite) TestImageCreateOk(c *check.C) {
// TODO: add a waituntil func to check the exsitence of image
time.Sleep(5000 * time.Millisecond)

resp, err = request.Delete("/images/" + helloworldImage + ":latest")
resp, err = request.Delete("/images/" + environment.HelloworldRepo + ":linux")
c.Assert(err, check.IsNil)
CheckRespStatus(c, resp, 204)
}
Expand All @@ -56,15 +56,15 @@ func (suite *APIImageCreateSuite) TestImageCreateNil(c *check.C) {
// TestImageCreateWithoutTag tests creating an image without tag, will use "latest" by default.
func (suite *APIImageCreateSuite) TestImageCreateWithoutTag(c *check.C) {
q := url.Values{}
q.Add("fromImage", helloworldImage)
q.Add("fromImage", environment.HelloworldRepo)
query := request.WithQuery(q)
resp, err := request.Post("/images/create", query)
c.Assert(err, check.IsNil)
CheckRespStatus(c, resp, 200)

time.Sleep(5000 * time.Millisecond)

resp, err = request.Delete("/images/" + helloworldImage + ":latest")
resp, err = request.Delete("/images/" + environment.HelloworldRepo + ":latest")
c.Assert(err, check.IsNil)
CheckRespStatus(c, resp, 204)
}
Expand Down
4 changes: 1 addition & 3 deletions test/api_image_inspect_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,10 @@ package main

import (
"github.com/alibaba/pouch/apis/types"
"github.com/alibaba/pouch/test/command"
"github.com/alibaba/pouch/test/environment"
"github.com/alibaba/pouch/test/request"

"github.com/go-check/check"
"github.com/gotestyourself/gotestyourself/icmd"
)

// APIImageInspectSuite is the test suite for image inspect API.
Expand All @@ -20,7 +18,7 @@ func init() {
// SetUpTest does common setup in the beginning of each test.
func (suite *APIImageInspectSuite) SetUpTest(c *check.C) {
SkipIfFalse(c, environment.IsLinux)
command.PouchRun("pull", busyboxImage).Assert(c, icmd.Success)
PullImage(c, busyboxImage)
}

// TestImageInspectOk tests inspecting images is OK.
Expand Down
2 changes: 1 addition & 1 deletion test/cli_alikernel_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ func (suite *PouchAliKernelSuite) SetUpSuite(c *check.C) {

environment.PruneAllContainers(apiClient)

command.PouchRun("pull", busyboxImage).Assert(c, icmd.Success)
PullImage(c, busyboxImage)
}

// TearDownTest does cleanup work in the end of each test.
Expand Down
2 changes: 1 addition & 1 deletion test/cli_create_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ func (suite *PouchCreateSuite) SetUpSuite(c *check.C) {

environment.PruneAllContainers(apiClient)

command.PouchRun("pull", busyboxImage).Assert(c, icmd.Success)
PullImage(c, busyboxImage)
}

// TearDownTest does cleanup work in the end of each test.
Expand Down
2 changes: 1 addition & 1 deletion test/cli_exec_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func (suite *PouchExecSuite) SetUpSuite(c *check.C) {

environment.PruneAllContainers(apiClient)

command.PouchRun("pull", busyboxImage).Assert(c, icmd.Success)
PullImage(c, busyboxImage)
}

// TearDownTest does cleanup work in the end of each test.
Expand Down
10 changes: 5 additions & 5 deletions test/cli_images_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package main
import (
"context"
"encoding/json"
"fmt"
"strings"

"github.com/alibaba/pouch/apis/types"
Expand Down Expand Up @@ -30,7 +31,7 @@ func (suite *PouchImagesSuite) SetUpSuite(c *check.C) {

environment.PruneAllContainers(apiClient)

command.PouchRun("pull", busyboxImage).Assert(c, icmd.Success)
PullImage(c, busyboxImage)
}

// TestImagesWorks tests "pouch image" work.
Expand All @@ -52,7 +53,8 @@ func (suite *PouchImagesSuite) TestImagesWorks(c *check.C) {
resQuiet := command.PouchRun("images", "--quiet").Assert(c, icmd.Success)

c.Assert(resQ.Combined(), check.Equals, resQuiet.Combined())
c.Assert(strings.TrimSpace(resQ.Combined()), check.Equals, utils.TruncateID(image.ID))
err := util.PartialEqual(strings.TrimSpace(resQ.Combined()), utils.TruncateID(image.ID))
c.Assert(err, check.IsNil)
}

// with --digest
Expand Down Expand Up @@ -106,9 +108,7 @@ func (suite *PouchImagesSuite) TestInspectImage(c *check.C) {

// inspect image name
output = command.PouchRun("image", "inspect", "-f", "{{.RepoTags}}", busyboxImage).Stdout()
if !strings.Contains(output, busyboxImage) {
c.Fatalf("output %s should contains %s", output, busyboxImage)
}
c.Assert(output, check.Equals, fmt.Sprintf("[%s]\n", busyboxImage))
}

// TestLoginAndLogout is to test login and logout command
Expand Down
2 changes: 1 addition & 1 deletion test/cli_inspect_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ func (suite *PouchInspectSuite) SetUpSuite(c *check.C) {

environment.PruneAllContainers(apiClient)

command.PouchRun("pull", busyboxImage).Assert(c, icmd.Success)
PullImage(c, busyboxImage)
}

// TearDownTest does cleanup work in the end of each test.
Expand Down
Loading

0 comments on commit 2f15bb9

Please sign in to comment.