This is an automated email from the ASF dual-hosted git repository.
pcongiusti pushed a commit to branch release-1.10.x
in repository https://gitbox.apache.org/repos/asf/camel-k.git
The following commit(s) were added to refs/heads/release-1.10.x by this push:
new 65b286b01 Add klb to olm_upgrade_test - branch 1.10.x
65b286b01 is described below
commit 65b286b012ff37c7ac524d379fa68918d62e5147
Author: Lucie Krejcirova <[email protected]>
AuthorDate: Thu May 4 10:32:53 2023 +0200
Add klb to olm_upgrade_test - branch 1.10.x
---
e2e/namespace/upgrade/olm_upgrade_test.go | 49 +++++++++++++++++--------------
e2e/support/test_support.go | 12 +++++---
2 files changed, 35 insertions(+), 26 deletions(-)
diff --git a/e2e/namespace/upgrade/olm_upgrade_test.go
b/e2e/namespace/upgrade/olm_upgrade_test.go
index 19e140931..c86a7ddb9 100644
--- a/e2e/namespace/upgrade/olm_upgrade_test.go
+++ b/e2e/namespace/upgrade/olm_upgrade_test.go
@@ -24,6 +24,7 @@ package common
import (
"fmt"
+ "github.com/apache/camel-k/pkg/apis/camel/v1alpha1"
"os"
"testing"
"time"
@@ -101,7 +102,7 @@ func TestOLMAutomaticUpgrade(t *testing.T) {
// IntegrationPlatform should match at least on the version
prefix
// CSV patch version can be increased with the OperatorHub
respin of the same Camel K release
var prevIPVersionPrefix string
- var newIPVersionPrefix string
+ var newIPVersionMajorMinorPatch string
prevCSVVersion = clusterServiceVersion(noAdditionalConditions,
ns)().Spec.Version
prevIPVersionPrefix = fmt.Sprintf("%d.%d",
prevCSVVersion.Version.Major, prevCSVVersion.Version.Minor)
@@ -111,16 +112,24 @@ func TestOLMAutomaticUpgrade(t *testing.T) {
Eventually(OperatorPodPhase(ns),
TestTimeoutMedium).Should(Equal(corev1.PodRunning))
// Check the IntegrationPlatform has been reconciled
+ t.Logf("Platform version: %s", PlatformVersion(ns)())
Eventually(PlatformVersion(ns)).Should(ContainSubstring(prevIPVersionPrefix))
name := "yaml"
Expect(Kamel("run", "-n", ns,
"files/yaml.yaml").Execute()).To(Succeed())
+ kbindName := "timer-to-log"
+ Expect(KamelBind(ns, "timer-source?message=Hello", "log-sink",
"--name", kbindName).Execute()).To(Succeed())
// Check the Integration runs correctly
Eventually(IntegrationPodPhase(ns, name),
TestTimeoutLong).Should(Equal(corev1.PodRunning))
Eventually(IntegrationConditionStatus(ns, name,
v1.IntegrationConditionReady),
TestTimeoutLong).Should(Equal(corev1.ConditionTrue))
+ Eventually(KameletBindingConditionStatus(ns, kbindName,
v1alpha1.KameletBindingConditionReady), TestTimeoutShort).
+ Should(Equal(corev1.ConditionTrue))
+ Eventually(IntegrationPodPhase(ns, kbindName),
TestTimeoutLong).Should(Equal(corev1.PodRunning))
+ Eventually(IntegrationConditionStatus(ns, kbindName,
v1.IntegrationConditionReady),
TestTimeoutLong).Should(Equal(corev1.ConditionTrue))
// Check the Integration version matches that of the current
operator
Expect(IntegrationVersion(ns,
name)()).To(ContainSubstring(prevIPVersionPrefix))
+ Expect(IntegrationVersion(ns,
kbindName)()).To(ContainSubstring(prevIPVersionPrefix))
t.Run("OLM upgrade", func(t *testing.T) {
// Trigger Camel K operator upgrade by updating the
CatalogSource with the new index image
@@ -139,11 +148,6 @@ func TestOLMAutomaticUpgrade(t *testing.T) {
Expect(subscription.Spec.Channel).To(Equal(newUpdateChannel))
}
- // Check the previous CSV is being replaced
- Eventually(clusterServiceVersionPhase(func(csv
olm.ClusterServiceVersion) bool {
- return csv.Spec.Version.Version.String() ==
prevCSVVersion.Version.String()
- }, ns),
TestTimeoutMedium).Should(Equal(olm.CSVPhaseReplacing))
-
// The new CSV is installed
Eventually(clusterServiceVersionPhase(func(csv
olm.ClusterServiceVersion) bool {
return csv.Spec.Version.Version.String() !=
prevCSVVersion.Version.String()
@@ -155,7 +159,7 @@ func TestOLMAutomaticUpgrade(t *testing.T) {
}, ns), TestTimeoutMedium).Should(BeNil())
newCSVVersion =
clusterServiceVersion(noAdditionalConditions, ns)().Spec.Version
- newIPVersionPrefix = fmt.Sprintf("%d.%d",
newCSVVersion.Version.Major, newCSVVersion.Version.Minor)
+ newIPVersionMajorMinorPatch = fmt.Sprintf("%d.%d.%d",
newCSVVersion.Version.Major, newCSVVersion.Version.Minor,
newCSVVersion.Version.Patch)
Expect(prevCSVVersion.Version.String()).NotTo(Equal(newCSVVersion.Version.String()))
@@ -163,7 +167,7 @@ func TestOLMAutomaticUpgrade(t *testing.T) {
Eventually(OperatorImage(ns),
TestTimeoutShort).Should(Equal(defaults.OperatorImage()))
// Check the IntegrationPlatform has been reconciled
-
Eventually(PlatformVersion(ns)).Should(ContainSubstring(newIPVersionPrefix))
+
Eventually(PlatformVersion(ns)).Should(ContainSubstring(newIPVersionMajorMinorPatch))
})
t.Run("Integration upgrade", func(t *testing.T) {
@@ -174,42 +178,43 @@ func TestOLMAutomaticUpgrade(t *testing.T) {
Consistently(IntegrationVersion(ns, name),
5*time.Second, 1*time.Second).Should(ContainSubstring(prevIPVersionPrefix))
// Rebuild the Integration
- Expect(Kamel("rebuild", name, "-n",
ns).Execute()).To(Succeed())
+ Expect(Kamel("rebuild", "--all", "-n",
ns).Execute()).To(Succeed())
+ Eventually(KameletBindingConditionStatus(ns, kbindName,
v1alpha1.KameletBindingConditionReady),
TestTimeoutMedium).Should(Equal(corev1.ConditionTrue))
// Check the Integration runs correctly
Eventually(IntegrationPodPhase(ns, name),
TestTimeoutLong).Should(Equal(corev1.PodRunning))
Eventually(IntegrationConditionStatus(ns, name,
v1.IntegrationConditionReady),
TestTimeoutMedium).Should(Equal(corev1.ConditionTrue))
// Check the Integration version has been upgraded
- Eventually(IntegrationVersion(ns,
name)).Should(ContainSubstring(newIPVersionPrefix))
+ Eventually(IntegrationVersion(ns,
name)).Should(ContainSubstring(newIPVersionMajorMinorPatch))
// Check the previous kit is not garbage collected
(skip Build - present in case of respin)
prevCSVVersionMajorMinorPatch := fmt.Sprintf("%d.%d.%d",
prevCSVVersion.Version.Major,
prevCSVVersion.Version.Minor, prevCSVVersion.Version.Patch)
- Eventually(Kits(ns,
KitWithVersion(prevCSVVersionMajorMinorPatch))).Should(HaveLen(1))
+ Eventually(Kits(ns,
KitWithVersionPrefix(prevCSVVersionMajorMinorPatch))).Should(HaveLen(2))
// Check a new kit is created with the current version
- Eventually(Kits(ns, KitWithVersion(defaults.Version)),
- TestTimeoutMedium).Should(HaveLen(1))
+ Eventually(Kits(ns,
KitWithVersionPrefix(newIPVersionMajorMinorPatch))).Should(HaveLen(2))
// Check the new kit is ready
- Eventually(Kits(ns, KitWithVersion(defaults.Version),
KitWithPhase(v1.IntegrationKitPhaseReady)),
- TestTimeoutMedium).Should(HaveLen(1))
+ Eventually(Kits(ns,
KitWithVersionPrefix(newIPVersionMajorMinorPatch),
KitWithPhase(v1.IntegrationKitPhaseReady)),
+ TestTimeoutMedium).Should(HaveLen(2))
- kit := Kits(ns, KitWithVersion(defaults.Version))()[0]
+ kit := Kits(ns,
KitWithVersionPrefix(newIPVersionMajorMinorPatch),
KitWithLabels(map[string]string{"camel.apache.org/created.by.name": name}))()[0]
+ kitKbind := Kits(ns,
KitWithVersionPrefix(newIPVersionMajorMinorPatch),
KitWithLabels(map[string]string{"camel.apache.org/created.by.name":
kbindName}))()[0]
// Check the Integration uses the new kit
Eventually(IntegrationKit(ns, name),
TestTimeoutMedium).Should(Equal(kit.Name))
+ Eventually(IntegrationKit(ns, kbindName),
TestTimeoutMedium).Should(Equal(kitKbind.Name))
// Check the Integration Pod uses the new image
Eventually(IntegrationPodImage(ns,
name)).Should(Equal(kit.Status.Image))
+ Eventually(IntegrationPodImage(ns,
kbindName)).Should(Equal(kitKbind.Status.Image))
// Check the Integration runs correctly
Eventually(IntegrationPodPhase(ns,
name)).Should(Equal(corev1.PodRunning))
+ Eventually(IntegrationPodPhase(ns,
kbindName)).Should(Equal(corev1.PodRunning))
Eventually(IntegrationConditionStatus(ns, name,
v1.IntegrationConditionReady),
TestTimeoutLong).Should(Equal(corev1.ConditionTrue))
-
- // 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", "-n", ns,
"--olm=false").Execute()).To(Succeed())
+ Eventually(IntegrationConditionStatus(ns, kbindName,
v1.IntegrationConditionReady),
TestTimeoutLong).Should(Equal(corev1.ConditionTrue))
})
+ // Clean up
+ Expect(Kamel("delete", "--all", "-n",
ns).Execute()).To(Succeed())
})
}
diff --git a/e2e/support/test_support.go b/e2e/support/test_support.go
index b006486d7..dde3be530 100644
--- a/e2e/support/test_support.go
+++ b/e2e/support/test_support.go
@@ -107,11 +107,9 @@ func setTestLocus(t *testing.T) {
testLocus = t
}
-//
// Only panic the test if absolutely necessary and there is
// no test locus. In most cases, the test should fail gracefully
// using the test locus to error out and fail now.
-//
func failTest(err error) {
if testLocus != nil {
testLocus.Error(err)
@@ -726,9 +724,7 @@ func ServiceType(ns string, name string) func()
corev1.ServiceType {
}
}
-//
// Find the service in the given namespace with the given type
-//
func ServicesByType(ns string, svcType corev1.ServiceType) func()
[]corev1.Service {
return func() []corev1.Service {
svcs := []corev1.Service{}
@@ -1058,6 +1054,14 @@ func KitWithVersion(version string) KitFilter {
}
}
+func KitWithVersionPrefix(versionPrefix string) KitFilter {
+ return &kitFilter{
+ filter: func(kit *v1.IntegrationKit) bool {
+ return strings.HasPrefix(kit.Status.Version,
versionPrefix)
+ },
+ }
+}
+
func KitWithLabels(kitLabels map[string]string) ctrl.ListOption {
return ctrl.MatchingLabelsSelector{
Selector: labels.Set(kitLabels).AsSelector(),