-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)) | ||
}) | ||
}) |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
# /usr/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"] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
30
test/extended/testdata/node/zstd-chunked/test-custom-build.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
2 changes: 2 additions & 0 deletions
2
test/extended/util/annotate/generated/zz_generated.annotations.go
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.