From ec3205226f8645da11e2e51f94f37d9d1f7e9ca8 Mon Sep 17 00:00:00 2001 From: Adam Kaplan Date: Tue, 29 Jun 2021 15:20:19 -0400 Subject: [PATCH] Bug 1977454: Use nodejs to test service connection Redis has tighter constraints on client HTTP calls to prevent malicious attacks. Only official redis clients are guaranteed to receive reliable HTTP responses. The build test for in-cluster service connections does not use a redis client, resulting in a test HTTP curl request receiving an empty repsonse. This updates the in-cluster service test to use a "hello world" nodejs application and service. The use of the upstream Redis image is also removed. --- test/extended/builds/service.go | 19 ++++++++++++------- test/extended/util/image/image.go | 9 ++++----- 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/test/extended/builds/service.go b/test/extended/builds/service.go index 5d8054f297e6..ee0e167fa58f 100644 --- a/test/extended/builds/service.go +++ b/test/extended/builds/service.go @@ -10,7 +10,6 @@ import ( 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" @@ -23,7 +22,7 @@ var _ = g.Describe("[sig-builds][Feature:Builds] build can reference a cluster s testDockerfile = fmt.Sprintf(` FROM %s RUN cat /etc/resolv.conf -RUN curl -vvv hello-openshift:6379 +RUN curl -vvv hello-nodejs:8080 `, image.ShellImage()) ) @@ -43,14 +42,20 @@ RUN curl -vvv hello-openshift:6379 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("--name", "hello-openshift", k8simage.GetE2EImage(k8simage.Redis)).Execute() + g.By("standing up a new hello world nodejs service via oc new-app") + err := oc.Run("new-app").Args("nodejs~https://github.com/sclorg/nodejs-ex.git", "--name", "hello-nodejs").Execute() o.Expect(err).NotTo(o.HaveOccurred()) - deploy, derr := oc.KubeClient().AppsV1().Deployments(oc.Namespace()).Get(context.Background(), "hello-openshift", metav1.GetOptions{}) + err = exutil.WaitForABuild(oc.BuildClient().BuildV1().Builds(oc.Namespace()), "hello-nodejs-1", nil, nil, nil) + if err != nil { + exutil.DumpBuildLogs("hello-nodejs", oc) + } + o.Expect(err).NotTo(o.HaveOccurred()) + + deploy, derr := oc.KubeClient().AppsV1().Deployments(oc.Namespace()).Get(context.Background(), "hello-nodejs", metav1.GetOptions{}) if kapierrs.IsNotFound(derr) { // if deployment is not there we're working with old new-app producing deployment configs - err := exutil.WaitForDeploymentConfig(oc.KubeClient(), oc.AppsClient().AppsV1(), oc.Namespace(), "hello-openshift", 1, true, oc) + err := exutil.WaitForDeploymentConfig(oc.KubeClient(), oc.AppsClient().AppsV1(), oc.Namespace(), "hello-nodejs", 1, true, oc) o.Expect(err).NotTo(o.HaveOccurred()) } else { // if present - wait for deployment @@ -59,7 +64,7 @@ RUN curl -vvv hello-openshift:6379 o.Expect(err).NotTo(o.HaveOccurred()) } - err = exutil.WaitForEndpoint(oc.KubeFramework().ClientSet, oc.Namespace(), "hello-openshift") + err = exutil.WaitForEndpoint(oc.KubeFramework().ClientSet, oc.Namespace(), "hello-nodejs") o.Expect(err).NotTo(o.HaveOccurred()) g.By("calling oc new-build with a Dockerfile") diff --git a/test/extended/util/image/image.go b/test/extended/util/image/image.go index 1ab14e3b6929..cda44d48f1fa 100644 --- a/test/extended/util/image/image.go +++ b/test/extended/util/image/image.go @@ -56,11 +56,10 @@ func init() { // allowed upstream kube images - index and value must match upstream or // tests will fail (vendor/k8s.io/kubernetes/test/utils/image/manifest.go) - "k8s.gcr.io/e2e-test-images/agnhost:2.32": 1, - "k8s.gcr.io/e2e-test-images/busybox:1.29-1": 7, - "k8s.gcr.io/e2e-test-images/nginx:1.14-1": 23, - "k8s.gcr.io/e2e-test-images/nginx:1.15-1": 24, - "k8s.gcr.io/e2e-test-images/redis:5.0.5-alpine": 34, + "k8s.gcr.io/e2e-test-images/agnhost:2.32": 1, + "k8s.gcr.io/e2e-test-images/busybox:1.29-1": 7, + "k8s.gcr.io/e2e-test-images/nginx:1.14-1": 23, + "k8s.gcr.io/e2e-test-images/nginx:1.15-1": 24, } images = GetMappedImages(allowedImages, os.Getenv("KUBE_TEST_REPO"))