image_id_test.go 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. /*
  2. Copyright 2016 The Kubernetes Authors.
  3. Licensed under the Apache License, Version 2.0 (the "License");
  4. you may not use this file except in compliance with the License.
  5. You may obtain a copy of the License at
  6. http://www.apache.org/licenses/LICENSE-2.0
  7. Unless required by applicable law or agreed to in writing, software
  8. distributed under the License is distributed on an "AS IS" BASIS,
  9. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  10. See the License for the specific language governing permissions and
  11. limitations under the License.
  12. */
  13. package e2enode
  14. import (
  15. "context"
  16. "k8s.io/api/core/v1"
  17. metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
  18. "k8s.io/kubernetes/test/e2e/framework"
  19. e2epod "k8s.io/kubernetes/test/e2e/framework/pod"
  20. "github.com/davecgh/go-spew/spew"
  21. "github.com/onsi/ginkgo"
  22. "github.com/onsi/gomega"
  23. )
  24. var _ = framework.KubeDescribe("ImageID [NodeFeature: ImageID]", func() {
  25. busyBoxImage := "k8s.gcr.io/busybox@sha256:4bdd623e848417d96127e16037743f0cd8b528c026e9175e22a84f639eca58ff"
  26. f := framework.NewDefaultFramework("image-id-test")
  27. ginkgo.It("should be set to the manifest digest (from RepoDigests) when available", func() {
  28. podDesc := &v1.Pod{
  29. ObjectMeta: metav1.ObjectMeta{
  30. Name: "pod-with-repodigest",
  31. },
  32. Spec: v1.PodSpec{
  33. Containers: []v1.Container{{
  34. Name: "test",
  35. Image: busyBoxImage,
  36. Command: []string{"sh"},
  37. }},
  38. RestartPolicy: v1.RestartPolicyNever,
  39. },
  40. }
  41. pod := f.PodClient().Create(podDesc)
  42. framework.ExpectNoError(e2epod.WaitTimeoutForPodNoLongerRunningInNamespace(
  43. f.ClientSet, pod.Name, f.Namespace.Name, framework.PodStartTimeout))
  44. runningPod, err := f.PodClient().Get(context.TODO(), pod.Name, metav1.GetOptions{})
  45. framework.ExpectNoError(err)
  46. status := runningPod.Status
  47. if len(status.ContainerStatuses) == 0 {
  48. framework.Failf("Unexpected pod status; %s", spew.Sdump(status))
  49. return
  50. }
  51. gomega.Expect(status.ContainerStatuses[0].ImageID).To(gomega.ContainSubstring(busyBoxImage))
  52. })
  53. })