Skip to content

Commit

Permalink
chore(e2e): Fix E2E tests
Browse files Browse the repository at this point in the history
  • Loading branch information
christophd committed Mar 8, 2024
1 parent 5fa6aaf commit 39097a5
Show file tree
Hide file tree
Showing 12 changed files with 20 additions and 13 deletions.
2 changes: 1 addition & 1 deletion e2e/common/cli/bind_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ func TestKamelCLIBind(t *testing.T) {
})

t.Run("unsuccessful binding, no property", func(t *testing.T) {
g.Expect(KamelBindWithID(t, operatorID, ns, "timer-source", "log:info").Execute()).NotTo(Succeed())
g.Expect(KamelBindWithID(t, operatorID, ns, operatorNS+"/timer-source", "log:info").Execute()).NotTo(Succeed())
})

t.Run("bind uris", func(t *testing.T) {
Expand Down
4 changes: 2 additions & 2 deletions e2e/common/cli/describe_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,10 @@ func TestKamelCliDescribe(t *testing.T) {
})

t.Run("Test kamel describe integration platform", func(t *testing.T) {
platform := GetOutputString(Kamel(t, "describe", "platform", operatorID, "-n", ns))
platform := GetOutputString(Kamel(t, "describe", "platform", operatorID, "-n", operatorNS))
g.Expect(platform).To(ContainSubstring(fmt.Sprintf("Name: %s", operatorID)))

r, _ := regexp.Compile("(?sm).*Namespace:\\s+" + ns + ".*")
r, _ := regexp.Compile("(?sm).*Namespace:\\s+" + operatorNS + ".*")
g.Expect(platform).To(MatchRegexp(r.String()))

r, _ = regexp.Compile("(?sm).*Runtime Version:\\s+" + defaults.DefaultRuntimeVersion + ".*")
Expand Down
2 changes: 1 addition & 1 deletion e2e/common/cli/dev_mode_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ func TestRunDevMode(t *testing.T) {
go kamelRun.Execute()

// Second run should start up within a few seconds
timeout := 10 * time.Second
timeout := 20 * time.Second
g.Eventually(logScanner.IsFound(`integration "`+name+`" in phase Running`), timeout).Should(BeTrue())
g.Eventually(logScanner.IsFound("Magicstring!"), timeout).Should(BeTrue())
})
Expand Down
2 changes: 1 addition & 1 deletion e2e/common/config/pipe_config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ func TestPipeConfig(t *testing.T) {
t.Parallel()

WithNewTestNamespace(t, func(g *WithT, ns string) {
operatorID := "camel-k-config"
operatorID := "camel-k-pipe-config"
g.Expect(CopyCamelCatalog(t, ns, operatorID)).To(Succeed())
g.Expect(CopyIntegrationKits(t, ns, operatorID)).To(Succeed())
g.Expect(KamelInstallWithID(t, operatorID, ns)).To(Succeed())
Expand Down
6 changes: 3 additions & 3 deletions e2e/common/misc/cron_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,21 +46,21 @@ func TestRunCronExample(t *testing.T) {

t.Run("cron", func(t *testing.T) {
g.Expect(KamelRunWithID(t, operatorID, ns, "files/cron.yaml").Execute()).To(Succeed())
g.Eventually(IntegrationCronJob(t, ns, "cron"), TestTimeoutMedium).ShouldNot(BeNil())
g.Eventually(IntegrationCronJob(t, ns, "cron"), TestTimeoutLong).ShouldNot(BeNil())
g.Eventually(IntegrationConditionStatus(t, ns, "cron", v1.IntegrationConditionReady), TestTimeoutMedium).Should(Equal(corev1.ConditionTrue))
g.Eventually(IntegrationLogs(t, ns, "cron"), TestTimeoutMedium).Should(ContainSubstring("Magicstring!"))
})

t.Run("cron-yaml", func(t *testing.T) {
g.Expect(KamelRunWithID(t, operatorID, ns, "files/cron-yaml.yaml").Execute()).To(Succeed())
g.Eventually(IntegrationCronJob(t, ns, "cron-yaml"), TestTimeoutMedium).ShouldNot(BeNil())
g.Eventually(IntegrationCronJob(t, ns, "cron-yaml"), TestTimeoutLong).ShouldNot(BeNil())
g.Eventually(IntegrationConditionStatus(t, ns, "cron-yaml", v1.IntegrationConditionReady), TestTimeoutMedium).Should(Equal(corev1.ConditionTrue))
g.Eventually(IntegrationLogs(t, ns, "cron-yaml"), TestTimeoutMedium).Should(ContainSubstring("Magicstring!"))
})

t.Run("cron-timer", func(t *testing.T) {
g.Expect(KamelRunWithID(t, operatorID, ns, "files/cron-timer.yaml").Execute()).To(Succeed())
g.Eventually(IntegrationCronJob(t, ns, "cron-timer"), TestTimeoutMedium).ShouldNot(BeNil())
g.Eventually(IntegrationCronJob(t, ns, "cron-timer"), TestTimeoutLong).ShouldNot(BeNil())
g.Eventually(IntegrationConditionStatus(t, ns, "cron-timer", v1.IntegrationConditionReady), TestTimeoutMedium).Should(Equal(corev1.ConditionTrue))
g.Eventually(IntegrationLogs(t, ns, "cron-timer"), TestTimeoutMedium).Should(ContainSubstring("Magicstring!"))
})
Expand Down
2 changes: 1 addition & 1 deletion e2e/common/misc/registry_maven_wagon_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ func TestImageRegistryIsAMavenRepository(t *testing.T) {
}

WithNewTestNamespace(t, func(g *WithT, ns string) {
operatorID := "camel-k-rest"
operatorID := "camel-k-registry-maven-repo"
g.Expect(CopyCamelCatalog(t, ns, operatorID)).To(Succeed())
g.Expect(CopyIntegrationKits(t, ns, operatorID)).To(Succeed())
g.Expect(KamelInstallWithID(t, operatorID, ns)).To(Succeed())
Expand Down
2 changes: 1 addition & 1 deletion e2e/common/misc/scale_binding_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ func TestPipeScale(t *testing.T) {
operatorID := "camel-k-pipe-scale"
g.Expect(CopyCamelCatalog(t, ns, operatorID)).To(Succeed())
g.Expect(CopyIntegrationKits(t, ns, operatorID)).To(Succeed())
g.Expect(KamelInstallWithID(t, operatorID, ns)).To(Succeed())
g.Expect(KamelInstallWithIDAndKameletCatalog(t, operatorID, ns)).To(Succeed())

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

Expand Down
2 changes: 1 addition & 1 deletion e2e/install/upgrade/cli_upgrade_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ func TestCLIOperatorUpgrade(t *testing.T) {
g.Expect(os.Setenv("KAMEL_BIN", "")).To(Succeed())

// Upgrade the operator by installing the current version
g.Expect(KamelInstall(t, ns, "--olm=false", "--force", "--operator-image", image, "--base-image", defaults.BaseImage())).To(Succeed())
g.Expect(Kamel(t, "install", "-n", ns, "--olm=false", "--skip-default-kamelets-setup", "--force", "--operator-image", image, "--base-image", defaults.BaseImage()).Execute()).To(Succeed())

// Check the operator image is the current built one
g.Eventually(OperatorImage(t, ns)).Should(Equal(image))
Expand Down
2 changes: 1 addition & 1 deletion e2e/install/upgrade/helm_upgrade_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ func TestHelmOperatorUpgrade(t *testing.T) {
t.FailNow()
}
}
g.Eventually(CRDs(t)).Should(HaveLen(0))
g.Eventually(CRDs(t), TestTimeoutMedium).Should(HaveLen(0))

WithNewTestNamespace(t, func(g *WithT, ns string) {
// Install operator in last released version
Expand Down
2 changes: 2 additions & 0 deletions e2e/knative/knative_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,8 @@ func TestRunBroker(t *testing.T) {
operatorID := fmt.Sprintf("camel-k-%s", ns)
g.Expect(KamelInstallWithID(t, operatorID, ns, "--trait-profile", "knative")).To(Succeed())

g.Eventually(SelectedPlatformPhase(t, ns, operatorID), TestTimeoutMedium).Should(Equal(camelv1.IntegrationPlatformPhaseReady))

g.Expect(KamelRunWithID(t, operatorID, ns, "files/knativeevt1.groovy").Execute()).To(Succeed())
g.Expect(KamelRunWithID(t, operatorID, ns, "files/knativeevt2.groovy").Execute()).To(Succeed())
g.Eventually(IntegrationPodPhase(t, ns, "knativeevt1"), TestTimeoutLong).Should(Equal(v1.PodRunning))
Expand Down
5 changes: 5 additions & 0 deletions e2e/support/test_support.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ var TestContext context.Context
var testClient client.Client
var clientMutex = sync.Mutex{}

var testSetupMutex = sync.Mutex{}
var kamelInstallMutex = sync.Mutex{}

// Only panic the test if absolutely necessary and there is
Expand Down Expand Up @@ -2069,12 +2070,16 @@ func UpdateIntegrationProfile(t *testing.T, ns string, upd func(ipr *v1.Integrat

func CreateCamelCatalog(t *testing.T, catalog *v1.CamelCatalog) func() error {
return func() error {
testSetupMutex.Lock()
defer testSetupMutex.Unlock()
return TestClient(t).Create(TestContext, catalog)
}
}

func CreateIntegrationKit(t *testing.T, kit *v1.IntegrationKit) func() error {
return func() error {
testSetupMutex.Lock()
defer testSetupMutex.Unlock()
return TestClient(t).Create(TestContext, kit)
}
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/cmd/builder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ func addTestBuilderCmd(options RootCmdOptions, rootCmd *cobra.Command) *builderC
func TestBuilderNonExistingFlag(t *testing.T) {
_, rootCmd, _ := initializeBuilderCmdOptions(t)
_, err := test.ExecuteCommand(rootCmd, cmdBuilder, "--nonExistingFlag")
require.NoError(t, err)
require.Error(t, err)
}

func TestBuilderBuildNameFlag(t *testing.T) {
Expand Down

0 comments on commit 39097a5

Please sign in to comment.