|
| 1 | +package node |
| 2 | + |
| 3 | +import ( |
| 4 | + "context" |
| 5 | + "fmt" |
| 6 | + "github.com/openshift/origin/test/extended/util/image" |
| 7 | + e2eoutput "k8s.io/kubernetes/test/e2e/framework/pod/output" |
| 8 | + "time" |
| 9 | + |
| 10 | + g "github.com/onsi/ginkgo/v2" |
| 11 | + o "github.com/onsi/gomega" |
| 12 | + |
| 13 | + corev1 "k8s.io/api/core/v1" |
| 14 | + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" |
| 15 | + e2epod "k8s.io/kubernetes/test/e2e/framework/pod" |
| 16 | + |
| 17 | + exutil "github.com/openshift/origin/test/extended/util" |
| 18 | +) |
| 19 | + |
| 20 | +var _ = g.Describe("zstd:chunked Image", func() { |
| 21 | + defer g.GinkgoRecover() |
| 22 | + var oc *exutil.CLI |
| 23 | + |
| 24 | + g.BeforeEach(func() { |
| 25 | + oc = exutil.NewCLI("zstd-chunked-image") |
| 26 | + }) |
| 27 | + |
| 28 | + g.It("should successfully run date command", func(ctx context.Context) { |
| 29 | + namespace := oc.Namespace() |
| 30 | + |
| 31 | + zstdChunkedImage := "quay.io/crio/busybox:zstd-chunked" |
| 32 | + // manifestEndpoint is used to check the image is zstd:chunked |
| 33 | + manifestEndpoint := "https://quay.io/v2/crio/busybox/manifests/zstd-chunked" |
| 34 | + |
| 35 | + // Define a pod that runs the date command using the zstd-chunked image |
| 36 | + pod := &corev1.Pod{ |
| 37 | + ObjectMeta: metav1.ObjectMeta{ |
| 38 | + Name: "zstd-chunked-pod", |
| 39 | + Namespace: namespace, |
| 40 | + }, |
| 41 | + Spec: corev1.PodSpec{ |
| 42 | + RestartPolicy: corev1.RestartPolicyNever, |
| 43 | + Containers: []corev1.Container{ |
| 44 | + { |
| 45 | + Name: "zstd-chunked-container", |
| 46 | + Image: image.LocationFor(zstdChunkedImage), |
| 47 | + Command: []string{"date"}, |
| 48 | + }, |
| 49 | + }, |
| 50 | + }, |
| 51 | + } |
| 52 | + |
| 53 | + g.By("Checking that the image is zstd:chunked") |
| 54 | + execpod := exutil.CreateExecPodOrFail(oc.KubeClient(), namespace, "execpod") |
| 55 | + _, err := e2eoutput.RunHostCmd(execpod.Namespace, execpod.Name, |
| 56 | + fmt.Sprintf( |
| 57 | + "curl %s -H 'Accept: application/vnd.oci.image.manifest.v1+json' | jq -e '.layers[0].annotations.\"io.github.containers.zstd-chunked.manifest-checksum\"'", |
| 58 | + manifestEndpoint, |
| 59 | + ), |
| 60 | + ) |
| 61 | + o.Expect(err).NotTo(o.HaveOccurred()) |
| 62 | + |
| 63 | + g.By("Creating a pod") |
| 64 | + pod, err = oc.KubeClient().CoreV1().Pods(namespace).Create(context.Background(), pod, metav1.CreateOptions{}) |
| 65 | + o.Expect(err).NotTo(o.HaveOccurred()) |
| 66 | + |
| 67 | + g.By("Waiting for pod to complete") |
| 68 | + err = e2epod.WaitForPodSuccessInNamespaceTimeout(ctx, oc.KubeClient(), pod.Name, namespace, 1*time.Minute) |
| 69 | + o.Expect(err).NotTo(o.HaveOccurred()) |
| 70 | + |
| 71 | + g.By("Verifying pod completed successfully") |
| 72 | + pod, err = oc.KubeClient().CoreV1().Pods(namespace).Get(context.Background(), pod.Name, metav1.GetOptions{}) |
| 73 | + o.Expect(err).NotTo(o.HaveOccurred()) |
| 74 | + o.Expect(pod.Status.Phase).To(o.Equal(corev1.PodSucceeded)) |
| 75 | + }) |
| 76 | +}) |
0 commit comments