squakez commented on code in PR #6997:
URL: https://github.com/apache/camel-k/pull/6997#discussion_r4766213556


##########
e2e/common/traits/deployer_test.go:
##########
@@ -0,0 +1,102 @@
+//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 TestDeployerRollsBackFailedIntegrationUpgrade(t *testing.T) {
+       t.Parallel()
+
+       WithNewTestNamespace(t, func(ctx context.Context, g *WithT, ns string) {
+               name := RandomizedSuffixName("rollback")
+
+               // Start with a working generation so the test can verify it 
survives
+               // a later deployment failure.
+               g.Expect(KamelRun(t, ctx, ns, "files/Java.java", "--name", 
name).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).

Review Comment:
   ```suggestion
                g.Eventually(IntegrationPodPhase(t, ctx, ns, name)).
   ```



##########
e2e/common/traits/deployer_test.go:
##########
@@ -0,0 +1,102 @@
+//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 TestDeployerRollsBackFailedIntegrationUpgrade(t *testing.T) {
+       t.Parallel()
+
+       WithNewTestNamespace(t, func(ctx context.Context, g *WithT, ns string) {
+               name := RandomizedSuffixName("rollback")
+
+               // Start with a working generation so the test can verify it 
survives
+               // a later deployment failure.
+               g.Expect(KamelRun(t, ctx, ns, "files/Java.java", "--name", 
name).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))
+
+               previousDeployment := Deployment(t, ctx, ns, name)()
+               if previousDeployment == nil {
+                       g.Expect(previousDeployment).NotTo(BeNil())
+
+                       return

Review Comment:
   I think we may avoid the return statement. The test should fail if the 
expectation is not met.



##########
e2e/common/traits/deployer_test.go:
##########
@@ -0,0 +1,102 @@
+//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 TestDeployerRollsBackFailedIntegrationUpgrade(t *testing.T) {
+       t.Parallel()
+
+       WithNewTestNamespace(t, func(ctx context.Context, g *WithT, ns string) {
+               name := RandomizedSuffixName("rollback")
+
+               // Start with a working generation so the test can verify it 
survives
+               // a later deployment failure.
+               g.Expect(KamelRun(t, ctx, ns, "files/Java.java", "--name", 
name).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))
+
+               previousDeployment := Deployment(t, ctx, ns, name)()
+               if previousDeployment == nil {
+                       g.Expect(previousDeployment).NotTo(BeNil())
+
+                       return
+               }
+
+               previousGeneration := 
previousDeployment.Labels[v1.IntegrationGenerationLabel]
+               if previousGeneration == "" {
+                       g.Expect(previousGeneration).NotTo(BeEmpty())
+
+                       return
+               }
+
+               // A Service port above Kubernetes' allowed range is parsed by 
the trait
+               // but rejected by the API server, after the Deployment has 
been updated.
+               g.Expect(KamelRun(t, ctx, ns, "files/Java.java", "--name", name,
+                       "-t", "container.ports=hello;8085",
+                       "-t", "service.ports=hello;70000;8085",

Review Comment:
   I think it would be good to add a Service also in the first generation. It 
would be a valid service in that situation and we can also check the Service 
generation 1 would still stand after rollback.



##########
e2e/common/traits/deployer_test.go:
##########
@@ -0,0 +1,102 @@
+//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 TestDeployerRollsBackFailedIntegrationUpgrade(t *testing.T) {
+       t.Parallel()
+
+       WithNewTestNamespace(t, func(ctx context.Context, g *WithT, ns string) {
+               name := RandomizedSuffixName("rollback")
+
+               // Start with a working generation so the test can verify it 
survives
+               // a later deployment failure.
+               g.Expect(KamelRun(t, ctx, ns, "files/Java.java", "--name", 
name).Execute()).To(Succeed())
+               g.Eventually(IntegrationConditionStatus(t, ctx, ns, name, 
v1.IntegrationConditionReady), TestTimeoutLong).

Review Comment:
   ```suggestion
                g.Eventually(IntegrationConditionStatus(t, ctx, ns, name, 
v1.IntegrationConditionReady), TestTimeoutMedium).
   ```



##########
e2e/common/traits/deployer_test.go:
##########
@@ -0,0 +1,102 @@
+//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 TestDeployerRollsBackFailedIntegrationUpgrade(t *testing.T) {
+       t.Parallel()
+
+       WithNewTestNamespace(t, func(ctx context.Context, g *WithT, ns string) {
+               name := RandomizedSuffixName("rollback")
+
+               // Start with a working generation so the test can verify it 
survives
+               // a later deployment failure.
+               g.Expect(KamelRun(t, ctx, ns, "files/Java.java", "--name", 
name).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))
+
+               previousDeployment := Deployment(t, ctx, ns, name)()
+               if previousDeployment == nil {
+                       g.Expect(previousDeployment).NotTo(BeNil())
+
+                       return
+               }
+
+               previousGeneration := 
previousDeployment.Labels[v1.IntegrationGenerationLabel]
+               if previousGeneration == "" {
+                       g.Expect(previousGeneration).NotTo(BeEmpty())
+
+                       return
+               }
+
+               // A Service port above Kubernetes' allowed range is parsed by 
the trait
+               // but rejected by the API server, after the Deployment has 
been updated.
+               g.Expect(KamelRun(t, ctx, ns, "files/Java.java", "--name", name,
+                       "-t", "container.ports=hello;8085",
+                       "-t", "service.ports=hello;70000;8085",
+               ).Execute()).To(Succeed())
+
+               g.Eventually(IntegrationPhase(t, ctx, ns, name), 
TestTimeoutMedium).
+                       Should(Equal(v1.IntegrationPhaseError))
+               g.Eventually(IntegrationConditionStatus(t, ctx, ns, name, 
v1.IntegrationConditionReady), TestTimeoutMedium).
+                       Should(Equal(corev1.ConditionFalse))
+               g.Eventually(func() string {
+                       condition := IntegrationCondition(t, ctx, ns, name, 
v1.IntegrationConditionReady)()
+                       if condition == nil {
+                               return ""
+                       }
+
+                       return condition.Message
+               }, TestTimeoutMedium).Should(ContainSubstring("previous 
generation has been preserved"))
+
+               g.Eventually(func() string {
+                       deployment := Deployment(t, ctx, ns, name)()
+                       if deployment == nil {
+                               return ""
+                       }
+
+                       return deployment.Labels[v1.IntegrationGenerationLabel]
+               }, TestTimeoutMedium).Should(Equal(previousGeneration))
+
+               // Restoring the Deployment recreates its pod; wait until the 
previous
+               // generation is serving again before considering the rollback 
complete.
+               g.Eventually(IntegrationPodPhase(t, ctx, ns, name), 
TestTimeoutLong).
+                       Should(Equal(corev1.PodRunning))
+               g.Eventually(IntegrationLogs(t, ctx, ns, name), 
TestTimeoutLong).

Review Comment:
   ```suggestion
                g.Eventually(IntegrationLogs(t, ctx, ns, name)).
   ```



##########
e2e/common/traits/deployer_test.go:
##########
@@ -0,0 +1,102 @@
+//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 TestDeployerRollsBackFailedIntegrationUpgrade(t *testing.T) {
+       t.Parallel()
+
+       WithNewTestNamespace(t, func(ctx context.Context, g *WithT, ns string) {
+               name := RandomizedSuffixName("rollback")
+
+               // Start with a working generation so the test can verify it 
survives
+               // a later deployment failure.
+               g.Expect(KamelRun(t, ctx, ns, "files/Java.java", "--name", 
name).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))
+
+               previousDeployment := Deployment(t, ctx, ns, name)()
+               if previousDeployment == nil {
+                       g.Expect(previousDeployment).NotTo(BeNil())
+
+                       return
+               }
+
+               previousGeneration := 
previousDeployment.Labels[v1.IntegrationGenerationLabel]
+               if previousGeneration == "" {
+                       g.Expect(previousGeneration).NotTo(BeEmpty())
+
+                       return

Review Comment:
   Ditto



##########
e2e/common/traits/deployer_test.go:
##########
@@ -0,0 +1,102 @@
+//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 TestDeployerRollsBackFailedIntegrationUpgrade(t *testing.T) {
+       t.Parallel()
+
+       WithNewTestNamespace(t, func(ctx context.Context, g *WithT, ns string) {
+               name := RandomizedSuffixName("rollback")
+
+               // Start with a working generation so the test can verify it 
survives
+               // a later deployment failure.
+               g.Expect(KamelRun(t, ctx, ns, "files/Java.java", "--name", 
name).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))
+
+               previousDeployment := Deployment(t, ctx, ns, name)()
+               if previousDeployment == nil {
+                       g.Expect(previousDeployment).NotTo(BeNil())
+
+                       return
+               }
+
+               previousGeneration := 
previousDeployment.Labels[v1.IntegrationGenerationLabel]
+               if previousGeneration == "" {
+                       g.Expect(previousGeneration).NotTo(BeEmpty())
+
+                       return
+               }
+
+               // A Service port above Kubernetes' allowed range is parsed by 
the trait
+               // but rejected by the API server, after the Deployment has 
been updated.
+               g.Expect(KamelRun(t, ctx, ns, "files/Java.java", "--name", name,
+                       "-t", "container.ports=hello;8085",
+                       "-t", "service.ports=hello;70000;8085",
+               ).Execute()).To(Succeed())
+
+               g.Eventually(IntegrationPhase(t, ctx, ns, name), 
TestTimeoutMedium).
+                       Should(Equal(v1.IntegrationPhaseError))
+               g.Eventually(IntegrationConditionStatus(t, ctx, ns, name, 
v1.IntegrationConditionReady), TestTimeoutMedium).
+                       Should(Equal(corev1.ConditionFalse))
+               g.Eventually(func() string {
+                       condition := IntegrationCondition(t, ctx, ns, name, 
v1.IntegrationConditionReady)()
+                       if condition == nil {
+                               return ""
+                       }
+
+                       return condition.Message
+               }, TestTimeoutMedium).Should(ContainSubstring("previous 
generation has been preserved"))
+
+               g.Eventually(func() string {
+                       deployment := Deployment(t, ctx, ns, name)()
+                       if deployment == nil {
+                               return ""
+                       }
+
+                       return deployment.Labels[v1.IntegrationGenerationLabel]
+               }, TestTimeoutMedium).Should(Equal(previousGeneration))
+
+               // Restoring the Deployment recreates its pod; wait until the 
previous
+               // generation is serving again before considering the rollback 
complete.
+               g.Eventually(IntegrationPodPhase(t, ctx, ns, name), 
TestTimeoutLong).

Review Comment:
   ```suggestion
                g.Eventually(IntegrationPodPhase(t, ctx, ns, name), 
TestTimeoutMedium).
   ```



-- 
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]

Reply via email to