Skip to content

Commit

Permalink
fix(e2e): Wait for IntegrationPlatform to become ready
Browse files Browse the repository at this point in the history
- Avoid running integrations when platform is not ready
- Stabilize tests
  • Loading branch information
christophd committed Feb 22, 2024
1 parent 53c2b77 commit 57a9dbb
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 5 deletions.
14 changes: 9 additions & 5 deletions e2e/advanced/debug_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,11 @@ import (
"testing"
"time"

corev1 "k8s.io/api/core/v1"

. "github.com/apache/camel-k/v2/e2e/support"
v1 "github.com/apache/camel-k/v2/pkg/apis/camel/v1"
. "github.com/onsi/gomega"
v1 "k8s.io/api/core/v1"
)

func TestKamelCLIDebug(t *testing.T) {
Expand All @@ -42,9 +44,11 @@ func TestKamelCLIDebug(t *testing.T) {
Expect(CopyCamelCatalog(ns, operatorID)).To(Succeed())
Expect(KamelInstallWithID(operatorID, ns).Execute()).To(Succeed())

Eventually(SelectedPlatformPhase(ns, operatorID), TestTimeoutMedium).Should(Equal(v1.IntegrationPlatformPhaseReady))

t.Run("debug local default port check", func(t *testing.T) {
Expect(KamelRunWithID(operatorID, ns, "files/yaml.yaml").Execute()).To(Succeed())
Eventually(IntegrationPodPhase(ns, "yaml"), TestTimeoutMedium).Should(Equal(v1.PodRunning))
Eventually(IntegrationPodPhase(ns, "yaml"), TestTimeoutMedium).Should(Equal(corev1.PodRunning))
Expect(portIsInUse("127.0.0.1", "5005")()).To(BeFalse())

debugTestContext, cancel := context.WithCancel(TestContext)
Expand All @@ -57,7 +61,7 @@ func TestKamelCLIDebug(t *testing.T) {

t.Run("debug local port check", func(t *testing.T) {
Expect(KamelRunWithID(operatorID, ns, "files/yaml.yaml").Execute()).To(Succeed())
Eventually(IntegrationPodPhase(ns, "yaml"), TestTimeoutMedium).Should(Equal(v1.PodRunning))
Eventually(IntegrationPodPhase(ns, "yaml"), TestTimeoutMedium).Should(Equal(corev1.PodRunning))
Expect(portIsInUse("127.0.0.1", "5006")()).To(BeFalse())

debugTestContext, cancel := context.WithCancel(TestContext)
Expand All @@ -70,7 +74,7 @@ func TestKamelCLIDebug(t *testing.T) {

t.Run("debug logs check", func(t *testing.T) {
Expect(KamelRunWithID(operatorID, ns, "files/yaml.yaml").Execute()).To(Succeed())
Eventually(IntegrationPodPhase(ns, "yaml"), TestTimeoutMedium).Should(Equal(v1.PodRunning))
Eventually(IntegrationPodPhase(ns, "yaml"), TestTimeoutMedium).Should(Equal(corev1.PodRunning))

debugTestContext, cancel := context.WithCancel(TestContext)
defer cancelAndWait(cancel)
Expand All @@ -82,7 +86,7 @@ func TestKamelCLIDebug(t *testing.T) {

t.Run("Pod config test", func(t *testing.T) {
Expect(KamelRunWithID(operatorID, ns, "files/yaml.yaml").Execute()).To(Succeed())
Eventually(IntegrationPodPhase(ns, "yaml"), TestTimeoutMedium).Should(Equal(v1.PodRunning))
Eventually(IntegrationPodPhase(ns, "yaml"), TestTimeoutMedium).Should(Equal(corev1.PodRunning))

debugTestContext, cancel := context.WithCancel(TestContext)
defer cancelAndWait(cancel)
Expand Down
3 changes: 3 additions & 0 deletions e2e/advanced/dump_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ package advanced

import (
"fmt"
v1 "github.com/apache/camel-k/v2/pkg/apis/camel/v1"
"testing"

. "github.com/onsi/gomega"
Expand All @@ -48,6 +49,8 @@ func TestKamelCLIDump(t *testing.T) {
operatorID := fmt.Sprintf("camel-k-%s", ns)
Expect(CopyCamelCatalog(ns, operatorID)).To(Succeed())
Expect(KamelInstallWithID(operatorID, ns).Execute()).To(Succeed())
Eventually(SelectedPlatformPhase(ns, operatorID), TestTimeoutMedium).Should(Equal(v1.IntegrationPlatformPhaseReady))

Expect(KamelRunWithID(operatorID, ns, "files/yaml.yaml").Execute()).To(Succeed())
Eventually(IntegrationPodPhase(ns, "yaml"), TestTimeoutLong).Should(Equal(corev1.PodRunning))
Eventually(IntegrationLogs(ns, "yaml")).Should(ContainSubstring("Magicstring!"))
Expand Down
2 changes: 2 additions & 0 deletions e2e/advanced/environment_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ func TestEnvironmentTrait(t *testing.T) {
"--operator-env-vars", "NO_PROXY="+strings.Join(noProxy, ","),
).Execute()).To(Succeed())

Eventually(SelectedPlatformPhase(ns, operatorID), TestTimeoutMedium).Should(Equal(v1.IntegrationPlatformPhaseReady))

t.Run("Run integration with default environment", func(t *testing.T) {
name := RandomizedSuffixName("java-default")
Expect(KamelRunWithID(operatorID, ns, "--name", name, "files/Java.java").Execute()).To(Succeed())
Expand Down
1 change: 1 addition & 0 deletions e2e/advanced/incremental_build_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ func TestRunIncrementalBuildRoutine(t *testing.T) {
operatorID := "camel-k-incremental-build"
Expect(CopyCamelCatalog(ns, operatorID)).To(Succeed())
Expect(KamelInstallWithID(operatorID, ns).Execute()).To(Succeed())
Eventually(SelectedPlatformPhase(ns, operatorID), TestTimeoutMedium).Should(Equal(v1.IntegrationPlatformPhaseReady))

name := RandomizedSuffixName("java")
Expect(KamelRunWithID(operatorID, ns, "files/Java.java",
Expand Down
2 changes: 2 additions & 0 deletions e2e/advanced/operator_metrics_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ func TestMetrics(t *testing.T) {
operatorID := "camel-k-metrics"
Expect(CopyCamelCatalog(ns, operatorID)).To(Succeed())
Expect(KamelInstallWithID(operatorID, ns, "--log-level", "debug").Execute()).To(Succeed())
Eventually(SelectedPlatformPhase(ns, operatorID), TestTimeoutMedium).Should(Equal(v1.IntegrationPlatformPhaseReady))

Expect(KamelRunWithID(operatorID, ns, "files/Java.java",
"--name", name,
"-t", "prometheus.enabled=true",
Expand Down
1 change: 1 addition & 0 deletions e2e/advanced/promote_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ func TestKamelCLIPromote(t *testing.T) {
operatorDevID := "camel-k-cli-promote-dev"
Expect(CopyCamelCatalog(nsDev, operatorDevID)).To(Succeed())
Expect(KamelInstallWithID(operatorDevID, nsDev).Execute()).To(Succeed())
Eventually(SelectedPlatformPhase(nsDev, operatorDevID), TestTimeoutMedium).Should(Equal(v1.IntegrationPlatformPhaseReady))

// Dev content configmap
var cmData = make(map[string]string)
Expand Down
3 changes: 3 additions & 0 deletions e2e/advanced/reset_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import (
corev1 "k8s.io/api/core/v1"

. "github.com/apache/camel-k/v2/e2e/support"
v1 "github.com/apache/camel-k/v2/pkg/apis/camel/v1"
)

func TestKamelReset(t *testing.T) {
Expand All @@ -37,6 +38,8 @@ func TestKamelReset(t *testing.T) {
Expect(CopyCamelCatalog(ns, operatorID)).To(Succeed())
Expect(KamelInstallWithID(operatorID, ns).Execute()).To(Succeed())

Eventually(SelectedPlatformPhase(ns, operatorID), TestTimeoutMedium).Should(Equal(v1.IntegrationPlatformPhaseReady))

t.Run("Reset the whole platform", func(t *testing.T) {
name := RandomizedSuffixName("yaml1")
Expect(KamelRunWithID(operatorID, ns, "files/yaml.yaml", "--name", name).Execute()).To(Succeed())
Expand Down
1 change: 1 addition & 0 deletions e2e/advanced/synthetic_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ func TestSyntheticIntegrationOff(t *testing.T) {
operatorID := "camel-k-synthetic-env-off"
Expect(CopyCamelCatalog(ns, operatorID)).To(Succeed())
Expect(KamelInstallWithID(operatorID, ns).Execute()).To(Succeed())
Eventually(SelectedPlatformPhase(ns, operatorID), TestTimeoutMedium).Should(Equal(v1.IntegrationPlatformPhaseReady))

// Run the external deployment
ExpectExecSucceed(t, Kubectl("apply", "-f", "files/deploy.yaml", "-n", ns))
Expand Down

0 comments on commit 57a9dbb

Please sign in to comment.