浏览代码

Merge pull request #11264 from brahmaroutu/fixtest_10967

Test image api through local V1 repo, skip network test.
Arnaud Porterie 10 年之前
父节点
当前提交
3b4ff1c132
共有 2 个文件被更改,包括 13 次插入0 次删除
  1. 2 0
      integration-cli/docker_cli_pull_test.go
  2. 11 0
      integration-cli/requirements.go

+ 2 - 0
integration-cli/docker_cli_pull_test.go

@@ -106,6 +106,8 @@ func TestPullNonExistingImage(t *testing.T) {
 // pulling an image from the central registry using official names should work
 // pulling an image from the central registry using official names should work
 // ensure all pulls result in the same image
 // ensure all pulls result in the same image
 func TestPullImageOfficialNames(t *testing.T) {
 func TestPullImageOfficialNames(t *testing.T) {
+	testRequires(t, Network)
+
 	names := []string{
 	names := []string{
 		"docker.io/hello-world",
 		"docker.io/hello-world",
 		"index.docker.io/hello-world",
 		"index.docker.io/hello-world",

+ 11 - 0
integration-cli/requirements.go

@@ -4,6 +4,7 @@ import (
 	"encoding/json"
 	"encoding/json"
 	"fmt"
 	"fmt"
 	"log"
 	"log"
+	"net/http"
 	"os/exec"
 	"os/exec"
 	"strings"
 	"strings"
 	"testing"
 	"testing"
@@ -32,6 +33,16 @@ var (
 		func() bool { return supportsExec },
 		func() bool { return supportsExec },
 		"Test requires 'docker exec' capabilities on the tested daemon.",
 		"Test requires 'docker exec' capabilities on the tested daemon.",
 	}
 	}
+	Network = TestRequirement{
+		func() bool {
+			resp, err := http.Get("http://hub.docker.com")
+			if resp != nil {
+				resp.Body.Close()
+			}
+			return err == nil
+		},
+		"Test requires network availability, environment variable set to none to run in a non-network enabled mode.",
+	}
 	RegistryHosting = TestRequirement{
 	RegistryHosting = TestRequirement{
 		func() bool {
 		func() bool {
 			// for now registry binary is built only if we're running inside
 			// for now registry binary is built only if we're running inside