You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ts...@apache.org on 2022/12/13 09:37:12 UTC
[camel-k] branch main updated (5f5842dca -> 77eb66bbc)
This is an automated email from the ASF dual-hosted git repository.
tsato pushed a change to branch main
in repository https://gitbox.apache.org/repos/asf/camel-k.git
from 5f5842dca chore(deps): bump github.com/prometheus/common from 0.37.0 to 0.38.0
new 5c8cc53e8 chore(e2e): polish kustomize tests
new 170ede6d5 fix(e2e): isolate kustomize tests not to interfere with each other
new cef27e242 fix(e2e): avoid using subshell for running kustomize commands
new abb2e2235 chore(kustomize): make parameter descriptions consistent
new 3880907a3 feat(kustomize): add INSTALL_DEFAULT_KAMELETS parameter to make operator
new e3144e334 fix(kustomize): allow specifying INSTALL_DEFAULT_KAMELETS from env var
new 06422443f fix(e2e): kustomize tests flakiness by making operator install/cleanup faster
new 3e311d0c0 chore(kustomize): fix typo
new 130a735ba chore(e2e): show running pod names at test namespace deletion
new 77eb66bbc chore(kustomize): force using bash in Makefile to avoid incompatibilities
The 10 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
...el.yaml => patch-install-default-kamelets.yaml} | 4 +-
e2e/namespace/install/kustomize/common.go | 18 ++++--
e2e/namespace/install/kustomize/operator_test.go | 28 ++++++--
e2e/namespace/install/kustomize/setup_test.go | 29 +++++----
e2e/support/test_support.go | 58 +++++++++--------
e2e/support/util/temp_file.go | 42 ++++++++----
install/Makefile | 75 ++++++++++++++--------
install/operator/kustomization.yaml | 2 +-
pkg/util/util.go | 42 +++++++++++-
pkg/util/util_test.go | 16 +++++
script/Makefile | 2 +-
11 files changed, 215 insertions(+), 101 deletions(-)
copy config/manager/{patch-log-level.yaml => patch-install-default-kamelets.yaml} (94%)
[camel-k] 06/10: fix(kustomize): allow specifying INSTALL_DEFAULT_KAMELETS from env var
Posted by ts...@apache.org.
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 e3144e3348b276fc14e1ee98fb2e2410aa10e35f
Author: Tadayoshi Sato <sa...@gmail.com>
AuthorDate: Sat Dec 10 22:14:10 2022 +0900
fix(kustomize): allow specifying INSTALL_DEFAULT_KAMELETS from env var
---
script/Makefile | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/script/Makefile b/script/Makefile
index b6583c8a0..2605d6e6f 100644
--- a/script/Makefile
+++ b/script/Makefile
@@ -20,7 +20,7 @@ LAST_RELEASED_VERSION ?= 1.11.0
RUNTIME_VERSION := 1.16.0
BUILDAH_VERSION := 1.23.3
KANIKO_VERSION := 0.17.1
-INSTALL_DEFAULT_KAMELETS := true
+INSTALL_DEFAULT_KAMELETS ?= true
CONTROLLER_GEN_VERSION := v0.6.1
CODEGEN_VERSION := v0.23.5
OPERATOR_SDK_VERSION := v1.16.0
[camel-k] 08/10: chore(kustomize): fix typo
Posted by ts...@apache.org.
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 3e311d0c0ce6459a9fa72315c49af99a14bb9667
Author: Tadayoshi Sato <sa...@gmail.com>
AuthorDate: Fri Dec 9 14:09:50 2022 +0900
chore(kustomize): fix typo
---
install/operator/kustomization.yaml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/install/operator/kustomization.yaml b/install/operator/kustomization.yaml
index e9412ac08..4d8cf1556 100644
--- a/install/operator/kustomization.yaml
+++ b/install/operator/kustomization.yaml
@@ -31,7 +31,7 @@
# modifies the WATCH_NAMESPACE env var to wildcard for all namespaces
#
# * patch-toleration.yaml
-# modifies the tolerations configuraion of the deployment
+# modifies the tolerations configuration of the deployment
# Edit the patch manually to add the required keys
#
# * patch-nodes-selector.yaml
[camel-k] 05/10: feat(kustomize): add INSTALL_DEFAULT_KAMELETS parameter to make operator
Posted by ts...@apache.org.
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 3880907a3a725bcf68e14b7781ff6f8203415ea5
Author: Tadayoshi Sato <sa...@gmail.com>
AuthorDate: Fri Dec 9 14:03:54 2022 +0900
feat(kustomize): add INSTALL_DEFAULT_KAMELETS parameter to make operator
---
config/manager/patch-install-default-kamelets.yaml | 22 +++++++++++++++
install/Makefile | 32 ++++++++++++++--------
2 files changed, 43 insertions(+), 11 deletions(-)
diff --git a/config/manager/patch-install-default-kamelets.yaml b/config/manager/patch-install-default-kamelets.yaml
new file mode 100644
index 000000000..fa3012076
--- /dev/null
+++ b/config/manager/patch-install-default-kamelets.yaml
@@ -0,0 +1,22 @@
+# ---------------------------------------------------------------------------
+# 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.
+# ---------------------------------------------------------------------------
+
+- op: add
+ path: /spec/template/spec/containers/0/env/-
+ value:
+ name: KAMEL_INSTALL_DEFAULT_KAMELETS
+ value: "false"
diff --git a/install/Makefile b/install/Makefile
index fbc3af67d..fa7a1608c 100644
--- a/install/Makefile
+++ b/install/Makefile
@@ -50,6 +50,8 @@ MONITORING_PORT ?= 8080
HEALTH_PORT ?= 8081
# Operator Logging Level: string [info, debug, 0, 1]
LOGGING_LEVEL ?= info
+# Install default kamelets: [true|false]
+INSTALL_DEFAULT_KAMELETS ?= true
CONFIG := config
MANAGER := $(CONFIG)/manager
@@ -70,6 +72,7 @@ ROLEBIN_TO_CROLEBIN_PATCH := $(RBAC)/patch-rolebinding-to-clusterrolebinding
# Operator patches
PORTS_PATCH := patch-ports
LOG_LEVEL_PATCH := patch-log-level
+INSTALL_DEFAULT_KAMELETS_PATCH := patch-install-default-kamelets
IMAGE_PULL_POLICY_PATCH := patch-image-pull-policy-always
WATCH_NAMESPACE_PATCH := patch-watch-namespace-global
# Platform patches
@@ -284,17 +287,18 @@ endif
#=== Cluster-admin privileges are required.
#
#* PARAMETERS:
-#** NAMESPACE: Set the namespace to install the operator into
-#** PLATFORM: Override the discovered platform, if required
-#** GLOBAL: Set the operator to watch all namespaces for custom resources [true|false]
-#** CUSTOM_IMAGE: Set a custom operator image name
-#** CUSTOM_VERSION: Set a custom operator image version/tag
-#** ALWAYS_PULL_IMAGES: Set whether to always pull the operator image [true|false]
-#** MONITORING: Add the prometheus monitoring resources
-#** MONITORING_PORT: Set a custom monitoring port
-#** HEALTH_PORT: Set a custom health port
-#** LOGGING_LEVEL: Set the level of logging [info|debug]
-#** DRY_RUN: Print the resources to be applied instead of applying them [true|false]
+#** NAMESPACE: Set the namespace to install the operator into
+#** PLATFORM: Override the discovered platform, if required
+#** GLOBAL: Set the operator to watch all namespaces for custom resources [true|false]
+#** CUSTOM_IMAGE: Set a custom operator image name
+#** CUSTOM_VERSION: Set a custom operator image version/tag
+#** ALWAYS_PULL_IMAGES: Set whether to always pull the operator image [true|false]
+#** MONITORING: Add the prometheus monitoring resources
+#** MONITORING_PORT: Set a custom monitoring port
+#** HEALTH_PORT: Set a custom health port
+#** LOGGING_LEVEL: Set the level of logging [info|debug]
+#** INSTALL_DEFAULT_KAMELETS: Install the default Kamelets from catalog [true|false]
+#** DRY_RUN: Print the resources to be applied instead of applying them [true|false]
#
#---
operator: check-admin have-platform check-crd-api-support kustomize kubectl .operator-port-patch .operator-log-level-patch
@@ -334,6 +338,12 @@ else ifneq ($(LOGGING_LEVEL), 0)
else
@$(call add-remove-kind-patch,$(MANAGER),remove,$(LOG_LEVEL_PATCH).$(YAML),Deployment)
endif
+# Set the INSTALL_DEFAULT_KAMELETS config depending on var
+ifeq ($(INSTALL_DEFAULT_KAMELETS),false)
+ @$(call add-remove-kind-patch,$(MANAGER),add,$(INSTALL_DEFAULT_KAMELETS_PATCH).$(YAML),Deployment)
+else
+ @$(call add-remove-kind-patch,$(MANAGER),remove,$(INSTALL_DEFAULT_KAMELETS_PATCH).$(YAML),Deployment)
+endif
ifeq ($(DRY_RUN), false)
@$(KUSTOMIZE) build $(KOPTIONS) $@ | kubectl apply -f -
else
[camel-k] 03/10: fix(e2e): avoid using subshell for running kustomize commands
Posted by ts...@apache.org.
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 cef27e24299abc5d449bcd1479239202cb8812df
Author: Tadayoshi Sato <sa...@gmail.com>
AuthorDate: Thu Dec 8 13:53:25 2022 +0900
fix(e2e): avoid using subshell for running kustomize commands
---
install/Makefile | 23 ++++++++++++++---------
1 file changed, 14 insertions(+), 9 deletions(-)
diff --git a/install/Makefile b/install/Makefile
index 6854f83b2..d93bde218 100644
--- a/install/Makefile
+++ b/install/Makefile
@@ -83,8 +83,8 @@ INT_PLATFORM_PATCH := patch-integration-platform
#
define set-kustomize-image
$(if $(filter $(IMAGE_NAME),$(CUSTOM_IMAGE):$(CUSTOM_VERSION)),,\
-
- @cd $(1) && $(KUSTOMIZE) edit set image $(IMAGE_NAME)=$(CUSTOM_IMAGE):$(CUSTOM_VERSION))
+ @cd $(1) || exit 1 && \
+ $(KUSTOMIZE) edit set image $(IMAGE_NAME)=$(CUSTOM_IMAGE):$(CUSTOM_VERSION))
endef
#
@@ -94,7 +94,8 @@ endef
# Parameter: directory of the kustomization.yaml
#
define set-kustomize-namespace
- @cd $(1) && $(KUSTOMIZE) edit set namespace $(NAMESPACE)
+ @cd $(1) || exit 1 && \
+ $(KUSTOMIZE) edit set namespace $(NAMESPACE)
endef
#
@@ -108,16 +109,16 @@ endef
# * kind of resources, eg. Deployment, Role
#
define add-remove-kind-patch
- @(cd $(1) && \
- $(KUSTOMIZE) edit $(2) patch --path $(3) --kind $(4) &> /dev/null)
+ @cd $(1) || exit 1 && \
+ $(KUSTOMIZE) edit $(2) patch --path $(3) --kind $(4) &> /dev/null
endef
#
# Macro for adding / removing the prometheus resources for monitoring
#
define add-remove-operator-monitoring
- @(cd $(1) && \
- $(KUSTOMIZE) edit $(2) resource ../$(CONFIG)/prometheus &> /dev/null)
+ @cd $(1) || exit 1 && \
+ $(KUSTOMIZE) edit $(2) resource ../$(CONFIG)/prometheus &> /dev/null
endef
.PHONY: have-platform check_admin setup-cluster .setup-kubernetes .setup-openshift setup
@@ -187,7 +188,9 @@ setup-cluster: check-admin check-crd-api-support have-platform kustomize kubectl
@$(call set-kustomize-namespace,$@)
ifeq ($(PLATFORM), openshift)
@for res in $(RBAC_OS)/operator-cluster*; do \
- (cd $@ && $(KUSTOMIZE) edit add resource ../$$res); \
+ cd $@ || exit 1 && \
+ $(KUSTOMIZE) edit add resource ../$$res && \
+ cd - &> /dev/null; \
done
endif
#
@@ -233,7 +236,9 @@ else
endif
ifeq ($(PLATFORM), openshift)
@for res in $(RBAC_OS)/operator-role*; do \
- (cd $@ && $(KUSTOMIZE) edit add resource ../$$res); \
+ cd $@ || exit 1 && \
+ $(KUSTOMIZE) edit add resource ../$$res && \
+ cd - &> /dev/null; \
done
endif
#
[camel-k] 04/10: chore(kustomize): make parameter descriptions consistent
Posted by ts...@apache.org.
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 abb2e22356678cd79d37218bf79a93958a5136e8
Author: Tadayoshi Sato <sa...@gmail.com>
AuthorDate: Thu Dec 8 15:54:57 2022 +0900
chore(kustomize): make parameter descriptions consistent
---
install/Makefile | 22 +++++++++++-----------
1 file changed, 11 insertions(+), 11 deletions(-)
diff --git a/install/Makefile b/install/Makefile
index d93bde218..fbc3af67d 100644
--- a/install/Makefile
+++ b/install/Makefile
@@ -178,9 +178,9 @@ endif
#=== Cluster-admin privileges are required.
#
#* PARAMETERS:
-#** NAMESPACE: Sets the namespace for the resources
+#** NAMESPACE: Set the namespace for the resources
#** PLATFORM: Override the discovered platform, if required
-#** DRY_RUN: If 'true', prints the resources to be applied instead of applying them
+#** DRY_RUN: Print the resources to be applied instead of applying them [true|false]
#
#---
setup-cluster: check-admin check-crd-api-support have-platform kustomize kubectl
@@ -217,10 +217,10 @@ endif
#=== Cluster-admin privileges are required.
#
#* PARAMETERS:
-#** NAMESPACE: Sets the namespace for the resources
-#** GLOBAL: Converts all roles & bindings to cluster-level [true|false]
+#** NAMESPACE: Set the namespace for the resources
+#** GLOBAL: Convert all roles & bindings to cluster-level [true|false]
#** PLATFORM: Override the discovered platform, if required
-#** DRY_RUN: If 'true', prints the resources to be applied instead of applying them
+#** DRY_RUN: Print the resources to be applied instead of applying them [true|false]
#
#---
setup: setup-cluster
@@ -286,15 +286,15 @@ endif
#* PARAMETERS:
#** NAMESPACE: Set the namespace to install the operator into
#** PLATFORM: Override the discovered platform, if required
-#** GLOBAL: Sets the operator to watch all namespaces for custom resources [true|false]
+#** GLOBAL: Set the operator to watch all namespaces for custom resources [true|false]
#** CUSTOM_IMAGE: Set a custom operator image name
#** CUSTOM_VERSION: Set a custom operator image version/tag
-#** ALWAYS_PULL_IMAGES: Sets whether to always pull the operator image [true|false]
-#** MONITORING: Adds the prometheus monitoring resources
+#** ALWAYS_PULL_IMAGES: Set whether to always pull the operator image [true|false]
+#** MONITORING: Add the prometheus monitoring resources
#** MONITORING_PORT: Set a custom monitoring port
#** HEALTH_PORT: Set a custom health port
#** LOGGING_LEVEL: Set the level of logging [info|debug]
-#** DRY_RUN: Prints the resources to be applied instead of applying them
+#** DRY_RUN: Print the resources to be applied instead of applying them [true|false]
#
#---
operator: check-admin have-platform check-crd-api-support kustomize kubectl .operator-port-patch .operator-log-level-patch
@@ -365,7 +365,7 @@ endif
#* PARAMETERS:
#** NAMESPACE: Set the namespace to install the operator into
#** PLATFORM: Override the discovered platform, if required
-#** DRY_RUN: Prints the resources to be applied instead of applying them [true,false]
+#** DRY_RUN: Print the resources to be applied instead of applying them [true|false]
#
#---
platform: have-platform kustomize kubectl
@@ -390,7 +390,7 @@ endif
#* PARAMETERS:
#** NAMESPACE: Set the namespace to install the example into
#** PLATFORM: Override the discovered platform, if required
-#** DRY_RUN: Prints the resources to be applied instead of applying them [true, false]
+#** DRY_RUN: Print the resources to be applied instead of applying them [true|false]
#
#---
example: kubectl
[camel-k] 01/10: chore(e2e): polish kustomize tests
Posted by ts...@apache.org.
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 <sa...@gmail.com>
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 {
[camel-k] 10/10: chore(kustomize): force using bash in Makefile to avoid incompatibilities
Posted by ts...@apache.org.
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 77eb66bbce2195a7c9a194885a4fd8799be24994
Author: Tadayoshi Sato <sa...@gmail.com>
AuthorDate: Mon Dec 12 15:19:46 2022 +0900
chore(kustomize): force using bash in Makefile to avoid incompatibilities
---
install/Makefile | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/install/Makefile b/install/Makefile
index fa7a1608c..7c998bbb7 100644
--- a/install/Makefile
+++ b/install/Makefile
@@ -13,6 +13,12 @@
# See the License for the specific language governing permissions and
# limitations under the License.
+#
+# Use bash explicitly in this Makefile to avoid unexpected platform
+# incompatibilities among Linux distros.
+#
+SHELL := /bin/bash
+
#
# Allows for resources to be loaded from outside the root location of
# the kustomize config file. Ensures that resource don't need to be
[camel-k] 07/10: fix(e2e): kustomize tests flakiness by making operator install/cleanup faster
Posted by ts...@apache.org.
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 06422443f3cc92ffad553eb68bce89c68f9e4e72
Author: Tadayoshi Sato <sa...@gmail.com>
AuthorDate: Fri Dec 9 14:02:23 2022 +0900
fix(e2e): kustomize tests flakiness by making operator install/cleanup faster
---
e2e/namespace/install/kustomize/operator_test.go | 18 +++++++++++++++---
1 file changed, 15 insertions(+), 3 deletions(-)
diff --git a/e2e/namespace/install/kustomize/operator_test.go b/e2e/namespace/install/kustomize/operator_test.go
index 03654d05f..63ee49ddf 100644
--- a/e2e/namespace/install/kustomize/operator_test.go
+++ b/e2e/namespace/install/kustomize/operator_test.go
@@ -45,7 +45,10 @@ func TestBasicOperator(t *testing.T) {
WithNewTestNamespace(t, func(ns string) {
ExecMake(t, Make("setup-cluster", fmt.Sprintf("NAMESPACE=%s", ns)))
ExecMake(t, Make("setup", fmt.Sprintf("NAMESPACE=%s", ns)))
- ExecMake(t, Make("operator", fmt.Sprintf("NAMESPACE=%s", ns)))
+ // Skip default kamelets installation for faster test runs
+ ExecMake(t, Make("operator",
+ fmt.Sprintf("NAMESPACE=%s", ns),
+ "INSTALL_DEFAULT_KAMELETS=false"))
Eventually(OperatorPod(ns)).ShouldNot(BeNil())
})
@@ -66,9 +69,14 @@ func TestAlternativeImageOperator(t *testing.T) {
ExecMake(t, Make("setup-cluster", fmt.Sprintf("NAMESPACE=%s", ns)))
ExecMake(t, Make("setup", fmt.Sprintf("NAMESPACE=%s", ns)))
+ // Skip default kamelets installation for faster test runs
newImage := "quay.io/kameltest/kamel-operator"
newTag := "1.1.1"
- ExecMake(t, Make("operator", fmt.Sprintf("CUSTOM_IMAGE=%s", newImage), fmt.Sprintf("CUSTOM_VERSION=%s", newTag), fmt.Sprintf("NAMESPACE=%s", ns)))
+ ExecMake(t, Make("operator",
+ fmt.Sprintf("CUSTOM_IMAGE=%s", newImage),
+ fmt.Sprintf("CUSTOM_VERSION=%s", newTag),
+ fmt.Sprintf("NAMESPACE=%s", ns),
+ "INSTALL_DEFAULT_KAMELETS=false"))
Eventually(OperatorImage(ns)).Should(Equal(fmt.Sprintf("%s:%s", newImage, newTag)))
})
@@ -88,7 +96,11 @@ func TestGlobalOperator(t *testing.T) {
ExecMake(t, Make("setup-cluster", fmt.Sprintf("NAMESPACE=%s", ns)))
ExecMake(t, Make("setup", fmt.Sprintf("NAMESPACE=%s", ns), "GLOBAL=true"))
- ExecMake(t, Make("operator", fmt.Sprintf("NAMESPACE=%s", ns), "GLOBAL=true"))
+ // Skip default kamelets installation for faster test runs
+ ExecMake(t, Make("operator",
+ fmt.Sprintf("NAMESPACE=%s", ns),
+ "GLOBAL=true",
+ "INSTALL_DEFAULT_KAMELETS=false"))
podFunc := OperatorPod(ns)
Eventually(podFunc).Should(Not(BeNil()))
[camel-k] 09/10: chore(e2e): show running pod names at test namespace deletion
Posted by ts...@apache.org.
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 130a735ba97b18bdafc9c927f8955bcb6bfd7c3a
Author: Tadayoshi Sato <sa...@gmail.com>
AuthorDate: Fri Dec 9 16:18:35 2022 +0900
chore(e2e): show running pod names at test namespace deletion
---
e2e/support/test_support.go | 31 ++++++++++++++++++-------------
1 file changed, 18 insertions(+), 13 deletions(-)
diff --git a/e2e/support/test_support.go b/e2e/support/test_support.go
index 11b56f97c..8470eb964 100644
--- a/e2e/support/test_support.go
+++ b/e2e/support/test_support.go
@@ -2065,21 +2065,21 @@ func AsTraitConfiguration(props map[string]string) *traitv1.Configuration {
Namespace testing functions
*/
-func NumPods(ns string) func() int {
- return func() int {
+func Pods(ns string) func() []corev1.Pod {
+ return func() []corev1.Pod {
lst := corev1.PodList{
TypeMeta: metav1.TypeMeta{
Kind: "Pod",
APIVersion: v1.SchemeGroupVersion.String(),
},
}
- if err := TestClient().List(TestContext, &lst, ctrl.InNamespace(ns)); err != nil && k8serrors.IsUnauthorized(err) {
- return 0
- } else if err != nil {
- log.Error(err, "Error while listing the pods")
- return 0
+ if err := TestClient().List(TestContext, &lst, ctrl.InNamespace(ns)); err != nil {
+ if !k8serrors.IsUnauthorized(err) {
+ log.Error(err, "Error while listing the pods")
+ }
+ return nil
}
- return len(lst.Items)
+ return lst.Items
}
}
@@ -2222,13 +2222,18 @@ func deleteTestNamespace(t *testing.T, ns ctrl.Object) {
}
// Wait for all pods to be deleted
- pods := NumPods(ns.GetName())()
- for i := 0; pods > 0 && i < 60; i++ {
+ pods := Pods(ns.GetName())()
+ for i := 0; len(pods) > 0 && i < 60; i++ {
time.Sleep(1 * time.Second)
- pods = NumPods(ns.GetName())()
+ pods = Pods(ns.GetName())()
}
- if pods > 0 {
- t.Logf("Warning: some pods are still running in namespace %q after deletion (%d)", ns.GetName(), pods)
+ if len(pods) > 0 {
+ names := []string{}
+ for _, pod := range pods {
+ names = append(names, pod.Name)
+ }
+ t.Logf("Warning: some pods are still running in namespace %q after deletion", ns.GetName())
+ t.Logf("Warning: %d running pods: %s", len(pods), names)
}
}
[camel-k] 02/10: fix(e2e): isolate kustomize tests not to interfere with each other
Posted by ts...@apache.org.
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 170ede6d5ab9c7adb7c82abb0cf1c2a1b131a1c4
Author: Tadayoshi Sato <sa...@gmail.com>
AuthorDate: Thu Dec 1 13:07:44 2022 +0900
fix(e2e): isolate kustomize tests not to interfere with each other
Fix #3772 #3861
---
e2e/namespace/install/kustomize/common.go | 4 +++
e2e/namespace/install/kustomize/operator_test.go | 10 ++++--
e2e/namespace/install/kustomize/setup_test.go | 7 ++--
e2e/support/util/temp_file.go | 42 ++++++++++++++++--------
pkg/util/util.go | 42 ++++++++++++++++++++++--
pkg/util/util_test.go | 16 +++++++++
6 files changed, 99 insertions(+), 22 deletions(-)
diff --git a/e2e/namespace/install/kustomize/common.go b/e2e/namespace/install/kustomize/common.go
index f697e43a6..15cc9bec4 100644
--- a/e2e/namespace/install/kustomize/common.go
+++ b/e2e/namespace/install/kustomize/common.go
@@ -59,6 +59,8 @@ const (
)
func ExecMake(t *testing.T, command *exec.Cmd) {
+ t.Helper()
+
var cmdOut strings.Builder
var cmdErr strings.Builder
@@ -80,6 +82,8 @@ func ExecMake(t *testing.T, command *exec.Cmd) {
// Expect a make error with an exit code of 1
//
func ExecMakeError(t *testing.T, command *exec.Cmd) {
+ t.Helper()
+
var cmdOut strings.Builder
var cmdErr strings.Builder
diff --git a/e2e/namespace/install/kustomize/operator_test.go b/e2e/namespace/install/kustomize/operator_test.go
index 1992548a9..03654d05f 100644
--- a/e2e/namespace/install/kustomize/operator_test.go
+++ b/e2e/namespace/install/kustomize/operator_test.go
@@ -28,11 +28,13 @@ import (
"testing"
. "github.com/apache/camel-k/e2e/support"
+ testutil "github.com/apache/camel-k/e2e/support/util"
. "github.com/onsi/gomega"
)
func TestBasicOperator(t *testing.T) {
- os.Setenv("CAMEL_K_TEST_MAKE_DIR", "../../../../install")
+ makeDir := testutil.MakeTempCopyDir(t, "../../../../install")
+ os.Setenv("CAMEL_K_TEST_MAKE_DIR", makeDir)
// Ensure no CRDs are already installed
UninstallAll()
@@ -50,7 +52,8 @@ func TestBasicOperator(t *testing.T) {
}
func TestAlternativeImageOperator(t *testing.T) {
- os.Setenv("CAMEL_K_TEST_MAKE_DIR", "../../../../install")
+ makeDir := testutil.MakeTempCopyDir(t, "../../../../install")
+ os.Setenv("CAMEL_K_TEST_MAKE_DIR", makeDir)
// Ensure no CRDs are already installed
UninstallAll()
@@ -72,7 +75,8 @@ func TestAlternativeImageOperator(t *testing.T) {
}
func TestGlobalOperator(t *testing.T) {
- os.Setenv("CAMEL_K_TEST_MAKE_DIR", "../../../../install")
+ makeDir := testutil.MakeTempCopyDir(t, "../../../../install")
+ os.Setenv("CAMEL_K_TEST_MAKE_DIR", makeDir)
// 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 18cb75b5d..eef0b1a40 100644
--- a/e2e/namespace/install/kustomize/setup_test.go
+++ b/e2e/namespace/install/kustomize/setup_test.go
@@ -28,11 +28,13 @@ import (
"testing"
. "github.com/apache/camel-k/e2e/support"
+ testutil "github.com/apache/camel-k/e2e/support/util"
. "github.com/onsi/gomega"
)
func TestBasicSetup(t *testing.T) {
- os.Setenv("CAMEL_K_TEST_MAKE_DIR", "../../../../install")
+ makeDir := testutil.MakeTempCopyDir(t, "../../../../install")
+ os.Setenv("CAMEL_K_TEST_MAKE_DIR", makeDir)
// Ensure no CRDs are already installed
UninstallAll()
@@ -61,7 +63,8 @@ func TestBasicSetup(t *testing.T) {
}
func TestGlobalSetup(t *testing.T) {
- os.Setenv("CAMEL_K_TEST_MAKE_DIR", "../../../../install")
+ makeDir := testutil.MakeTempCopyDir(t, "../../../../install")
+ os.Setenv("CAMEL_K_TEST_MAKE_DIR", makeDir)
// Ensure no CRDs are already installed
UninstallAll()
diff --git a/e2e/support/util/temp_file.go b/e2e/support/util/temp_file.go
index e10a3e326..b6c80f40b 100644
--- a/e2e/support/util/temp_file.go
+++ b/e2e/support/util/temp_file.go
@@ -21,48 +21,62 @@ limitations under the License.
package util
import (
- "io/ioutil"
"os"
- "path"
+ "path/filepath"
"strings"
"testing"
+
+ "github.com/apache/camel-k/pkg/util"
)
func MakeTempCopy(t *testing.T, fileName string) string {
- _, simpleName := path.Split(fileName)
- var err error
+ t.Helper()
+
+ _, simpleName := filepath.Split(fileName)
tmpDir := MakeTempDir(t)
- tmpFileName := path.Join(tmpDir, simpleName)
- var content []byte
- if content, err = ioutil.ReadFile(fileName); err != nil {
+ tmpFileName := filepath.Join(tmpDir, simpleName)
+ if _, err := util.CopyFile(fileName, tmpFileName); err != nil {
t.Error(err)
t.FailNow()
}
- if err = ioutil.WriteFile(tmpFileName, content, os.FileMode(0777)); err != nil {
+ return tmpFileName
+}
+
+func MakeTempCopyDir(t *testing.T, dirName string) string {
+ t.Helper()
+
+ dirName = strings.TrimSuffix(dirName, "/")
+ _, simpleName := filepath.Split(dirName)
+ tmpDir := MakeTempDir(t)
+ tmpDirName := filepath.Join(tmpDir, simpleName)
+ if err := util.CopyDir(dirName, tmpDirName); err != nil {
t.Error(err)
t.FailNow()
}
- return tmpFileName
+ return tmpDirName
}
// ReplaceInFile replace strings in a file with new values
func ReplaceInFile(t *testing.T, fileName string, old, new string) {
- content, err := ioutil.ReadFile(fileName)
+ t.Helper()
+
+ content, err := os.ReadFile(fileName)
if err != nil {
t.Error(err)
t.FailNow()
}
res := strings.ReplaceAll(string(content), old, new)
- if err = ioutil.WriteFile(fileName, []byte(res), os.FileMode(0777)); err != nil {
+ if err = os.WriteFile(fileName, []byte(res), os.FileMode(0777)); err != nil {
t.Error(err)
t.FailNow()
}
}
func MakeTempDir(t *testing.T) string {
- var tmpDir string
- var err error
- if tmpDir, err = ioutil.TempDir("", "camel-k-"); err != nil {
+ t.Helper()
+
+ tmpDir, err := os.MkdirTemp("", "camel-k-")
+ if err != nil {
t.Error(err)
t.FailNow()
return ""
diff --git a/pkg/util/util.go b/pkg/util/util.go
index 25ca86517..80fb19910 100644
--- a/pkg/util/util.go
+++ b/pkg/util/util.go
@@ -23,7 +23,7 @@ import (
"encoding/xml"
"fmt"
"io"
- "io/ioutil"
+ "io/fs"
"math/rand"
"os"
"path"
@@ -288,6 +288,42 @@ func CopyFile(src, dst string) (int64, error) {
return nBytes, err
}
+func CopyDir(src, dst string) error {
+ entries, err := os.ReadDir(src)
+ if err != nil {
+ return err
+ }
+
+ for _, entry := range entries {
+ srcEntry := filepath.Join(src, entry.Name())
+ dstEntry := filepath.Join(dst, entry.Name())
+ realEntry := entry
+ if entry.Type() == os.ModeSymlink {
+ realPath, err := filepath.EvalSymlinks(srcEntry)
+ if err != nil {
+ return err
+ }
+ realInfo, err := os.Stat(realPath)
+ if err != nil {
+ return err
+ }
+ srcEntry = realPath
+ realEntry = fs.FileInfoToDirEntry(realInfo)
+ }
+ if realEntry.IsDir() {
+ if err := CopyDir(srcEntry, dstEntry); err != nil {
+ return err
+ }
+ } else {
+ if _, err := CopyFile(srcEntry, dstEntry); err != nil {
+ return err
+ }
+ }
+ }
+
+ return nil
+}
+
func WriteFileWithBytesMarshallerContent(basePath string, filePath string, content BytesMarshaller) error {
data, err := content.MarshalBytes()
if err != nil {
@@ -452,7 +488,7 @@ func MapToYAML(src map[string]interface{}) ([]byte, error) {
}
func WriteToFile(filePath string, fileContents string) error {
- err := ioutil.WriteFile(filePath, []byte(fileContents), 0o400)
+ err := os.WriteFile(filePath, []byte(fileContents), 0o400)
if err != nil {
return errors.Errorf("error writing file: %v", filePath)
}
@@ -598,7 +634,7 @@ func WriteFileWithContent(filePath string, content []byte) error {
// WithTempDir a safe wrapper to deal with temporary directories.
func WithTempDir(pattern string, consumer func(string) error) error {
- tmpDir, err := ioutil.TempDir("", pattern)
+ tmpDir, err := os.MkdirTemp("", pattern)
if err != nil {
return err
}
diff --git a/pkg/util/util_test.go b/pkg/util/util_test.go
index 597308d25..6a428b234 100644
--- a/pkg/util/util_test.go
+++ b/pkg/util/util_test.go
@@ -18,9 +18,13 @@ limitations under the License.
package util
import (
+ "fmt"
+ "os"
+ "path/filepath"
"testing"
"github.com/stretchr/testify/assert"
+ "github.com/stretchr/testify/require"
)
func TestStringContainsPrefix(t *testing.T) {
@@ -44,3 +48,15 @@ func TestSubstringBefore(t *testing.T) {
assert.Equal(t, "aaa/bbb", SubstringBefore("aaa/bbb?ccc=ddd", "?"))
assert.Empty(t, SubstringBefore("aaa/bbb/ccc", "?"))
}
+
+func TestCopyDir(t *testing.T) {
+ srcDir := "../../install"
+ tmpDir, err := os.MkdirTemp("", "TestCopyDir-*")
+ defer os.RemoveAll(tmpDir)
+ destDir := filepath.Join(tmpDir, "install")
+
+ require.NoError(t, err)
+ fmt.Println(destDir)
+ err = CopyDir(srcDir, destDir)
+ assert.NoError(t, err)
+}