diff --git a/.github/workflows/install.yml b/.github/workflows/install.yml index f7078e812f..c1fad2c505 100644 --- a/.github/workflows/install.yml +++ b/.github/workflows/install.yml @@ -83,27 +83,6 @@ jobs: run: | make release-helm - - name: Install OLM - shell: bash - run: | - kubectl create -f https://github.com/operator-framework/operator-lifecycle-manager/releases/download/v0.28.0/crds.yaml - kubectl create -f https://github.com/operator-framework/operator-lifecycle-manager/releases/download/v0.28.0/olm.yaml - kubectl wait --for=jsonpath='{.status.phase}'=Succeeded csv packageserver -n olm --timeout=2m - - - name: Login to staging container registry - uses: docker/login-action@v3 - with: - registry: ghcr.io - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} - - - name: Build and push OLM bundle - shell: bash - run: | - echo "BUNDLE_IMAGE_NAME=ghcr.io/${{ github.actor }}/camel-k-bundle" >> $GITHUB_ENV - echo "Setting bundle image name as as $BUNDLE_IMAGE_NAME which is required by OLM tests" - BUNDLE_IMAGE_NAME=ghcr.io/${{ github.actor }}/camel-k-bundle make bundle-push - - name: Run tests shell: bash run: | diff --git a/.github/workflows/nightly-install-olm.yml b/.github/workflows/nightly-install-olm.yml new file mode 100644 index 0000000000..1ae89d381d --- /dev/null +++ b/.github/workflows/nightly-install-olm.yml @@ -0,0 +1,78 @@ +--- # --------------------------------------------------------------------------- + +# --------------------------------------------------------------------------- +# 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. +# --------------------------------------------------------------------------- + +# TODO: follow up the evolution of https://github.com/operator-framework/operator-sdk/issues/6699 +# and move into a normal test once it is possible for the operator-sdk to test local bundles +name: Nightly OLM test + + +env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + +on: + schedule: + - cron: "15 1 * * *" + workflow_dispatch: + +jobs: + release: + strategy: + fail-fast: false + matrix: + ref-branch: [main, release-2.3.x, release-2.4.x] + + if: github.repository == 'apache/camel-k' + runs-on: ubuntu-latest + steps: + - name: "Checkout code" + uses: actions/checkout@v4 + with: + ref: ${{ matrix.ref-branch }} + persist-credentials: false + submodules: recursive + + - name: Infra setting + uses: ./.github/actions/infra-setting + + - name: Install OLM + shell: bash + run: | + kubectl create -f https://github.com/operator-framework/operator-lifecycle-manager/releases/download/v0.28.0/crds.yaml + kubectl create -f https://github.com/operator-framework/operator-lifecycle-manager/releases/download/v0.28.0/olm.yaml + kubectl wait --for=jsonpath='{.status.phase}'=Succeeded csv packageserver -n olm --timeout=2m + + # Building and pushing a bundle to a running container is required due to how + # Operator-SDK works. Once it allows for local bundle testing, this part may be omitted + - name: Login to staging container registry + uses: docker/login-action@v3 + with: + username: ${{ secrets.TEST_DOCKER_HUB_USERNAME }} + password: ${{ secrets.TEST_DOCKER_HUB_PASSWORD }} + + - name: Build and push OLM bundle + shell: bash + run: | + echo "BUNDLE_IMAGE_NAME=docker.io/testcamelk/camel-k-bundle" >> $GITHUB_ENV + echo "Setting bundle image name as as $BUNDLE_IMAGE_NAME which is required by OLM tests" + BUNDLE_IMAGE_NAME=docker.io/testcamelk/camel-k-bundle make bundle-push + + - name: Run tests + shell: bash + run: | + DO_TEST_PREBUILD=false GOTESTFMT="-json 2>&1 | gotestfmt" make test-install-olm diff --git a/e2e/install/helm/setup_test.go b/e2e/install/helm/setup_test.go index a3e9a2efd6..f9c25b38b9 100644 --- a/e2e/install/helm/setup_test.go +++ b/e2e/install/helm/setup_test.go @@ -63,6 +63,8 @@ func TestHelmInstallation(t *testing.T) { "--force", ), ) + // Refresh the test client to account for the newly installed CRDs + RefreshClient(t) g.Eventually(OperatorPod(t, ctx, ns)).ShouldNot(BeNil()) // Check if restricted security context has been applied @@ -74,10 +76,9 @@ func TestHelmInstallation(t *testing.T) { // Test a simple route t.Run("simple route", func(t *testing.T) { - name := RandomizedSuffixName("yaml") - g.Expect(KamelRunWithID(t, ctx, operatorID, ns, "files/yaml.yaml", "--name", name).Execute()).To(Succeed()) - g.Eventually(IntegrationPodPhase(t, ctx, ns, name), TestTimeoutMedium).Should(Equal(corev1.PodRunning)) - g.Eventually(IntegrationLogs(t, ctx, ns, name), TestTimeoutShort).Should(ContainSubstring("Magicstring!")) + g.Expect(KamelRunWithID(t, ctx, operatorID, ns, "files/yaml.yaml").Execute()).To(Succeed()) + g.Eventually(IntegrationPodPhase(t, ctx, ns, "yaml"), TestTimeoutMedium).Should(Equal(corev1.PodRunning)) + g.Eventually(IntegrationLogs(t, ctx, ns, "yaml"), TestTimeoutShort).Should(ContainSubstring("Magicstring!")) }) ExpectExecSucceed(t, g, @@ -91,5 +92,10 @@ func TestHelmInstallation(t *testing.T) { ) g.Eventually(OperatorPod(t, ctx, ns)).Should(BeNil()) + + // Test CRD uninstall (will remove Integrations as well) + UninstallCRDs(t, ctx, g, "../../../") + + g.Eventually(CRDs(t)).Should(BeNil()) }) } diff --git a/e2e/install/kustomize/setup_test.go b/e2e/install/kustomize/setup_test.go index 926ab1d683..78114bd691 100644 --- a/e2e/install/kustomize/setup_test.go +++ b/e2e/install/kustomize/setup_test.go @@ -117,7 +117,6 @@ func TestKustomizeNamespaced(t *testing.T) { UninstallCRDs(t, ctx, g, "../../../") g.Eventually(OperatorPod(t, ctx, ns)).Should(BeNil()) - g.Eventually(Integration(t, ctx, ns, "yaml"), TestTimeoutShort).Should(BeNil()) g.Eventually(CRDs(t)).Should(BeNil()) }) } @@ -219,7 +218,6 @@ func TestKustomizeDescoped(t *testing.T) { UninstallCRDs(t, ctx, g, "../../../") g.Eventually(OperatorPod(t, ctx, ns)).Should(BeNil()) - g.Eventually(Integration(t, ctx, nsIntegration, "yaml"), TestTimeoutShort).Should(BeNil()) g.Eventually(CRDs(t)).Should(BeNil()) }) }) diff --git a/e2e/install/olm/olm_install_test.go b/e2e/install/olm/olm_install_test.go index 31d7f322d4..5f6b6f7d2d 100644 --- a/e2e/install/olm/olm_install_test.go +++ b/e2e/install/olm/olm_install_test.go @@ -63,6 +63,8 @@ func TestOLMInstallation(t *testing.T) { ), "180s", ) + // Refresh the test client to account for the newly installed CRDs + RefreshClient(t) // Find the only one Camel K CSV noAdditionalConditions := func(csv olm.ClusterServiceVersion) bool { return true @@ -73,8 +75,6 @@ func TestOLMInstallation(t *testing.T) { g.Eventually(OperatorPodPhase(t, ctx, ns), TestTimeoutMedium).Should(Equal(corev1.PodRunning)) g.Eventually(OperatorImage(t, ctx, ns), TestTimeoutShort).Should(Equal(defaults.OperatorImage())) - // This is required in order to wait the availability of IntegrationPlatform CRDs - g.Eventually(CRDs(t)).Should(HaveLen(ExpectedCRDs)) // Check the IntegrationPlatform has been reconciled after setting the expected container registry g.Expect(UpdatePlatform(t, ctx, ns, func(ip *v1.IntegrationPlatform) { ip.Spec.Build.Registry.Address = containerRegistry @@ -105,5 +105,9 @@ func TestOLMInstallation(t *testing.T) { g.Consistently( IntegrationConditionStatus(t, ctx, ns, "yaml", v1.IntegrationConditionReady), 15*time.Second, 5*time.Second). Should(Equal(corev1.ConditionTrue)) + + // Test CRD uninstall (will remove Integrations as well) + UninstallCRDs(t, ctx, g, "../../../") + g.Eventually(CRDs(t)).Should(BeNil()) }) } diff --git a/e2e/install/upgrade/upgrade_test.go b/e2e/install/upgrade/upgrade_test.go index 28d6ad76c0..50903ccc04 100644 --- a/e2e/install/upgrade/upgrade_test.go +++ b/e2e/install/upgrade/upgrade_test.go @@ -78,13 +78,15 @@ func TestUpgrade(t *testing.T) { installPrevCmd.Dir = lastVersionDir ExpectExecSucceed(t, g, installPrevCmd) + // Refresh the test client to account for the newly installed CRDs + RefreshClient(t) // Check the operator image is the previous one g.Eventually(OperatorImage(t, ctx, ns)).Should(ContainSubstring(lastVersion)) // Check the operator pod is running g.Eventually(OperatorPodPhase(t, ctx, ns), TestTimeoutMedium).Should(Equal(corev1.PodRunning)) // Check the IntegrationPlatform has been reconciled - g.Eventually(PlatformPhase(t, ctx, ns), TestTimeoutMedium).Should(Equal(v1.IntegrationPlatformPhaseReady)) - g.Eventually(PlatformVersion(t, ctx, ns), TestTimeoutMedium).Should(Equal(lastVersion)) + g.Eventually(PlatformPhase(t, ctx, ns)).Should(Equal(v1.IntegrationPlatformPhaseReady)) + g.Eventually(PlatformVersion(t, ctx, ns)).Should(Equal(lastVersion)) // We need a different namespace from the global operator WithNewTestNamespace(t, func(ctx context.Context, g *WithT, nsIntegration string) { @@ -105,6 +107,8 @@ func TestUpgrade(t *testing.T) { ) installNextCmd.Dir = "../../.." ExpectExecSucceed(t, g, installNextCmd) + // Refresh the test client to account for the newly installed CRDs + RefreshClient(t) // Check the operator image is the current built one g.Eventually(OperatorImage(t, ctx, ns)).Should(ContainSubstring(defaults.Version)) diff --git a/script/Makefile b/script/Makefile index 8462286509..68391a750f 100644 --- a/script/Makefile +++ b/script/Makefile @@ -301,16 +301,23 @@ test-advanced: exit $${FAILED} # -# Installation procedure test using CLi and Kustomize methodologies +# Installation and upgrade procedure test using # test-install: FAILED=0; \ go test -timeout 20m -v ./e2e/install/kustomize -tags=integration $(GOTESTFMT) || ((FAILED++)); \ go test -timeout 20m -v ./e2e/install/helm -tags=integration $(GOTESTFMT) || ((FAILED++)); \ - go test -timeout 20m -v ./e2e/install/olm -tags=integration $(GOTESTFMT) || ((FAILED++)); \ go test -timeout 60m -v ./e2e/install/upgrade -tags=integration $(GOTESTFMT) || ((FAILED++)); \ exit $${FAILED} +# +# Installation procedure test via OLM +# +test-install-olm: + FAILED=0; \ + go test -timeout 20m -v ./e2e/install/olm -tags=integration $(GOTESTFMT) || ((FAILED++)); \ + exit $${FAILED} + # # Knative tests that require the presence of Knative configuration #