This is an automated email from the ASF dual-hosted git repository. pcongiusti pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/camel-k.git
commit b84980c007f93fd0d93704033ce9b6296ab59a89 Author: Pasquale Congiusti <[email protected]> AuthorDate: Tue Jun 25 13:16:27 2024 +0200 fix(e2e): check kit layout --- e2e/native/native_test.go | 48 ++++++++++++--------------------------- e2e/native/native_test_support.go | 8 ------- e2e/support/test_support.go | 28 +++++++++++++++++++++++ 3 files changed, 42 insertions(+), 42 deletions(-) diff --git a/e2e/native/native_test.go b/e2e/native/native_test.go index 8c7f006aa..893f96daa 100644 --- a/e2e/native/native_test.go +++ b/e2e/native/native_test.go @@ -54,54 +54,37 @@ func TestNativeIntegrations(t *testing.T) { Should(WithTransform(getContainerCommand(), MatchRegexp(".*camel-k-integration-\\d+\\.\\d+\\.\\d+[-A-Za-z]*-runner.*"))) g.Eventually(IntegrationConditionStatus(t, ctx, ns, name, v1.IntegrationConditionReady), TestTimeoutShort). Should(Equal(corev1.ConditionTrue)) - g.Eventually(IntegrationLogs(t, ctx, ns, name), TestTimeoutShort).Should(ContainSubstring("XML Magicstring!")) + + g.Eventually(IntegrationKitLayout(t, ctx, ns, name), TestTimeoutShort).Should(Equal(v1.IntegrationKitLayoutNativeSources)) }) t.Run("automatic rollout deployment from jvm to native kit", func(t *testing.T) { name := RandomizedSuffixName("yaml-native") g.Expect(KamelRun(t, ctx, ns, "files/yaml.yaml", "--name", name, "-t", "quarkus.build-mode=jvm", "-t", "quarkus.build-mode=native", "-t", "builder.tasks-limit-memory=quarkus-native:6.5Gi").Execute()).To(Succeed()) - // Check that two Kits are created with distinct layout - g.Eventually(Kits(t, ctx, ns, withFastJarLayout)).Should(HaveLen(1)) - g.Eventually(Kits(t, ctx, ns, withNativeLayout)).Should(HaveLen(1)) - // Check the fast-jar Kit is ready - g.Eventually(Kits(t, ctx, ns, withFastJarLayout, KitWithPhase(v1.IntegrationKitPhaseReady)), - TestTimeoutLong).Should(HaveLen(1)) - - fastJarKit := Kits(t, ctx, ns, withFastJarLayout, KitWithPhase(v1.IntegrationKitPhaseReady))()[0] - // Check the Integration uses the fast-jar Kit - g.Eventually(IntegrationKit(t, ctx, ns, name), TestTimeoutShort).Should(Equal(fastJarKit.Name)) - // Check the Integration Pod uses the fast-jar Kit - g.Eventually(IntegrationPodImage(t, ctx, ns, name)).Should(Equal(fastJarKit.Status.Image)) + g.Eventually(IntegrationKitLayout(t, ctx, ns, name), TestTimeoutShort).Should(Equal(v1.IntegrationKitLayoutFastJar)) + g.Eventually(IntegrationKitStatusPhase(t, ctx, ns, name), TestTimeoutLong).Should(Equal(v1.IntegrationKitPhaseReady)) // Check the Integration is ready - g.Eventually(IntegrationPodPhase(t, ctx, ns, name), TestTimeoutLong).Should(Equal(corev1.PodRunning)) + g.Eventually(IntegrationPodPhase(t, ctx, ns, name)).Should(Equal(corev1.PodRunning)) g.Eventually(IntegrationPod(t, ctx, ns, name), TestTimeoutShort). Should(WithTransform(getContainerCommand(), ContainSubstring("java"))) g.Eventually(IntegrationConditionStatus(t, ctx, ns, name, v1.IntegrationConditionReady), TestTimeoutShort). Should(Equal(corev1.ConditionTrue)) - g.Eventually(IntegrationLogs(t, ctx, ns, name), TestTimeoutMedium).Should(ContainSubstring("Magicstring!")) // Check the native Kit is ready - g.Eventually(Kits(t, ctx, ns, withNativeLayout, KitWithPhase(v1.IntegrationKitPhaseReady)), - TestTimeoutVeryLong).Should(HaveLen(1)) - - nativeKit := Kits(t, ctx, ns, withNativeLayout, KitWithPhase(v1.IntegrationKitPhaseReady))()[0] - // Check the Integration uses the native Kit - g.Eventually(IntegrationKit(t, ctx, ns, name), TestTimeoutShort).Should(Equal(nativeKit.Name)) - // Check the Integration Pod uses the native Kit - g.Eventually(IntegrationPodImage(t, ctx, ns, name)).Should(Equal(nativeKit.Status.Image)) + g.Eventually(IntegrationKitLayout(t, ctx, ns, name), TestTimeoutVeryLong).Should(Equal(v1.IntegrationKitLayoutNativeSources)) + g.Eventually(IntegrationKitStatusPhase(t, ctx, ns, name)).Should(Equal(v1.IntegrationKitPhaseReady)) // Check the Integration is still ready - g.Eventually(IntegrationPodPhase(t, ctx, ns, name), TestTimeoutVeryLong).Should(Equal(corev1.PodRunning)) + g.Eventually(IntegrationPodPhase(t, ctx, ns, name)).Should(Equal(corev1.PodRunning)) g.Eventually(IntegrationPod(t, ctx, ns, name), TestTimeoutShort). Should(WithTransform(getContainerCommand(), MatchRegexp(".*camel-k-integration-\\d+\\.\\d+\\.\\d+[-A-Za-z]*-runner.*"))) g.Eventually(IntegrationConditionStatus(t, ctx, ns, name, v1.IntegrationConditionReady), TestTimeoutShort). Should(Equal(corev1.ConditionTrue)) - g.Eventually(IntegrationLogs(t, ctx, ns, name), TestTimeoutShort).Should(ContainSubstring("Magicstring!")) t.Run("yaml native should not rebuild", func(t *testing.T) { @@ -109,7 +92,7 @@ func TestNativeIntegrations(t *testing.T) { g.Expect(KamelRun(t, ctx, ns, "files/yaml2.yaml", "--name", name, "-t", "quarkus.build-mode=native", "-t", "builder.tasks-limit-memory=quarkus-native:6.5Gi").Execute()).To(Succeed()) // This one should run quickly as it suppose to reuse an IntegrationKit - g.Eventually(IntegrationPodPhase(t, ctx, ns, name), TestTimeoutShort).Should(Equal(corev1.PodRunning)) + g.Eventually(IntegrationPodPhase(t, ctx, ns, name), TestTimeoutVeryLong).Should(Equal(corev1.PodRunning)) g.Eventually(IntegrationPod(t, ctx, ns, name), TestTimeoutShort). Should(WithTransform(getContainerCommand(), MatchRegexp(".*camel-k-integration-\\d+\\.\\d+\\.\\d+[-A-Za-z]*-runner.*"))) g.Eventually(IntegrationConditionStatus(t, ctx, ns, name, v1.IntegrationConditionReady), TestTimeoutShort). @@ -131,18 +114,15 @@ func TestNativeBinding(t *testing.T) { "--trait", "quarkus.build-mode=native", "--trait", "builder.tasks-limit-memory=quarkus-native:6.5Gi", "--name", bindingName).Execute()).To(Succeed()) - g.Eventually(Kits(t, ctx, ns, withNativeLayout, KitWithPhase(v1.IntegrationKitPhaseReady)), - TestTimeoutVeryLong).Should(HaveLen(1)) - - nativeKit := Kits(t, ctx, ns, withNativeLayout, KitWithPhase(v1.IntegrationKitPhaseReady))()[0] - g.Eventually(IntegrationKit(t, ctx, ns, bindingName), TestTimeoutShort).Should(Equal(nativeKit.Name)) - - g.Eventually(IntegrationPodPhase(t, ctx, ns, bindingName), TestTimeoutLong).Should(Equal(corev1.PodRunning)) + g.Eventually(IntegrationPodPhase(t, ctx, ns, bindingName), TestTimeoutVeryLong).Should(Equal(corev1.PodRunning)) + g.Eventually(IntegrationConditionStatus(t, ctx, ns, bindingName, v1.IntegrationConditionReady), TestTimeoutShort). + Should(Equal(corev1.ConditionTrue)) g.Eventually(IntegrationLogs(t, ctx, ns, bindingName), TestTimeoutShort).Should(ContainSubstring(message)) - g.Eventually(IntegrationPod(t, ctx, ns, bindingName), TestTimeoutShort). Should(WithTransform(getContainerCommand(), MatchRegexp(".*camel-k-integration-\\d+\\.\\d+\\.\\d+[-A-Za-z]*-runner.*"))) + + g.Eventually(IntegrationKitLayout(t, ctx, ns, bindingName), TestTimeoutShort).Should(Equal(v1.IntegrationKitLayoutNativeSources)) }) }) } diff --git a/e2e/native/native_test_support.go b/e2e/native/native_test_support.go index 576c19d8c..6582296b5 100644 --- a/e2e/native/native_test_support.go +++ b/e2e/native/native_test_support.go @@ -26,14 +26,6 @@ import ( "strings" 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" -) - -var ( - withFastJarLayout = KitWithLabels(map[string]string{v1.IntegrationKitLayoutLabel: v1.IntegrationKitLayoutFastJar}) - withNativeLayout = KitWithLabels(map[string]string{v1.IntegrationKitLayoutLabel: v1.IntegrationKitLayoutNativeSources}) ) func getContainerCommand() func(pod *corev1.Pod) string { diff --git a/e2e/support/test_support.go b/e2e/support/test_support.go index e3467b229..dad82e2a4 100644 --- a/e2e/support/test_support.go +++ b/e2e/support/test_support.go @@ -1131,6 +1131,34 @@ func IntegrationKitNamespace(t *testing.T, ctx context.Context, integrationNames } } +func IntegrationKitLayout(t *testing.T, ctx context.Context, ns string, name string) func() string { + return func() string { + it := Integration(t, ctx, ns, name)() + if it == nil { + return "" + } + if it.Status.IntegrationKit == nil { + return "" + } + kit := Kit(t, ctx, it.Status.IntegrationKit.Namespace, it.Status.IntegrationKit.Name)() + return kit.Labels[v1.IntegrationKitLayoutLabel] + } +} + +func IntegrationKitStatusPhase(t *testing.T, ctx context.Context, ns string, name string) func() v1.IntegrationKitPhase { + return func() v1.IntegrationKitPhase { + it := Integration(t, ctx, ns, name)() + if it == nil { + return v1.IntegrationKitPhaseNone + } + if it.Status.IntegrationKit == nil { + return v1.IntegrationKitPhaseNone + } + kit := Kit(t, ctx, it.Status.IntegrationKit.Namespace, it.Status.IntegrationKit.Name)() + return kit.Status.Phase + } +} + func Kit(t *testing.T, ctx context.Context, ns, name string) func() *v1.IntegrationKit { return func() *v1.IntegrationKit { kit := v1.NewIntegrationKit(ns, name)
