Initial commit
This commit is contained in:
151
vendor/github.com/hyperhq/hypercli/integration-cli/final/cli/hyper_cli_load_basic_ext_test.go
generated
vendored
Executable file
151
vendor/github.com/hyperhq/hypercli/integration-cli/final/cli/hyper_cli_load_basic_ext_test.go
generated
vendored
Executable file
@@ -0,0 +1,151 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/docker/docker/pkg/integration/checker"
|
||||
"github.com/go-check/check"
|
||||
"os"
|
||||
"time"
|
||||
)
|
||||
|
||||
//Prerequisite: update image balance to 2 in tenant collection of hypernetes in mongodb
|
||||
//db.tenant.update({tenantid:"<tenant_id>"},{$set:{"resourceinfo.balance.images":2}})
|
||||
func (s *DockerSuite) TestCliLoadUrlBasicFromPublicURLWithQuota(c *check.C) {
|
||||
printTestCaseName()
|
||||
defer printTestDuration(time.Now())
|
||||
testRequires(c, DaemonIsLinux)
|
||||
|
||||
deleteAllImages()
|
||||
|
||||
helloworldURL := "http://image-tarball.s3.amazonaws.com/test/public/helloworld.tar"
|
||||
multiImgURL := "http://image-tarball.s3.amazonaws.com/test/public/busybox_alpine.tar"
|
||||
ubuntuURL := "http://image-tarball.s3.amazonaws.com/test/public/ubuntu.tar.gz"
|
||||
//exceedQuotaMsg := "Exceeded quota, please either delete images, or email support@hyper.sh to request increased quota"
|
||||
exceedQuotaMsg := "you do not have enough quota"
|
||||
|
||||
///// [init] /////
|
||||
// balance 3, images 0
|
||||
out, _ := dockerCmd(c, "info")
|
||||
c.Assert(out, checker.Contains, "Images: 0")
|
||||
|
||||
///// [step 1] load new hello-world image /////
|
||||
// balance 3 -> 2, image: 0 -> 1
|
||||
output, exitCode, err := dockerCmdWithError("load", "-i", helloworldURL)
|
||||
c.Assert(output, checker.Contains, "has been loaded.")
|
||||
c.Assert(exitCode, checker.Equals, 0)
|
||||
c.Assert(err, checker.IsNil)
|
||||
|
||||
checkImage(c, true, "hello-world")
|
||||
|
||||
out, _ = dockerCmd(c, "info")
|
||||
c.Assert(out, checker.Contains, "Images: 1")
|
||||
|
||||
///// [step 2] load hello-world image again /////
|
||||
// balance 2 -> 2, image 1 -> 1
|
||||
output, exitCode, err = dockerCmdWithError("load", "-i", helloworldURL)
|
||||
c.Assert(output, checker.Contains, "has been loaded.")
|
||||
c.Assert(exitCode, checker.Equals, 0)
|
||||
c.Assert(err, checker.IsNil)
|
||||
|
||||
checkImage(c, true, "hello-world")
|
||||
|
||||
out, _ = dockerCmd(c, "info")
|
||||
c.Assert(out, checker.Contains, "Images: 1")
|
||||
|
||||
///// [step 3] load multiple image(busybox+alpine) /////
|
||||
// balance 2 -> 2, image 1 -> 1
|
||||
output, exitCode, err = dockerCmdWithError("load", "-i", multiImgURL)
|
||||
c.Assert(output, checker.Contains, exceedQuotaMsg)
|
||||
c.Assert(exitCode, checker.Equals, 1)
|
||||
c.Assert(err, checker.NotNil)
|
||||
|
||||
checkImage(c, false, "busybox")
|
||||
checkImage(c, false, "alpine")
|
||||
|
||||
out, _ = dockerCmd(c, "info")
|
||||
c.Assert(out, checker.Contains, "Images: 1")
|
||||
|
||||
///// [step 4] load new ubuntu image /////
|
||||
// balance 2 -> 1, image 1 -> 2
|
||||
output, exitCode, err = dockerCmdWithError("load", "-i", ubuntuURL)
|
||||
c.Assert(output, checker.Contains, "has been loaded.")
|
||||
c.Assert(exitCode, checker.Equals, 0)
|
||||
c.Assert(err, checker.IsNil)
|
||||
|
||||
checkImage(c, true, "ubuntu")
|
||||
|
||||
out, _ = dockerCmd(c, "info")
|
||||
c.Assert(out, checker.Contains, "Images: 2")
|
||||
|
||||
///// [step 5] remove hello-world image /////
|
||||
// balance 1 -> 2, image 2 -> 1
|
||||
images, _ := dockerCmd(c, "rmi", "-f", "hello-world")
|
||||
c.Assert(images, checker.Contains, "Untagged: hello-world:latest")
|
||||
|
||||
checkImage(c, false, "hello-world")
|
||||
|
||||
out, _ = dockerCmd(c, "info")
|
||||
c.Assert(out, checker.Contains, "Images: 1")
|
||||
|
||||
///// [step 6] remove busybox and ubuntu image /////
|
||||
// balance 2 -> 3, image 1 -> 0
|
||||
images, _ = dockerCmd(c, "rmi", "-f", "ubuntu:latest")
|
||||
c.Assert(images, checker.Contains, "Untagged: ubuntu:latest")
|
||||
|
||||
checkImage(c, false, "ubuntu")
|
||||
|
||||
out, _ = dockerCmd(c, "info")
|
||||
c.Assert(out, checker.Contains, "Images: 0")
|
||||
|
||||
///// [step 7] load multiple image(busybox+alpine) again /////
|
||||
// balance 3 -> 0, image 0 -> 3
|
||||
output, exitCode, err = dockerCmdWithError("load", "-i", multiImgURL)
|
||||
c.Assert(output, checker.Contains, "has been loaded.")
|
||||
c.Assert(exitCode, checker.Equals, 0)
|
||||
c.Assert(err, checker.IsNil)
|
||||
|
||||
checkImage(c, true, "busybox")
|
||||
checkImage(c, true, "alpine")
|
||||
|
||||
out, _ = dockerCmd(c, "info")
|
||||
c.Assert(out, checker.Contains, "Images: 3")
|
||||
}
|
||||
|
||||
func (s *DockerSuite) TestCliLoadUrlBasicFromAWSS3PreSignedURL(c *check.C) {
|
||||
printTestCaseName()
|
||||
defer printTestDuration(time.Now())
|
||||
testRequires(c, DaemonIsLinux)
|
||||
|
||||
deleteAllImages()
|
||||
|
||||
s3Region := "us-west-1"
|
||||
s3Bucket := "image-tarball"
|
||||
s3Key := "test/private/cirros.tar"
|
||||
preSignedUrl, err_ := generateS3PreSignedURL(s3Region, s3Bucket, s3Key)
|
||||
c.Assert(err_, checker.IsNil)
|
||||
time.Sleep(1 * time.Second)
|
||||
|
||||
output, err := dockerCmd(c, "load", "-i", preSignedUrl)
|
||||
if err != 0 {
|
||||
fmt.Printf("preSignedUrl:[%v]\n", preSignedUrl)
|
||||
fmt.Printf("output:\n%v\n", output)
|
||||
}
|
||||
c.Assert(output, checker.Contains, "has been loaded.")
|
||||
c.Assert(err, checker.Equals, 0)
|
||||
|
||||
checkImage(c, true, "cirros")
|
||||
}
|
||||
|
||||
func (s *DockerSuite) TestCliLoadUrlBasicFromBasicAuthURL(c *check.C) {
|
||||
printTestCaseName()
|
||||
defer printTestDuration(time.Now())
|
||||
testRequires(c, DaemonIsLinux)
|
||||
|
||||
urlWithAuth := os.Getenv("URL_WITH_BASIC_AUTH")
|
||||
c.Assert(urlWithAuth, checker.NotNil)
|
||||
|
||||
dockerCmd(c, "load", "-i", urlWithAuth)
|
||||
|
||||
images, _ := dockerCmd(c, "images", "ubuntu")
|
||||
c.Assert(images, checker.Contains, "ubuntu")
|
||||
}
|
||||
26
vendor/github.com/hyperhq/hypercli/integration-cli/final/cli/hyper_cli_load_large_test.go
generated
vendored
Executable file
26
vendor/github.com/hyperhq/hypercli/integration-cli/final/cli/hyper_cli_load_large_test.go
generated
vendored
Executable file
@@ -0,0 +1,26 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"time"
|
||||
"github.com/docker/docker/pkg/integration/checker"
|
||||
"github.com/go-check/check"
|
||||
"strings"
|
||||
)
|
||||
|
||||
func (s *DockerSuite) TestCliLoadFromUrlLargeImageArchiveFile(c *check.C) {
|
||||
printTestCaseName(); defer printTestDuration(time.Now())
|
||||
testRequires(c, DaemonIsLinux)
|
||||
|
||||
imageName := "consol/centos-xfce-vnc";
|
||||
imageUrl := "http://image-tarball.s3.amazonaws.com/test/public/consol_centos-xfce-vnc.tar"; //1.53GB
|
||||
|
||||
output, exitCode, err := dockerCmdWithError("load", "-i", imageUrl)
|
||||
c.Assert(output, checker.Contains, "Starting to download and load the image archive, please wait...\n")
|
||||
c.Assert(output, checker.Contains, "has been loaded.\n")
|
||||
c.Assert(exitCode, checker.Equals, 0)
|
||||
c.Assert(err, checker.IsNil)
|
||||
|
||||
images, _ := dockerCmd(c, "images")
|
||||
c.Assert(images, checker.Contains, imageName)
|
||||
c.Assert(len(strings.Split(images, "\n")), checker.Equals, 3)
|
||||
}
|
||||
165
vendor/github.com/hyperhq/hypercli/integration-cli/final/cli/hyper_cli_load_legacy_ext_test.go
generated
vendored
Executable file
165
vendor/github.com/hyperhq/hypercli/integration-cli/final/cli/hyper_cli_load_legacy_ext_test.go
generated
vendored
Executable file
@@ -0,0 +1,165 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"time"
|
||||
"github.com/docker/docker/pkg/integration/checker"
|
||||
"github.com/go-check/check"
|
||||
"strings"
|
||||
|
||||
"gopkg.in/mgo.v2"
|
||||
"gopkg.in/mgo.v2/bson"
|
||||
"os"
|
||||
//"fmt"
|
||||
)
|
||||
|
||||
func (s *DockerSuite) TestCliLoadFromUrlLegacyImageArchiveFileWithQuota(c *check.C) {
|
||||
printTestCaseName(); defer printTestDuration(time.Now())
|
||||
testRequires(c, DaemonIsLinux)
|
||||
|
||||
imageName := "ubuntu";
|
||||
legacyImageUrl := "http://image-tarball.s3.amazonaws.com/test/public/old/ubuntu_1.8.tar.gz"
|
||||
imageUrl := "http://image-tarball.s3.amazonaws.com/test/public/ubuntu.tar.gz"
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////
|
||||
checkImageQuota(c, 2)
|
||||
//load legacy image(saved by docker 1.8)
|
||||
output, exitCode, err := dockerCmdWithError("load", "-i", legacyImageUrl)
|
||||
c.Assert(output, checker.Contains, "Starting to download and load the image archive, please wait...\n")
|
||||
c.Assert(output, checker.Contains, "has been loaded.\n")
|
||||
c.Assert(exitCode, checker.Equals, 0)
|
||||
c.Assert(err, checker.IsNil)
|
||||
|
||||
output, _ = dockerCmd(c, "images")
|
||||
c.Assert(output, checker.Contains, imageName)
|
||||
c.Assert(len(strings.Split(output, "\n")), checker.Equals, 3)
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////
|
||||
checkImageQuota(c, 1)
|
||||
//load new format image(saved by docker 1.10)
|
||||
output, exitCode, err = dockerCmdWithError("load", "-i", imageUrl)
|
||||
c.Assert(output, checker.Contains, "Start to download and load the image archive, please wait...\n")
|
||||
c.Assert(output, checker.Contains, "has been loaded.\n")
|
||||
c.Assert(exitCode, checker.Equals, 0)
|
||||
c.Assert(err, checker.IsNil)
|
||||
|
||||
output, _ = dockerCmd(c, "images")
|
||||
c.Assert(output, checker.Contains, imageName)
|
||||
c.Assert(len(strings.Split(output, "\n")), checker.Equals, 3)
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////
|
||||
checkImageQuota(c, 1)
|
||||
//delete single layer
|
||||
output, _ = dockerCmd(c, "images", "-q", imageName)
|
||||
imageId := strings.Split(output, "\n")[0]
|
||||
c.Assert(imageId, checker.Not(checker.Equals), "")
|
||||
|
||||
output, _ = dockerCmd(c, "rmi", "--no-prune", imageId)
|
||||
c.Assert(output, checker.Contains, "Untagged:")
|
||||
c.Assert(output, checker.Contains, "Deleted:")
|
||||
|
||||
checkImageQuota(c, 1)
|
||||
|
||||
output, _ = dockerCmd(c, "images")
|
||||
c.Assert(output, checker.Contains, "<none>")
|
||||
c.Assert(len(strings.Split(output, "\n")), checker.Equals, 3)
|
||||
imageId = strings.Split(output, "\n")[0]
|
||||
|
||||
output, _ = dockerCmd(c, "images", "-a")
|
||||
c.Assert(output, checker.Contains, "<none>")
|
||||
c.Assert(len(strings.Split(output, "\n")), checker.Equals, 6)
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////
|
||||
checkImageQuota(c, 1)
|
||||
//delete all rest layer
|
||||
output, _ = dockerCmd(c, "images", "-q")
|
||||
imageId = strings.Split(output, "\n")[0]
|
||||
c.Assert(imageId, checker.Not(checker.Equals), "")
|
||||
|
||||
output, _ = dockerCmd(c, "rmi", imageId)
|
||||
c.Assert(output, checker.Contains, "Deleted:")
|
||||
|
||||
checkImageQuota(c, 2)
|
||||
|
||||
output, _ = dockerCmd(c, "images")
|
||||
c.Assert(len(strings.Split(output, "\n")), checker.Equals, 2)
|
||||
|
||||
output, _ = dockerCmd(c, "images", "-a")
|
||||
c.Assert(len(strings.Split(output, "\n")), checker.Equals, 2)
|
||||
}
|
||||
|
||||
|
||||
//func (s *DockerSuite) TestCliLoadFromUrlLegacyCheckImageQuota(c *check.C) {
|
||||
// printTestCaseName(); defer printTestDuration(time.Now())
|
||||
// testRequires(c, DaemonIsLinux)
|
||||
// checkImageQuota(c, 2)
|
||||
//}
|
||||
|
||||
func checkImageQuota(c *check.C, expected int) {
|
||||
|
||||
//collection struct: credential
|
||||
type Credential struct {
|
||||
TenantId string `bson:"tenantId"`
|
||||
}
|
||||
|
||||
//collection struct: tenant
|
||||
type Total struct {
|
||||
Images int `bson:"images"`
|
||||
}
|
||||
type Balance struct {
|
||||
Images int `bson:"images"`
|
||||
}
|
||||
type Resourceinfo struct {
|
||||
Total Total `bson:"total"`
|
||||
Balance Balance `bson:"balance"`
|
||||
}
|
||||
type Tenant struct {
|
||||
Resourceinfo Resourceinfo `bson:"resourceinfo"`
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////
|
||||
//init connection to mongodb
|
||||
session, err := mgo.Dial(os.Getenv("MONGODB_URL"))
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
defer session.Close()
|
||||
// Optional. Switch the session to a monotonic behavior.
|
||||
session.SetMode(mgo.Monotonic, true)
|
||||
db := session.DB("hypernetes")
|
||||
|
||||
///////////////////////////////////////////
|
||||
// query tenantId by accessKey
|
||||
collection := db.C("credentials")
|
||||
resultCred := Credential{}
|
||||
|
||||
//countNum, _ := collection.Find(condition).Count()
|
||||
//fmt.Println("\ncount:\n", countNum)
|
||||
|
||||
collection.Find(bson.M{"accessKey": os.Getenv("ACCESS_KEY")}).Select(bson.M{"tenantId": 1}).One(&resultCred)
|
||||
c.Assert(resultCred.TenantId, checker.NotNil)
|
||||
tenantId := resultCred.TenantId
|
||||
|
||||
|
||||
///////////////////////////////////////////
|
||||
// query image quota by tenant
|
||||
collection = db.C("tenant")
|
||||
resultTenant := Tenant{}
|
||||
|
||||
//countNum, _ := collection.Find(condition).Count()
|
||||
//fmt.Println("\ncount:\n", countNum)
|
||||
|
||||
collection.Find(bson.M{"tenantid": tenantId}).Select(bson.M{"resourceinfo": 1}).One(&resultTenant)
|
||||
//fmt.Printf("total images: %v\n", resultTenant.Resourceinfo.Total.Images)
|
||||
//fmt.Printf("balance images: %v\n", resultTenant.Resourceinfo.Balance.Images)
|
||||
totalImages := resultTenant.Resourceinfo.Total.Images
|
||||
balanceImages := resultTenant.Resourceinfo.Balance.Images
|
||||
|
||||
c.Assert(totalImages, checker.GreaterThan, 0)
|
||||
c.Assert(balanceImages, checker.LessOrEqualThan, totalImages)
|
||||
c.Assert(balanceImages, checker.Equals, expected)
|
||||
}
|
||||
66
vendor/github.com/hyperhq/hypercli/integration-cli/final/cli/hyper_cli_load_local_ext_test.go
generated
vendored
Executable file
66
vendor/github.com/hyperhq/hypercli/integration-cli/final/cli/hyper_cli_load_local_ext_test.go
generated
vendored
Executable file
@@ -0,0 +1,66 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"os/exec"
|
||||
"time"
|
||||
|
||||
"github.com/docker/docker/pkg/integration/checker"
|
||||
"github.com/go-check/check"
|
||||
)
|
||||
|
||||
func (s *DockerSuite) TestCliLoadFromLocalDocker(c *check.C) {
|
||||
printTestCaseName()
|
||||
defer printTestDuration(time.Now())
|
||||
testRequires(c, DaemonIsLinux)
|
||||
|
||||
testImage := "hello-world:latest"
|
||||
|
||||
//local docker pull image
|
||||
pullCmd := exec.Command("docker", "--region", os.Getenv("LOCAL_DOCKER_HOST"), "pull", testImage)
|
||||
output, exitCode, err := runCommandWithOutput(pullCmd)
|
||||
c.Assert(err, checker.IsNil)
|
||||
c.Assert(exitCode, checker.Equals, 0)
|
||||
|
||||
//load image from local docker to hyper
|
||||
output, exitCode, err = dockerCmdWithError("load", "-l", testImage)
|
||||
c.Assert(output, checker.Contains, "has been loaded.")
|
||||
c.Assert(err, checker.IsNil)
|
||||
c.Assert(exitCode, checker.Equals, 0)
|
||||
|
||||
//check image
|
||||
images, _ := dockerCmd(c, "images", "hello-world")
|
||||
c.Assert(images, checker.Contains, "hello-world")
|
||||
}
|
||||
|
||||
func (s *DockerSuite) TestCliLoadFromLocalTarSize600MB(c *check.C) {
|
||||
printTestCaseName()
|
||||
defer printTestDuration(time.Now())
|
||||
testRequires(c, DaemonIsLinux)
|
||||
|
||||
publicURL := "http://image-tarball.s3.amazonaws.com/test/public/jenkins.tar"
|
||||
imagePath := fmt.Sprintf("%s/jenkins.tar", os.Getenv("IMAGE_DIR"))
|
||||
|
||||
//download image tar
|
||||
wgetCmd := exec.Command("wget", "-cO", imagePath, publicURL)
|
||||
output, exitCode, err := runCommandWithOutput(wgetCmd)
|
||||
c.Assert(exitCode, checker.Equals, 0)
|
||||
c.Assert(err, checker.IsNil)
|
||||
c.Assert(pathExist(imagePath), checker.Equals, true)
|
||||
|
||||
//ensure jenkins:latest not exist
|
||||
dockerCmdWithError("rmi", "jenkins:latest")
|
||||
images, _ := dockerCmd(c, "images", "jenkins:latest")
|
||||
c.Assert(images, checker.Not(checker.Contains), "jenkins")
|
||||
|
||||
//load image tar
|
||||
output, exitCode, err = dockerCmdWithError("load", "-i", imagePath)
|
||||
c.Assert(output, checker.Contains, "has been loaded.")
|
||||
c.Assert(err, checker.IsNil)
|
||||
c.Assert(exitCode, checker.Equals, 0)
|
||||
|
||||
//check image
|
||||
images, _ = dockerCmd(c, "images", "jenkins:latest")
|
||||
c.Assert(images, checker.Contains, "jenkins")
|
||||
}
|
||||
84
vendor/github.com/hyperhq/hypercli/integration-cli/final/cli/hyper_cli_logs_ext_test.go
generated
vendored
Executable file
84
vendor/github.com/hyperhq/hypercli/integration-cli/final/cli/hyper_cli_logs_ext_test.go
generated
vendored
Executable file
@@ -0,0 +1,84 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
//"encoding/json"
|
||||
"fmt"
|
||||
//"io"
|
||||
"os"
|
||||
"os/exec"
|
||||
"regexp"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/docker/docker/pkg/integration/checker"
|
||||
"github.com/docker/docker/pkg/jsonlog"
|
||||
"github.com/go-check/check"
|
||||
)
|
||||
|
||||
//TODO: get exited container log
|
||||
// Regression test for #8832
|
||||
func (s *DockerSuite) TestCliLogsFollowSlowStdoutConsumer(c *check.C) {
|
||||
printTestCaseName()
|
||||
defer printTestDuration(time.Now())
|
||||
testRequires(c, DaemonIsLinux)
|
||||
pullImageIfNotExist("busybox")
|
||||
out, _ := dockerCmd(c, "run", "-d", "busybox", "/bin/sh", "-c", `usleep 600000;yes X | head -c 200000`)
|
||||
time.Sleep(10 * time.Second)
|
||||
id := strings.TrimSpace(out)
|
||||
|
||||
stopSlowRead := make(chan bool)
|
||||
|
||||
go func() {
|
||||
exec.Command(dockerBinary, "stop", id).Run()
|
||||
time.Sleep(10 * time.Second)
|
||||
stopSlowRead <- true
|
||||
}()
|
||||
|
||||
logCmd := exec.Command(dockerBinary, "logs", "-f", id)
|
||||
stdout, err := logCmd.StdoutPipe()
|
||||
c.Assert(err, checker.IsNil)
|
||||
c.Assert(logCmd.Start(), checker.IsNil)
|
||||
|
||||
// First read slowly
|
||||
bytes1, err := consumeWithSpeed(stdout, 10, 50*time.Millisecond, stopSlowRead)
|
||||
c.Assert(err, checker.IsNil)
|
||||
|
||||
// After the container has finished we can continue reading fast
|
||||
bytes2, err := consumeWithSpeed(stdout, 32*1024, 0, nil)
|
||||
c.Assert(err, checker.IsNil)
|
||||
|
||||
actual := bytes1 + bytes2
|
||||
expected := 200000
|
||||
c.Assert(actual, checker.Equals, expected)
|
||||
}
|
||||
|
||||
//TODO: get exited container log
|
||||
func (s *DockerSuite) TestCliLogsFollowStopped(c *check.C) {
|
||||
printTestCaseName()
|
||||
defer printTestDuration(time.Now())
|
||||
testRequires(c, DaemonIsLinux)
|
||||
pullImageIfNotExist("busybox")
|
||||
out, _ := dockerCmd(c, "run", "-d", "busybox", "echo", "hello")
|
||||
time.Sleep(5 * time.Second)
|
||||
|
||||
id := strings.TrimSpace(out)
|
||||
dockerCmd(c, "stop", id)
|
||||
time.Sleep(5 * time.Second)
|
||||
|
||||
logsCmd := exec.Command(dockerBinary, "logs", "-f", id)
|
||||
c.Assert(logsCmd.Start(), checker.IsNil)
|
||||
|
||||
errChan := make(chan error)
|
||||
go func() {
|
||||
errChan <- logsCmd.Wait()
|
||||
close(errChan)
|
||||
}()
|
||||
|
||||
select {
|
||||
case err := <-errChan:
|
||||
c.Assert(err, checker.IsNil)
|
||||
case <-time.After(10 * time.Second):
|
||||
c.Fatal("Following logs is hanged")
|
||||
}
|
||||
}
|
||||
38
vendor/github.com/hyperhq/hypercli/integration-cli/final/cli/hyper_cli_push_test.go
generated
vendored
Normal file
38
vendor/github.com/hyperhq/hypercli/integration-cli/final/cli/hyper_cli_push_test.go
generated
vendored
Normal file
@@ -0,0 +1,38 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/go-check/check"
|
||||
"github.com/hyperhq/hypercli/pkg/integration/checker"
|
||||
)
|
||||
|
||||
func (s *DockerSuite) TestCliPush(c *check.C) {
|
||||
printTestCaseName()
|
||||
defer printTestDuration(time.Now())
|
||||
testRequires(c, DaemonIsLinux)
|
||||
|
||||
var (
|
||||
out string
|
||||
err error
|
||||
newImage = fmt.Sprintf("%v/busybox:latest", os.Getenv("DOCKERHUB_USERNAME"))
|
||||
)
|
||||
pullImageIfNotExist("busybox")
|
||||
out, _ = dockerCmd(c, "run", "-d", "busybox", "bash", "-c", "touch", "test")
|
||||
cleanedContainerID := strings.TrimSpace(out)
|
||||
|
||||
_, _, err = dockerCmdWithError("commit", cleanedContainerID, newImage)
|
||||
c.Assert(err, checker.IsNil)
|
||||
|
||||
//login dockerhub
|
||||
out, _ = dockerCmd(c, "login", "-e", os.Getenv("DOCKERHUB_EMAIL"), "-u", os.Getenv("DOCKERHUB_USERNAME"), "-p", os.Getenv("DOCKERHUB_PASSWD"))
|
||||
c.Assert(out, checker.Contains, "Login Succeeded")
|
||||
|
||||
//push to dockerhub
|
||||
out, _, err = dockerCmdWithError("push", newImage)
|
||||
c.Assert(out, checker.Contains, "digest:")
|
||||
c.Assert(err, checker.IsNil)
|
||||
}
|
||||
84
vendor/github.com/hyperhq/hypercli/integration-cli/final/cli/hyper_cli_region_test.go
generated
vendored
Executable file
84
vendor/github.com/hyperhq/hypercli/integration-cli/final/cli/hyper_cli_region_test.go
generated
vendored
Executable file
@@ -0,0 +1,84 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"time"
|
||||
"os"
|
||||
"os/exec"
|
||||
|
||||
"github.com/go-check/check"
|
||||
"github.com/docker/docker/pkg/integration/checker"
|
||||
)
|
||||
|
||||
func (s *DockerSuite) TestCliRegionBasic(c *check.C) {
|
||||
printTestCaseName()
|
||||
defer printTestDuration(time.Now())
|
||||
|
||||
var (
|
||||
defaultRegion = os.Getenv("REGION")
|
||||
anotherRegion = ""
|
||||
err error
|
||||
)
|
||||
switch defaultRegion {
|
||||
case "":
|
||||
defaultRegion = "us-west-1"
|
||||
anotherRegion = "eu-central-1"
|
||||
case "us-west-1":
|
||||
anotherRegion = "eu-central-1"
|
||||
case "eu-central-1":
|
||||
anotherRegion = "us-west-1"
|
||||
}
|
||||
|
||||
////////////////////////////////////////////
|
||||
//pull image with default region
|
||||
cmd := exec.Command(dockerBinary, "pull", "busybox")
|
||||
out, _, err := runCommandWithOutput(cmd)
|
||||
if err != nil {
|
||||
c.Fatal(err, out)
|
||||
}
|
||||
c.Assert(out, checker.Contains, "Status: Downloaded newer image for busybox:latest")
|
||||
|
||||
cmd = exec.Command(dockerBinary, "run", "busybox", "echo", "test123")
|
||||
out, _, err = runCommandWithOutput(cmd)
|
||||
if err != nil {
|
||||
c.Fatal(err, out)
|
||||
}
|
||||
c.Assert(out, checker.Not(checker.Contains), "Unable to find image 'busybox:latest' in the current region")
|
||||
c.Assert(out, checker.Contains, "test123")
|
||||
|
||||
////////////////////////////////////////////
|
||||
//image not exist in another region
|
||||
cmd = exec.Command(dockerBinary, "--region", anotherRegion, "images", "busybox")
|
||||
out, _, err = runCommandWithOutput(cmd)
|
||||
if err != nil {
|
||||
c.Fatal(err, out)
|
||||
}
|
||||
c.Assert(out, checker.Not(checker.Contains), "busybox")
|
||||
|
||||
////////////////////////////////////////////
|
||||
//pull image with specified region
|
||||
cmd = exec.Command(dockerBinary, "--region", anotherRegion, "pull", "ubuntu")
|
||||
out, _, err = runCommandWithOutput(cmd)
|
||||
if err != nil {
|
||||
c.Fatal(err, out)
|
||||
}
|
||||
c.Assert(out, checker.Contains, "Status: Downloaded newer image for ubuntu:latest")
|
||||
|
||||
cmd = exec.Command(dockerBinary, "--region", anotherRegion, "run", "ubuntu", "echo", "test123")
|
||||
out, _, err = runCommandWithOutput(cmd)
|
||||
if err != nil {
|
||||
c.Fatal(err, out)
|
||||
}
|
||||
c.Assert(out, checker.Not(checker.Contains), "Unable to find image 'ubuntu:latest' in the current region")
|
||||
c.Assert(out, checker.Contains, "test123")
|
||||
}
|
||||
|
||||
func (s *DockerSuite) TestCliRegionWithFullEntrypoint(c *check.C) {
|
||||
printTestCaseName()
|
||||
defer printTestDuration(time.Now())
|
||||
cmd := exec.Command(dockerBinary, "--region", os.Getenv("DOCKER_HOST"), "pull", "busybox")
|
||||
out, _, err := runCommandWithOutput(cmd)
|
||||
if err != nil {
|
||||
c.Fatal(err, out)
|
||||
}
|
||||
c.Assert(out, checker.Contains, "Status: Downloaded newer image for busybox:latest")
|
||||
}
|
||||
Reference in New Issue
Block a user