Skip to content

Commit

Permalink
chore: bind with operator id
Browse files Browse the repository at this point in the history
  • Loading branch information
squakez committed May 10, 2023
1 parent e04fbbb commit 67f8671
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 37 deletions.
35 changes: 12 additions & 23 deletions e2e/knative/kamelet_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,40 +39,29 @@ import (
// Test that a Pipe can be changed and the changes are propagated to the Integration
func TestKameletChange(t *testing.T) {
RegisterTestingT(t)
timerPipe := "timer-binding"

knChannel := "test-kamelet-messages"
knChannelConf := fmt.Sprintf("%s:InMemoryChannel:%s", messaging.SchemeGroupVersion.String(), knChannel)
timerSource := "my-timer-source"
Expect(CreateTimerKamelet(ns, timerSource)()).To(Succeed())
Expect(CreateKnativeChannel(ns, knChannel)()).To(Succeed())
// Consumer route that will read from the KNative channel
Expect(KamelRunWithID(operatorID, ns, "files/test-kamelet-display.groovy", "-w").Execute()).To(Succeed())

from := corev1.ObjectReference{
Kind: "Kamelet",
APIVersion: v1.SchemeGroupVersion.String(),
Name: timerSource,
}

to := corev1.ObjectReference{
Kind: "InMemoryChannel",
Name: knChannel,
APIVersion: messaging.SchemeGroupVersion.String(),
}

timerPipe := "timer-binding"

// Create the Pipe
Expect(KamelBind(ns,
from.Name,
to.Name,
"-p", "source.message=message is Hello",
Expect(KamelBindWithID(operatorID, ns,
timerSource,
knChannelConf,
"-p", "source.message=HelloKNative!",
"--annotation", "trait.camel.apache.org/health.enabled=true",
"--annotation", "trait.camel.apache.org/health.readiness-initial-delay=10",
"--name", timerPipe,
).Execute()).To(Succeed())

Eventually(IntegrationPodPhase(ns, timerPipe), TestTimeoutLong).Should(Equal(corev1.PodRunning))
Eventually(IntegrationConditionStatus(ns, timerPipe, v1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(corev1.ConditionTrue))
Eventually(IntegrationLogs(ns, timerPipe), TestTimeoutShort).Should(ContainSubstring("message is Hello"))
Eventually(IntegrationLogs(ns, "test-kamelet-display"), TestTimeoutShort).Should(ContainSubstring("HelloKNative!"))

Eventually(PipeCondition(ns, timerPipe, v1.PipeConditionReady), TestTimeoutMedium).Should(And(
WithTransform(PipeConditionStatusExtract, Equal(corev1.ConditionTrue)),
Expand All @@ -81,9 +70,9 @@ func TestKameletChange(t *testing.T) {
))

// Update the Pipe
Expect(KamelBind(ns,
from.Name,
to.Name,
Expect(KamelBindWithID(operatorID, ns,
timerSource,
knChannelConf,
"-p", "source.message=message is Hi",
"--annotation", "trait.camel.apache.org/health.enabled=true",
"--annotation", "trait.camel.apache.org/health.readiness-initial-delay=10",
Expand All @@ -92,7 +81,7 @@ func TestKameletChange(t *testing.T) {

Eventually(IntegrationPodPhase(ns, timerPipe), TestTimeoutLong).Should(Equal(corev1.PodRunning))
Eventually(IntegrationConditionStatus(ns, timerPipe, v1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(corev1.ConditionTrue))
Eventually(IntegrationLogs(ns, timerPipe), TestTimeoutShort).Should(ContainSubstring("message is Hi"))
Eventually(IntegrationLogs(ns, "test-kamelet-display"), TestTimeoutShort).Should(ContainSubstring("message is Hi"))

Eventually(PipeCondition(ns, timerPipe, v1.PipeConditionReady), TestTimeoutMedium).
Should(And(
Expand Down
18 changes: 4 additions & 14 deletions e2e/native/native_binding_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,24 +55,14 @@ func TestNativeBinding(t *testing.T) {
},
))

from := corev1.ObjectReference{
Kind: "Kamelet",
Name: "timer-source",
APIVersion: v1.SchemeGroupVersion.String(),
}
to := corev1.ObjectReference{
Kind: "Kamelet",
Name: "log-sink",
APIVersion: v1.SchemeGroupVersion.String(),
}
message := "Magicstring!"

t.Run("binding with native build", func(t *testing.T) {
bindingName := "native-binding"
Expect(KamelBind(ns,
from.Name,
to.Name,
"-p", "source.message=message",
Expect(KamelBindWithID(operatorID, ns,
"timer-source",
"log-sink",
"-p", "source.message="+message,
"--annotation", "trait.camel.apache.org/quarkus.package-type=native",
"--name", bindingName,
).Execute()).To(Succeed())
Expand Down

0 comments on commit 67f8671

Please sign in to comment.