Skip to content

Commit

Permalink
E2e test for route annotations
Browse files Browse the repository at this point in the history
  • Loading branch information
lfabriko authored and squakez committed Nov 7, 2023
1 parent 2b3f148 commit 367730b
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 0 deletions.
14 changes: 14 additions & 0 deletions e2e/common/traits/route_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,20 @@ func TestRunRoutes(t *testing.T) {
Eventually(httpRequest(url, true), TestTimeoutShort).Should(Equal("Hello " + code))
Expect(Kamel("delete", "--all", "-n", ns).Execute()).Should(BeNil())
})

t.Run("Route annotations added", func(t *testing.T) {
Expect(KamelRunWithID(operatorID, ns, "files/PlatformHttpServer.java",
"-t", "route.annotations.'haproxy.router.openshift.io/balance'=roundrobin").Execute()).To(Succeed())
Eventually(IntegrationPodPhase(ns, integrationName), TestTimeoutLong).Should(Equal(corev1.PodRunning))
route := RouteFull(ns, integrationName)()
Eventually(route, TestTimeoutMedium).ShouldNot(BeNil())
// must wait a little time after route is created, before an http request,
// otherwise the route is unavailable and the http request will fail
time.Sleep(waitBeforeHttpRequest)
var annotations = route.ObjectMeta.Annotations
Expect(annotations["haproxy.router.openshift.io/balance"]).To(Equal("roundrobin"))
Expect(Kamel("delete", "--all", "-n", ns).Execute()).Should(BeNil())
})
Expect(TestClient().Delete(TestContext, &secret)).To(Succeed())
}

Expand Down
26 changes: 26 additions & 0 deletions e2e/support/test_support.go
Original file line number Diff line number Diff line change
Expand Up @@ -893,6 +893,32 @@ func Route(ns string, name string) func() *routev1.Route {
}
}

func RouteFull(ns string, name string) func() *routev1.Route {
return func() *routev1.Route {
answer := routev1.Route{
TypeMeta: metav1.TypeMeta{
Kind: "Route",
APIVersion: servingv1.SchemeGroupVersion.String(),
},
ObjectMeta: metav1.ObjectMeta{
Namespace: ns,
Name: name,
},
}
key := ctrl.ObjectKey{
Namespace: ns,
Name: name,
}
err := TestClient().Get(TestContext, key, &answer)
if err != nil && k8serrors.IsNotFound(err) {
return nil
} else if err != nil {
failTest(err)
}
return &answer
}
}

func RouteStatus(ns string, name string) func() string {
return func() string {
route := Route(ns, name)()
Expand Down

0 comments on commit 367730b

Please sign in to comment.