|
| 1 | +package node |
| 2 | + |
| 3 | +import ( |
| 4 | + "context" |
| 5 | + "fmt" |
| 6 | + "time" |
| 7 | + |
| 8 | + g "github.com/onsi/ginkgo/v2" |
| 9 | + o "github.com/onsi/gomega" |
| 10 | + |
| 11 | + corev1 "k8s.io/api/core/v1" |
| 12 | + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" |
| 13 | + e2epod "k8s.io/kubernetes/test/e2e/framework/pod" |
| 14 | + |
| 15 | + exutil "github.com/openshift/origin/test/extended/util" |
| 16 | +) |
| 17 | + |
| 18 | +var _ = g.Describe("[sig-node][Feature:Builds] zstd:chunked Image", func() { |
| 19 | + defer g.GinkgoRecover() |
| 20 | + var ( |
| 21 | + oc = exutil.NewCLI("zstd-chunked-image") |
| 22 | + customBuildAdd = exutil.FixturePath("testdata", "node", "zstd-chunked") |
| 23 | + customBuildFixture = exutil.FixturePath("testdata", "node", "zstd-chunked", "test-custom-build.yaml") |
| 24 | + ) |
| 25 | + |
| 26 | + g.It("should successfully run date command", func(ctx context.Context) { |
| 27 | + namespace := oc.Namespace() |
| 28 | + |
| 29 | + g.By("creating custom builder image") |
| 30 | + // Build with buildah with --compression-format zstd:chunked to ensure the image is compressed with zstd:chunked. |
| 31 | + // https://docs.redhat.com/en/documentation/openshift_container_platform/4.18/html/builds_using_buildconfig/custom-builds-buildah#builds-build-custom-builder-image_custom-builds-buildah |
| 32 | + err := oc.Run("new-build").Args("--binary", "--strategy=docker", "--name=custom-builder-image").Execute() |
| 33 | + o.Expect(err).NotTo(o.HaveOccurred()) |
| 34 | + br, _ := exutil.StartBuildAndWait(oc, "custom-builder-image", fmt.Sprintf("--from-dir=%s", customBuildAdd)) |
| 35 | + br.AssertSuccess() |
| 36 | + g.By("start custom build and build should complete") |
| 37 | + err = oc.AsAdmin().Run("create").Args("-f", customBuildFixture).Execute() |
| 38 | + o.Expect(err).NotTo(o.HaveOccurred()) |
| 39 | + err = oc.AsAdmin().Run("start-build").Args("sample-custom-build").Execute() |
| 40 | + o.Expect(err).NotTo(o.HaveOccurred()) |
| 41 | + err = exutil.WaitForABuild(oc.BuildClient().BuildV1().Builds(oc.Namespace()), "sample-custom-build-1", nil, nil, nil) |
| 42 | + o.Expect(err).NotTo(o.HaveOccurred()) |
| 43 | + |
| 44 | + // Define a pod that runs the date command using the zstd-chunked image |
| 45 | + pod := &corev1.Pod{ |
| 46 | + ObjectMeta: metav1.ObjectMeta{ |
| 47 | + Name: "zstd-chunked-pod", |
| 48 | + Namespace: namespace, |
| 49 | + }, |
| 50 | + Spec: corev1.PodSpec{ |
| 51 | + RestartPolicy: corev1.RestartPolicyNever, |
| 52 | + Containers: []corev1.Container{ |
| 53 | + { |
| 54 | + Name: "zstd-chunked-container", |
| 55 | + Image: fmt.Sprintf("image-registry.openshift-image-registry.svc:5000/%s/sample-custom:latest", namespace), |
| 56 | + Command: []string{"date"}, |
| 57 | + }, |
| 58 | + }, |
| 59 | + }, |
| 60 | + } |
| 61 | + |
| 62 | + g.By("Creating a pod") |
| 63 | + pod, err = oc.KubeClient().CoreV1().Pods(namespace).Create(context.Background(), pod, metav1.CreateOptions{}) |
| 64 | + o.Expect(err).NotTo(o.HaveOccurred()) |
| 65 | + |
| 66 | + g.By("Waiting for pod to complete") |
| 67 | + err = e2epod.WaitForPodSuccessInNamespaceTimeout(ctx, oc.KubeClient(), pod.Name, namespace, 1*time.Minute) |
| 68 | + o.Expect(err).NotTo(o.HaveOccurred()) |
| 69 | + |
| 70 | + g.By("Verifying pod completed successfully") |
| 71 | + pod, err = oc.KubeClient().CoreV1().Pods(namespace).Get(context.Background(), pod.Name, metav1.GetOptions{}) |
| 72 | + o.Expect(err).NotTo(o.HaveOccurred()) |
| 73 | + o.Expect(pod.Status.Phase).To(o.Equal(corev1.PodSucceeded)) |
| 74 | + }) |
| 75 | +}) |
0 commit comments