This is an automated email from the ASF dual-hosted git repository.

pcongiusti pushed a commit to branch release-2.0.x
in repository https://gitbox.apache.org/repos/asf/camel-k.git

commit 556fe54505854fe8ec6cc5026ac97cc335a787e4
Author: Gaelle Fournier <gaelle.fournier.w...@gmail.com>
AuthorDate: Tue Dec 5 17:05:03 2023 +0100

    chore(e2e): Refactor resources number const
---
 e2e/install/kustomize/common.go          | 117 -------------------------------
 e2e/install/upgrade/helm_upgrade_test.go |   4 +-
 e2e/support/test_support.go              |  24 +++++++
 3 files changed, 26 insertions(+), 119 deletions(-)

diff --git a/e2e/install/kustomize/common.go b/e2e/install/kustomize/common.go
deleted file mode 100644
index 88009ccfd..000000000
--- a/e2e/install/kustomize/common.go
+++ /dev/null
@@ -1,117 +0,0 @@
-//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 kustomize
-
-import (
-       "os/exec"
-       "strings"
-       "testing"
-
-       . "github.com/apache/camel-k/v2/e2e/support"
-       . "github.com/onsi/gomega"
-       "github.com/onsi/gomega/gexec"
-       "github.com/stretchr/testify/assert"
-)
-
-const (
-       // v1.Build,          v1.Integration
-       // v1.IntegrationKit, v1.IntegrationPlatform
-       // v1.Kamelet,  v1.Pipe,
-       // v1alpha1.Kamelet, v1alpha1.KameletBinding
-       ExpectedCRDs = 8
-
-       // camel-k-operator,             camel-k-operator-events,
-       // camel-k-operator-knative,     camel-k-operator-leases,
-       // camel-k-operator-podmonitors, camel-k-operator-strimzi,
-       // camel-k-operator-keda
-       ExpectedKubePromoteRoles = 7
-
-       // camel-k-edit
-       // camel-k-operator-custom-resource-definitions
-       // camel-k-operator-bind-addressable-resolver
-       // camel-k-operator-local-registry
-       ExpectedKubeClusterRoles = 4
-
-       // camel-k-operator-openshift
-       ExpectedOSPromoteRoles = 1
-
-       // camel-k-operator-console-openshift
-       ExpectedOSClusterRoles = 1
-)
-
-func ExpectExecSucceed(t *testing.T, command *exec.Cmd) {
-       t.Helper()
-
-       var cmdOut strings.Builder
-       var cmdErr strings.Builder
-
-       defer func() {
-               if t.Failed() {
-                       t.Logf("Output from make command:\n%s\n", 
cmdOut.String())
-                       t.Logf("Error from make command:\n%s\n", 
cmdErr.String())
-               }
-       }()
-
-       session, err := gexec.Start(command, &cmdOut, &cmdErr)
-       session.Wait()
-       Eventually(session).Should(gexec.Exit(0))
-       assert.NoError(t, err)
-       assert.NotContains(t, strings.ToUpper(cmdErr.String()), "ERROR")
-}
-
-//
-// Expect a command error with an exit code of 1
-//
-func ExpectExecError(t *testing.T, command *exec.Cmd) {
-       t.Helper()
-
-       var cmdOut strings.Builder
-       var cmdErr strings.Builder
-
-       defer func() {
-               if t.Failed() {
-                       t.Logf("Output from make command:\n%s\n", 
cmdOut.String())
-                       t.Logf("Error from make command:\n%s\n", 
cmdErr.String())
-               }
-       }()
-
-       session, err := gexec.Start(command, &cmdOut, &cmdErr)
-       session.Wait()
-       Eventually(session).ShouldNot(gexec.Exit(0))
-       assert.NoError(t, err)
-       assert.Contains(t, strings.ToUpper(cmdErr.String()), "ERROR")
-}
-
-// Clean up the cluster ready for the next set of tests
-func Cleanup() {
-       // Remove the locally installed operator
-       UninstallAll()
-
-       // Ensure the CRDs & ClusterRoles are reinstalled if not already
-       Kamel("install", "--olm=false", "--cluster-setup").Execute()
-}
-
-// Removes all items
-func UninstallAll() {
-       Kamel("uninstall", "--olm=false", "--all").Execute()
-}
diff --git a/e2e/install/upgrade/helm_upgrade_test.go 
b/e2e/install/upgrade/helm_upgrade_test.go
index 768da149c..f966acb42 100644
--- a/e2e/install/upgrade/helm_upgrade_test.go
+++ b/e2e/install/upgrade/helm_upgrade_test.go
@@ -67,7 +67,7 @@ func TestHelmOperatorUpgrade(t *testing.T) {
 
                Eventually(OperatorPod(ns)).ShouldNot(BeNil())
                
Eventually(OperatorImage(ns)).Should(ContainSubstring(releaseVersion))
-               Eventually(CRDs()).Should(HaveLen(8))
+               Eventually(CRDs()).Should(HaveLen(ExpectedCRDs))
 
                //Test a simple route
                t.Run("simple route", func(t *testing.T) {
@@ -132,7 +132,7 @@ func TestHelmOperatorUpgrade(t *testing.T) {
                Eventually(OperatorPod(ns)).Should(BeNil())
 
                //  helm does not remove the CRDs
-               Eventually(CRDs()).Should(HaveLen(8))
+               Eventually(CRDs()).Should(HaveLen(ExpectedCRDs))
                ExpectExecSucceed(t,
                        exec.Command(
                                "kubectl",
diff --git a/e2e/support/test_support.go b/e2e/support/test_support.go
index d6908752e..4677e296b 100644
--- a/e2e/support/test_support.go
+++ b/e2e/support/test_support.go
@@ -92,6 +92,30 @@ import (
 const kubeConfigEnvVar = "KUBECONFIG"
 const ciPID = "/tmp/ci-k8s-pid"
 
+// v1.Build,          v1.Integration
+// v1.IntegrationKit, v1.IntegrationPlatform
+// v1.Kamelet,  v1.Pipe,
+// v1alpha1.Kamelet, v1alpha1.KameletBinding
+const ExpectedCRDs = 8
+
+// camel-k-operator,             camel-k-operator-events,
+// camel-k-operator-knative,     camel-k-operator-leases,
+// camel-k-operator-podmonitors, camel-k-operator-strimzi,
+// camel-k-operator-keda
+const ExpectedKubePromoteRoles = 7
+
+// camel-k-edit
+// camel-k-operator-custom-resource-definitions
+// camel-k-operator-bind-addressable-resolver
+// camel-k-operator-local-registry
+const ExpectedKubeClusterRoles = 4
+
+// camel-k-operator-openshift
+const ExpectedOSPromoteRoles = 1
+
+// camel-k-operator-console-openshift
+const ExpectedOSClusterRoles = 1
+
 var TestTimeoutShort = 1 * time.Minute
 var TestTimeoutMedium = 5 * time.Minute
 var TestTimeoutLong = 15 * time.Minute

Reply via email to