knockknock10 commented on code in PR #6967: URL: https://github.com/apache/camel-k/pull/6967#discussion_r4583706125
########## e2e/common/traits/environment_test.go: ########## @@ -0,0 +1,113 @@ +//go:build integration +// +build integration + +// To enable compilation of this file in Goland, go to "Settings -> Go -> Vendoring & Build Tags -> Custom Tags" and add "integration" + +/* +Licensed to the Apache Software Foundation (ASF) under one or more +contributor license agreements. See the NOTICE file distributed with +this work for additional information regarding copyright ownership. +The ASF licenses this file to You under the Apache License, Version 2.0 +(the "License"); you may not use this file except in compliance with +the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package common + +import ( + "context" + "testing" + + . "github.com/onsi/gomega" + + 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 TestEnvironmentTrait(t *testing.T) { + t.Parallel() + + WithNewTestNamespace(t, func(ctx context.Context, g *WithT, ns string) { + t.Run("custom variables and container metadata are available to the route", func(t *testing.T) { + name := RandomizedSuffixName("environment-enabled") + customValue := "environment-trait-e2e-value" + + g.Expect(KamelRun(t, ctx, ns, "files/EnvironmentTrait.java", + "--name", name, + "-t", "environment.container-meta=true", + "-t", "environment.vars=CAMEL_K_TEST_VALUE="+customValue, + ).Execute()).To(Succeed()) + + g.Eventually(IntegrationConditionStatus(t, ctx, ns, name, v1.IntegrationConditionReady), TestTimeoutLong). + Should(Equal(corev1.ConditionTrue)) + g.Eventually(IntegrationPodPhase(t, ctx, ns, name), TestTimeoutLong).Should(Equal(corev1.PodRunning)) + + pod := IntegrationPod(t, ctx, ns, name)() + g.Expect(pod).NotTo(BeNil()) + g.Expect(pod.Spec.Containers).To(HaveLen(1)) + + envVars := make(map[string]corev1.EnvVar) Review Comment: > Why exporting to a new var? Could not we check directly the Pod item array instead? You're right. I've updated it to check `pod.Spec.Containers[0].Env` directly, without exporting it to a separate variable. Thanks! -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
