This is an automated email from the ASF dual-hosted git repository. tsato pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/camel-k.git
commit 5c8cc53e8ec34567030e818da1fe51f1aac6fb2c Author: Tadayoshi Sato <[email protected]> AuthorDate: Wed Nov 30 16:24:43 2022 +0900 chore(e2e): polish kustomize tests --- e2e/namespace/install/kustomize/common.go | 14 ++++++------ e2e/namespace/install/kustomize/operator_test.go | 6 +++--- e2e/namespace/install/kustomize/setup_test.go | 26 +++++++++++------------ e2e/support/test_support.go | 27 ++++++++++++------------ 4 files changed, 36 insertions(+), 37 deletions(-) diff --git a/e2e/namespace/install/kustomize/common.go b/e2e/namespace/install/kustomize/common.go index adcc1ce5d..f697e43a6 100644 --- a/e2e/namespace/install/kustomize/common.go +++ b/e2e/namespace/install/kustomize/common.go @@ -37,25 +37,25 @@ const ( // v1.Build, v1.Integration // v1.IntegrationKit, v1.IntegrationPlatform // v1alpha1.Kamelet, v1alpha1.KameletBinding - ExpCrds = 6 + ExpectedCRDs = 6 - // camel-k-operator, camel-k-operator-events, - // camel-k-operator-knative, camel-k-operator-leases, + // 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 - ExpKubePromoteRoles = 7 + ExpectedKubePromoteRoles = 7 // camel-k-edit // camel-k-operator-custom-resource-definitions // camel-k-operator-bind-addressable-resolver // camel-k-operator-local-registry - ExpKubeClusterRoles = 4 + ExpectedKubeClusterRoles = 4 // camel-k-operator-openshift - ExpOSPromoteRoles = 1 + ExpectedOSPromoteRoles = 1 // camel-k-operator-console-openshift - ExpOSClusterRoles = 1 + ExpectedOSClusterRoles = 1 ) func ExecMake(t *testing.T, command *exec.Cmd) { diff --git a/e2e/namespace/install/kustomize/operator_test.go b/e2e/namespace/install/kustomize/operator_test.go index a6a9f8738..1992548a9 100644 --- a/e2e/namespace/install/kustomize/operator_test.go +++ b/e2e/namespace/install/kustomize/operator_test.go @@ -32,7 +32,7 @@ import ( ) func TestBasicOperator(t *testing.T) { - os.Setenv("MAKE_DIR", "../../../../install") + os.Setenv("CAMEL_K_TEST_MAKE_DIR", "../../../../install") // Ensure no CRDs are already installed UninstallAll() @@ -50,7 +50,7 @@ func TestBasicOperator(t *testing.T) { } func TestAlternativeImageOperator(t *testing.T) { - os.Setenv("MAKE_DIR", "../../../../install") + os.Setenv("CAMEL_K_TEST_MAKE_DIR", "../../../../install") // Ensure no CRDs are already installed UninstallAll() @@ -72,7 +72,7 @@ func TestAlternativeImageOperator(t *testing.T) { } func TestGlobalOperator(t *testing.T) { - os.Setenv("MAKE_DIR", "../../../../install") + os.Setenv("CAMEL_K_TEST_MAKE_DIR", "../../../../install") // Ensure no CRDs are already installed UninstallAll() diff --git a/e2e/namespace/install/kustomize/setup_test.go b/e2e/namespace/install/kustomize/setup_test.go index 2ace67ab3..18cb75b5d 100644 --- a/e2e/namespace/install/kustomize/setup_test.go +++ b/e2e/namespace/install/kustomize/setup_test.go @@ -32,7 +32,7 @@ import ( ) func TestBasicSetup(t *testing.T) { - os.Setenv("MAKE_DIR", "../../../../install") + os.Setenv("CAMEL_K_TEST_MAKE_DIR", "../../../../install") // Ensure no CRDs are already installed UninstallAll() @@ -42,17 +42,17 @@ func TestBasicSetup(t *testing.T) { WithNewTestNamespace(t, func(ns string) { ExecMake(t, Make("setup-cluster", fmt.Sprintf("NAMESPACE=%s", ns))) - Eventually(CRDs()).Should(HaveLen(ExpCrds)) + Eventually(CRDs()).Should(HaveLen(ExpectedCRDs)) ExecMake(t, Make("setup", fmt.Sprintf("NAMESPACE=%s", ns))) - kroles := ExpKubePromoteRoles - osroles := kroles + ExpOSPromoteRoles - Eventually(Role(ns)).Should(Or(HaveLen(kroles), HaveLen(osroles))) + kpRoles := ExpectedKubePromoteRoles + opRoles := kpRoles + ExpectedOSPromoteRoles + Eventually(Role(ns)).Should(Or(HaveLen(kpRoles), HaveLen(opRoles))) - kcroles := ExpKubeClusterRoles - oscroles := kcroles + ExpOSClusterRoles - Eventually(ClusterRole()).Should(Or(HaveLen(kcroles), HaveLen(oscroles))) + kcRoles := ExpectedKubeClusterRoles + ocRoles := kcRoles + ExpectedOSClusterRoles + Eventually(ClusterRole()).Should(Or(HaveLen(kcRoles), HaveLen(ocRoles))) // Tidy up to ensure next test works Expect(Kamel("uninstall", "-n", ns).Execute()).To(Succeed()) @@ -61,7 +61,7 @@ func TestBasicSetup(t *testing.T) { } func TestGlobalSetup(t *testing.T) { - os.Setenv("MAKE_DIR", "../../../../install") + os.Setenv("CAMEL_K_TEST_MAKE_DIR", "../../../../install") // Ensure no CRDs are already installed UninstallAll() @@ -71,14 +71,14 @@ func TestGlobalSetup(t *testing.T) { WithNewTestNamespace(t, func(ns string) { ExecMake(t, Make("setup-cluster", fmt.Sprintf("NAMESPACE=%s", ns))) - Eventually(CRDs()).Should(HaveLen(ExpCrds)) + Eventually(CRDs()).Should(HaveLen(ExpectedCRDs)) ExecMake(t, Make("setup", "GLOBAL=true", fmt.Sprintf("NAMESPACE=%s", ns))) Eventually(Role(ns)).Should(HaveLen(0)) - kcroles := ExpKubeClusterRoles + ExpKubePromoteRoles - oscroles := kcroles + ExpOSClusterRoles + ExpOSPromoteRoles - Eventually(ClusterRole()).Should(Or(HaveLen(kcroles), HaveLen(oscroles))) + kcpRoles := ExpectedKubeClusterRoles + ExpectedKubePromoteRoles + ocpRoles := kcpRoles + ExpectedOSClusterRoles + ExpectedOSPromoteRoles + Eventually(ClusterRole()).Should(Or(HaveLen(kcpRoles), HaveLen(ocpRoles))) }) } diff --git a/e2e/support/test_support.go b/e2e/support/test_support.go index 9ccb72408..11b56f97c 100644 --- a/e2e/support/test_support.go +++ b/e2e/support/test_support.go @@ -398,15 +398,16 @@ func Make(rule string, args ...string) *exec.Cmd { } func MakeWithContext(ctx context.Context, rule string, args ...string) *exec.Cmd { - makeArgs := os.Getenv("MAKE_ARGS") + makeArgs := os.Getenv("CAMEL_K_TEST_MAKE_ARGS") defaultArgs := strings.Fields(makeArgs) args = append(defaultArgs, args...) - makeDir := os.Getenv("MAKE_DIR") + defaultDir := "../../../../install" + makeDir := os.Getenv("CAMEL_K_TEST_MAKE_DIR") if makeDir == "" { - makeDir = "../../../../install" - } else { - fmt.Printf("Using alternative make directory on path %s\n", makeDir) + makeDir = defaultDir + } else if makeDir != defaultDir { + fmt.Printf("Using alternative make directory on path: %s\n", makeDir) } if fi, e := os.Stat(makeDir); e != nil && os.IsNotExist(e) { @@ -420,9 +421,9 @@ func MakeWithContext(ctx context.Context, rule string, args ...string) *exec.Cmd return exec.Command("make", args...) } -/* - Curryied utility functions for testing -*/ +// ============================================================================= +// Curried utility functions for testing +// ============================================================================= func IntegrationLogs(ns, name string) func() string { return func() string { @@ -1728,12 +1729,11 @@ func Role(ns string) func() []rbacv1.Role { APIVersion: rbacv1.SchemeGroupVersion.String(), }, } - err := TestClient().List(TestContext, &lst, + if err := TestClient().List(TestContext, &lst, ctrl.InNamespace(ns), ctrl.MatchingLabels{ "app": "camel-k", - }) - if err != nil { + }); err != nil { failTest(err) } if len(lst.Items) == 0 { @@ -1751,12 +1751,11 @@ func RoleBinding(ns string) func() *rbacv1.RoleBinding { APIVersion: metav1.SchemeGroupVersion.String(), }, } - err := TestClient().List(TestContext, &lst, + if err := TestClient().List(TestContext, &lst, ctrl.InNamespace(ns), ctrl.MatchingLabels{ "app": "camel-k", - }) - if err != nil { + }); err != nil { failTest(err) } if len(lst.Items) == 0 {
