Skip to content

Commit

Permalink
test: Move openshift images to replacements
Browse files Browse the repository at this point in the history
  • Loading branch information
smarterclayton committed Apr 30, 2020
1 parent 5c7648b commit eb5d771
Show file tree
Hide file tree
Showing 84 changed files with 413 additions and 368 deletions.
2 changes: 1 addition & 1 deletion test/e2e/upgrade/alert/alert.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ func (t *UpgradeTest) Test(f *framework.Framework, done <-chan struct{}, upgrade
}
t.oc.SetupProject()
ns := t.oc.Namespace()
execPod := exutil.CreateCentosExecPodOrFail(t.oc.AdminKubeClient(), ns, "execpod", nil)
execPod := exutil.CreateExecPodOrFail(t.oc.AdminKubeClient(), ns, "execpod")
defer func() {
t.oc.AdminKubeClient().CoreV1().Pods(ns).Delete(ctx, execPod.Name, *metav1.NewDeleteOptions(1))
}()
Expand Down
3 changes: 2 additions & 1 deletion test/e2e/upgrade/monitor.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (

configv1 "github.com/openshift/api/config/v1"
configv1client "github.com/openshift/client-go/config/clientset/versioned"
"github.com/openshift/origin/test/extended/util/image"
)

type versionMonitor struct {
Expand Down Expand Up @@ -306,7 +307,7 @@ func triggerReboot(kubeClient kubernetes.Interface, target string, attempt int,
RunAsUser: &zero,
Privileged: &isTrue,
},
Image: "centos:7",
Image: image.ShellImage(),
Command: []string{
"/bin/bash",
"-c",
Expand Down
3 changes: 2 additions & 1 deletion test/extended/builds/contextdir.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (

imageeco "github.com/openshift/origin/test/extended/image_ecosystem"
exutil "github.com/openshift/origin/test/extended/util"
"github.com/openshift/origin/test/extended/util/image"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

Expand Down Expand Up @@ -102,7 +103,7 @@ var _ = g.Describe("[sig-builds][Feature:Builds][Slow] builds with a context dir
repo, err := exutil.NewGitRepo("contextdir")
o.Expect(err).NotTo(o.HaveOccurred())
defer repo.Remove()
err = repo.AddAndCommit("2.3/Dockerfile", "FROM busybox")
err = repo.AddAndCommit("2.3/Dockerfile", fmt.Sprintf("FROM %s", image.ShellImage()))
o.Expect(err).NotTo(o.HaveOccurred())

exutil.WaitForOpenShiftNamespaceImageStreams(oc)
Expand Down
21 changes: 11 additions & 10 deletions test/extended/builds/dockerfile.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,20 @@ import (
"github.com/openshift/library-go/pkg/image/imageutil"

exutil "github.com/openshift/origin/test/extended/util"
"github.com/openshift/origin/test/extended/util/image"
)

var _ = g.Describe("[sig-builds][Feature:Builds][Slow] build can have Dockerfile input", func() {
defer g.GinkgoRecover()
var (
oc = exutil.NewCLI("build-dockerfile-env")
dockerfileAdd = exutil.FixturePath("testdata", "builds", "docker-add")
testDockerfile = `
FROM library/busybox
testDockerfile = fmt.Sprintf(`
FROM %s
USER 1001
`
`, image.ShellImage())
testDockerfile2 = `
FROM centos:7
FROM image-registry.openshift-image-registry.svc:5000/openshift/ruby:2.5
USER 1001
`
testDockerfile3 = `
Expand Down Expand Up @@ -85,31 +86,31 @@ USER 1001
o.Expect(err).NotTo(o.HaveOccurred())

g.By("checking the buildconfig content")
bc, err := oc.BuildClient().BuildV1().BuildConfigs(oc.Namespace()).Get(context.Background(), "centos", metav1.GetOptions{})
bc, err := oc.BuildClient().BuildV1().BuildConfigs(oc.Namespace()).Get(context.Background(), "ruby", metav1.GetOptions{})
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(bc.Spec.Source.Git).To(o.BeNil())
o.Expect(*bc.Spec.Source.Dockerfile).To(o.Equal(testDockerfile2))
o.Expect(bc.Spec.Output.To).ToNot(o.BeNil())
o.Expect(bc.Spec.Output.To.Name).To(o.Equal("centos:latest"))
o.Expect(bc.Spec.Output.To.Name).To(o.Equal("ruby:latest"))

buildName := "centos-1"
buildName := "ruby-1"
g.By("expecting the Dockerfile build is in Complete phase")
err = exutil.WaitForABuild(oc.BuildClient().BuildV1().Builds(oc.Namespace()), buildName, nil, nil, nil)
//debug for failures
if err != nil {
exutil.DumpBuildLogs("centos", oc)
exutil.DumpBuildLogs("ruby", oc)
}
o.Expect(err).NotTo(o.HaveOccurred())

g.By("getting the built container image reference from ImageStream")
image, err := oc.ImageClient().ImageV1().ImageStreamTags(oc.Namespace()).Get(context.Background(), "centos:latest", metav1.GetOptions{})
image, err := oc.ImageClient().ImageV1().ImageStreamTags(oc.Namespace()).Get(context.Background(), "ruby:latest", metav1.GetOptions{})
o.Expect(err).NotTo(o.HaveOccurred())
err = imageutil.ImageWithMetadata(&image.Image)
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(image.Image.DockerImageMetadata.Object.(*docker10.DockerImage).Config.User).To(o.Equal("1001"))

g.By("checking for the imported tag")
_, err = oc.ImageClient().ImageV1().ImageStreamTags(oc.Namespace()).Get(context.Background(), "centos:7", metav1.GetOptions{})
_, err = oc.ImageClient().ImageV1().ImageStreamTags(oc.Namespace()).Get(context.Background(), "ruby:2.5", metav1.GetOptions{})
o.Expect(err).NotTo(o.HaveOccurred())
})

Expand Down
4 changes: 3 additions & 1 deletion test/extended/builds/hooks.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package builds

import (
"context"
"fmt"
"time"

metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
Expand All @@ -10,6 +11,7 @@ import (
o "github.com/onsi/gomega"

exutil "github.com/openshift/origin/test/extended/util"
"github.com/openshift/origin/test/extended/util/image"
)

var _ = g.Describe("[sig-builds][Feature:Builds][Slow] testing build configuration hooks", func() {
Expand Down Expand Up @@ -163,7 +165,7 @@ var _ = g.Describe("[sig-builds][Feature:Builds][Slow] testing build configurati
o.Expect(err).NotTo(o.HaveOccurred())
err = oc.Run("patch").Args("bc/mydockertest", "-p", `{"spec":{"output":{"to":{"kind":"ImageStreamTag","name":"mydockertest:latest"}}}}`).Execute()
o.Expect(err).NotTo(o.HaveOccurred())
err = oc.Run("patch").Args("bc/mydockertest", "-p", `{"spec":{"source":{"dockerfile":"FROM busybox:latest \n ENTRYPOINT /bin/sleep 600 \n"}}}`).Execute()
err = oc.Run("patch").Args("bc/mydockertest", "-p", fmt.Sprintf(`{"spec":{"source":{"dockerfile":"FROM %s \n ENTRYPOINT /bin/sleep 600 \n"}}}`, image.ShellImage())).Execute()
o.Expect(err).NotTo(o.HaveOccurred())

g.By("starting a build")
Expand Down
15 changes: 8 additions & 7 deletions test/extended/builds/multistage.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,21 @@ import (
buildv1 "github.com/openshift/api/build/v1"
eximages "github.com/openshift/origin/test/extended/images"
exutil "github.com/openshift/origin/test/extended/util"
"github.com/openshift/origin/test/extended/util/image"
)

var _ = g.Describe("[sig-builds][Feature:Builds] Multi-stage image builds", func() {
defer g.GinkgoRecover()
var (
oc = exutil.NewCLI("build-multistage")
testDockerfile = `
testDockerfile = fmt.Sprintf(`
FROM scratch as test
USER 1001
FROM centos:7
FROM %[1]s
COPY --from=test /usr/bin/curl /test/
COPY --from=busybox:latest /bin/echo /test/
COPY --from=busybox:latest /bin/ping /test/
`
COPY --from=%[1]s /bin/echo /test/
COPY --from=%[1]s /bin/ping /test/
`, image.ShellImage())
)

g.Context("", func() {
Expand All @@ -54,7 +55,7 @@ COPY --from=busybox:latest /bin/ping /test/
Source: buildv1.BuildSource{
Dockerfile: &testDockerfile,
Images: []buildv1.ImageSource{
{From: corev1.ObjectReference{Kind: "DockerImage", Name: "centos:7"}, As: []string{"scratch"}},
{From: corev1.ObjectReference{Kind: "DockerImage", Name: image.ShellImage()}, As: []string{"scratch"}},
},
},
Strategy: buildv1.BuildStrategy{
Expand Down Expand Up @@ -82,7 +83,7 @@ COPY --from=busybox:latest /bin/ping /test/
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(s).ToNot(o.ContainSubstring("--> FROM scratch"))
o.Expect(s).ToNot(o.ContainSubstring("FROM busybox"))
o.Expect(s).To(o.ContainSubstring("STEP 1: FROM centos:7 AS test"))
o.Expect(s).To(o.ContainSubstring(fmt.Sprintf("STEP 1: FROM %s AS test", image.ShellImage())))
o.Expect(s).To(o.ContainSubstring("COPY --from"))
o.Expect(s).To(o.ContainSubstring(fmt.Sprintf("\"OPENSHIFT_BUILD_NAMESPACE\"=\"%s\"", oc.Namespace())))
e2e.Logf("Build logs:\n%s", result)
Expand Down
7 changes: 4 additions & 3 deletions test/extended/builds/optimized.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,19 @@ import (

buildv1 "github.com/openshift/api/build/v1"
exutil "github.com/openshift/origin/test/extended/util"
"github.com/openshift/origin/test/extended/util/image"
)

var _ = g.Describe("[sig-builds][Feature:Builds] Optimized image builds", func() {
defer g.GinkgoRecover()
var (
oc = exutil.NewCLI("build-dockerfile-env")
skipLayers = buildv1.ImageOptimizationSkipLayers
testDockerfile = `
FROM centos:7
testDockerfile = fmt.Sprintf(`
FROM %s
RUN yum list installed
USER 1001
`
`, image.ShellImage())
)

g.Context("", func() {
Expand Down
19 changes: 11 additions & 8 deletions test/extended/builds/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,29 @@ package builds

import (
"context"
"fmt"

g "github.com/onsi/ginkgo"
o "github.com/onsi/gomega"

kapierrs "k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
kdeployutil "k8s.io/kubernetes/test/e2e/framework/deployment"
k8simage "k8s.io/kubernetes/test/utils/image"

exutil "github.com/openshift/origin/test/extended/util"
"github.com/openshift/origin/test/extended/util/image"
)

var _ = g.Describe("[sig-builds][Feature:Builds] build can reference a cluster service", func() {
defer g.GinkgoRecover()
var (
oc = exutil.NewCLI("build-service")
testDockerfile = `
FROM centos:7
testDockerfile = fmt.Sprintf(`
FROM %s
RUN cat /etc/resolv.conf
RUN curl -vvv hello-openshift:8080
`
RUN curl -vvv hello-openshift:6379
`, image.ShellImage())
)

g.Context("", func() {
Expand All @@ -41,7 +44,7 @@ RUN curl -vvv hello-openshift:8080
g.Describe("with a build being created from new-build", func() {
g.It("should be able to run a build that references a cluster service", func() {
g.By("standing up a new hello world service")
err := oc.Run("new-app").Args("docker.io/openshift/hello-openshift").Execute()
err := oc.Run("new-app").Args("--name", "hello-openshift", k8simage.GetE2EImage(k8simage.Redis)).Execute()
o.Expect(err).NotTo(o.HaveOccurred())

deploy, derr := oc.KubeClient().AppsV1().Deployments(oc.Namespace()).Get(context.Background(), "hello-openshift", metav1.GetOptions{})
Expand All @@ -60,14 +63,14 @@ RUN curl -vvv hello-openshift:8080
o.Expect(err).NotTo(o.HaveOccurred())

g.By("calling oc new-build with a Dockerfile")
err = oc.Run("new-build").Args("-D", "-").InputString(testDockerfile).Execute()
err = oc.Run("new-build").Args("-D", "-", "--to", "test:latest").InputString(testDockerfile).Execute()
o.Expect(err).NotTo(o.HaveOccurred())

g.By("expecting the build is in Complete phase")
err = exutil.WaitForABuild(oc.BuildClient().BuildV1().Builds(oc.Namespace()), "centos-1", nil, nil, nil)
err = exutil.WaitForABuild(oc.BuildClient().BuildV1().Builds(oc.Namespace()), "test-1", nil, nil, nil)
//debug for failures
if err != nil {
exutil.DumpBuildLogs("centos", oc)
exutil.DumpBuildLogs("test", oc)
}
o.Expect(err).NotTo(o.HaveOccurred())
})
Expand Down
44 changes: 5 additions & 39 deletions test/extended/cli/compat.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"

exutil "github.com/openshift/origin/test/extended/util"
"github.com/openshift/origin/test/extended/util/image"
)

func cliPod(cli *exutil.CLI, shell string) *kapiv1.Pod {
Expand Down Expand Up @@ -41,60 +42,25 @@ func cliPod(cli *exutil.CLI, shell string) *kapiv1.Pod {
}
}

func cliPodWithImage(cli *exutil.CLI, image string, shell string) *kapiv1.Pod {
cliImage, _ := exutil.FindCLIImage(cli)

func cliPodWithImage(cli *exutil.CLI, shell string) *kapiv1.Pod {
return &kapiv1.Pod{
ObjectMeta: metav1.ObjectMeta{
Name: "cli-test",
},
Spec: kapiv1.PodSpec{
ServiceAccountName: "builder",
RestartPolicy: kapiv1.RestartPolicyNever,
Volumes: []kapiv1.Volume{
{
Name: "bin",
VolumeSource: kapiv1.VolumeSource{
EmptyDir: &kapiv1.EmptyDirVolumeSource{},
},
},
},
InitContainers: []kapiv1.Container{
{
Name: "cli",
Image: cliImage,
Command: []string{"/bin/bash", "-c", "set -e; cp /usr/bin/oc /tmp/bin/"},
Env: []kapiv1.EnvVar{
{
Name: "HOME",
Value: "/tmp",
},
},
VolumeMounts: []kapiv1.VolumeMount{
{
Name: "bin",
MountPath: "/tmp/bin",
},
},
},
},
Containers: []kapiv1.Container{
{
Name: "test",
Image: cliImage,
Command: []string{"/bin/bash", "-c", "set -euo pipefail; export PATH=/tmp/bin:$PATH; " + shell},
Image: image.ShellImage(),
Command: []string{"/bin/bash", "-c", shell},
Env: []kapiv1.EnvVar{
{
Name: "HOME",
Value: "/tmp",
},
},
VolumeMounts: []kapiv1.VolumeMount{
{
Name: "bin",
MountPath: "/tmp/bin",
},
},
},
},
},
Expand Down Expand Up @@ -128,7 +94,7 @@ var _ = g.Describe("[sig-cli] CLI", func() {
}, metav1.CreateOptions{})
o.Expect(err).NotTo(o.HaveOccurred())

pod := cli.Create(cliPodWithImage(oc, "busybox:latest", heredoc.Docf(`
pod := cli.Create(cliPodWithImage(oc, heredoc.Docf(`
set -x
# verify we can make API calls
Expand Down
3 changes: 2 additions & 1 deletion test/extended/csrapprover/csrapprover.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import (

exutil "github.com/openshift/origin/test/extended/util"
"github.com/openshift/origin/test/extended/util/ibmcloud"
"github.com/openshift/origin/test/extended/util/image"
)

var _ = g.Describe("[sig-cluster-lifecycle]", func() {
Expand All @@ -45,7 +46,7 @@ var _ = g.Describe("[sig-cluster-lifecycle]", func() {
// the /config/master API port+endpoint is only visible from inside the cluster
// (-> we need to create a pod to try to reach it) and contains the token
// of the node-bootstrapper SA, so no random pods should be able to see it
pod, err := exutil.NewPodExecutor(oc, "get-bootstrap-creds", "registry.fedoraproject.org/fedora:30")
pod, err := exutil.NewPodExecutor(oc, "get-bootstrap-creds", image.ShellImage())
o.Expect(err).NotTo(o.HaveOccurred())

// get the API server URL, mutate to internal API (use infra.Status.APIServerURLInternal) once API is bumped
Expand Down
9 changes: 5 additions & 4 deletions test/extended/deployments/deployments.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import (
"github.com/openshift/library-go/pkg/image/imageutil"

exutil "github.com/openshift/origin/test/extended/util"
"github.com/openshift/origin/test/extended/util/image"
)

const deploymentRunTimeout = 5 * time.Minute
Expand Down Expand Up @@ -425,7 +426,7 @@ var _ = g.Describe("[sig-apps][Feature:DeploymentConfig] deploymentconfigs", fun
o.Expect(waitForSyncedConfig(oc, dcName, deploymentRunTimeout)).NotTo(o.HaveOccurred())

g.By("tagging the ubi-minimal:latest as test:v1 image")
_, err = oc.Run("tag").Args("registry.access.redhat.com/ubi8/ubi-minimal:latest", "test:v1").Output()
_, err = oc.Run("tag").Args("image-registry.openshift-image-registry.svc:5000/openshift/tools:latest", "test:v1").Output()
o.Expect(err).NotTo(o.HaveOccurred())

expectLatestVersion := func(version int) {
Expand Down Expand Up @@ -502,8 +503,8 @@ var _ = g.Describe("[sig-apps][Feature:DeploymentConfig] deploymentconfigs", fun
}
o.Expect(pollErr).NotTo(o.HaveOccurred())

if istag.Tag == nil || istag.Tag.From == nil || istag.Tag.From.Name != "openshift/origin-pod" {
err = fmt.Errorf("expected %q to be part of the image reference in %#v", "openshift/origin-pod", istag)
if istag.Tag == nil || istag.Tag.From == nil || istag.Tag.From.Name != image.ShellImage() {
err = fmt.Errorf("expected %q to be part of the image reference in %#v", image.ShellImage(), istag)
o.Expect(err).NotTo(o.HaveOccurred())
}
})
Expand Down Expand Up @@ -1507,7 +1508,7 @@ var _ = g.Describe("[sig-apps][Feature:DeploymentConfig] deploymentconfigs", fun
o.Expect(err).NotTo(o.HaveOccurred())

g.By("tagging the ubi-minimal:latest as test:v1 image to create ImageStream")
out, err := oc.Run("tag").Args("registry.access.redhat.com/ubi8/ubi-minimal:latest", "test:v1").Output()
out, err := oc.Run("tag").Args("image-registry.openshift-image-registry.svc:5000/openshift/tools:latest", "test:v1").Output()
e2e.Logf("%s", out)
o.Expect(err).NotTo(o.HaveOccurred())

Expand Down
Loading

0 comments on commit eb5d771

Please sign in to comment.