Fix #1257: add e2e test for CBR in knative
diff --git a/e2e/files/knative1.groovy b/e2e/files/knative1.groovy
index d49be14..a089525 100644
--- a/e2e/files/knative1.groovy
+++ b/e2e/files/knative1.groovy
@@ -17,5 +17,11 @@
from('timer:tick')
.setBody().constant("")
- .to('knative:endpoint/knative2')
- .log('Received: ${body}')
+ .choice()
+ .when().simple('${random(0, 2)} == 0')
+ .to('knative:endpoint/knative2')
+ .log('Received from 2: ${body}')
+ .otherwise()
+ .to('knative:endpoint/knative3')
+ .log('Received from 3: ${body}')
+ .end()
diff --git a/e2e/files/knative3.groovy b/e2e/files/knative3.groovy
new file mode 100644
index 0000000..5603298
--- /dev/null
+++ b/e2e/files/knative3.groovy
@@ -0,0 +1,19 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+from('knative:endpoint/knative3')
+ .setBody().constant("Hello from knative3")
diff --git a/e2e/knative_test.go b/e2e/knative_test.go
index 0b4dbf7..564ca4a 100644
--- a/e2e/knative_test.go
+++ b/e2e/knative_test.go
@@ -35,9 +35,17 @@
Expect(kamel("install", "-n", ns, "--trait-profile", "knative").Execute()).Should(BeNil())
Expect(kamel("run", "-n", ns, "files/knative2.groovy").Execute()).Should(BeNil())
Eventually(integrationPodPhase(ns, "knative2"), 10*time.Minute).Should(Equal(v1.PodRunning))
+ Expect(kamel("run", "-n", ns, "files/knative3.groovy").Execute()).Should(BeNil())
+ Eventually(integrationPodPhase(ns, "knative3"), 10*time.Minute).Should(Equal(v1.PodRunning))
Expect(kamel("run", "-n", ns, "files/knative1.groovy").Execute()).Should(BeNil())
Eventually(integrationPodPhase(ns, "knative1"), 10*time.Minute).Should(Equal(v1.PodRunning))
- Eventually(integrationLogs(ns, "knative1"), 5*time.Minute).Should(ContainSubstring("Received: Hello from knative2"))
+ // Correct logs
+ Eventually(integrationLogs(ns, "knative1"), 5*time.Minute).Should(ContainSubstring("Received from 2: Hello from knative2"))
+ Eventually(integrationLogs(ns, "knative1"), 5*time.Minute).Should(ContainSubstring("Received from 3: Hello from knative3"))
+ // Incorrect logs
+ Consistently(integrationLogs(ns, "knative1"), 10*time.Second).ShouldNot(ContainSubstring("Received from 2: Hello from knative3"))
+ Consistently(integrationLogs(ns, "knative1"), 10*time.Second).ShouldNot(ContainSubstring("Received from 3: Hello from knative2"))
+ // Cleanup
Expect(kamel("delete", "--all", "-n", ns).Execute()).Should(BeNil())
})
}