You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by as...@apache.org on 2022/01/31 08:58:27 UTC
[camel-k] 16/40: Cleanup using kamel uninstall
This is an automated email from the ASF dual-hosted git repository.
astefanutti pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel-k.git
commit eb63dad34b7c0773f337307c538ca88dd172c8c4
Author: phantomjinx <p....@phantomjinx.co.uk>
AuthorDate: Fri Nov 26 12:54:50 2021 +0000
Cleanup using kamel uninstall
* Replaces use of unintall in e2e code as latter was uninstalling
CRDs between tests so all subsequent tests were failing
---
.github/actions/kamel-cleanup/action.yaml | 10 ++++++++--
e2e/support/test_support.go | 23 -----------------------
e2e/upgrade/cli_upgrade_test.go | 6 ++++--
e2e/upgrade/olm_upgrade_test.go | 5 ++---
4 files changed, 14 insertions(+), 30 deletions(-)
diff --git a/.github/actions/kamel-cleanup/action.yaml b/.github/actions/kamel-cleanup/action.yaml
index fce1451..338ad37 100644
--- a/.github/actions/kamel-cleanup/action.yaml
+++ b/.github/actions/kamel-cleanup/action.yaml
@@ -21,12 +21,18 @@ description: 'Cleans up the target cluster, removing any e2e test resources'
runs:
using: "composite"
steps:
- - id: remove-installed-camel-crds
- name: Remove Installed Camel CRDs
+ - id: remove-installed-kamel
+ name: Remove Installed Kamel
shell: bash
if: ${{ always() }}
run: |
set +e
+ if command -v kamel &> /dev/null
+ then
+ kamel uninstall --olm=false --all
+ fi
+
+ # Ensure the CRDs are removed
kubectl get crds | grep camel | awk '{print $1}' | xargs kubectl delete crd &> /dev/null
set -e
diff --git a/e2e/support/test_support.go b/e2e/support/test_support.go
index 8e045df..436f5b4 100644
--- a/e2e/support/test_support.go
+++ b/e2e/support/test_support.go
@@ -1686,12 +1686,6 @@ func InvokeUserTestCode(t *testing.T, ns string, doRun func(string)) {
if err := util.Dump(TestContext, TestClient(), ns, t); err != nil {
t.Logf("Error while dumping namespace %s: %v\n", ns, err)
}
-
- //
- // Ensure everything is removed after dumping
- // in order to ensure a clean cluster
- //
- uninstallKamelInternal(t, "--all", "--olm=false")
}
}()
@@ -1830,23 +1824,6 @@ func NewTestNamespace(injectKnativeBroker bool) ctrl.Object {
return obj
}
-func uninstallKamelInternal(t *testing.T, args ...string) {
- uargs := []string{"uninstall"}
- uargs = append(uargs, args...)
- if err := Kamel(uargs...).Execute(); err != nil {
- t.Logf("Warning: An error occurred whilst trying to uninstall kamel: %s", err.Error())
- }
-}
-
-func UninstallKamel(t *testing.T, args ...string) {
- if t.Failed() {
- // then dump needs to execute first
- return
- }
-
- uninstallKamelInternal(t, args...)
-}
-
func GetOutputString(command *cobra.Command) string {
var buf bytes.Buffer
diff --git a/e2e/upgrade/cli_upgrade_test.go b/e2e/upgrade/cli_upgrade_test.go
index f8e5a91..65415bb 100644
--- a/e2e/upgrade/cli_upgrade_test.go
+++ b/e2e/upgrade/cli_upgrade_test.go
@@ -38,8 +38,6 @@ import (
func TestOperatorUpgrade(t *testing.T) {
WithNewTestNamespace(t, func(ns string) {
- defer UninstallKamel(t, "--all", "--olm=false")
-
version, ok := os.LookupEnv("KAMEL_K_TEST_RELEASE_VERSION")
Expect(ok).To(BeTrue())
@@ -114,5 +112,9 @@ func TestOperatorUpgrade(t *testing.T) {
// Check the Integration runs correctly
Eventually(IntegrationPodPhase(ns, name), TestTimeoutMedium).Should(Equal(corev1.PodRunning))
Eventually(IntegrationConditionStatus(ns, name, v1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(corev1.ConditionTrue))
+
+ // Clean up
+ Expect(Kamel("delete", "--all", "-n", ns).Execute()).To(Succeed())
+ Expect(Kamel("uninstall", "--all", "--olm=false").Execute()).To(Succeed())
})
}
diff --git a/e2e/upgrade/olm_upgrade_test.go b/e2e/upgrade/olm_upgrade_test.go
index f454d37..6f6cde3 100644
--- a/e2e/upgrade/olm_upgrade_test.go
+++ b/e2e/upgrade/olm_upgrade_test.go
@@ -46,9 +46,6 @@ import (
const catalogSourceName = "test-camel-k-source"
func TestOLMAutomaticUpgrade(t *testing.T) {
- // Clean up cluster-wide resources that are not removed by OLM
- defer UninstallKamel(t, "--all", "--olm=false")
-
prevIIB := os.Getenv("CAMEL_K_PREV_IIB")
newIIB := os.Getenv("CAMEL_K_NEW_IIB")
kamel := os.Getenv("RELEASED_KAMEL_BIN")
@@ -196,6 +193,8 @@ func TestOLMAutomaticUpgrade(t *testing.T) {
// Clean up
Expect(Kamel("delete", "--all", "-n", ns).Execute()).To(Succeed())
Expect(Kamel("uninstall", "-n", ns).Execute()).To(Succeed())
+ // Clean up cluster-wide resources that are not removed by OLM
+ Expect(Kamel("uninstall", "--all", "--olm=false").Execute()).To(Succeed())
})
})
}