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
The following commit(s) were added to refs/heads/main by this push:
new d0f64e0 [TEST] Add cross-channel upgrade test feature
d0f64e0 is described below
commit d0f64e066332c1bd4535bcffb6b09bd9f98ce11c
Author: Jan Bouska <[email protected]>
AuthorDate: Mon Oct 25 06:26:37 2021 -0400
[TEST] Add cross-channel upgrade test feature
---
e2e/upgrade/olm_upgrade_test.go | 26 +++++++++++++++++++++++++-
e2e/upgrade/util.go | 15 +++++++++++++++
2 files changed, 40 insertions(+), 1 deletion(-)
diff --git a/e2e/upgrade/olm_upgrade_test.go b/e2e/upgrade/olm_upgrade_test.go
index ac4d39c..9da68a1 100644
--- a/e2e/upgrade/olm_upgrade_test.go
+++ b/e2e/upgrade/olm_upgrade_test.go
@@ -50,10 +50,20 @@ func TestOLMAutomaticUpgrade(t *testing.T) {
newIIB := os.Getenv("CAMEL_K_NEW_IIB")
kamel := os.Getenv("RELEASED_KAMEL_BIN")
+ // optional options
+ prevUpdateChannel := os.Getenv("CAMEL_K_PREV_UPGRADE_CHANNEL")
+ newUpdateChannel := os.Getenv("CAMEL_K_NEW_UPGRADE_CHANNEL")
+
if prevIIB == "" || newIIB == "" {
t.Skip("OLM Upgrade test requires the CAMEL_K_PREV_IIB and
CAMEL_K_NEW_IIB environment variables")
}
+ crossChannelUpgrade := false
+ if prevUpdateChannel != "" && newUpdateChannel != "" &&
prevUpdateChannel != newUpdateChannel {
+ crossChannelUpgrade = true
+ t.Logf("Testing cross-OLM channel upgrade %s -> %s",
prevUpdateChannel, newUpdateChannel)
+ }
+
WithNewTestNamespace(t, func(ns string) {
Expect(createOrUpdateCatalogSource(ns, catalogSourceName,
prevIIB)).To(Succeed())
Eventually(catalogSourcePhase(ns, catalogSourceName),
TestTimeoutMedium).Should(Equal("READY"))
@@ -61,7 +71,13 @@ func TestOLMAutomaticUpgrade(t *testing.T) {
// Set KAMEL_BIN only for this test - don't override the ENV
variable for all tests
Expect(os.Setenv("KAMEL_BIN", kamel)).To(Succeed())
- Expect(Kamel("install", "-n", ns, "--olm=true", "--olm-source",
catalogSourceName, "--olm-source-namespace", ns).Execute()).To(Succeed())
+ args := []string{"install", "-n", ns, "--olm=true",
"--olm-source", catalogSourceName, "--olm-source-namespace", ns}
+
+ if crossChannelUpgrade {
+ args = append(args, "--olm-channel",
os.Getenv("CAMEL_K_PREV_UPGRADE_CHANNEL"))
+ }
+
+ Expect(Kamel(args...).Execute()).To(Succeed())
// Find the only one Camel-K CSV
noAdditionalConditions := func(csv olm.ClusterServiceVersion)
bool {
@@ -102,6 +118,14 @@ func TestOLMAutomaticUpgrade(t *testing.T) {
// Trigger Camel K operator upgrade by updating the
CatalogSource with the new index image
Expect(createOrUpdateCatalogSource(ns,
catalogSourceName, newIIB)).To(Succeed())
+ if crossChannelUpgrade {
+ t.Log("Updating Camel-K subscription OLM update
channel.")
+ s := ckSubscription(ns)()
+ ctrlutil.CreateOrUpdate(TestContext,
TestClient(), s, func() error {
+ s.Spec.Channel = newUpdateChannel
+ return nil
+ })
+ }
// Check the previous CSV is being replaced
Eventually(clusterServiceVersionPhase(func(csv
olm.ClusterServiceVersion) bool {
return csv.Spec.Version.Version.String() ==
prevCSVVersion.Version.String()
diff --git a/e2e/upgrade/util.go b/e2e/upgrade/util.go
index 7bbeccd..3514e97 100644
--- a/e2e/upgrade/util.go
+++ b/e2e/upgrade/util.go
@@ -91,3 +91,18 @@ func catalogSourcePhase(ns, name string) func() string {
return ""
}
}
+
+func ckSubscription(ns string) func() *olm.Subscription {
+ return func() *olm.Subscription {
+ lst := olm.SubscriptionList{}
+ if err := TestClient().List(TestContext, &lst,
ctrl.InNamespace(ns)); err != nil {
+ panic(err)
+ }
+ for _, s := range lst.Items {
+ if strings.Contains(s.Name, "camel-k") {
+ return &s
+ }
+ }
+ return nil
+ }
+}