From 1a678e2e98362e3002927e9d1d92b579f2e0b1c6 Mon Sep 17 00:00:00 2001 From: pjuarezd Date: Tue, 13 Aug 2024 13:03:36 -0700 Subject: [PATCH] Fix tests for backported versions of Operator 5.0.x Signed-off-by: pjuarezd --- .github/workflows/kubernetes-tests.yml | 2 +- .github/workflows/ui.yaml | 30 ++++- testing/common.sh | 6 +- {tests => testing}/console-sa-secret.yaml | 0 {tests => testing}/start-tests-tenant.sh | 0 tests/common.sh | 132 ---------------------- web-app/Makefile | 4 +- web-app/check-warnings.sh | 2 +- 8 files changed, 37 insertions(+), 139 deletions(-) rename {tests => testing}/console-sa-secret.yaml (100%) rename {tests => testing}/start-tests-tenant.sh (100%) delete mode 100755 tests/common.sh diff --git a/.github/workflows/kubernetes-tests.yml b/.github/workflows/kubernetes-tests.yml index bce796b1fdc..00b2fd30e8d 100644 --- a/.github/workflows/kubernetes-tests.yml +++ b/.github/workflows/kubernetes-tests.yml @@ -174,7 +174,7 @@ jobs: key: ${{ runner.os }}-binary-${{ github.run_id }} - name: Tenant upgrade test on Kind run: | - "${GITHUB_WORKSPACE}/testing/deploy-tenant-upgrade.sh" + "${GITHUB_WORKSPACE}/testing/deploy-tenant-upgrade.sh" "5.0.16" test-kes: timeout-minutes: 30 runs-on: ${{ matrix.os }} diff --git a/.github/workflows/ui.yaml b/.github/workflows/ui.yaml index b1450da7375..bb5f9084bb2 100644 --- a/.github/workflows/ui.yaml +++ b/.github/workflows/ui.yaml @@ -15,6 +15,27 @@ concurrency: cancel-in-progress: true jobs: + operator: + timeout-minutes: 30 + runs-on: ${{ matrix.os }} + strategy: + matrix: + go-version: [ 1.21.x ] + os: [ ubuntu-latest ] + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-go@v4 + with: + go-version: ${{ matrix.go-version }} + - uses: actions/cache@v3 + name: Operator Binary Cache + with: + path: | + ./minio-operator + key: ${{ runner.os }}-ui-binary-${{ github.run_id }} + - name: Operator Binary + run: | + make operator semgrep-static-code-analysis: timeout-minutes: 30 @@ -311,6 +332,7 @@ jobs: - ui-assets - reuse-golang-dependencies - semgrep-static-code-analysis + - operator runs-on: ubuntu-latest strategy: @@ -327,13 +349,19 @@ jobs: go-version: ${{ matrix.go-version }} cache: true id: go + - uses: actions/cache@v3 + name: Operator Binary Cache + with: + path: | + ./minio-operator + key: ${{ runner.os }}-ui-binary-${{ github.run_id }} - name: Operator API Tests run: | curl -sLO "https://dl.k8s.io/release/v1.23.1/bin/linux/amd64/kubectl" -o kubectl chmod +x kubectl mv kubectl /usr/local/bin - "${GITHUB_WORKSPACE}/tests/start-tests-tenant.sh" + "${GITHUB_WORKSPACE}/testing/start-tests-tenant.sh" echo "start ---> make test-operator-integration"; make test-operator-integration; diff --git a/testing/common.sh b/testing/common.sh index 7f3605e3a01..068c671b39a 100644 --- a/testing/common.sh +++ b/testing/common.sh @@ -745,7 +745,7 @@ function check_tenant_status() { function install_cert_manager_tenant() { echo "Install cert-manager tenant from our example:" - try kubectl apply -k github.com/minio/operator/examples/kustomization/tenant-certmanager + try kubectl apply -k "${SCRIPT_DIR}/../examples/kustomization/tenant-certmanager" echo "Wait until tenant-certmanager-tls secret is generated by cert-manager..." while ! kubectl get secret tenant-certmanager-tls --namespace tenant-certmanager @@ -816,7 +816,9 @@ function install_tenant() { value=myminio echo "Installing lite tenant for version $1" - try kubectl apply -k "github.com/minio/operator/testing/tenant\?ref\=$1" + tenant_version="v${1}" + + try kubectl apply -k "github.com/minio/operator/testing/tenant?ref=$tenant_version" fi echo "Waiting for the tenant statefulset, this indicates the tenant is being fulfilled" diff --git a/tests/console-sa-secret.yaml b/testing/console-sa-secret.yaml similarity index 100% rename from tests/console-sa-secret.yaml rename to testing/console-sa-secret.yaml diff --git a/tests/start-tests-tenant.sh b/testing/start-tests-tenant.sh similarity index 100% rename from tests/start-tests-tenant.sh rename to testing/start-tests-tenant.sh diff --git a/tests/common.sh b/tests/common.sh deleted file mode 100755 index b3344df47e8..00000000000 --- a/tests/common.sh +++ /dev/null @@ -1,132 +0,0 @@ -#!/usr/bin/env bash -# Copyright (C) 2022, MinIO, Inc. -# -# This code is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License, version 3, -# as published by the Free Software Foundation. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License, version 3, -# along with this program. If not, see - -source "${GITHUB_WORKSPACE}/shared-functions/shared-code.sh" # This is common.sh for k8s tests across multiple repos. - -yell() { echo "$0: $*" >&2; } - -die() { - yell "$*" - (kind delete cluster || true ) && exit 111 -} - -try() { "$@" || die "cannot $*"; } - -function setup_kind() { - # TODO once feature is added: https://github.com/kubernetes-sigs/kind/issues/1300 - { - printf "kind: Cluster\n" - printf "apiVersion: kind.x-k8s.io/v1alpha4\n" - printf "nodes:\n" - printf " - role: control-plane\n" - printf " - role: worker\n" - printf " - role: worker\n" - printf " - role: worker\n" - printf " - role: worker\n" - } >> kind-config.yaml - echo "---" - cat kind-config.yaml - echo "----" - try kind create cluster --config kind-config.yaml - echo "Kind is ready" - try kubectl get nodes -} - -function get_latest_release() { - curl --silent "https://api.github.com/repos/$1/releases/latest" | - grep '"tag_name":' | - sed -E 's/.*"([^"]+)".*/\1/' -} - -function install_operator() { - - OPR_LATEST=$(get_latest_release minio/operator) - echo " Load minio/operator image ($OPR_LATEST) to the cluster" - try kubectl apply -k "github.com/minio/operator/?ref=$OPR_LATEST" - echo "Waiting for k8s api" - sleep 10 - echo "Waiting for Operator Pods to come online (2m timeout)" - - try kubectl wait --namespace minio-operator \ - --for=condition=ready pod \ - --selector=name=minio-operator \ - --timeout=120s -} - -function destroy_kind() { - kind delete cluster -} - -function check_tenant_status() { - # Check MinIO is accessible - - waitdone=0 - totalwait=0 - while true; do - waitdone=$(kubectl -n $1 get pods -l v1.min.io/tenant=$2 --no-headers | wc -l) - if [ "$waitdone" -ne 0 ]; then - echo "Found $waitdone pods" - break - fi - sleep 5 - totalwait=$((totalwait + 5)) - if [ "$totalwait" -gt 305 ]; then - echo "Unable to create tenant after 5 minutes, exiting." - try false - fi - done - - echo "Waiting for pods to be ready. (5m timeout)" - - USER=$(kubectl -n $1 get secrets $2-env-configuration -o go-template='{{index .data "config.env"|base64decode }}' | grep 'export MINIO_ROOT_USER="' | sed -e 's/export MINIO_ROOT_USER="//g' | sed -e 's/"//g') - PASSWORD=$(kubectl -n $1 get secrets $2-env-configuration -o go-template='{{index .data "config.env"|base64decode }}' | grep 'export MINIO_ROOT_PASSWORD="' | sed -e 's/export MINIO_ROOT_PASSWORD="//g' | sed -e 's/"//g') - - try kubectl wait --namespace $1 \ - --for=condition=ready pod \ - --selector=v1.min.io/tenant=$2 \ - --timeout=300s - - echo "Tenant is created successfully, proceeding to validate 'mc admin info minio/'" - - kubectl run admin-mc -i --tty --image minio/mc --command -- bash -c "until (mc alias set minio/ https://minio.$1.svc.cluster.local $USER $PASSWORD); do echo \"...waiting... for 5secs\" && sleep 5; done; mc admin info minio/;" - - echo "Done." -} - -# Install tenant function is being used by deploy-tenant and check-prometheus -function install_tenant() { - - namespace=tenant-lite - key=v1.min.io/tenant - value=myminio - echo "Installing lite tenant" - - try kubectl apply -k "${GITHUB_WORKSPACE}/examples/kustomization/tenant-lite" - - echo "Waiting for the tenant statefulset, this indicates the tenant is being fulfilled" - echo $namespace - echo $value - echo $key - wait_for_resource $namespace $value $key - - echo "Waiting for tenant pods to come online (5m timeout)" - try kubectl wait --namespace $namespace \ - --for=condition=ready pod \ - --selector $key=$value \ - --timeout=300s - - echo "Build passes basic tenant creation" - -} diff --git a/web-app/Makefile b/web-app/Makefile index e79e87f4c70..3b5fea3891a 100644 --- a/web-app/Makefile +++ b/web-app/Makefile @@ -3,9 +3,9 @@ default: build-static build-static: @echo "Building frontend static assets to 'build'" @if [ -f "${NVM_DIR}/nvm.sh" ]; then \. "${NVM_DIR}/nvm.sh" && nvm install && nvm use; fi && \ - NODE_OPTIONS=--openssl-legacy-provider yarn build + yarn build -test-warnings: +test-warnings build-static: ./check-warnings.sh test-prettier: diff --git a/web-app/check-warnings.sh b/web-app/check-warnings.sh index 9013400d62e..202a6c094a2 100755 --- a/web-app/check-warnings.sh +++ b/web-app/check-warnings.sh @@ -11,7 +11,7 @@ die() { try() { "$@" &> yarn.log || die "cannot $*"; } rm -f yarn.log -try make build-static +try yarn build if grep "Compiled with warnings" yarn.log; then echo "There are warnings in the code"