diff --git a/test/extended/include.go b/test/extended/include.go index b58d358adeeb..b5c57f156546 100644 --- a/test/extended/include.go +++ b/test/extended/include.go @@ -40,6 +40,7 @@ import ( _ "github.com/openshift/origin/test/extended/machine_config" _ "github.com/openshift/origin/test/extended/machines" _ "github.com/openshift/origin/test/extended/networking" + _ "github.com/openshift/origin/test/extended/node" _ "github.com/openshift/origin/test/extended/node_tuning" _ "github.com/openshift/origin/test/extended/oauth" _ "github.com/openshift/origin/test/extended/olm" diff --git a/test/extended/node/zstd_chunked.go b/test/extended/node/zstd_chunked.go new file mode 100644 index 000000000000..4c36201570b4 --- /dev/null +++ b/test/extended/node/zstd_chunked.go @@ -0,0 +1,75 @@ +package node + +import ( + "context" + "fmt" + "time" + + g "github.com/onsi/ginkgo/v2" + o "github.com/onsi/gomega" + + corev1 "k8s.io/api/core/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + e2epod "k8s.io/kubernetes/test/e2e/framework/pod" + + exutil "github.com/openshift/origin/test/extended/util" +) + +var _ = g.Describe("[sig-node][Feature:Builds][apigroup:build.openshift.io] zstd:chunked Image", func() { + defer g.GinkgoRecover() + var ( + oc = exutil.NewCLI("zstd-chunked-image") + customBuildAdd = exutil.FixturePath("testdata", "node", "zstd-chunked") + customBuildFixture = exutil.FixturePath("testdata", "node", "zstd-chunked", "test-custom-build.yaml") + ) + + g.It("should successfully run date command", func(ctx context.Context) { + namespace := oc.Namespace() + + g.By("creating custom builder image") + // Build with buildah with --compression-format zstd:chunked to ensure the image is compressed with zstd:chunked. + // 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 + err := oc.Run("new-build").Args("--binary", "--strategy=docker", "--name=custom-builder-image").Execute() + o.Expect(err).NotTo(o.HaveOccurred()) + br, _ := exutil.StartBuildAndWait(oc, "custom-builder-image", fmt.Sprintf("--from-dir=%s", customBuildAdd)) + br.AssertSuccess() + g.By("start custom build and build should complete") + err = oc.AsAdmin().Run("create").Args("-f", customBuildFixture).Execute() + o.Expect(err).NotTo(o.HaveOccurred()) + err = oc.AsAdmin().Run("start-build").Args("sample-custom-build").Execute() + o.Expect(err).NotTo(o.HaveOccurred()) + err = exutil.WaitForABuild(oc.BuildClient().BuildV1().Builds(oc.Namespace()), "sample-custom-build-1", nil, nil, nil) + o.Expect(err).NotTo(o.HaveOccurred()) + + // Define a pod that runs the date command using the zstd-chunked image + pod := &corev1.Pod{ + ObjectMeta: metav1.ObjectMeta{ + Name: "zstd-chunked-pod", + Namespace: namespace, + }, + Spec: corev1.PodSpec{ + RestartPolicy: corev1.RestartPolicyNever, + Containers: []corev1.Container{ + { + Name: "zstd-chunked-container", + Image: fmt.Sprintf("image-registry.openshift-image-registry.svc:5000/%s/sample-custom:latest", namespace), + Command: []string{"date"}, + }, + }, + }, + } + + g.By("Creating a pod") + pod, err = oc.KubeClient().CoreV1().Pods(namespace).Create(context.Background(), pod, metav1.CreateOptions{}) + o.Expect(err).NotTo(o.HaveOccurred()) + + g.By("Waiting for pod to complete") + err = e2epod.WaitForPodSuccessInNamespaceTimeout(ctx, oc.KubeClient(), pod.Name, namespace, 1*time.Minute) + o.Expect(err).NotTo(o.HaveOccurred()) + + g.By("Verifying pod completed successfully") + pod, err = oc.KubeClient().CoreV1().Pods(namespace).Get(context.Background(), pod.Name, metav1.GetOptions{}) + o.Expect(err).NotTo(o.HaveOccurred()) + o.Expect(pod.Status.Phase).To(o.Equal(corev1.PodSucceeded)) + }) +}) diff --git a/test/extended/testdata/bindata.go b/test/extended/testdata/bindata.go index ed0f5791d68b..1b52faab52f6 100644 --- a/test/extended/testdata/bindata.go +++ b/test/extended/testdata/bindata.go @@ -434,6 +434,10 @@ // test/extended/testdata/net-attach-defs/whereabouts-nad.yml // test/extended/testdata/net-attach-defs/whereabouts-race-awake.yml // test/extended/testdata/net-attach-defs/whereabouts-race-sleepy.yml +// test/extended/testdata/node/zstd-chunked/Dockerfile +// test/extended/testdata/node/zstd-chunked/Dockerfile.sample +// test/extended/testdata/node/zstd-chunked/build.sh +// test/extended/testdata/node/zstd-chunked/test-custom-build.yaml // test/extended/testdata/node_tuning/nto-stalld.yaml // test/extended/testdata/oauthserver/cabundle-cm.yaml // test/extended/testdata/oauthserver/oauth-network.yaml @@ -49807,6 +49811,135 @@ func testExtendedTestdataNetAttachDefsWhereaboutsRaceSleepyYml() (*asset, error) return a, nil } +var _testExtendedTestdataNodeZstdChunkedDockerfile = []byte(`FROM registry.redhat.io/rhel8/buildah:latest +# For simplicity, /tmp/build contains the inputs we’ll be building when we +# run this custom builder image. Normally the custom builder image would +# fetch this content from some location at build time. (e.g. via git clone). +ADD Dockerfile.sample /tmp/input/Dockerfile +ADD build.sh /usr/bin +RUN chmod a+x /usr/bin/build.sh +# /tmp/build/build.sh contains the actual custom build logic that will be executed when +# this custom builder image is executed. +ENTRYPOINT ["/usr/bin/build.sh"] +`) + +func testExtendedTestdataNodeZstdChunkedDockerfileBytes() ([]byte, error) { + return _testExtendedTestdataNodeZstdChunkedDockerfile, nil +} + +func testExtendedTestdataNodeZstdChunkedDockerfile() (*asset, error) { + bytes, err := testExtendedTestdataNodeZstdChunkedDockerfileBytes() + if err != nil { + return nil, err + } + + info := bindataFileInfo{name: "test/extended/testdata/node/zstd-chunked/Dockerfile", size: 0, mode: os.FileMode(0), modTime: time.Unix(0, 0)} + a := &asset{bytes: bytes, info: info} + return a, nil +} + +var _testExtendedTestdataNodeZstdChunkedDockerfileSample = []byte(`FROM image-registry.openshift-image-registry.svc:5000/openshift/tools:latest +CMD ["date"]`) + +func testExtendedTestdataNodeZstdChunkedDockerfileSampleBytes() ([]byte, error) { + return _testExtendedTestdataNodeZstdChunkedDockerfileSample, nil +} + +func testExtendedTestdataNodeZstdChunkedDockerfileSample() (*asset, error) { + bytes, err := testExtendedTestdataNodeZstdChunkedDockerfileSampleBytes() + if err != nil { + return nil, err + } + + info := bindataFileInfo{name: "test/extended/testdata/node/zstd-chunked/Dockerfile.sample", size: 0, mode: os.FileMode(0), modTime: time.Unix(0, 0)} + a := &asset{bytes: bytes, info: info} + return a, nil +} + +var _testExtendedTestdataNodeZstdChunkedBuildSh = []byte(`#!/bin/sh + +set -euo pipefail + +# Note that in this case the build inputs are part of the custom builder image, but normally this +# would be retrieved from an external source. +cd /tmp/input +# OUTPUT_REGISTRY and OUTPUT_IMAGE are env variables provided by the custom +# build framework +TAG="${OUTPUT_REGISTRY}/${OUTPUT_IMAGE}" + +cp -R /var/run/configs/openshift.io/certs/certs.d/* /etc/containers/certs.d/ + +# buildah requires a slight modification to the push secret provided by the service account in order to use it for pushing the image +echo "{ \"auths\": $(cat /var/run/secrets/openshift.io/pull/.dockercfg)}" > /tmp/.pull +echo "{ \"auths\": $(cat /var/run/secrets/openshift.io/push/.dockercfg)}" > /tmp/.push + +# performs the build of the new image defined by Dockerfile.sample +buildah --authfile /tmp/.pull --storage-driver vfs bud --isolation chroot -t ${TAG} . +# push the new image to the target for the build +buildah --authfile /tmp/.push --storage-driver vfs push --compression-format zstd:chunked ${TAG}`) + +func testExtendedTestdataNodeZstdChunkedBuildShBytes() ([]byte, error) { + return _testExtendedTestdataNodeZstdChunkedBuildSh, nil +} + +func testExtendedTestdataNodeZstdChunkedBuildSh() (*asset, error) { + bytes, err := testExtendedTestdataNodeZstdChunkedBuildShBytes() + if err != nil { + return nil, err + } + + info := bindataFileInfo{name: "test/extended/testdata/node/zstd-chunked/build.sh", size: 0, mode: os.FileMode(0), modTime: time.Unix(0, 0)} + a := &asset{bytes: bytes, info: info} + return a, nil +} + +var _testExtendedTestdataNodeZstdChunkedTestCustomBuildYaml = []byte(`kind: List +apiVersion: v1 +items: +- kind: ImageStream + apiVersion: image.openshift.io/v1 + metadata: + name: sample-custom +- kind: BuildConfig + apiVersion: build.openshift.io/v1 + metadata: + name: sample-custom-build + labels: + name: sample-custom-build + annotations: + template.alpha.openshift.io/wait-for-ready: 'true' + spec: + strategy: + type: Custom + customStrategy: + env: + - name: "BUILD_LOGLEVEL" + value: "2" + forcePull: true + from: + kind: ImageStreamTag + name: custom-builder-image:latest + output: + to: + kind: ImageStreamTag + name: sample-custom:latest +`) + +func testExtendedTestdataNodeZstdChunkedTestCustomBuildYamlBytes() ([]byte, error) { + return _testExtendedTestdataNodeZstdChunkedTestCustomBuildYaml, nil +} + +func testExtendedTestdataNodeZstdChunkedTestCustomBuildYaml() (*asset, error) { + bytes, err := testExtendedTestdataNodeZstdChunkedTestCustomBuildYamlBytes() + if err != nil { + return nil, err + } + + info := bindataFileInfo{name: "test/extended/testdata/node/zstd-chunked/test-custom-build.yaml", size: 0, mode: os.FileMode(0), modTime: time.Unix(0, 0)} + a := &asset{bytes: bytes, info: info} + return a, nil +} + var _testExtendedTestdataNode_tuningNtoStalldYaml = []byte(`apiVersion: tuned.openshift.io/v1 kind: Tuned metadata: @@ -55789,6 +55922,10 @@ var _bindata = map[string]func() (*asset, error){ "test/extended/testdata/net-attach-defs/whereabouts-nad.yml": testExtendedTestdataNetAttachDefsWhereaboutsNadYml, "test/extended/testdata/net-attach-defs/whereabouts-race-awake.yml": testExtendedTestdataNetAttachDefsWhereaboutsRaceAwakeYml, "test/extended/testdata/net-attach-defs/whereabouts-race-sleepy.yml": testExtendedTestdataNetAttachDefsWhereaboutsRaceSleepyYml, + "test/extended/testdata/node/zstd-chunked/Dockerfile": testExtendedTestdataNodeZstdChunkedDockerfile, + "test/extended/testdata/node/zstd-chunked/Dockerfile.sample": testExtendedTestdataNodeZstdChunkedDockerfileSample, + "test/extended/testdata/node/zstd-chunked/build.sh": testExtendedTestdataNodeZstdChunkedBuildSh, + "test/extended/testdata/node/zstd-chunked/test-custom-build.yaml": testExtendedTestdataNodeZstdChunkedTestCustomBuildYaml, "test/extended/testdata/node_tuning/nto-stalld.yaml": testExtendedTestdataNode_tuningNtoStalldYaml, "test/extended/testdata/oauthserver/cabundle-cm.yaml": testExtendedTestdataOauthserverCabundleCmYaml, "test/extended/testdata/oauthserver/oauth-network.yaml": testExtendedTestdataOauthserverOauthNetworkYaml, @@ -56548,6 +56685,14 @@ var _bintree = &bintree{nil, map[string]*bintree{ "whereabouts-race-awake.yml": {testExtendedTestdataNetAttachDefsWhereaboutsRaceAwakeYml, map[string]*bintree{}}, "whereabouts-race-sleepy.yml": {testExtendedTestdataNetAttachDefsWhereaboutsRaceSleepyYml, map[string]*bintree{}}, }}, + "node": {nil, map[string]*bintree{ + "zstd-chunked": {nil, map[string]*bintree{ + "Dockerfile": {testExtendedTestdataNodeZstdChunkedDockerfile, map[string]*bintree{}}, + "Dockerfile.sample": {testExtendedTestdataNodeZstdChunkedDockerfileSample, map[string]*bintree{}}, + "build.sh": {testExtendedTestdataNodeZstdChunkedBuildSh, map[string]*bintree{}}, + "test-custom-build.yaml": {testExtendedTestdataNodeZstdChunkedTestCustomBuildYaml, map[string]*bintree{}}, + }}, + }}, "node_tuning": {nil, map[string]*bintree{ "nto-stalld.yaml": {testExtendedTestdataNode_tuningNtoStalldYaml, map[string]*bintree{}}, }}, diff --git a/test/extended/testdata/node/zstd-chunked/Dockerfile b/test/extended/testdata/node/zstd-chunked/Dockerfile new file mode 100644 index 000000000000..c7dc1bd4bd12 --- /dev/null +++ b/test/extended/testdata/node/zstd-chunked/Dockerfile @@ -0,0 +1,10 @@ +FROM registry.redhat.io/rhel8/buildah:latest +# For simplicity, /tmp/build contains the inputs we’ll be building when we +# run this custom builder image. Normally the custom builder image would +# fetch this content from some location at build time. (e.g. via git clone). +ADD Dockerfile.sample /tmp/input/Dockerfile +ADD build.sh /usr/bin +RUN chmod a+x /usr/bin/build.sh +# /tmp/build/build.sh contains the actual custom build logic that will be executed when +# this custom builder image is executed. +ENTRYPOINT ["/usr/bin/build.sh"] diff --git a/test/extended/testdata/node/zstd-chunked/Dockerfile.sample b/test/extended/testdata/node/zstd-chunked/Dockerfile.sample new file mode 100644 index 000000000000..d16448520c57 --- /dev/null +++ b/test/extended/testdata/node/zstd-chunked/Dockerfile.sample @@ -0,0 +1,2 @@ +FROM image-registry.openshift-image-registry.svc:5000/openshift/tools:latest +CMD ["date"] \ No newline at end of file diff --git a/test/extended/testdata/node/zstd-chunked/build.sh b/test/extended/testdata/node/zstd-chunked/build.sh new file mode 100644 index 000000000000..ffb37b004de2 --- /dev/null +++ b/test/extended/testdata/node/zstd-chunked/build.sh @@ -0,0 +1,21 @@ +#!/bin/sh + +set -euo pipefail + +# Note that in this case the build inputs are part of the custom builder image, but normally this +# would be retrieved from an external source. +cd /tmp/input +# OUTPUT_REGISTRY and OUTPUT_IMAGE are env variables provided by the custom +# build framework +TAG="${OUTPUT_REGISTRY}/${OUTPUT_IMAGE}" + +cp -R /var/run/configs/openshift.io/certs/certs.d/* /etc/containers/certs.d/ + +# buildah requires a slight modification to the push secret provided by the service account in order to use it for pushing the image +echo "{ \"auths\": $(cat /var/run/secrets/openshift.io/pull/.dockercfg)}" > /tmp/.pull +echo "{ \"auths\": $(cat /var/run/secrets/openshift.io/push/.dockercfg)}" > /tmp/.push + +# performs the build of the new image defined by Dockerfile.sample +buildah --authfile /tmp/.pull --storage-driver vfs bud --isolation chroot -t ${TAG} . +# push the new image to the target for the build +buildah --authfile /tmp/.push --storage-driver vfs push --compression-format zstd:chunked ${TAG} \ No newline at end of file diff --git a/test/extended/testdata/node/zstd-chunked/test-custom-build.yaml b/test/extended/testdata/node/zstd-chunked/test-custom-build.yaml new file mode 100644 index 000000000000..344172ce9f70 --- /dev/null +++ b/test/extended/testdata/node/zstd-chunked/test-custom-build.yaml @@ -0,0 +1,30 @@ +kind: List +apiVersion: v1 +items: +- kind: ImageStream + apiVersion: image.openshift.io/v1 + metadata: + name: sample-custom +- kind: BuildConfig + apiVersion: build.openshift.io/v1 + metadata: + name: sample-custom-build + labels: + name: sample-custom-build + annotations: + template.alpha.openshift.io/wait-for-ready: 'true' + spec: + strategy: + type: Custom + customStrategy: + env: + - name: "BUILD_LOGLEVEL" + value: "2" + forcePull: true + from: + kind: ImageStreamTag + name: custom-builder-image:latest + output: + to: + kind: ImageStreamTag + name: sample-custom:latest diff --git a/test/extended/util/annotate/generated/zz_generated.annotations.go b/test/extended/util/annotate/generated/zz_generated.annotations.go index 3f96d7b8c355..64f859f4b024 100644 --- a/test/extended/util/annotate/generated/zz_generated.annotations.go +++ b/test/extended/util/annotate/generated/zz_generated.annotations.go @@ -1745,6 +1745,8 @@ var Annotations = map[string]string{ "[sig-node][Disruptive][Feature:KubeletGracefulShutdown] Kubelet with graceful shutdown configuration should respect pods termination grace period": " [Serial]", + "[sig-node][Feature:Builds][apigroup:build.openshift.io] zstd:chunked Image should successfully run date command": " [Skipped:Disconnected] [Suite:openshift/conformance/parallel]", + "[sig-node][Late] should not have pod creation failures due to systemd timeouts": " [Suite:openshift/conformance/parallel]", "[sig-node][Suite:openshift/nodes/realtime/latency][Disruptive] Real time kernel should meet latency requirements when tested with cyclictest": " [Serial]", diff --git a/test/extended/util/annotate/rules.go b/test/extended/util/annotate/rules.go index 91676e22ae51..ad7feb9d1f50 100644 --- a/test/extended/util/annotate/rules.go +++ b/test/extended/util/annotate/rules.go @@ -219,6 +219,7 @@ var ( `\[sig-network\]\[Feature:Router\]\[apigroup:operator.openshift.io\] The HAProxy router should set Forwarded headers appropriately`, `\[sig-network\]\[Feature:Router\]\[apigroup:route.openshift.io\]\[apigroup:operator.openshift.io\] The HAProxy router should support reencrypt to services backed by a serving certificate automatically`, `\[sig-node\] Managed cluster should report ready nodes the entire duration of the test run`, + `\[sig-node\]\[Feature:Builds\]\[apigroup:build.openshift.io\] zstd:chunked Image should successfully run date command`, `\[sig-storage\]\[Late\] Metrics should report short attach times`, `\[sig-storage\]\[Late\] Metrics should report short mount times`, },