Remove unused image test.
This commit is contained in:
		| @@ -16,7 +16,6 @@ go_library( | |||||||
|         "benchmark_util.go", |         "benchmark_util.go", | ||||||
|         "container.go", |         "container.go", | ||||||
|         "doc.go", |         "doc.go", | ||||||
|         "image.go", |  | ||||||
|         "image_list.go", |         "image_list.go", | ||||||
|         "resource_collector.go", |         "resource_collector.go", | ||||||
|         "simple_mount.go", |         "simple_mount.go", | ||||||
| @@ -30,9 +29,6 @@ go_library( | |||||||
|         "//pkg/apis/componentconfig:go_default_library", |         "//pkg/apis/componentconfig:go_default_library", | ||||||
|         "//pkg/apis/componentconfig/v1alpha1:go_default_library", |         "//pkg/apis/componentconfig/v1alpha1:go_default_library", | ||||||
|         "//pkg/kubelet/api/v1alpha1/stats:go_default_library", |         "//pkg/kubelet/api/v1alpha1/stats:go_default_library", | ||||||
|         "//pkg/kubelet/container:go_default_library", |  | ||||||
|         "//pkg/kubelet/dockertools:go_default_library", |  | ||||||
|         "//pkg/kubelet/pod:go_default_library", |  | ||||||
|         "//pkg/labels:go_default_library", |         "//pkg/labels:go_default_library", | ||||||
|         "//pkg/util/procfs:go_default_library", |         "//pkg/util/procfs:go_default_library", | ||||||
|         "//pkg/util/runtime:go_default_library", |         "//pkg/util/runtime:go_default_library", | ||||||
| @@ -61,7 +57,6 @@ go_test( | |||||||
|         "disk_eviction_test.go", |         "disk_eviction_test.go", | ||||||
|         "dynamic_kubelet_configuration_test.go", |         "dynamic_kubelet_configuration_test.go", | ||||||
|         "e2e_node_suite_test.go", |         "e2e_node_suite_test.go", | ||||||
|         "image_conformance_test.go", |  | ||||||
|         "image_id_test.go", |         "image_id_test.go", | ||||||
|         "kubelet_test.go", |         "kubelet_test.go", | ||||||
|         "lifecycle_hook_test.go", |         "lifecycle_hook_test.go", | ||||||
|   | |||||||
| @@ -1,82 +0,0 @@ | |||||||
| /* |  | ||||||
| Copyright 2016 The Kubernetes Authors. |  | ||||||
|  |  | ||||||
| Licensed under the Apache License, Version 2.0 (the "License"); |  | ||||||
| you may not use this file except in compliance with the License. |  | ||||||
| You may obtain a copy of the License at |  | ||||||
|  |  | ||||||
|     http://www.apache.org/licenses/LICENSE-2.0 |  | ||||||
|  |  | ||||||
| Unless required by applicable law or agreed to in writing, software |  | ||||||
| distributed under the License is distributed on an "AS IS" BASIS, |  | ||||||
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |  | ||||||
| See the License for the specific language governing permissions and |  | ||||||
| limitations under the License. |  | ||||||
| */ |  | ||||||
|  |  | ||||||
| package e2e_node |  | ||||||
|  |  | ||||||
| import ( |  | ||||||
| 	"fmt" |  | ||||||
|  |  | ||||||
| 	kubecontainer "k8s.io/kubernetes/pkg/kubelet/container" |  | ||||||
| 	"k8s.io/kubernetes/pkg/kubelet/dockertools" |  | ||||||
| 	kubepod "k8s.io/kubernetes/pkg/kubelet/pod" |  | ||||||
| ) |  | ||||||
|  |  | ||||||
| type ConformanceImage struct { |  | ||||||
| 	Image   kubecontainer.ImageSpec |  | ||||||
| 	Runtime kubecontainer.Runtime |  | ||||||
| } |  | ||||||
|  |  | ||||||
| func NewConformanceImage(containerRuntime string, image string) (ci ConformanceImage, err error) { |  | ||||||
| 	ci.Image = kubecontainer.ImageSpec{Image: image} |  | ||||||
| 	if containerRuntime == "docker" { |  | ||||||
| 		ci.Runtime = dockerRuntime() |  | ||||||
| 		return ci, nil |  | ||||||
| 	} |  | ||||||
| 	return ci, fmt.Errorf("Unsupported runtime : %s.", containerRuntime) |  | ||||||
| } |  | ||||||
|  |  | ||||||
| //TODO: do not expose kubelet implementation details after we refactor the runtime API. |  | ||||||
| func dockerRuntime() kubecontainer.Runtime { |  | ||||||
| 	dockerClient := dockertools.ConnectToDockerOrDie("", 0) |  | ||||||
| 	pm := kubepod.NewBasicPodManager(nil) |  | ||||||
| 	dm := dockertools.NewDockerManager( |  | ||||||
| 		dockerClient, |  | ||||||
| 		nil, nil, nil, pm, nil, |  | ||||||
| 		"", 0, 0, "", |  | ||||||
| 		nil, nil, nil, nil, nil, nil, nil, |  | ||||||
| 		false, nil, true, false, false, "", |  | ||||||
| 	) |  | ||||||
|  |  | ||||||
| 	return dm |  | ||||||
| } |  | ||||||
|  |  | ||||||
| func (ci *ConformanceImage) Pull() error { |  | ||||||
| 	return ci.Runtime.PullImage(ci.Image, nil) |  | ||||||
| } |  | ||||||
|  |  | ||||||
| func (ci *ConformanceImage) Present() (bool, error) { |  | ||||||
| 	return ci.Runtime.IsImagePresent(ci.Image) |  | ||||||
| } |  | ||||||
|  |  | ||||||
| func (ci *ConformanceImage) List() ([]string, error) { |  | ||||||
| 	if images, err := ci.Runtime.ListImages(); err != nil { |  | ||||||
| 		return nil, err |  | ||||||
| 	} else { |  | ||||||
| 		var tags []string |  | ||||||
| 		for _, image := range images { |  | ||||||
| 			tags = append(tags, image.RepoTags...) |  | ||||||
| 		} |  | ||||||
| 		return tags, nil |  | ||||||
| 	} |  | ||||||
| } |  | ||||||
|  |  | ||||||
| func (ci *ConformanceImage) Remove() error { |  | ||||||
| 	return ci.Runtime.RemoveImage(ci.Image) |  | ||||||
| } |  | ||||||
|  |  | ||||||
| func (ci *ConformanceImage) GetTag() string { |  | ||||||
| 	return ci.Image.Image |  | ||||||
| } |  | ||||||
| @@ -1,120 +0,0 @@ | |||||||
| /* |  | ||||||
| Copyright 2016 The Kubernetes Authors. |  | ||||||
|  |  | ||||||
| Licensed under the Apache License, Version 2.0 (the "License"); |  | ||||||
| you may not use this file except in compliance with the License. |  | ||||||
| You may obtain a copy of the License at |  | ||||||
|  |  | ||||||
|     http://www.apache.org/licenses/LICENSE-2.0 |  | ||||||
|  |  | ||||||
| Unless required by applicable law or agreed to in writing, software |  | ||||||
| distributed under the License is distributed on an "AS IS" BASIS, |  | ||||||
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |  | ||||||
| See the License for the specific language governing permissions and |  | ||||||
| limitations under the License. |  | ||||||
| */ |  | ||||||
|  |  | ||||||
| package e2e_node |  | ||||||
|  |  | ||||||
| import ( |  | ||||||
| 	"time" |  | ||||||
|  |  | ||||||
| 	. "github.com/onsi/ginkgo" |  | ||||||
| 	. "github.com/onsi/gomega" |  | ||||||
| ) |  | ||||||
|  |  | ||||||
| const ( |  | ||||||
| 	imageRetryTimeout         = time.Minute * 10 // Image pulls can take a long time and shouldn't cause flakes |  | ||||||
| 	imagePullInterval         = time.Second * 15 |  | ||||||
| 	imageConsistentlyTimeout  = time.Second * 30 |  | ||||||
| 	imageConsistentlyInterval = time.Second * 5 |  | ||||||
| ) |  | ||||||
|  |  | ||||||
| var _ = Describe("Image Container Conformance Test", func() { |  | ||||||
| 	Describe("[Flaky] image conformance blackbox test", func() { |  | ||||||
| 		Context("when testing images that exist", func() { |  | ||||||
| 			var conformImages []ConformanceImage |  | ||||||
| 			BeforeEach(func() { |  | ||||||
| 				existImageTags := []string{ |  | ||||||
| 					"gcr.io/google_containers/exechealthz:1.0", |  | ||||||
| 					"gcr.io/google_containers/alpine-with-bash:1.0", |  | ||||||
| 				} |  | ||||||
| 				for _, existImageTag := range existImageTags { |  | ||||||
| 					conformImage, _ := NewConformanceImage("docker", existImageTag) |  | ||||||
| 					// Pulling images from gcr.io is flaky, so retry failures |  | ||||||
| 					Eventually(func() error { |  | ||||||
| 						return conformImage.Pull() |  | ||||||
| 					}, imageRetryTimeout, imagePullInterval).ShouldNot(HaveOccurred()) |  | ||||||
| 					conformImages = append(conformImages, conformImage) |  | ||||||
| 				} |  | ||||||
| 			}) |  | ||||||
|  |  | ||||||
| 			It("It should present successfully", func() { |  | ||||||
| 				for _, conformImage := range conformImages { |  | ||||||
| 					present, err := conformImage.Present() |  | ||||||
| 					Expect(err).ShouldNot(HaveOccurred()) |  | ||||||
| 					Expect(present).To(BeTrue()) |  | ||||||
| 				} |  | ||||||
| 			}) |  | ||||||
|  |  | ||||||
| 			It("should list pulled images", func() { |  | ||||||
| 				image, _ := NewConformanceImage("docker", "") |  | ||||||
| 				tags, err := image.List() |  | ||||||
| 				Expect(err).ShouldNot(HaveOccurred()) |  | ||||||
| 				for _, conformImage := range conformImages { |  | ||||||
| 					Expect(tags).To(ContainElement(conformImage.GetTag())) |  | ||||||
| 				} |  | ||||||
| 			}) |  | ||||||
|  |  | ||||||
| 			AfterEach(func() { |  | ||||||
| 				for _, conformImage := range conformImages { |  | ||||||
| 					conformImage.Remove() |  | ||||||
| 				} |  | ||||||
| 				conformImages = []ConformanceImage{} |  | ||||||
| 			}) |  | ||||||
|  |  | ||||||
| 		}) |  | ||||||
| 		Context("when testing image that does not exist", func() { |  | ||||||
| 			var conformImages []ConformanceImage |  | ||||||
| 			invalidImageTags := []string{ |  | ||||||
| 				// nonexistent image registry |  | ||||||
| 				"foo.com/foo/fooimage", |  | ||||||
| 				// nonexistent image |  | ||||||
| 				"gcr.io/google_containers/not_exist", |  | ||||||
| 				// TODO(random-liu): Add test for image pulling credential |  | ||||||
| 			} |  | ||||||
| 			It("should ignore pull failures", func() { |  | ||||||
| 				for _, invalidImageTag := range invalidImageTags { |  | ||||||
| 					conformImage, _ := NewConformanceImage("docker", invalidImageTag) |  | ||||||
| 					// Pulling images from gcr.io is flaky, so retry to make sure failure is not caused by flaky. |  | ||||||
| 					Expect(conformImage.Pull()).Should(HaveOccurred()) |  | ||||||
| 					conformImages = append(conformImages, conformImage) |  | ||||||
| 				} |  | ||||||
|  |  | ||||||
| 				By("not presenting images", func() { |  | ||||||
| 					for _, conformImage := range conformImages { |  | ||||||
| 						present, err := conformImage.Present() |  | ||||||
| 						Expect(err).ShouldNot(HaveOccurred()) |  | ||||||
| 						Expect(present).To(BeFalse()) |  | ||||||
| 					} |  | ||||||
| 				}) |  | ||||||
|  |  | ||||||
| 				By("not listing pulled images", func() { |  | ||||||
| 					image, _ := NewConformanceImage("docker", "") |  | ||||||
| 					tags, err := image.List() |  | ||||||
| 					Expect(err).ShouldNot(HaveOccurred()) |  | ||||||
| 					for _, conformImage := range conformImages { |  | ||||||
| 						Expect(tags).NotTo(ContainElement(conformImage.GetTag())) |  | ||||||
| 					} |  | ||||||
| 				}) |  | ||||||
|  |  | ||||||
| 				By("not removing non-exist images", func() { |  | ||||||
| 					for _, conformImage := range conformImages { |  | ||||||
| 						err := conformImage.Remove() |  | ||||||
| 						Expect(err).Should(HaveOccurred()) |  | ||||||
| 					} |  | ||||||
| 				}) |  | ||||||
| 			}) |  | ||||||
| 		}) |  | ||||||
| 	}) |  | ||||||
| }) |  | ||||||
		Reference in New Issue
	
	Block a user
	 Random-Liu
					Random-Liu