From 0360e99fca5c6b4ccf29783f5a6d40de02f254e2 Mon Sep 17 00:00:00 2001 From: lfabriko Date: Tue, 2 May 2023 11:17:37 +0200 Subject: [PATCH 1/3] Add often used cli commands I suggest to add to overview cli commands which are referenced in other parts of documentation (kamel install/uninstall/bind) or are often used (rebuild, reset, version) --- docs/modules/ROOT/pages/cli/cli.adoc | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/docs/modules/ROOT/pages/cli/cli.adoc b/docs/modules/ROOT/pages/cli/cli.adoc index 083998393f..6628071e23 100644 --- a/docs/modules/ROOT/pages/cli/cli.adoc +++ b/docs/modules/ROOT/pages/cli/cli.adoc @@ -59,6 +59,30 @@ Some of the most used commands are: |Delete integrations deployed on Kubernetes |kamel delete routes +|bind +|Bind Kubernetes resources, such as Kamelets, in an integration flow. +|kamel bind timer-source -p "source.message=hello world" channel:mychannel + +|install +|Install Camel K on a Kubernetes cluster +|kamel install + +|rebuild +|Clear the state of integrations to rebuild them. +|kamel rebuild --all + +|reset +|Reset the Camel K installation +|kamel reset + +|uninstall +|Uninstall Camel K from a Kubernetes cluster +|kamel uninstall + +|version +|Display client version +|kamel version + |=== The list above is not the full list of available commands. From 2c6fb203b22d0c41650992fc3a8ab78ab90edcd6 Mon Sep 17 00:00:00 2001 From: Lucie Krejcirova Date: Wed, 6 Sep 2023 11:20:57 +0200 Subject: [PATCH 2/3] Add pipe to olm_upgrade_test --- e2e/install/upgrade/olm_upgrade_test.go | 65 +++++++++++++++---------- e2e/support/test_support.go | 8 +++ 2 files changed, 47 insertions(+), 26 deletions(-) diff --git a/e2e/install/upgrade/olm_upgrade_test.go b/e2e/install/upgrade/olm_upgrade_test.go index 64bcf57b29..0d8fa442a8 100644 --- a/e2e/install/upgrade/olm_upgrade_test.go +++ b/e2e/install/upgrade/olm_upgrade_test.go @@ -24,23 +24,20 @@ package upgrade import ( "fmt" - "os" - "testing" - "time" - . "github.com/apache/camel-k/v2/e2e/support" + v1 "github.com/apache/camel-k/v2/pkg/apis/camel/v1" . "github.com/onsi/gomega" "github.com/stretchr/testify/assert" - - corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/types" - + "os" ctrl "sigs.k8s.io/controller-runtime/pkg/client" + "testing" + "time" "github.com/operator-framework/api/pkg/lib/version" olm "github.com/operator-framework/api/pkg/operators/v1alpha1" + corev1 "k8s.io/api/core/v1" - v1 "github.com/apache/camel-k/v2/pkg/apis/camel/v1" "github.com/apache/camel-k/v2/pkg/util/defaults" "github.com/apache/camel-k/v2/pkg/util/openshift" ) @@ -67,6 +64,7 @@ func TestOLMOperatorUpgrade(t *testing.T) { } WithNewTestNamespace(t, func(ns string) { + Expect(CreateOrUpdateCatalogSource(ns, catalogSourceName, prevIIB)).To(Succeed()) ocp, err := openshift.IsOpenShift(TestClient()) assert.Nil(t, err) @@ -115,11 +113,11 @@ func TestOLMOperatorUpgrade(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) - t.Logf("Using Previous CSV Version: %s", prevCSVVersion.Version.String()) + prevIPVersionPrefix = fmt.Sprintf("%d.%d", prevCSVVersion.Version.Major, prevCSVVersion.Version.Minor) //1.10 + t.Logf("Using Previous CSV Version: %s", prevCSVVersion.Version.String()) //Using Previous CSV Version: 1.10.1+0.1693789561.p // Check the operator pod is running Eventually(OperatorPodPhase(ns), TestTimeoutMedium).Should(Equal(corev1.PodRunning)) @@ -129,13 +127,23 @@ func TestOLMOperatorUpgrade(t *testing.T) { 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)) + if prevCSVVersion.Version.String() >= "2" { // since 2.0 Pipe, previously KameletBinding + Eventually(PipeConditionStatus(ns, kbindName, v1.PipeConditionReady), 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 @@ -156,11 +164,6 @@ func TestOLMOperatorUpgrade(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() @@ -172,7 +175,7 @@ func TestOLMOperatorUpgrade(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())) @@ -180,7 +183,7 @@ func TestOLMOperatorUpgrade(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) { @@ -192,7 +195,11 @@ func TestOLMOperatorUpgrade(t *testing.T) { Should(ContainSubstring(prevIPVersionPrefix)) // Rebuild the Integration - Expect(Kamel("rebuild", name, "-n", ns).Execute()).To(Succeed()) + Expect(Kamel("rebuild", "--all", "-n", ns).Execute()).To(Succeed()) + if prevCSVVersion.Version.String() >= "2" { + Eventually(PipeConditionStatus(ns, kbindName, v1.PipeConditionReady), TestTimeoutMedium). + Should(Equal(corev1.ConditionTrue)) + } // Check the Integration runs correctly Eventually(IntegrationPodPhase(ns, name), TestTimeoutLong).Should(Equal(corev1.PodRunning)) @@ -200,30 +207,36 @@ func TestOLMOperatorUpgrade(t *testing.T) { 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)) + Eventually(IntegrationVersion(ns, kbindName)).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, KitWithVersion(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, KitWithVersion(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)) + 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 50827025eb..7531c32b1b 100644 --- a/e2e/support/test_support.go +++ b/e2e/support/test_support.go @@ -1239,6 +1239,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(), From 117d05bef007cd21836e0b6660308e5c39bb3ca9 Mon Sep 17 00:00:00 2001 From: Lucie Krejcirova Date: Wed, 6 Sep 2023 11:31:12 +0200 Subject: [PATCH 3/3] Removed comments --- e2e/install/upgrade/olm_upgrade_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/e2e/install/upgrade/olm_upgrade_test.go b/e2e/install/upgrade/olm_upgrade_test.go index 0d8fa442a8..4b1fb92b53 100644 --- a/e2e/install/upgrade/olm_upgrade_test.go +++ b/e2e/install/upgrade/olm_upgrade_test.go @@ -116,8 +116,8 @@ func TestOLMOperatorUpgrade(t *testing.T) { var newIPVersionMajorMinorPatch string prevCSVVersion = ClusterServiceVersion(noAdditionalConditions, ns)().Spec.Version - prevIPVersionPrefix = fmt.Sprintf("%d.%d", prevCSVVersion.Version.Major, prevCSVVersion.Version.Minor) //1.10 - t.Logf("Using Previous CSV Version: %s", prevCSVVersion.Version.String()) //Using Previous CSV Version: 1.10.1+0.1693789561.p + prevIPVersionPrefix = fmt.Sprintf("%d.%d", prevCSVVersion.Version.Major, prevCSVVersion.Version.Minor) + t.Logf("Using Previous CSV Version: %s", prevCSVVersion.Version.String()) // Check the operator pod is running Eventually(OperatorPodPhase(ns), TestTimeoutMedium).Should(Equal(corev1.PodRunning))