Skip to content

OCPNODE-3138: Add zstd:chunked image test #29713

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions test/extended/include.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
75 changes: 75 additions & 0 deletions test/extended/node/zstd_chunked.go
Original file line number Diff line number Diff line change
@@ -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))
})
})
145 changes: 145 additions & 0 deletions test/extended/testdata/bindata.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions test/extended/testdata/node/zstd-chunked/Dockerfile
Original file line number Diff line number Diff line change
@@ -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"]
2 changes: 2 additions & 0 deletions test/extended/testdata/node/zstd-chunked/Dockerfile.sample
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
FROM image-registry.openshift-image-registry.svc:5000/openshift/tools:latest
CMD ["date"]
21 changes: 21 additions & 0 deletions test/extended/testdata/node/zstd-chunked/build.sh
Original file line number Diff line number Diff line change
@@ -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}
30 changes: 30 additions & 0 deletions test/extended/testdata/node/zstd-chunked/test-custom-build.yaml
Original file line number Diff line number Diff line change
@@ -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

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions test/extended/util/annotate/rules.go
Original file line number Diff line number Diff line change
Expand Up @@ -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`,
},
Expand Down