From e8d062bd4a99f5cb824be62ec5ca498c6be87617 Mon Sep 17 00:00:00 2001 From: Claudiu Belu Date: Fri, 20 Sep 2019 19:42:43 +0300 Subject: [PATCH] tests: Replaces guestbook with agnhost equivalent The redis version has been bumped to version 5.0.5, but the maximum version supported on Windows is 3.2. This can lead to failing tests, the output and behaviour can be different (see #80516). In order to prevent such failures, the amount of times the Redis image is used can be reduced. This commit uses the previously added agnhost guestbook subcommand as a replacement for the Guestbook application created by the test "should create and stop a working application". Adds AgnhostPrivate to test/utils/image/manifest. Some tests are trying to pull the agnhost image from the private registry, meaning that we would need to always build and push the agnhost image to both e2e and private registry whenever we bump its version. Decoupling them would mean that we only need to push the image to the e2e registry. --- test/e2e/apps/rc.go | 3 +- test/e2e/apps/replica_set.go | 3 +- test/e2e/common/util.go | 24 ++++++++-------- test/e2e/kubectl/kubectl.go | 18 ++++++------ .../agnhost-master-deployment.yaml.in | 28 +++++++++++++++++++ .../guestbook/agnhost-master-service.yaml | 16 +++++++++++ .../agnhost-slave-deployment.yaml.in | 28 +++++++++++++++++++ .../guestbook/agnhost-slave-service.yaml | 15 ++++++++++ .../guestbook/frontend-deployment.yaml.in | 13 ++------- test/utils/image/manifest.go | 8 +++--- 10 files changed, 116 insertions(+), 40 deletions(-) create mode 100644 test/e2e/testing-manifests/guestbook/agnhost-master-deployment.yaml.in create mode 100644 test/e2e/testing-manifests/guestbook/agnhost-master-service.yaml create mode 100644 test/e2e/testing-manifests/guestbook/agnhost-slave-deployment.yaml.in create mode 100644 test/e2e/testing-manifests/guestbook/agnhost-slave-service.yaml diff --git a/test/e2e/apps/rc.go b/test/e2e/apps/rc.go index 3da81a4a35e..6ed684d04b8 100644 --- a/test/e2e/apps/rc.go +++ b/test/e2e/apps/rc.go @@ -52,8 +52,7 @@ var _ = SIGDescribe("ReplicationController", func() { ginkgo.It("should serve a basic image on each replica with a private image", func() { // requires private images framework.SkipUnlessProviderIs("gce", "gke") - privateimage := imageutils.GetConfig(imageutils.Agnhost) - privateimage.SetRegistry(imageutils.PrivateRegistry) + privateimage := imageutils.GetConfig(imageutils.AgnhostPrivate) TestReplicationControllerServeImageOrFail(f, "private", privateimage.GetE2EImage()) }) diff --git a/test/e2e/apps/replica_set.go b/test/e2e/apps/replica_set.go index 8a020bae94a..77497f22e61 100644 --- a/test/e2e/apps/replica_set.go +++ b/test/e2e/apps/replica_set.go @@ -96,8 +96,7 @@ var _ = SIGDescribe("ReplicaSet", func() { ginkgo.It("should serve a basic image on each replica with a private image", func() { // requires private images framework.SkipUnlessProviderIs("gce", "gke") - privateimage := imageutils.GetConfig(imageutils.Agnhost) - privateimage.SetRegistry(imageutils.PrivateRegistry) + privateimage := imageutils.GetConfig(imageutils.AgnhostPrivate) testReplicaSetServeImageOrFail(f, "private", privateimage.GetE2EImage()) }) diff --git a/test/e2e/common/util.go b/test/e2e/common/util.go index 55b0b574d29..e6e29d2af8f 100644 --- a/test/e2e/common/util.go +++ b/test/e2e/common/util.go @@ -66,18 +66,17 @@ var CommonImageWhiteList = sets.NewString( ) type testImagesStruct struct { - AgnhostImage string - BusyBoxImage string - GBFrontendImage string - KittenImage string - MounttestImage string - NautilusImage string - NginxImage string - NginxNewImage string - HttpdImage string - HttpdNewImage string - PauseImage string - RedisImage string + AgnhostImage string + BusyBoxImage string + KittenImage string + MounttestImage string + NautilusImage string + NginxImage string + NginxNewImage string + HttpdImage string + HttpdNewImage string + PauseImage string + RedisImage string } var testImages testImagesStruct @@ -86,7 +85,6 @@ func init() { testImages = testImagesStruct{ imageutils.GetE2EImage(imageutils.Agnhost), imageutils.GetE2EImage(imageutils.BusyBox), - imageutils.GetE2EImage(imageutils.GBFrontend), imageutils.GetE2EImage(imageutils.Kitten), imageutils.GetE2EImage(imageutils.Mounttest), imageutils.GetE2EImage(imageutils.Nautilus), diff --git a/test/e2e/kubectl/kubectl.go b/test/e2e/kubectl/kubectl.go index 7f7244184aa..d3beabd3a8d 100644 --- a/test/e2e/kubectl/kubectl.go +++ b/test/e2e/kubectl/kubectl.go @@ -378,12 +378,12 @@ var _ = SIGDescribe("Kubectl client", func() { forEachGBFile := func(run func(s string)) { guestbookRoot := "test/e2e/testing-manifests/guestbook" for _, gbAppFile := range []string{ - "redis-slave-service.yaml", - "redis-master-service.yaml", + "agnhost-slave-service.yaml", + "agnhost-master-service.yaml", "frontend-service.yaml", "frontend-deployment.yaml.in", - "redis-master-deployment.yaml.in", - "redis-slave-deployment.yaml.in", + "agnhost-master-deployment.yaml.in", + "agnhost-slave-deployment.yaml.in", } { contents := commonutils.SubstituteImageName(string(testfiles.ReadOrDie(filepath.Join(guestbookRoot, gbAppFile)))) run(contents) @@ -393,7 +393,7 @@ var _ = SIGDescribe("Kubectl client", func() { /* Release : v1.9 Testname: Kubectl, guestbook application - Description: Create Guestbook application that contains redis server, 2 instances of redis slave, frontend application, frontend service and redis master service and redis slave service. Using frontend service, the test will write an entry into the guestbook application which will store the entry into the backend redis database. Application flow MUST work as expected and the data written MUST be available to read. + Description: Create Guestbook application that contains an agnhost master server, 2 agnhost slaves, frontend application, frontend service and agnhost master service and agnhost slave service. Using frontend service, the test will write an entry into the guestbook application which will store the entry into the backend agnhost store. Application flow MUST work as expected and the data written MUST be available to read. */ framework.ConformanceIt("should create and stop a working application ", func() { defer forEachGBFile(func(contents string) { @@ -2216,17 +2216,17 @@ func validateGuestbookApp(c clientset.Interface, ns string) { err := testutils.WaitForPodsWithLabelRunning(c, ns, label) framework.ExpectNoError(err) framework.Logf("Waiting for frontend to serve content.") - if !waitForGuestbookResponse(c, "get", "", `{"data": ""}`, guestbookStartupTimeout, ns) { + if !waitForGuestbookResponse(c, "get", "", `{"data":""}`, guestbookStartupTimeout, ns) { framework.Failf("Frontend service did not start serving content in %v seconds.", guestbookStartupTimeout.Seconds()) } framework.Logf("Trying to add a new entry to the guestbook.") - if !waitForGuestbookResponse(c, "set", "TestEntry", `{"message": "Updated"}`, guestbookResponseTimeout, ns) { + if !waitForGuestbookResponse(c, "set", "TestEntry", `{"message":"Updated"}`, guestbookResponseTimeout, ns) { framework.Failf("Cannot added new entry in %v seconds.", guestbookResponseTimeout.Seconds()) } framework.Logf("Verifying that added entry can be retrieved.") - if !waitForGuestbookResponse(c, "get", "", `{"data": "TestEntry"}`, guestbookResponseTimeout, ns) { + if !waitForGuestbookResponse(c, "get", "", `{"data":"TestEntry"}`, guestbookResponseTimeout, ns) { framework.Failf("Entry to guestbook wasn't correctly added in %v seconds.", guestbookResponseTimeout.Seconds()) } } @@ -2255,7 +2255,7 @@ func makeRequestToGuestbook(c clientset.Interface, cmd, value string, ns string) result, err := proxyRequest.Namespace(ns). Context(ctx). Name("frontend"). - Suffix("/guestbook.php"). + Suffix("/guestbook"). Param("cmd", cmd). Param("key", "messages"). Param("value", value). diff --git a/test/e2e/testing-manifests/guestbook/agnhost-master-deployment.yaml.in b/test/e2e/testing-manifests/guestbook/agnhost-master-deployment.yaml.in new file mode 100644 index 00000000000..94bd9e8339b --- /dev/null +++ b/test/e2e/testing-manifests/guestbook/agnhost-master-deployment.yaml.in @@ -0,0 +1,28 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: agnhost-master +spec: + replicas: 1 + selector: + matchLabels: + app: agnhost + role: master + tier: backend + template: + metadata: + labels: + app: agnhost + role: master + tier: backend + spec: + containers: + - name: master + image: {{.AgnhostImage}} + args: [ "guestbook", "--http-port", "6379" ] + resources: + requests: + cpu: 100m + memory: 100Mi + ports: + - containerPort: 6379 diff --git a/test/e2e/testing-manifests/guestbook/agnhost-master-service.yaml b/test/e2e/testing-manifests/guestbook/agnhost-master-service.yaml new file mode 100644 index 00000000000..a164a36a44f --- /dev/null +++ b/test/e2e/testing-manifests/guestbook/agnhost-master-service.yaml @@ -0,0 +1,16 @@ +apiVersion: v1 +kind: Service +metadata: + name: agnhost-master + labels: + app: agnhost + role: master + tier: backend +spec: + ports: + - port: 6379 + targetPort: 6379 + selector: + app: agnhost + role: master + tier: backend diff --git a/test/e2e/testing-manifests/guestbook/agnhost-slave-deployment.yaml.in b/test/e2e/testing-manifests/guestbook/agnhost-slave-deployment.yaml.in new file mode 100644 index 00000000000..88f65d3e145 --- /dev/null +++ b/test/e2e/testing-manifests/guestbook/agnhost-slave-deployment.yaml.in @@ -0,0 +1,28 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: agnhost-slave +spec: + replicas: 2 + selector: + matchLabels: + app: agnhost + role: slave + tier: backend + template: + metadata: + labels: + app: agnhost + role: slave + tier: backend + spec: + containers: + - name: slave + image: {{.AgnhostImage}} + args: [ "guestbook", "--slaveof", "agnhost-master", "--http-port", "6379" ] + resources: + requests: + cpu: 100m + memory: 100Mi + ports: + - containerPort: 6379 diff --git a/test/e2e/testing-manifests/guestbook/agnhost-slave-service.yaml b/test/e2e/testing-manifests/guestbook/agnhost-slave-service.yaml new file mode 100644 index 00000000000..93b06287bcf --- /dev/null +++ b/test/e2e/testing-manifests/guestbook/agnhost-slave-service.yaml @@ -0,0 +1,15 @@ +apiVersion: v1 +kind: Service +metadata: + name: agnhost-slave + labels: + app: agnhost + role: slave + tier: backend +spec: + ports: + - port: 6379 + selector: + app: agnhost + role: slave + tier: backend diff --git a/test/e2e/testing-manifests/guestbook/frontend-deployment.yaml.in b/test/e2e/testing-manifests/guestbook/frontend-deployment.yaml.in index de9ceccedea..4ed3cac1607 100644 --- a/test/e2e/testing-manifests/guestbook/frontend-deployment.yaml.in +++ b/test/e2e/testing-manifests/guestbook/frontend-deployment.yaml.in @@ -15,19 +15,12 @@ spec: tier: frontend spec: containers: - - name: php-redis - image: {{.GBFrontendImage}} + - name: guestbook-frontend + image: {{.AgnhostImage}} + args: [ "guestbook", "--backend-port", "6379" ] resources: requests: cpu: 100m memory: 100Mi - env: - - name: GET_HOSTS_FROM - value: dns - # If your cluster config does not include a dns service, then to - # instead access environment variables to find service host - # info, comment out the 'value: dns' line above, and uncomment the - # line below: - # value: env ports: - containerPort: 80 diff --git a/test/utils/image/manifest.go b/test/utils/image/manifest.go index f22809bdb92..cf48e88b46b 100644 --- a/test/utils/image/manifest.go +++ b/test/utils/image/manifest.go @@ -118,6 +118,8 @@ var ( const ( // Agnhost image Agnhost = iota + // AgnhostPrivate image + AgnhostPrivate // APIServer image APIServer // AppArmorLoader image @@ -140,8 +142,6 @@ const ( EchoServer // Etcd image Etcd - // GBFrontend image - GBFrontend // GlusterDynamicProvisioner image GlusterDynamicProvisioner // Httpd image @@ -207,7 +207,8 @@ const ( func initImageConfigs() map[int]Config { configs := map[int]Config{} - configs[Agnhost] = Config{e2eRegistry, "agnhost", "2.6"} + configs[Agnhost] = Config{e2eRegistry, "agnhost", "2.8"} + configs[AgnhostPrivate] = Config{PrivateRegistry, "agnhost", "2.6"} configs[AuthenticatedAlpine] = Config{gcAuthenticatedRegistry, "alpine", "3.7"} configs[AuthenticatedWindowsNanoServer] = Config{gcAuthenticatedRegistry, "windows-nanoserver", "v1"} configs[APIServer] = Config{e2eRegistry, "sample-apiserver", "1.10"} @@ -219,7 +220,6 @@ func initImageConfigs() map[int]Config { configs[Dnsutils] = Config{e2eRegistry, "dnsutils", "1.1"} configs[EchoServer] = Config{e2eRegistry, "echoserver", "2.2"} configs[Etcd] = Config{gcRegistry, "etcd", "3.4.3"} - configs[GBFrontend] = Config{sampleRegistry, "gb-frontend", "v6"} configs[GlusterDynamicProvisioner] = Config{dockerGluster, "glusterdynamic-provisioner", "v1.0"} configs[Httpd] = Config{dockerLibraryRegistry, "httpd", "2.4.38-alpine"} configs[HttpdNew] = Config{dockerLibraryRegistry, "httpd", "2.4.39-alpine"}