Skip to content

Commit

Permalink
Make correct CLI image available for tests and check in e2e
Browse files Browse the repository at this point in the history
  • Loading branch information
smarterclayton committed Dec 25, 2018
1 parent fe7bff0 commit c6655ab
Show file tree
Hide file tree
Showing 10 changed files with 57 additions and 11 deletions.
4 changes: 3 additions & 1 deletion images/cli/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ RUN INSTALL_PKGS="origin-clients" && \
yum --enablerepo=origin-local-release install -y ${INSTALL_PKGS} && \
rpm -V ${INSTALL_PKGS} && \
yum clean all
COPY manifests /manifests

LABEL io.k8s.display-name="OpenShift Client" \
io.k8s.description="OpenShift is a platform for developing, building, and deploying containerized applications." \
io.openshift.tags="openshift,cli"
io.openshift.tags="openshift,cli" \
io.openshift.release.operator="true"
11 changes: 11 additions & 0 deletions images/cli/manifests/01_imagestream.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
kind: ImageStream
apiVersion: image.openshift.io/v1
metadata:
namespace: openshift
name: cli
spec:
tags:
- name: latest
from:
kind: DockerImage
name: docker.io/openshift/origin-cli:v4.0
8 changes: 8 additions & 0 deletions images/cli/manifests/image-references
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
kind: ImageStream
apiVersion: image.openshift.io/v1
spec:
tags:
- name: cli
from:
kind: DockerImage
name: docker.io/openshift/origin-cli:v4.0
3 changes: 1 addition & 2 deletions test/extended/images/append.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ func cliPodWithPullSecret(cli *exutil.CLI, shell string) *kapiv1.Pod {
o.Expect(sa.ImagePullSecrets).NotTo(o.BeEmpty())
pullSecretName := sa.ImagePullSecrets[0].Name

format, _ := exutil.FindImageFormatString(cli)
cliImage := strings.Replace(format, "${component}", "cli", -1)
cliImage, _ := exutil.FindCLIImage(cli)

return &kapiv1.Pod{
ObjectMeta: metav1.ObjectMeta{
Expand Down
2 changes: 1 addition & 1 deletion test/extended/router/config_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ var _ = g.Describe("[Conformance][Area:Networking][Feature:Router]", func() {
g.BeforeEach(func() {
ns = oc.Namespace()

routerImage, _ := exutil.FindImageFormatString(oc)
routerImage, _ := exutil.FindRouterImage(oc)
routerImage = strings.Replace(routerImage, "${component}", "haproxy-router", -1)

err := oc.AsAdmin().Run("new-app").Args("-f", configPath, "-p", "IMAGE="+routerImage).Execute()
Expand Down
2 changes: 1 addition & 1 deletion test/extended/router/scoped.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ var _ = g.Describe("[Conformance][Area:Networking][Feature:Router]", func() {
g.BeforeEach(func() {
ns = oc.Namespace()

routerImage, _ = exutil.FindImageFormatString(oc)
routerImage, _ = exutil.FindRouterImage(oc)
routerImage = strings.Replace(routerImage, "${component}", "haproxy-router", -1)

configPath := exutil.FixturePath("testdata", "router-common.yaml")
Expand Down
2 changes: 1 addition & 1 deletion test/extended/router/stress.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ var _ = g.Describe("[Conformance][Area:Networking][Feature:Router]", func() {
g.BeforeEach(func() {
ns = oc.Namespace()

routerImage, _ = exutil.FindImageFormatString(oc)
routerImage, _ = exutil.FindRouterImage(oc)
routerImage = strings.Replace(routerImage, "${component}", "haproxy-router", -1)

_, err := oc.AdminKubeClient().Rbac().RoleBindings(ns).Create(&rbacv1.RoleBinding{
Expand Down
2 changes: 1 addition & 1 deletion test/extended/router/unprivileged.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ var _ = g.Describe("[Conformance][Area:Networking][Feature:Router]", func() {
g.BeforeEach(func() {
ns = oc.Namespace()

routerImage, _ = exutil.FindImageFormatString(oc)
routerImage, _ = exutil.FindRouterImage(oc)
routerImage = strings.Replace(routerImage, "${component}", "haproxy-router", -1)

configPath := exutil.FixturePath("testdata", "router-common.yaml")
Expand Down
2 changes: 1 addition & 1 deletion test/extended/router/weighted.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ var _ = g.Describe("[Conformance][Area:Networking][Feature:Router]", func() {
)

g.BeforeEach(func() {
routerImage, _ := exutil.FindImageFormatString(oc)
routerImage, _ := exutil.FindRouterImage(oc)
routerImage = strings.Replace(routerImage, "${component}", "haproxy-router", -1)
err := oc.AsAdmin().Run("new-app").Args("-f", configPath, "-p", "IMAGE="+routerImage).Execute()
o.Expect(err).NotTo(o.HaveOccurred())
Expand Down
32 changes: 29 additions & 3 deletions test/extended/util/framework.go
Original file line number Diff line number Diff line change
Expand Up @@ -1489,16 +1489,42 @@ func GetRouterPodTemplate(oc *CLI) (*corev1.PodTemplateSpec, string, error) {
return nil, "", errors.NewNotFound(schema.GroupResource{Group: "apps.openshift.io", Resource: "deploymentconfigs"}, "router")
}

// FindImageFormatString returns a format string for components on the cluster. It returns false
// if no format string could be inferred from the cluster. OpenShift 4.0 clusters will not be able
// to infer an image format string, so you must wrap this method in one that can locate your specific
// image.
func FindImageFormatString(oc *CLI) (string, bool) {
// the router is expected to be on all clusters
// TODO: switch this to read from the global config
// legacy support for 3.x clusters
template, _, err := GetRouterPodTemplate(oc)
if err == nil {
return strings.Replace(template.Spec.Containers[0].Image, "haproxy-router", "${component}", -1), true
if strings.Contains(template.Spec.Containers[0].Image, "haproxy-router") {
return strings.Replace(template.Spec.Containers[0].Image, "haproxy-router", "${component}", -1), true
}
}
// in openshift 4.0, no image format can be calculated on cluster
return "openshift/origin-${component}:latest", false
}

func FindCLIImage(oc *CLI) (string, bool) {
// look up image stream
is, err := oc.AdminImageClient().ImageV1().ImageStreams("openshift").Get("cli", metav1.GetOptions{})
if err == nil {
for _, tag := range is.Spec.Tags {
if tag.Name == "latest" && tag.From != nil && tag.From.Kind == "DockerImage" {
return tag.From.Name, true
}
}
}

format, ok := FindImageFormatString(oc)
return strings.Replace(format, "${component}", "cli", -1), ok
}

func FindRouterImage(oc *CLI) (string, bool) {
format, ok := FindImageFormatString(oc)
return strings.Replace(format, "${component}", "haproxy-router", -1), ok
}

func IsClusterOperated(oc *CLI) bool {
configclient := oc.AdminConfigClient().ConfigV1()
o, err := configclient.Images().Get("cluster", metav1.GetOptions{})
Expand Down

0 comments on commit c6655ab

Please sign in to comment.