Skip to content

Commit

Permalink
chore(e2e): Do not run fast setup locally
Browse files Browse the repository at this point in the history
- Only run main_test.go fast setup optimizations when env var is set (usually on GitHub CI workflow)
  • Loading branch information
christophd committed Mar 13, 2024
1 parent 8793fa3 commit 834d469
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 43 deletions.
52 changes: 25 additions & 27 deletions e2e/advanced/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,34 +43,32 @@ func TestMain(m *testing.M) {
}

fastSetup := GetEnvOrDefault("CAMEL_K_E2E_FAST_SETUP", "false")
if fastSetup != "true" {
os.Exit(m.Run())
if fastSetup == "true" {
operatorID := platform.DefaultPlatformName
ns := GetEnvOrDefault("CAMEL_K_GLOBAL_OPERATOR_NS", TestDefaultNamespace)

g := NewGomega(func(message string, callerSkip ...int) {
fmt.Printf("Test fast setup failed! - %s\n", message)
})

var t *testing.T
g.Expect(TestClient(t)).ShouldNot(BeNil())
ctx := TestContext()
g.Expect(KamelRunWithID(t, ctx, operatorID, ns, "files/Java.java").Execute()).To(Succeed())
g.Eventually(IntegrationPodPhase(t, ctx, ns, "java"), TestTimeoutLong).Should(Equal(corev1.PodRunning))
g.Eventually(IntegrationConditionStatus(t, ctx, ns, "java", v1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(corev1.ConditionTrue))
g.Eventually(IntegrationLogs(t, ctx, ns, "java"), TestTimeoutShort).Should(ContainSubstring("Magicstring!"))

g.Expect(KamelRunWithID(t, ctx, operatorID, ns, "files/yaml.yaml").Execute()).To(Succeed())
g.Eventually(IntegrationPodPhase(t, ctx, ns, "yaml"), TestTimeoutLong).Should(Equal(corev1.PodRunning))
g.Eventually(IntegrationConditionStatus(t, ctx, ns, "yaml", v1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(corev1.ConditionTrue))
g.Eventually(IntegrationLogs(t, ctx, ns, "yaml"), TestTimeoutShort).Should(ContainSubstring("Magicstring!"))

g.Expect(KamelRunWithID(t, ctx, operatorID, ns, "files/timer-source.groovy").Execute()).To(Succeed())
g.Eventually(IntegrationPodPhase(t, ctx, ns, "timer-source"), TestTimeoutLong).Should(Equal(corev1.PodRunning))
g.Eventually(IntegrationConditionStatus(t, ctx, ns, "timer-source", v1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(corev1.ConditionTrue))
g.Eventually(IntegrationLogs(t, ctx, ns, "timer-source"), TestTimeoutShort).Should(ContainSubstring("Magicstring!"))
}

operatorID := platform.DefaultPlatformName
ns := GetEnvOrDefault("CAMEL_K_GLOBAL_OPERATOR_NS", TestDefaultNamespace)

g := NewGomega(func(message string, callerSkip ...int) {
fmt.Printf("Test fast setup failed! - %s\n", message)
})

var t *testing.T
g.Expect(TestClient(t)).ShouldNot(BeNil())
ctx := TestContext()
g.Expect(KamelRunWithID(t, ctx, operatorID, ns, "files/Java.java").Execute()).To(Succeed())
g.Eventually(IntegrationPodPhase(t, ctx, ns, "java"), TestTimeoutLong).Should(Equal(corev1.PodRunning))
g.Eventually(IntegrationConditionStatus(t, ctx, ns, "java", v1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(corev1.ConditionTrue))
g.Eventually(IntegrationLogs(t, ctx, ns, "java"), TestTimeoutShort).Should(ContainSubstring("Magicstring!"))

g.Expect(KamelRunWithID(t, ctx, operatorID, ns, "files/yaml.yaml").Execute()).To(Succeed())
g.Eventually(IntegrationPodPhase(t, ctx, ns, "yaml"), TestTimeoutLong).Should(Equal(corev1.PodRunning))
g.Eventually(IntegrationConditionStatus(t, ctx, ns, "yaml", v1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(corev1.ConditionTrue))
g.Eventually(IntegrationLogs(t, ctx, ns, "yaml"), TestTimeoutShort).Should(ContainSubstring("Magicstring!"))

g.Expect(KamelRunWithID(t, ctx, operatorID, ns, "files/timer-source.groovy").Execute()).To(Succeed())
g.Eventually(IntegrationPodPhase(t, ctx, ns, "timer-source"), TestTimeoutLong).Should(Equal(corev1.PodRunning))
g.Eventually(IntegrationConditionStatus(t, ctx, ns, "timer-source", v1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(corev1.ConditionTrue))
g.Eventually(IntegrationLogs(t, ctx, ns, "timer-source"), TestTimeoutShort).Should(ContainSubstring("Magicstring!"))

os.Exit(m.Run())
}
35 changes: 19 additions & 16 deletions e2e/common/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,26 +41,29 @@ func TestMain(m *testing.M) {
os.Exit(m.Run())
}

operatorID := platform.DefaultPlatformName
ns := GetEnvOrDefault("CAMEL_K_GLOBAL_OPERATOR_NS", TestDefaultNamespace)
fastSetup := GetEnvOrDefault("CAMEL_K_E2E_FAST_SETUP", "false")
if fastSetup == "true" {
operatorID := platform.DefaultPlatformName
ns := GetEnvOrDefault("CAMEL_K_GLOBAL_OPERATOR_NS", TestDefaultNamespace)

g := NewGomega(func(message string, callerSkip ...int) {
fmt.Printf("Test setup failed! - %s\n", message)
})
g := NewGomega(func(message string, callerSkip ...int) {
fmt.Printf("Test setup failed! - %s\n", message)
})

var t *testing.T
var t *testing.T

g.Expect(TestClient(t)).ShouldNot(BeNil())
ctx := TestContext()
g.Expect(KamelRunWithID(t, ctx, operatorID, ns, "languages/files/Java.java").Execute()).To(Succeed())
g.Eventually(IntegrationPodPhase(t, ctx, ns, "java"), TestTimeoutLong).Should(Equal(corev1.PodRunning))
g.Eventually(IntegrationConditionStatus(t, ctx, ns, "java", v1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(corev1.ConditionTrue))
g.Eventually(IntegrationLogs(t, ctx, ns, "java"), TestTimeoutShort).Should(ContainSubstring("Magicstring!"))
g.Expect(TestClient(t)).ShouldNot(BeNil())
ctx := TestContext()
g.Expect(KamelRunWithID(t, ctx, operatorID, ns, "languages/files/Java.java").Execute()).To(Succeed())
g.Eventually(IntegrationPodPhase(t, ctx, ns, "java"), TestTimeoutLong).Should(Equal(corev1.PodRunning))
g.Eventually(IntegrationConditionStatus(t, ctx, ns, "java", v1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(corev1.ConditionTrue))
g.Eventually(IntegrationLogs(t, ctx, ns, "java"), TestTimeoutShort).Should(ContainSubstring("Magicstring!"))

g.Expect(KamelRunWithID(t, ctx, operatorID, ns, "languages/files/yaml.yaml").Execute()).To(Succeed())
g.Eventually(IntegrationPodPhase(t, ctx, ns, "yaml"), TestTimeoutLong).Should(Equal(corev1.PodRunning))
g.Eventually(IntegrationConditionStatus(t, ctx, ns, "yaml", v1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(corev1.ConditionTrue))
g.Eventually(IntegrationLogs(t, ctx, ns, "yaml"), TestTimeoutShort).Should(ContainSubstring("Magicstring!"))
g.Expect(KamelRunWithID(t, ctx, operatorID, ns, "languages/files/yaml.yaml").Execute()).To(Succeed())
g.Eventually(IntegrationPodPhase(t, ctx, ns, "yaml"), TestTimeoutLong).Should(Equal(corev1.PodRunning))
g.Eventually(IntegrationConditionStatus(t, ctx, ns, "yaml", v1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(corev1.ConditionTrue))
g.Eventually(IntegrationLogs(t, ctx, ns, "yaml"), TestTimeoutShort).Should(ContainSubstring("Magicstring!"))
}

os.Exit(m.Run())
}

0 comments on commit 834d469

Please sign in to comment.