From de4d0c04957a0af35b520a7ee9142b8f3c243f8d Mon Sep 17 00:00:00 2001 From: Christie Wilson Date: Thu, 5 Apr 2018 16:30:04 -0700 Subject: [PATCH] Add Revision annotations to conformance tests In https://github.com/elafros/elafros/pull/572 Revision was made to be updated with the generation of the Configuration that triggered its creation. This commit updates the conformance tests to assert that it is being populated correctly. Also fixed a bug: after updating the Configuration with a new image, we were (I mean *I was*, I created this bug XD) waiting for the previous Revision to be ready (which of course it was right away), not the new Revision. This means that the health check we had added MIGHT have actually been working (i.e. saving us from 404s and 503s). Snuck in a rename of `routeIsReady` to `isRouteReady` to be consistent with other functions in the file. This partially addresses #593. --- test/conformance/BUILD.bazel | 1 + test/conformance/route_test.go | 16 ++++++++++------ 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/test/conformance/BUILD.bazel b/test/conformance/BUILD.bazel index 4425a9b24929..2fd774b45d73 100644 --- a/test/conformance/BUILD.bazel +++ b/test/conformance/BUILD.bazel @@ -33,6 +33,7 @@ go_test( ], embed = [":go_default_library"], deps = [ + "//pkg/apis/ela:go_default_library", "//pkg/apis/ela/v1alpha1:go_default_library", "//pkg/client/clientset/versioned:go_default_library", "//pkg/client/clientset/versioned/typed/ela/v1alpha1:go_default_library", diff --git a/test/conformance/route_test.go b/test/conformance/route_test.go index 73d74ba419a6..fe9e6dda0874 100644 --- a/test/conformance/route_test.go +++ b/test/conformance/route_test.go @@ -23,6 +23,8 @@ import ( "fmt" "strings" + "github.com/elafros/elafros/pkg/apis/ela" + . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" @@ -83,7 +85,7 @@ func configuration(imagePath string) *v1alpha1.Configuration { } } -func routeIsReady() func(r *v1alpha1.Route) (bool, error) { +func isRouteReady() func(r *v1alpha1.Route) (bool, error) { return func(r *v1alpha1.Route) (bool, error) { return r.Status.IsReady(), nil } @@ -103,15 +105,17 @@ func allRouteTrafficAtRevision(routeName string, revisionName string) func(r *v1 } } -func isRevisionReady(revisionName string) func(r *v1alpha1.Revision) (bool, error) { +func isRevisionReady(confGen string) func(r *v1alpha1.Revision) (bool, error) { return func(r *v1alpha1.Revision) (bool, error) { if len(r.Status.Conditions) > 0 { Expect(r.Status.Conditions[0].Type).To(Equal(v1alpha1.RevisionConditionType("Ready"))) - if r.Status.Conditions[0].Status == "False" { + if r.Status.Conditions[0].Status == corev1.ConditionStatus("False") { Expect(r.Status.Conditions[0].Reason).To(Equal("Deploying")) } else { Expect(r.Status.Conditions[0].Status).To(Equal(corev1.ConditionStatus("True"))) Expect(r.Status.Conditions[0].Reason).To(Equal("ServiceReady")) + Expect(r.Annotations).To(HaveKey(ela.ConfigurationGenerationAnnotationKey)) + Expect(r.Annotations[ela.ConfigurationGenerationAnnotationKey]).To(Equal(confGen)) return true, nil } } @@ -207,7 +211,7 @@ var _ = Describe("Route", func() { }) By("The Revision will be updated when it is ready to serve traffic") - WaitForRevisionState(revisionClient, revisionName, isRevisionReady(revisionName)) + WaitForRevisionState(revisionClient, revisionName, isRevisionReady("1")) By("The Configuration will be updated when the Revision is ready to serve traffic") WaitForConfigurationState(configClient, configName, func(c *v1alpha1.Configuration) (bool, error) { @@ -218,7 +222,7 @@ var _ = Describe("Route", func() { WaitForRouteState(routeClient, routeName, allRouteTrafficAtRevision(routeName, revisionName)) By("Once the Route Ingress has an IP, the Route will be marked as Ready.") - WaitForRouteState(routeClient, routeName, routeIsReady()) + WaitForRouteState(routeClient, routeName, isRouteReady()) updatedRoute, err := routeClient.Get(routeName, metav1.GetOptions{}) Expect(err).NotTo(HaveOccurred()) @@ -250,7 +254,7 @@ var _ = Describe("Route", func() { }) By("The new Revision will be updated when it is ready to serve traffic") - WaitForRevisionState(revisionClient, revisionName, isRevisionReady(newRevisionName)) + WaitForRevisionState(revisionClient, newRevisionName, isRevisionReady("2")) By("The Configuration will be updated to indicate the new revision is ready") WaitForConfigurationState(configClient, configName, func(c *v1alpha1.Configuration) (bool, error) {