From 4d4d7916634947e6b4e087b3a1826f1206233d90 Mon Sep 17 00:00:00 2001 From: Todd Swatling Date: Mon, 16 Dec 2024 14:14:06 -0500 Subject: [PATCH] operators-installer - private registry support tests refactor implement/refactor unit tests for the operators-installer operator approvaer job image pull from a private registry --- .../action.yaml | 168 ++++++++++++++++++ ...integration-tests-operators-installer.yaml | 150 +++++++--------- .github/workflows/install-unit-test.yaml | 59 +----- .../kind-config.yaml | 5 + .../private-registry/Chart.yaml | 0 _test/private-registry/README.md | 4 + .../templates/ConfigMap_local-registry.yaml | 11 ++ .../templates/Deployment_registry.yaml | 0 .../private-registry/templates/Ingress.yaml | 2 +- .../templates/PersistentVolumeClaim.yaml | 0 .../templates/Secret_htpasswd.yaml | 0 .../private-registry/templates/Service.yaml | 0 .../private-registry/templates/values.yaml | 0 _test/private-registry/values.yaml | 3 + .../private-registry/values.yaml | 3 - ...c-intermediate-manual-upgrades-values.yaml | 4 +- ...-approver-image-from-private-registry.yaml | 23 +++ ...ator-approve-not-via-helm-hook-values.yaml | 4 +- 18 files changed, 283 insertions(+), 153 deletions(-) create mode 100644 .github/actions/setup-kind-cluster-for-helm-chart-testing/action.yaml rename {charts/operators-installer/_integration-tests => _test}/kind-config.yaml (54%) rename {charts/operators-installer/_integration-tests => _test}/private-registry/Chart.yaml (100%) create mode 100644 _test/private-registry/README.md create mode 100644 _test/private-registry/templates/ConfigMap_local-registry.yaml rename {charts/operators-installer/_integration-tests => _test}/private-registry/templates/Deployment_registry.yaml (100%) rename {charts/operators-installer/_integration-tests => _test}/private-registry/templates/Ingress.yaml (86%) rename {charts/operators-installer/_integration-tests => _test}/private-registry/templates/PersistentVolumeClaim.yaml (100%) rename {charts/operators-installer/_integration-tests => _test}/private-registry/templates/Secret_htpasswd.yaml (100%) rename {charts/operators-installer/_integration-tests => _test}/private-registry/templates/Service.yaml (100%) rename {charts/operators-installer/_integration-tests => _test}/private-registry/templates/values.yaml (100%) create mode 100644 _test/private-registry/values.yaml delete mode 100644 charts/operators-installer/_integration-tests/private-registry/values.yaml create mode 100644 charts/operators-installer/_integration-tests/test-install-operator-with-approver-image-from-private-registry.yaml diff --git a/.github/actions/setup-kind-cluster-for-helm-chart-testing/action.yaml b/.github/actions/setup-kind-cluster-for-helm-chart-testing/action.yaml new file mode 100644 index 00000000..5de80753 --- /dev/null +++ b/.github/actions/setup-kind-cluster-for-helm-chart-testing/action.yaml @@ -0,0 +1,168 @@ +name: 'Setup Kind Cluster for Helm Chart Testing' +description: 'Setup Kind cluster for testing Helm Charts that expect to run with OLM and ingress' +inputs: + # renovate: datasource=github-releases depName=helm/helm + helm-version: + description: helm version to install + required: true + default: 'v3.16.3' + + # renovate: datasource=github-tags depName=python/cpython + python-version: + description: python version to install + required: true + default: 'v3.13.0' + + # renovate: datasource=github-releases depName=kubernetes-sigs/kind + kind-version: + description: kind version to install + required: true + default: 'v0.25.0' + + # renovate: datasource=github-releases depName=operator-framework/operator-lifecycle-manager + olm-version: + description: olm version to install + required: true + default: 'v0.30.0' + + local-registry-enabled: + description: whether to enable local authenticated registry + required: true + type: boolean + default: false + + local-registry-user: + description: local authenticated registry username + required: false + default: 'registryuser1' + + local-registry-password: + description: local authenticated registry password + required: false + default: 'registrypassword1' + + local-registry-uri: + description: local authenticated registry uri + required: false + default: 'registry.localhost' + + local-registry-images: + description: space separated list of remote container images to seed into the local private registry + required: false + default: '' + +runs: + using: "composite" + steps: + - name: Setup Helm 🧰 + uses: azure/setup-helm@fe7b79cd5ee1e45176fcad797de68ecaf3ca4814 # v4 + with: + version: ${{ inputs.helm-version }} + + - name: Setup Python 🐍 + uses: actions/setup-python@0b93645e9fea7318ecaed2b359559ac225c90a2b # v5 + with: + python-version: ${{ inputs.python-version }} + + - name: Setup kind cluster 🧰 + uses: helm/kind-action@0025e74a8c7512023d06dc019c617aa3cf561fde # v1.10.0 + with: + version: ${{ inputs.kind-version }} + config: _test/kind-config.yaml + + # for helm charts we are testing that require installing operators + - name: Setup kind cluster - Install OLM 🧰 + env: + OLM_VERSION: ${{ inputs.olm-version }} + shell: bash + run: | + curl -L https://github.com/operator-framework/operator-lifecycle-manager/releases/download/${OLM_VERSION}/install.sh -o install.sh + chmod +x install.sh + ./install.sh ${OLM_VERSION} + + # for helm charts we are testing that require ingress + - name: Setup kind cluster - Install ingress controller 🧰 + shell: bash + run: | + helm repo add haproxy-ingress https://haproxy-ingress.github.io/charts + helm install haproxy-ingress haproxy-ingress/haproxy-ingress \ + --create-namespace --namespace=ingress-controller \ + --set controller.hostNetwork=true + kubectl apply -f - <> $GITHUB_OUTPUT fi - - - name: Setup kind cluster 🧰 - uses: helm/kind-action@0025e74a8c7512023d06dc019c617aa3cf561fde # v1.10.0 - with: - version: ${{ env.KIND_VERSION }} - if: steps.changed-charts.outputs.changed == 'true' - - # for helm charts we are testing that require installing operators - - name: Setup kind cluster - Install OLM 🧰 - run: | - curl -L https://github.com/operator-framework/operator-lifecycle-manager/releases/download/${OLM_VERSION}/install.sh -o install.sh - chmod +x install.sh - ./install.sh ${OLM_VERSION} - if: steps.changed-charts.outputs.changed == 'true' - - # for helm charts we are testing that require ingress - - name: Setup kind cluster - Install ingress controller 🧰 - run: | - helm repo add haproxy-ingress https://haproxy-ingress.github.io/charts - helm install haproxy-ingress haproxy-ingress/haproxy-ingress \ - --create-namespace --namespace=ingress-controller \ - --set controller.hostNetwork=true - kubectl apply -f - <