Skip to content

Commit 2b816c9

Browse files
committed
OCPNODE-3138: Add zstd:chunked image test
Signed-off-by: Ayato Tokubi <[email protected]>
1 parent ea71886 commit 2b816c9

File tree

7 files changed

+196
-0
lines changed

7 files changed

+196
-0
lines changed

test/extended/include.go

+1
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ import (
4040
_ "github.com/openshift/origin/test/extended/machine_config"
4141
_ "github.com/openshift/origin/test/extended/machines"
4242
_ "github.com/openshift/origin/test/extended/networking"
43+
_ "github.com/openshift/origin/test/extended/node"
4344
_ "github.com/openshift/origin/test/extended/node_tuning"
4445
_ "github.com/openshift/origin/test/extended/oauth"
4546
_ "github.com/openshift/origin/test/extended/olm"

test/extended/node/ztsd_chunked.go

+66
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
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] zstd:chunked Image", func() {
19+
defer g.GinkgoRecover()
20+
var (
21+
oc = exutil.NewCLI("zstd-chunked-image")
22+
customImage = exutil.FixturePath("testdata", "node", "zstd-chunked")
23+
)
24+
25+
g.It("should successfully run date command", func(ctx context.Context) {
26+
name := "zstd-chunked-build"
27+
namespace := oc.Namespace()
28+
29+
g.By("creating custom builder image")
30+
err := oc.Run("new-build").Args("--binary", "--strategy=docker", fmt.Sprintf("--name=%s", name)).Execute()
31+
o.Expect(err).NotTo(o.HaveOccurred())
32+
br, _ := exutil.StartBuildAndWait(oc, name, fmt.Sprintf("--from-dir=%s", customImage))
33+
br.AssertSuccess()
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: fmt.Sprintf("image-registry.openshift-image-registry.svc:5000/%s/%s", namespace, name),
47+
Command: []string{"date"},
48+
},
49+
},
50+
},
51+
}
52+
53+
g.By("Creating a pod")
54+
pod, err = oc.KubeClient().CoreV1().Pods(namespace).Create(context.Background(), pod, metav1.CreateOptions{})
55+
o.Expect(err).NotTo(o.HaveOccurred())
56+
57+
g.By("Waiting for pod to complete")
58+
err = e2epod.WaitForPodSuccessInNamespaceTimeout(ctx, oc.KubeClient(), pod.Name, namespace, 1*time.Minute)
59+
o.Expect(err).NotTo(o.HaveOccurred())
60+
61+
g.By("Verifying pod completed successfully")
62+
pod, err = oc.KubeClient().CoreV1().Pods(namespace).Get(context.Background(), pod.Name, metav1.GetOptions{})
63+
o.Expect(err).NotTo(o.HaveOccurred())
64+
o.Expect(pod.Status.Phase).To(o.Equal(corev1.PodSucceeded))
65+
})
66+
})

test/extended/testdata/bindata.go

+94
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
FROM registry.redhat.io/rhel8/buildah
2+
# In this example, `/tmp/build` contains the inputs that build when this
3+
# custom builder image is run. Normally the custom builder image fetches
4+
# this content from some location at build time, by using git clone as an example.
5+
ADD Dockerfile.target /tmp/input/Dockerfile
6+
ADD build.sh /usr/bin
7+
RUN chmod a+x /usr/bin/build.sh
8+
# /usr/bin/build.sh contains the actual custom build logic that will be run when
9+
# this custom builder image is run.
10+
ENTRYPOINT ["/usr/bin/build.sh"]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
FROM image-registry.openshift-image-registry.svc:5000/openshift/tools:latest
2+
CMD ["date"]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#!/bin/sh
2+
# Note that in this case the build inputs are part of the custom builder image, but normally this
3+
# is retrieved from an external source.
4+
cd /tmp/input
5+
# OUTPUT_REGISTRY and OUTPUT_IMAGE are env variables provided by the custom
6+
# build framework
7+
TAG="${OUTPUT_REGISTRY}/${OUTPUT_IMAGE}"
8+
9+
10+
# performs the build of the new image defined by Dockerfile.target
11+
buildah --storage-driver vfs bud --isolation chroot -t ${TAG} .
12+
13+
14+
# buildah requires a slight modification to the push secret provided by the service
15+
# account to use it for pushing the image
16+
cp /var/run/secrets/openshift.io/push/.dockercfg /tmp
17+
(echo "{ \"auths\": " ; cat /var/run/secrets/openshift.io/push/.dockercfg ; echo "}") > /tmp/.dockercfg
18+
19+
20+
# push the new image to the target for the build
21+
buildah --storage-driver vfs push --tls-verify=false --authfile /tmp/.dockercfg --compression-format zstd:chunked ${TAG}

test/extended/util/annotate/generated/zz_generated.annotations.go

+2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)