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:20 UTC

[camel-k] 09/40: Adds the creation of a catalog source to tests

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 363c9981a93c53cc0a6d8437975535cd5a21a928
Author: phantomjinx <p....@phantomjinx.co.uk>
AuthorDate: Tue Nov 23 18:26:02 2021 +0000

    Adds the creation of a catalog source to tests
    
    * Since the bundle is built by default for OLM-enabled cluster, the tests
      need a catalog source with which to access it. Having it created within
      each namespace does not work as the catalogsource can take a couple of
      restarts to execute correctly. Therefore, a single catalogsource created
      prior to the test-running is far more effective.
---
 .github/actions/e2e-kubernetes/action.yml          | 10 ++++++
 .github/actions/e2e-upgrade/action.yml             |  3 +-
 .github/actions/kamel-build-bundle/action.yaml     | 38 ++++++++++++++++++++++
 .github/actions/kamel-build/action.yml             |  4 +++
 .../actions/kamel-config-cluster-custom/action.yml |  1 +
 5 files changed, 55 insertions(+), 1 deletion(-)

diff --git a/.github/actions/e2e-kubernetes/action.yml b/.github/actions/e2e-kubernetes/action.yml
index 05b84db..44adb5f 100644
--- a/.github/actions/e2e-kubernetes/action.yml
+++ b/.github/actions/e2e-kubernetes/action.yml
@@ -47,6 +47,8 @@ runs:
       image-namespace: ${{ env.CLUSTER_IMAGE_NAMESPACE }}
       # Builds the bundle if an OLM is available - depends on cluster being tested
       build-bundle: ${{ env.CLUSTER_HAS_OLM }}
+      # Can be empty and so catalog source will not be created
+      catalog-source-namespace: ${{ env.CLUSTER_CATALOG_SOURCE_NAMESPACE }}
 
   - id: install-kamel-cluster-setup
     name: Install Kamel Cluster Setup
@@ -62,6 +64,14 @@ runs:
       export CUSTOM_IMAGE=${{ env.BUILD_BINARY_LOCAL_IMAGE_NAME }}
       export CUSTOM_VERSION=${{ env.BUILD_BINARY_LOCAL_IMAGE_VERSION }}
 
+      #
+      # If bundle has been built and installed then use it
+      #
+      if [ -n "${{ env.BUILD_BUNDLE_CATALOG_SOURCE }}" ]; then
+        export KAMEL_INSTALL_OLM_SOURCE_NAMESPACE=${{ env.CLUSTER_IMAGE_NAMESPACE }}
+        export KAMEL_INSTALL_OLM_SOURCE=${{ env.BUILD_BUNDLE_CATALOG_SOURCE }}
+      fi
+
       export KAMEL_INSTALL_MAVEN_REPOSITORIES=$(make get-staging-repo)
       export KAMEL_INSTALL_REGISTRY=${{ env.CLUSTER_IMAGE_REGISTRY_PULL_HOST }}
       export KAMEL_INSTALL_REGISTRY_INSECURE=${{ env.CLUSTER_IMAGE_REGISTRY_INSECURE }}
diff --git a/.github/actions/e2e-upgrade/action.yml b/.github/actions/e2e-upgrade/action.yml
index b2516b6..5b3c36a 100644
--- a/.github/actions/e2e-upgrade/action.yml
+++ b/.github/actions/e2e-upgrade/action.yml
@@ -73,7 +73,8 @@ runs:
       # Builds the bundle if an OLM is available.
       # Since configure-cluster requires OLM then this should be true
       build-bundle: ${{ env.CLUSTER_HAS_OLM }}
-      kube-admin-user-ctx: ${{ env.CLUSTER_KUBE_ADMIN_USER_CTX }}
+      # Can be empty and so catalog source will not be created
+      catalog-source-namespace: ${{ env.CLUSTER_CATALOG_SOURCE_NAMESPACE }}
 
   - name: Run IT
     shell: bash
diff --git a/.github/actions/kamel-build-bundle/action.yaml b/.github/actions/kamel-build-bundle/action.yaml
index e490b41..54cc48f 100644
--- a/.github/actions/kamel-build-bundle/action.yaml
+++ b/.github/actions/kamel-build-bundle/action.yaml
@@ -35,6 +35,9 @@ inputs:
   local-image-version:
     description: "Reference of the camel-k image version"
     required: true
+  catalog-source-namespace:
+    description: 'Namespace in which to install the catalog source for the bundle (if required)'
+    required: false
 
 runs:
   using: "composite"
@@ -185,3 +188,38 @@ runs:
 
         docker push ${LOCAL_IIB}
         echo "BUILD_BUNDLE_LOCAL_IMAGE_BUNDLE_INDEX=${{ inputs.image-registry-pull-host }}/${{ inputs.image-namespace }}/camel-k-iib:${{ inputs.local-image-version }}" >> $GITHUB_ENV
+
+    - id: build-image-catalog
+      name: Create a new catalog to host the index image
+      shell: bash
+      run: |
+
+        if [ -z "${{ inputs.catalog-source-namespace }}" ]; then
+          echo "No catalog source namespace defined ... skipping catalog source creation"
+          exit 0
+        fi
+
+        kubectl get ns ${{ inputs.catalog-source-namespace }} &> /dev/null
+        if [ $? != 0 ]; then
+          echo "Error: Catalog source cannot be created as namespace ${{ inputs.catalog-source-namespace }} does not exist."
+          exit 1
+        fi
+
+        export BUILD_CATALOG_SOURCE="camel-k-test-source"
+        echo "BUILD_BUNDLE_CATALOG_SOURCE=${BUILD_CATALOG_SOURCE}" >> $GITHUB_ENV
+
+        cat <<EOF | kubectl apply -f -
+        apiVersion: operators.coreos.com/v1alpha1
+        kind: CatalogSource
+        metadata:
+          name: ${BUILD_CATALOG_SOURCE}
+          namespace: ${{ inputs.image-namespace }}
+        spec:
+          displayName: OLM upgrade test Catalog
+          image: ${{ env.BUILD_BUNDLE_LOCAL_IMAGE_BUNDLE_INDEX }}
+          sourceType: grpc
+          publisher: grpc
+          updateStrategy:
+            registryPoll:
+              interval: 1m0s
+        EOF
diff --git a/.github/actions/kamel-build/action.yml b/.github/actions/kamel-build/action.yml
index 1d23a34..ba84c06 100644
--- a/.github/actions/kamel-build/action.yml
+++ b/.github/actions/kamel-build/action.yml
@@ -36,6 +36,9 @@ inputs:
     description: 'Build a bundle for install into OLM catalog'
     required: true
     default: false
+  catalog-source-namespace:
+    description: 'Namespace in which to install the catalog source for the bundle (if required)'
+    required: false
 
 runs:
   using: "composite"
@@ -62,3 +65,4 @@ runs:
         image-namespace: ${{ inputs.image-namespace }}
         local-image-name: ${{ env.BUILD_BINARY_LOCAL_IMAGE_NAME }}
         local-image-version: ${{ env.BUILD_BINARY_LOCAL_IMAGE_VERSION }}
+        catalog-source-namespace: ${{ inputs.catalog-source-namespace }}
diff --git a/.github/actions/kamel-config-cluster-custom/action.yml b/.github/actions/kamel-config-cluster-custom/action.yml
index bb566e2..9af8276 100644
--- a/.github/actions/kamel-config-cluster-custom/action.yml
+++ b/.github/actions/kamel-config-cluster-custom/action.yml
@@ -196,6 +196,7 @@ runs:
         echo "CLUSTER_IMAGE_REGISTRY_PUSH_HOST=${{ env.e2e_image-registry-push-host }}" >> $GITHUB_ENV
         echo "CLUSTER_IMAGE_REGISTRY_PULL_HOST=${{ env.e2e_image-registry-pull-host }}" >> $GITHUB_ENV
         echo "CLUSTER_IMAGE_REGISTRY_INSECURE=${{ env.e2e_image-registry-insecure }}" >> $GITHUB_ENV
+        echo "CLUSTER_CATALOG_SOURCE_NAMESPACE=${{ env.e2e_catalog-source-namespace }}" >> $GITHUB_ENV
 
         #
         # Export the image namespace if defined in the cluster config