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 2300c01a343a8addff85548785f8b035e65e3927
Author: Pasquale Congiusti <[email protected]>
AuthorDate: Thu Jun 20 11:20:05 2024 +0200

    chore(e2e): remove check structure
    
    E2E should test the behavior. Integration structure etc should be part of 
unit test instead
---
 e2e/advanced/builder_test.go          | 83 +++++++++++++++++++++++++++++++++++
 e2e/advanced/environment_test.go      | 11 -----
 e2e/common/config/config_test.go      |  9 ----
 e2e/common/misc/kamelet_test.go       |  9 ----
 e2e/common/traits/container_test.go   |  9 ----
 e2e/common/traits/deployment_test.go  |  9 ----
 e2e/common/traits/health_test.go      | 15 ++++---
 e2e/common/traits/istio_test.go       |  9 ----
 e2e/common/traits/jolokia_test.go     | 22 ++++------
 e2e/common/traits/jvm_test.go         | 37 ----------------
 e2e/common/traits/pdb_test.go         | 10 -----
 e2e/common/traits/prometheus_test.go  |  9 ----
 e2e/common/traits/pull_secret_test.go |  9 ----
 e2e/common/traits/route_test.go       |  9 ----
 e2e/common/traits/service_test.go     | 10 -----
 e2e/native/native_test.go             |  9 ----
 e2e/support/test_support.go           | 81 ++++++++++++++++++----------------
 e2e/telemetry/telemetry_test.go       | 13 ------
 18 files changed, 141 insertions(+), 222 deletions(-)

diff --git a/e2e/advanced/builder_test.go b/e2e/advanced/builder_test.go
index dd82970a8..409278035 100644
--- a/e2e/advanced/builder_test.go
+++ b/e2e/advanced/builder_test.go
@@ -83,3 +83,86 @@ func TestBuilderTimeout(t *testing.T) {
                })
        })
 }
+
+func TestMavenProfile(t *testing.T) {
+       t.Parallel()
+
+       WithNewTestNamespace(t, func(ctx context.Context, g *WithT, ns string) {
+               t.Run("Run maven profile", func(t *testing.T) {
+                       name := RandomizedSuffixName("java-maven-profile")
+
+                       mavenProfile1Cm := newMavenProfileConfigMap(ns, 
"maven-profile-owasp", "owasp-profile")
+                       g.Expect(TestClient(t).Create(ctx, 
mavenProfile1Cm)).To(Succeed())
+                       mavenProfile2Cm := newMavenProfileConfigMap(ns, 
"maven-profile-dependency", "dependency-profile")
+                       g.Expect(TestClient(t).Create(ctx, 
mavenProfile2Cm)).To(Succeed())
+
+                       g.Expect(KamelRun(t, ctx, ns, "files/Java.java", 
"--name", name, "-t", 
"builder.maven-profiles=configmap:maven-profile-owasp/owasp-profile", "-t", 
"builder.maven-profiles=configmap:maven-profile-dependency/dependency-profile", 
"-t", "builder.tasks=custom1;alpine;cat maven/pom.xml", "-t", 
"builder.strategy=pod").Execute()).To(Succeed())
+
+                       g.Eventually(IntegrationPodPhase(t, ctx, ns, name), 
TestTimeoutLong).Should(Equal(corev1.PodRunning))
+                       g.Eventually(IntegrationConditionStatus(t, ctx, ns, 
name, v1.IntegrationConditionReady), 
TestTimeoutLong).Should(Equal(corev1.ConditionTrue))
+                       g.Eventually(IntegrationLogs(t, ctx, ns, name), 
TestTimeoutShort).Should(ContainSubstring("Magicstring!"))
+
+                       integrationKitName := IntegrationKit(t, ctx, ns, name)()
+                       integrationKitNamespace := IntegrationKitNamespace(t, 
ctx, ns, name)()
+                       builderKitName := fmt.Sprintf("camel-k-%s-builder", 
integrationKitName)
+                       g.Eventually(BuilderPod(t, ctx, 
integrationKitNamespace, builderKitName), TestTimeoutShort).ShouldNot(BeNil())
+                       g.Eventually(len(BuilderPod(t, ctx, 
integrationKitNamespace, builderKitName)().Spec.InitContainers), 
TestTimeoutShort).Should(Equal(3))
+                       g.Eventually(BuilderPod(t, ctx, 
integrationKitNamespace, builderKitName)().Spec.InitContainers[0].Name, 
TestTimeoutShort).Should(Equal("builder"))
+                       g.Eventually(BuilderPod(t, ctx, 
integrationKitNamespace, builderKitName)().Spec.InitContainers[1].Name, 
TestTimeoutShort).Should(Equal("custom1"))
+                       g.Eventually(BuilderPod(t, ctx, 
integrationKitNamespace, builderKitName)().Spec.InitContainers[2].Name, 
TestTimeoutShort).Should(Equal("package"))
+
+                       // Check containers conditions
+                       g.Eventually(Build(t, ctx, integrationKitNamespace, 
integrationKitName), TestTimeoutShort).ShouldNot(BeNil())
+                       g.Eventually(
+                               Build(t, ctx, integrationKitNamespace, 
integrationKitName)().Status.GetCondition(v1.BuildConditionType("Containercustom1Succeeded")).Status,
+                               
TestTimeoutShort).Should(Equal(corev1.ConditionTrue))
+                       g.Eventually(
+                               Build(t, ctx, integrationKitNamespace, 
integrationKitName)().Status.GetCondition(v1.BuildConditionType("Containercustom1Succeeded")).Message,
+                               
TestTimeoutShort).Should(ContainSubstring("</project>"))
+
+                       // Check logs
+                       g.Eventually(Logs(t, ctx, integrationKitNamespace, 
builderKitName, corev1.PodLogOptions{Container: 
"custom1"})).Should(ContainSubstring(`<id>owasp-profile</id>`))
+                       g.Eventually(Logs(t, ctx, integrationKitNamespace, 
builderKitName, corev1.PodLogOptions{Container: 
"custom1"})).Should(ContainSubstring(`<id>dependency-profile</id>`))
+
+                       g.Expect(TestClient(t).Delete(ctx, 
mavenProfile1Cm)).To(Succeed())
+                       g.Expect(TestClient(t).Delete(ctx, 
mavenProfile2Cm)).To(Succeed())
+               })
+       })
+}
+
+func newMavenProfileConfigMap(ns, name, key string) *corev1.ConfigMap {
+       return &corev1.ConfigMap{
+               TypeMeta: metav1.TypeMeta{
+                       Kind:       "ConfigMap",
+                       APIVersion: corev1.SchemeGroupVersion.String(),
+               },
+               ObjectMeta: metav1.ObjectMeta{
+                       Namespace: ns,
+                       Name:      name,
+               },
+               Data: map[string]string{
+                       key: fmt.Sprintf(`
+<profile>
+  <id>` + key + `</id>
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.owasp</groupId>
+        <artifactId>dependency-check-maven</artifactId>
+        <version>5.3.0</version>
+        <executions>
+          <execution>
+            <goals>
+              <goal>check</goal>
+            </goals>
+          </execution>
+        </executions>
+      </plugin>
+    </plugins>
+  </build>
+</profile>
+`,
+                       ),
+               },
+       }
+}
diff --git a/e2e/advanced/environment_test.go b/e2e/advanced/environment_test.go
index eadde81f6..27efc987f 100644
--- a/e2e/advanced/environment_test.go
+++ b/e2e/advanced/environment_test.go
@@ -32,7 +32,6 @@ import (
        . "github.com/onsi/gomega"
 
        corev1 "k8s.io/api/core/v1"
-       "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
 
        . "github.com/apache/camel-k/v2/e2e/support"
        v1 "github.com/apache/camel-k/v2/pkg/apis/camel/v1"
@@ -150,17 +149,7 @@ func TestEnvironmentTrait(t *testing.T) {
                                Not(ContainElement(corev1.EnvVar{Name: 
"HTTP_PROXY", Value: httpProxy})),
                                Not(ContainElement(corev1.EnvVar{Name: 
"NO_PROXY", Value: strings.Join(noProxy, ",")})),
                        )))
-
-                       // check integration schema does not contains unwanted 
default trait value.
-                       g.Eventually(UnstructuredIntegration(t, ctx, ns, 
name)).ShouldNot(BeNil())
-                       unstructuredIntegration := UnstructuredIntegration(t, 
ctx, ns, name)()
-                       envTrait, _, _ := 
unstructured.NestedMap(unstructuredIntegration.Object, "spec", "traits", 
"environment")
-                       g.Expect(envTrait).ToNot(BeNil())
-                       g.Expect(len(envTrait)).To(Equal(1))
-                       g.Expect(envTrait["httpProxy"]).To(Equal(false))
                })
-
-               g.Expect(Kamel(t, ctx, "delete", "--all", "-n", 
ns).Execute()).To(Succeed())
        })
 }
 
diff --git a/e2e/common/config/config_test.go b/e2e/common/config/config_test.go
index d70cd702d..aef0efda6 100644
--- a/e2e/common/config/config_test.go
+++ b/e2e/common/config/config_test.go
@@ -29,7 +29,6 @@ import (
        . "github.com/onsi/gomega"
 
        corev1 "k8s.io/api/core/v1"
-       "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
 
        . "github.com/apache/camel-k/v2/e2e/support"
        v1 "github.com/apache/camel-k/v2/pkg/apis/camel/v1"
@@ -118,14 +117,6 @@ func TestRunConfigExamples(t *testing.T) {
                        g.Eventually(IntegrationPodPhase(t, ctx, ns, 
"property-secret-route"), TestTimeoutLong).Should(Equal(corev1.PodRunning))
                        g.Eventually(IntegrationConditionStatus(t, ctx, ns, 
"property-secret-route", v1.IntegrationConditionReady), 
TestTimeoutShort).Should(Equal(corev1.ConditionTrue))
                        g.Eventually(IntegrationLogs(t, ctx, ns, 
"property-secret-route"), 
TestTimeoutShort).Should(ContainSubstring("my-secret-external-value"))
-
-                       // check integration schema does not contains unwanted 
default trait value.
-                       g.Eventually(UnstructuredIntegration(t, ctx, ns, 
"property-secret-route")).ShouldNot(BeNil())
-                       unstructuredIntegration := UnstructuredIntegration(t, 
ctx, ns, "property-secret-route")()
-                       mountTrait, _, _ := 
unstructured.NestedMap(unstructuredIntegration.Object, "spec", "traits", 
"mount")
-                       g.Expect(mountTrait).ToNot(BeNil())
-                       g.Expect(len(mountTrait)).To(Equal(1))
-                       g.Expect(mountTrait["configs"]).ToNot(BeNil())
                })
 
                // Configmap
diff --git a/e2e/common/misc/kamelet_test.go b/e2e/common/misc/kamelet_test.go
index 95c055e17..c7c4eff54 100644
--- a/e2e/common/misc/kamelet_test.go
+++ b/e2e/common/misc/kamelet_test.go
@@ -28,7 +28,6 @@ import (
 
        . "github.com/onsi/gomega"
        corev1 "k8s.io/api/core/v1"
-       "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
 
        . "github.com/apache/camel-k/v2/e2e/support"
 )
@@ -116,14 +115,6 @@ spec:
                        g.Expect(KamelRun(t, ctx, ns, 
"files/TimerKameletIntegration.java", "-t", "kamelets.enabled=false", 
"--resource", "configmap:my-kamelet-cm@/kamelets", "-p 
camel.component.kamelet.location=file:/kamelets", "-d", "camel:yaml-dsl", "-d", 
"camel:timer").Execute()).To(Succeed())
                        g.Eventually(IntegrationPodPhase(t, ctx, ns, 
"timer-kamelet-integration"), TestTimeoutLong).Should(Equal(corev1.PodRunning))
                        g.Eventually(IntegrationLogs(t, ctx, ns, 
"timer-kamelet-integration")).Should(ContainSubstring("important message"))
-
-                       // check integration schema does not contains unwanted 
default trait value.
-                       g.Eventually(UnstructuredIntegration(t, ctx, ns, 
"timer-kamelet-integration")).ShouldNot(BeNil())
-                       unstructuredIntegration := UnstructuredIntegration(t, 
ctx, ns, "timer-kamelet-integration")()
-                       kameletsTrait, _, _ := 
unstructured.NestedMap(unstructuredIntegration.Object, "spec", "traits", 
"kamelets")
-                       g.Expect(kameletsTrait).ToNot(BeNil())
-                       g.Expect(len(kameletsTrait)).To(Equal(1))
-                       g.Expect(kameletsTrait["enabled"]).To(Equal(false))
                })
        })
 }
diff --git a/e2e/common/traits/container_test.go 
b/e2e/common/traits/container_test.go
index 44687f20a..f5c8a1dc0 100644
--- a/e2e/common/traits/container_test.go
+++ b/e2e/common/traits/container_test.go
@@ -29,7 +29,6 @@ import (
        . "github.com/onsi/gomega"
 
        corev1 "k8s.io/api/core/v1"
-       "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
 
        . "github.com/apache/camel-k/v2/e2e/support"
        v1 "github.com/apache/camel-k/v2/pkg/apis/camel/v1"
@@ -84,14 +83,6 @@ func TestContainerTrait(t *testing.T) {
                                podContainerName := pod.Spec.Containers[0].Name
                                return podContainerName == containerName
                        }), TestTimeoutShort).Should(BeTrue())
-
-                       // check integration schema does not contains unwanted 
default trait value.
-                       g.Eventually(UnstructuredIntegration(t, ctx, ns, 
name)).ShouldNot(BeNil())
-                       unstructuredIntegration := UnstructuredIntegration(t, 
ctx, ns, name)()
-                       containerTrait, _, _ := 
unstructured.NestedMap(unstructuredIntegration.Object, "spec", "traits", 
"container")
-                       g.Expect(containerTrait).ToNot(BeNil())
-                       g.Expect(len(containerTrait)).To(Equal(1))
-                       
g.Expect(containerTrait["name"]).To(Equal(containerName))
                })
        })
 }
diff --git a/e2e/common/traits/deployment_test.go 
b/e2e/common/traits/deployment_test.go
index 99d6cd698..31791ae91 100644
--- a/e2e/common/traits/deployment_test.go
+++ b/e2e/common/traits/deployment_test.go
@@ -27,7 +27,6 @@ import (
        "testing"
 
        appsv1 "k8s.io/api/apps/v1"
-       "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
 
        . "github.com/onsi/gomega"
        . "github.com/onsi/gomega/gstruct"
@@ -61,14 +60,6 @@ func TestRecreateDeploymentStrategyTrait(t *testing.T) {
                                                }),
                                }),
                        ))
-
-                       // check integration schema does not contains unwanted 
default trait value.
-                       g.Eventually(UnstructuredIntegration(t, ctx, ns, 
name)).ShouldNot(BeNil())
-                       unstructuredIntegration := UnstructuredIntegration(t, 
ctx, ns, name)()
-                       deploymentTrait, _, _ := 
unstructured.NestedMap(unstructuredIntegration.Object, "spec", "traits", 
"deployment")
-                       g.Expect(deploymentTrait).ToNot(BeNil())
-                       g.Expect(len(deploymentTrait)).To(Equal(1))
-                       
g.Expect(deploymentTrait["strategy"]).To(Equal(string(appsv1.RecreateDeploymentStrategyType)))
                })
        })
 }
diff --git a/e2e/common/traits/health_test.go b/e2e/common/traits/health_test.go
index b27bce5be..bd0b8b302 100644
--- a/e2e/common/traits/health_test.go
+++ b/e2e/common/traits/health_test.go
@@ -49,7 +49,8 @@ func TestHealthTrait(t *testing.T) {
                        g.Expect(KamelRun(t, ctx, ns, "files/Java.java",
                                "-t", "health.enabled=true",
                                "-t", "jolokia.enabled=true", "-t", 
"jolokia.use-ssl-client-authentication=false",
-                               "-t", "jolokia.protocol=http", "--name", 
name).Execute()).To(Succeed())
+                               "-t", "jolokia.protocol=http",
+                               "--name", name).Execute()).To(Succeed())
 
                        g.Eventually(IntegrationPodPhase(t, ctx, ns, name), 
TestTimeoutLong).Should(Equal(corev1.PodRunning))
                        g.Eventually(IntegrationPhase(t, ctx, ns, name), 
TestTimeoutShort).Should(Equal(v1.IntegrationPhaseRunning))
@@ -73,9 +74,7 @@ func TestHealthTrait(t *testing.T) {
                        t.Logf("Stopping routes for integration %s/%s (%d)", 
ns, name, len(pods))
 
                        for i, pod := range pods {
-
                                t.Logf("Stopping route on integration pod 
%s/%s", pod.Namespace, pod.Name)
-
                                // Stop the Camel route
                                request := map[string]string{
                                        "type":      "exec",
@@ -94,7 +93,6 @@ func TestHealthTrait(t *testing.T) {
 
                                g.Eventually(IntegrationConditionStatus(t, ctx, 
ns, name, v1.IntegrationConditionReady), TestTimeoutShort).
                                        Should(Equal(corev1.ConditionFalse))
-
                                g.Eventually(IntegrationCondition(t, ctx, ns, 
name, v1.IntegrationConditionReady), TestTimeoutLong).Should(And(
                                        
WithTransform(IntegrationConditionReason, 
Equal(v1.IntegrationConditionRuntimeNotReadyReason)),
                                        
WithTransform(IntegrationConditionMessage, Equal(fmt.Sprintf("%d/3 pods are not 
ready", i+1)))))
@@ -147,7 +145,8 @@ func TestHealthTrait(t *testing.T) {
                        g.Expect(KamelRun(t, ctx, ns, "files/Java.java",
                                "-t", "health.enabled=true",
                                "-t", "jolokia.enabled=true", "-t", 
"jolokia.use-ssl-client-authentication=false",
-                               "-t", "jolokia.protocol=http", "--name", 
name).Execute()).To(Succeed())
+                               "-t", "jolokia.protocol=http",
+                               "--name", name).Execute()).To(Succeed())
 
                        g.Eventually(IntegrationPodPhase(t, ctx, ns, name), 
TestTimeoutLong).Should(Equal(corev1.PodRunning))
                        g.Eventually(IntegrationPhase(t, ctx, ns, name), 
TestTimeoutShort).Should(Equal(v1.IntegrationPhaseRunning))
@@ -242,7 +241,8 @@ func TestHealthTrait(t *testing.T) {
                                "--trait", "health.enabled=true",
                                "--trait", "jolokia.enabled=true",
                                "--trait", 
"jolokia.use-ssl-client-authentication=false",
-                               "--trait", "jolokia.protocol=http", "--name", 
name).Execute()).To(Succeed())
+                               "--trait", "jolokia.protocol=http",
+                               "--name", name).Execute()).To(Succeed())
 
                        g.Eventually(IntegrationPodPhase(t, ctx, ns, name), 
TestTimeoutLong).Should(Equal(corev1.PodRunning))
                        g.Eventually(IntegrationPhase(t, ctx, ns, name), 
TestTimeoutShort).Should(Equal(v1.IntegrationPhaseRunning))
@@ -347,7 +347,8 @@ func TestHealthTrait(t *testing.T) {
                t.Run("Readiness condition with never ready route", func(t 
*testing.T) {
                        name := RandomizedSuffixName("never-ready")
 
-                       g.Expect(KamelRun(t, ctx, ns, "files/NeverReady.java", 
"--name", name, "-t", "health.enabled=true",
+                       g.Expect(KamelRun(t, ctx, ns, "files/NeverReady.java", 
"--name", name,
+                               "-t", "health.enabled=true",
                                "-p", "camel.health.routesEnabled=false",
                        ).Execute()).To(Succeed())
 
diff --git a/e2e/common/traits/istio_test.go b/e2e/common/traits/istio_test.go
index 7f34e2234..6c04334aa 100644
--- a/e2e/common/traits/istio_test.go
+++ b/e2e/common/traits/istio_test.go
@@ -29,7 +29,6 @@ import (
        . "github.com/onsi/gomega"
 
        corev1 "k8s.io/api/core/v1"
-       "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
 
        . "github.com/apache/camel-k/v2/e2e/support"
        v1 "github.com/apache/camel-k/v2/pkg/apis/camel/v1"
@@ -50,14 +49,6 @@ func TestIstioTrait(t *testing.T) {
                        annotations := pod.ObjectMeta.Annotations
                        
g.Expect(annotations["sidecar.istio.io/inject"]).To(Equal("true"))
                        
g.Expect(annotations["traffic.sidecar.istio.io/includeOutboundIPRanges"]).To(Equal("10.0.0.0/8,172.16.0.0/12,192.168.0.0/16"))
-
-                       // check integration schema does not contains unwanted 
default trait value.
-                       g.Eventually(UnstructuredIntegration(t, ctx, ns, 
name)).ShouldNot(BeNil())
-                       unstructuredIntegration := UnstructuredIntegration(t, 
ctx, ns, name)()
-                       istioTrait, _, _ := 
unstructured.NestedMap(unstructuredIntegration.Object, "spec", "traits", 
"istio")
-                       g.Expect(istioTrait).ToNot(BeNil())
-                       g.Expect(len(istioTrait)).To(Equal(1))
-                       g.Expect(istioTrait["enabled"]).To(Equal(true))
                })
        })
 }
diff --git a/e2e/common/traits/jolokia_test.go 
b/e2e/common/traits/jolokia_test.go
index 12916f224..e2454b5de 100644
--- a/e2e/common/traits/jolokia_test.go
+++ b/e2e/common/traits/jolokia_test.go
@@ -30,7 +30,6 @@ import (
        . "github.com/onsi/gomega"
 
        corev1 "k8s.io/api/core/v1"
-       "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
 
        . "github.com/apache/camel-k/v2/e2e/support"
        v1 "github.com/apache/camel-k/v2/pkg/apis/camel/v1"
@@ -41,7 +40,14 @@ func TestJolokiaTrait(t *testing.T) {
        WithNewTestNamespace(t, func(ctx context.Context, g *WithT, ns string) {
                t.Run("Run Java with Jolokia", func(t *testing.T) {
                        name := RandomizedSuffixName("java")
-                       g.Expect(KamelRun(t, ctx, ns, "files/Java.java", 
"--name", name, "-t", "jolokia.enabled=true", "-t", 
"jolokia.use-ssl-client-authentication=false", "-t", "jolokia.protocol=http", 
"-t", "jolokia.extended-client-check=false").Execute()).To(Succeed())
+                       g.Expect(KamelRun(t, ctx, ns, "files/Java.java", 
"--name", name,
+                               "-t", "jolokia.enabled=true",
+                               "-t", 
"jolokia.use-ssl-client-authentication=false",
+                               "-t", "jolokia.protocol=http",
+                               "-t", "jolokia.extended-client-check=false",
+                               // TODO check if the WA is valid
+                               "--build-property", "jolokia=true",
+                       ).Execute()).To(Succeed())
                        g.Eventually(IntegrationPodPhase(t, ctx, ns, name), 
TestTimeoutLong).Should(Equal(corev1.PodRunning))
                        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!"))
@@ -51,18 +57,6 @@ func TestJolokiaTrait(t *testing.T) {
                                
AbsPath(fmt.Sprintf("/api/v1/namespaces/%s/pods/%s/proxy/jolokia/", ns, 
pod().Name)).DoRaw(ctx)
                        g.Expect(err).To(BeNil())
                        g.Expect(response).To(ContainSubstring(`"status":200`))
-
-                       // check integration schema does not contains unwanted 
default trait value.
-                       g.Eventually(UnstructuredIntegration(t, ctx, ns, 
name)).ShouldNot(BeNil())
-                       unstructuredIntegration := UnstructuredIntegration(t, 
ctx, ns, name)()
-                       jolokiaTrait, _, _ := 
unstructured.NestedMap(unstructuredIntegration.Object, "spec", "traits", 
"jolokia")
-                       g.Expect(jolokiaTrait).ToNot(BeNil())
-                       g.Expect(len(jolokiaTrait)).To(Equal(4))
-                       g.Expect(jolokiaTrait["enabled"]).To(Equal(true))
-                       
g.Expect(jolokiaTrait["useSSLClientAuthentication"]).To(Equal(false))
-                       g.Expect(jolokiaTrait["protocol"]).To(Equal("http"))
-                       
g.Expect(jolokiaTrait["extendedClientCheck"]).To(Equal(false))
-
                })
        })
 }
diff --git a/e2e/common/traits/jvm_test.go b/e2e/common/traits/jvm_test.go
index bc9e92041..a2c627e80 100644
--- a/e2e/common/traits/jvm_test.go
+++ b/e2e/common/traits/jvm_test.go
@@ -31,7 +31,6 @@ import (
        "github.com/stretchr/testify/require"
 
        corev1 "k8s.io/api/core/v1"
-       "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
 
        . "github.com/apache/camel-k/v2/e2e/support"
        v1 "github.com/apache/camel-k/v2/pkg/apis/camel/v1"
@@ -59,18 +58,6 @@ func TestJVMTrait(t *testing.T) {
                        g.Eventually(IntegrationPodPhase(t, ctx, ns, name), 
TestTimeoutLong).Should(Equal(corev1.PodRunning))
                        g.Eventually(IntegrationConditionStatus(t, ctx, ns, 
name, v1.IntegrationConditionReady), 
TestTimeoutShort).Should(Equal(corev1.ConditionTrue))
                        g.Eventually(IntegrationLogs(t, ctx, ns, name), 
TestTimeoutShort).Should(ContainSubstring("Hello World!"))
-
-                       // check integration schema does not contains unwanted 
default trait value.
-                       g.Eventually(UnstructuredIntegration(t, ctx, ns, 
name)).ShouldNot(BeNil())
-                       unstructuredIntegration := UnstructuredIntegration(t, 
ctx, ns, name)()
-                       jvmTrait, _, _ := 
unstructured.NestedMap(unstructuredIntegration.Object, "spec", "traits", "jvm")
-                       g.Expect(jvmTrait).ToNot(BeNil())
-                       g.Expect(len(jvmTrait)).To(Equal(1))
-                       
g.Expect(jvmTrait["classpath"]).To(Equal("/etc/camel/resources.d/_configmaps/my-deps/sample-1.0.jar"))
-                       mountTrait, _, _ := 
unstructured.NestedMap(unstructuredIntegration.Object, "spec", "traits", 
"mount")
-                       g.Expect(mountTrait).ToNot(BeNil())
-                       g.Expect(len(mountTrait)).To(Equal(1))
-
                })
 
                t.Run("JVM trait classpath on deprecated path", func(t 
*testing.T) {
@@ -83,18 +70,6 @@ func TestJVMTrait(t *testing.T) {
                        g.Eventually(IntegrationPodPhase(t, ctx, ns, name), 
TestTimeoutLong).Should(Equal(corev1.PodRunning))
                        g.Eventually(IntegrationConditionStatus(t, ctx, ns, 
name, v1.IntegrationConditionReady), 
TestTimeoutShort).Should(Equal(corev1.ConditionTrue))
                        g.Eventually(IntegrationLogs(t, ctx, ns, name), 
TestTimeoutShort).Should(ContainSubstring("Hello World!"))
-
-                       // check integration schema does not contains unwanted 
default trait value.
-                       g.Eventually(UnstructuredIntegration(t, ctx, ns, 
name)).ShouldNot(BeNil())
-                       unstructuredIntegration := UnstructuredIntegration(t, 
ctx, ns, name)()
-                       jvmTrait, _, _ := 
unstructured.NestedMap(unstructuredIntegration.Object, "spec", "traits", "jvm")
-                       g.Expect(jvmTrait).ToNot(BeNil())
-                       g.Expect(len(jvmTrait)).To(Equal(1))
-                       
g.Expect(jvmTrait["classpath"]).To(Equal("/etc/camel/resources/my-deps/sample-1.0.jar"))
-                       mountTrait, _, _ := 
unstructured.NestedMap(unstructuredIntegration.Object, "spec", "traits", 
"mount")
-                       g.Expect(mountTrait).ToNot(BeNil())
-                       g.Expect(len(mountTrait)).To(Equal(1))
-                       
g.Expect(mountTrait["resources"]).To(ContainElements("configmap:my-deps/sample-1.0.jar@/etc/camel/resources"))
                })
 
                t.Run("JVM trait classpath on specific classpath", func(t 
*testing.T) {
@@ -107,18 +82,6 @@ func TestJVMTrait(t *testing.T) {
                        g.Eventually(IntegrationPodPhase(t, ctx, ns, name), 
TestTimeoutLong).Should(Equal(corev1.PodRunning))
                        g.Eventually(IntegrationConditionStatus(t, ctx, ns, 
name, v1.IntegrationConditionReady), 
TestTimeoutShort).Should(Equal(corev1.ConditionTrue))
                        g.Eventually(IntegrationLogs(t, ctx, ns, name), 
TestTimeoutShort).Should(ContainSubstring("Hello World!"))
-
-                       // check integration schema does not contains unwanted 
default trait value.
-                       g.Eventually(UnstructuredIntegration(t, ctx, ns, 
name)).ShouldNot(BeNil())
-                       unstructuredIntegration := UnstructuredIntegration(t, 
ctx, ns, name)()
-                       jvmTrait, _, _ := 
unstructured.NestedMap(unstructuredIntegration.Object, "spec", "traits", "jvm")
-                       g.Expect(jvmTrait).ToNot(BeNil())
-                       g.Expect(len(jvmTrait)).To(Equal(1))
-                       
g.Expect(jvmTrait["classpath"]).To(Equal("/etc/other/resources/my-deps/sample-1.0.jar"))
-                       mountTrait, _, _ := 
unstructured.NestedMap(unstructuredIntegration.Object, "spec", "traits", 
"mount")
-                       g.Expect(mountTrait).ToNot(BeNil())
-                       g.Expect(len(mountTrait)).To(Equal(1))
-                       
g.Expect(mountTrait["resources"]).To(ContainElements("configmap:my-deps/sample-1.0.jar@/etc/other/resources"))
                })
        })
 }
diff --git a/e2e/common/traits/pdb_test.go b/e2e/common/traits/pdb_test.go
index 89758ded3..aa7bdb815 100644
--- a/e2e/common/traits/pdb_test.go
+++ b/e2e/common/traits/pdb_test.go
@@ -34,7 +34,6 @@ import (
        policyv1 "k8s.io/api/policy/v1"
        k8serrors "k8s.io/apimachinery/pkg/api/errors"
        metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
-       "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
        "k8s.io/apimachinery/pkg/util/intstr"
 
        ctrl "sigs.k8s.io/controller-runtime/pkg/client"
@@ -53,15 +52,6 @@ func TestPodDisruptionBudgetTrait(t *testing.T) {
                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!"))
 
-               // check integration schema does not contains unwanted default 
trait value.
-               g.Eventually(UnstructuredIntegration(t, ctx, ns, 
name)).ShouldNot(BeNil())
-               unstructuredIntegration := UnstructuredIntegration(t, ctx, ns, 
name)()
-               pdbTrait, _, _ := 
unstructured.NestedMap(unstructuredIntegration.Object, "spec", "traits", "pdb")
-               g.Expect(pdbTrait).ToNot(BeNil())
-               g.Expect(len(pdbTrait)).To(Equal(2))
-               g.Expect(pdbTrait["enabled"]).To(Equal(true))
-               g.Expect(pdbTrait["minAvailable"]).To(Equal("2"))
-
                // Check PodDisruptionBudget
                g.Eventually(podDisruptionBudget(t, ctx, ns, name), 
TestTimeoutShort).ShouldNot(BeNil())
                pdb := podDisruptionBudget(t, ctx, ns, name)()
diff --git a/e2e/common/traits/prometheus_test.go 
b/e2e/common/traits/prometheus_test.go
index 41e41b87e..940a32a08 100644
--- a/e2e/common/traits/prometheus_test.go
+++ b/e2e/common/traits/prometheus_test.go
@@ -33,7 +33,6 @@ import (
 
        corev1 "k8s.io/api/core/v1"
        k8serrors "k8s.io/apimachinery/pkg/api/errors"
-       "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
 
        ctrl "sigs.k8s.io/controller-runtime/pkg/client"
 
@@ -56,14 +55,6 @@ func TestPrometheusTrait(t *testing.T) {
                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!"))
 
-               // check integration schema does not contains unwanted default 
trait value.
-               g.Eventually(UnstructuredIntegration(t, ctx, ns, 
"java")).ShouldNot(BeNil())
-               unstructuredIntegration := UnstructuredIntegration(t, ctx, ns, 
"java")()
-               prometheusTrait, _, _ := 
unstructured.NestedMap(unstructuredIntegration.Object, "spec", "traits", 
"prometheus")
-               g.Expect(prometheusTrait).ToNot(BeNil())
-               g.Expect(len(prometheusTrait)).To(Equal(2))
-               g.Expect(prometheusTrait["enabled"]).To(Equal(true))
-               g.Expect(prometheusTrait["podMonitor"]).ToNot(BeNil())
                t.Run("Metrics endpoint works", func(t *testing.T) {
                        pod := IntegrationPod(t, ctx, ns, "java")
                        response, err := 
TestClient(t).CoreV1().RESTClient().Get().
diff --git a/e2e/common/traits/pull_secret_test.go 
b/e2e/common/traits/pull_secret_test.go
index 7249651cd..4910cf150 100644
--- a/e2e/common/traits/pull_secret_test.go
+++ b/e2e/common/traits/pull_secret_test.go
@@ -29,7 +29,6 @@ import (
        . "github.com/onsi/gomega"
 
        corev1 "k8s.io/api/core/v1"
-       "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
 
        . "github.com/apache/camel-k/v2/e2e/support"
        v1 "github.com/apache/camel-k/v2/pkg/apis/camel/v1"
@@ -60,14 +59,6 @@ func TestPullSecretTrait(t *testing.T) {
                        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!"))
 
-                       // check integration schema does not contains unwanted 
default trait value.
-                       g.Eventually(UnstructuredIntegration(t, ctx, ns, 
name)).ShouldNot(BeNil())
-                       unstructuredIntegration := UnstructuredIntegration(t, 
ctx, ns, name)()
-                       pullSecretTrait, _, _ := 
unstructured.NestedMap(unstructuredIntegration.Object, "spec", "traits", 
"pull-secret")
-                       g.Expect(pullSecretTrait).ToNot(BeNil())
-                       g.Expect(len(pullSecretTrait)).To(Equal(1))
-                       g.Expect(pullSecretTrait["enabled"]).To(Equal(false))
-
                        pod := IntegrationPod(t, ctx, ns, name)()
                        if ocp {
                                // OpenShift `default` service account has 
imagePullSecrets so it's always set
diff --git a/e2e/common/traits/route_test.go b/e2e/common/traits/route_test.go
index f6bba6d0c..1573b7c94 100644
--- a/e2e/common/traits/route_test.go
+++ b/e2e/common/traits/route_test.go
@@ -41,7 +41,6 @@ import (
        "github.com/stretchr/testify/require"
        corev1 "k8s.io/api/core/v1"
        metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
-       "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
 
        . "github.com/apache/camel-k/v2/e2e/support"
        "github.com/apache/camel-k/v2/pkg/util"
@@ -189,14 +188,6 @@ func TestRunRoutes(t *testing.T) {
                        route := RouteFull(t, ctx, ns, integrationName)()
                        var annotations = route.ObjectMeta.Annotations
                        
g.Expect(annotations["haproxy.router.openshift.io/balance"]).To(Equal("roundrobin"))
-
-                       // check integration schema does not contains unwanted 
default trait value.
-                       g.Eventually(UnstructuredIntegration(t, ctx, ns, 
integrationName)).ShouldNot(BeNil())
-                       unstructuredIntegration := UnstructuredIntegration(t, 
ctx, ns, integrationName)()
-                       routeTrait, _, _ := 
unstructured.NestedMap(unstructuredIntegration.Object, "spec", "traits", 
"route")
-                       g.Expect(routeTrait).ToNot(BeNil())
-                       g.Expect(len(routeTrait)).To(Equal(1))
-                       g.Expect(routeTrait["annotations"]).ToNot(BeNil())
                })
                g.Expect(TestClient(t).Delete(ctx, &secret)).To(Succeed())
        })
diff --git a/e2e/common/traits/service_test.go 
b/e2e/common/traits/service_test.go
index d7993e1f2..9fda55c3d 100644
--- a/e2e/common/traits/service_test.go
+++ b/e2e/common/traits/service_test.go
@@ -29,7 +29,6 @@ import (
        . "github.com/onsi/gomega"
 
        corev1 "k8s.io/api/core/v1"
-       "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
 
        . "github.com/apache/camel-k/v2/e2e/support"
 )
@@ -83,15 +82,6 @@ func TestServiceTrait(t *testing.T) {
                        // sometimes being created first and being given the 
root name
                        //
                        g.Eventually(ServicesByType(t, ctx, ns, 
corev1.ServiceTypeClusterIP), TestTimeoutLong).ShouldNot(BeEmpty())
-
-                       // check integration schema does not contains unwanted 
default trait value.
-                       g.Eventually(UnstructuredIntegration(t, ctx, ns, 
"platform-http-server")).ShouldNot(BeNil())
-                       unstructuredIntegration := UnstructuredIntegration(t, 
ctx, ns, "platform-http-server")()
-                       serviceTrait, _, _ := 
unstructured.NestedMap(unstructuredIntegration.Object, "spec", "traits", 
"service")
-                       g.Expect(serviceTrait).ToNot(BeNil())
-                       g.Expect(len(serviceTrait)).To(Equal(2))
-                       g.Expect(serviceTrait["enabled"]).To(Equal(true))
-                       g.Expect(serviceTrait["type"]).To(Equal("ClusterIP"))
                })
 
                t.Run("LoadBalancer service from Type", func(t *testing.T) {
diff --git a/e2e/native/native_test.go b/e2e/native/native_test.go
index beb2fe0a0..8c7f006aa 100644
--- a/e2e/native/native_test.go
+++ b/e2e/native/native_test.go
@@ -29,7 +29,6 @@ import (
        . "github.com/onsi/gomega"
 
        corev1 "k8s.io/api/core/v1"
-       "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
 
        . "github.com/apache/camel-k/v2/e2e/support"
        v1 "github.com/apache/camel-k/v2/pkg/apis/camel/v1"
@@ -44,14 +43,6 @@ func TestNativeIntegrations(t *testing.T) {
                        g.Eventually(IntegrationPhase(t, ctx, ns, 
name)).Should(Equal(v1.IntegrationPhaseError))
                        g.Eventually(IntegrationConditionStatus(t, ctx, ns, 
name, v1.IntegrationConditionKitAvailable)).
                                Should(Equal(corev1.ConditionFalse))
-
-                       // check integration schema does not contains unwanted 
default trait value.
-                       g.Eventually(UnstructuredIntegration(t, ctx, ns, 
name)).ShouldNot(BeNil())
-                       unstructuredIntegration := UnstructuredIntegration(t, 
ctx, ns, name)()
-                       quarkusTrait, _, _ := 
unstructured.NestedMap(unstructuredIntegration.Object, "spec", "traits", 
"quarkus")
-                       g.Expect(quarkusTrait).ToNot(BeNil())
-                       g.Expect(len(quarkusTrait)).To(Equal(1))
-                       g.Expect(quarkusTrait["buildMode"]).ToNot(BeNil())
                })
 
                t.Run("xml native support", func(t *testing.T) {
diff --git a/e2e/support/test_support.go b/e2e/support/test_support.go
index 5c13723f2..e3467b229 100644
--- a/e2e/support/test_support.go
+++ b/e2e/support/test_support.go
@@ -56,7 +56,6 @@ import (
        rbacv1 "k8s.io/api/rbac/v1"
        k8serrors "k8s.io/apimachinery/pkg/api/errors"
        metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
-       "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
        "k8s.io/apimachinery/pkg/labels"
        "k8s.io/apimachinery/pkg/runtime/schema"
        "k8s.io/apimachinery/pkg/runtime/serializer"
@@ -1046,28 +1045,6 @@ func Integration(t *testing.T, ctx context.Context, ns 
string, name string) func
        }
 }
 
-func UnstructuredIntegration(t *testing.T, ctx context.Context, ns string, 
name string) func() *unstructured.Unstructured {
-       return func() *unstructured.Unstructured {
-               gvk := schema.GroupVersionKind{Group: 
v1.SchemeGroupVersion.Group, Version: v1.SchemeGroupVersion.Version, Kind: 
v1.IntegrationKind}
-               return UnstructuredObject(t, ctx, ns, name, gvk)()
-       }
-}
-
-func UnstructuredObject(t *testing.T, ctx context.Context, ns string, name 
string, gvk schema.GroupVersionKind) func() *unstructured.Unstructured {
-       return func() *unstructured.Unstructured {
-               object := &unstructured.Unstructured{}
-               object.SetNamespace(ns)
-               object.SetName(name)
-               object.SetGroupVersionKind(gvk)
-               if err := TestClient(t).Get(ctx, 
ctrl.ObjectKeyFromObject(object), object); err != nil && 
!k8serrors.IsNotFound(err) {
-                       failTest(t, err)
-               } else if err != nil && k8serrors.IsNotFound(err) {
-                       return nil
-               }
-               return object
-       }
-}
-
 func IntegrationVersion(t *testing.T, ctx context.Context, ns string, name 
string) func() string {
        return func() string {
                it := Integration(t, ctx, ns, name)()
@@ -2439,25 +2416,51 @@ func ConsoleCLIDownload(t *testing.T, ctx 
context.Context, name string) func() *
        }
 }
 
+func operatorPods(t *testing.T, ctx context.Context, ns string) []corev1.Pod {
+       lst := corev1.PodList{
+               TypeMeta: metav1.TypeMeta{
+                       Kind:       "Pod",
+                       APIVersion: v1.SchemeGroupVersion.String(),
+               },
+       }
+       opts := []ctrl.ListOption{
+               ctrl.MatchingLabels{
+                       "camel.apache.org/component": "operator",
+               },
+       }
+       if ns != "" {
+               opts = append(opts, ctrl.InNamespace(ns))
+       }
+       if err := TestClient(t).List(ctx, &lst, opts...); err != nil {
+               failTest(t, err)
+       }
+       if len(lst.Items) == 0 {
+               return nil
+       }
+       return lst.Items
+}
+
 func OperatorPod(t *testing.T, ctx context.Context, ns string) func() 
*corev1.Pod {
        return func() *corev1.Pod {
-               lst := corev1.PodList{
-                       TypeMeta: metav1.TypeMeta{
-                               Kind:       "Pod",
-                               APIVersion: v1.SchemeGroupVersion.String(),
-                       },
-               }
-               if err := TestClient(t).List(ctx, &lst,
-                       ctrl.InNamespace(ns),
-                       ctrl.MatchingLabels{
-                               "camel.apache.org/component": "operator",
-                       }); err != nil {
-                       failTest(t, err)
-               }
-               if len(lst.Items) == 0 {
-                       return nil
+               pods := operatorPods(t, ctx, ns)
+               return &pods[0]
+       }
+}
+
+// Return the first global operator Pod found in the cluster (if any).
+func OperatorPodGlobal(t *testing.T, ctx context.Context) func() *corev1.Pod {
+       return func() *corev1.Pod {
+               pods := operatorPods(t, ctx, "")
+               for _, pod := range pods {
+                       for _, envVar := range pod.Spec.Containers[0].Env {
+                               if envVar.Name == "WATCH_NAMESPACE" {
+                                       if envVar.Value == "" {
+                                               return &pod
+                                       }
+                               }
+                       }
                }
-               return &lst.Items[0]
+               return nil
        }
 }
 
diff --git a/e2e/telemetry/telemetry_test.go b/e2e/telemetry/telemetry_test.go
index e08dc8ac4..e12216126 100644
--- a/e2e/telemetry/telemetry_test.go
+++ b/e2e/telemetry/telemetry_test.go
@@ -30,7 +30,6 @@ import (
        . "github.com/onsi/gomega"
 
        corev1 "k8s.io/api/core/v1"
-       "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
 
        . "github.com/apache/camel-k/v2/e2e/support"
 )
@@ -69,17 +68,5 @@ func TestTelemetryTrait(t *testing.T) {
                // Ensured logs in opentelemetry collector pod are present
                g.Eventually(TailedLogs(t, ctx, pod.Namespace, pod.Name, 100), 
TestTimeoutLong).Should(ContainSubstring(fmt.Sprintf("http.target: 
Str(/customers/%s)", name)))
                g.Eventually(TailedLogs(t, ctx, pod.Namespace, pod.Name, 100), 
TestTimeoutLong).Should(ContainSubstring(fmt.Sprintf("http.url: 
Str(http://%s/customers/%s)", serviceName, name)))
-
-               // check integration schema does not contains unwanted default 
trait value.
-               g.Eventually(UnstructuredIntegration(t, ctx, ns, 
"rest-consumer")).ShouldNot(BeNil())
-               unstructuredIntegration := UnstructuredIntegration(t, ctx, ns, 
"rest-consumer")()
-               builderTrait, _, _ := 
unstructured.NestedMap(unstructuredIntegration.Object, "spec", "traits", 
"addons", "telemetry")
-               g.Expect(builderTrait).NotTo(BeNil())
-               g.Expect(len(builderTrait)).To(Equal(2))
-               g.Expect(builderTrait["enabled"]).To(Equal(true))
-               
g.Expect(builderTrait["endpoint"]).To(Equal("http://opentelemetrycollector.otlp:4317";))
-
-               // Clean up
-               g.Expect(Kamel(t, ctx, "delete", "--all", "-n", 
ns).Execute()).To(Succeed())
        })
 }


Reply via email to