diff --git a/.github/workflows/bash.yml b/.github/workflows/bash.yml new file mode 100644 index 00000000000..e2a24e991b6 --- /dev/null +++ b/.github/workflows/bash.yml @@ -0,0 +1,33 @@ +# This is a basic workflow to execute our Tenant deployment script + +name: Bash + +# Controls when the workflow will run +on: + # Triggers the workflow on push or pull request events but only for the main branch + push: + branches: [ master ] + pull_request: + branches: [ master ] + + # Allows you to run this workflow manually from the Actions tab + workflow_dispatch: + +# A workflow run is made up of one or more jobs that can run sequentially or in parallel +jobs: + # This workflow contains a single job called "build" + build: + # The type of runner that the job will run on + runs-on: ubuntu-latest + + # Steps represent a sequence of tasks that will be executed as part of the job + steps: + # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it + - uses: actions/checkout@v2 + + # Runs a set of commands using the runners shell + - name: Run a multi-line script + run: | + chmod 755 "${GITHUB_WORKSPACE}/testing/basic-tenant.sh" + cd "${GITHUB_WORKSPACE}/testing/" + "${GITHUB_WORKSPACE}/testing/basic-tenant.sh" diff --git a/testing/basic-tenant.sh b/testing/basic-tenant.sh new file mode 100644 index 00000000000..c1d146972d5 --- /dev/null +++ b/testing/basic-tenant.sh @@ -0,0 +1,91 @@ +#!/bin/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 + +# This script requires: kubectl, kind + +yell() { echo "$0: $*" >&2; } + +die() { + yell "$*" + (kind delete cluster || true ) && exit 111 +} + +try() { "$@" || die "cannot $*"; } + +try kind create cluster --config kind-config.yaml + +echo "Installing Current Operator" + +# TODO: Compile the current branch and create an overlay to use that image version +try kubectl apply -k ../resources + +echo "Waiting for Operator Pods to come online" + +try kubectl wait --namespace minio-operator \ + --for=condition=ready pod \ + --selector=name=minio-operator \ + --timeout=90s + +echo "Installing lite tenant" + +try kubectl apply -k ../examples/kustomization/tenant-lite + + +echo "Waiting for the tenant statefulset, this indicates the tenant is being fulfilled" +waitdone=0 +totalwait=0 +while true; do + waitdone=$(kubectl -n tenant-lite get pods -l v1.min.io/tenant=storage-lite --no-headers | wc -l) + if [ "$waitdone" -ne 0 ]; then + echo "Found $waitdone pods" + break + fi + sleep 5 + totalwait=$((totalwait + 5)) + if [ "$totalwait" -gt 300 ]; then + echo "Tenant never created statefulset after 5 minutes" + try false + fi +done + +echo "Waiting for tenant pods to come online (5m timeout)" +try kubectl wait --namespace tenant-lite \ + --for=condition=ready pod \ + --selector="v1.min.io/tenant=storage-lite" \ + --timeout=300s + +echo "Build passes basic tenant creation" + +# Check MinIO is accessible + +waitdone=0 +totalwait=0 +while true; do + waitdone=$(kubectl -n tenant-lite get pods -l v1.min.io/tenant=storage-lite --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 + +# clean up +kind delete cluster diff --git a/testing/kind-config.yaml b/testing/kind-config.yaml new file mode 100644 index 00000000000..d0e1792e37d --- /dev/null +++ b/testing/kind-config.yaml @@ -0,0 +1,9 @@ +# four node (two workers) cluster config +kind: Cluster +apiVersion: kind.x-k8s.io/v1alpha4 +nodes: + - role: control-plane + - role: worker + - role: worker + - role: worker + - role: worker