From 05de8e6fb689dceedce669bdf42c128d01f93946 Mon Sep 17 00:00:00 2001 From: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com> Date: Mon, 3 Jan 2022 12:55:27 -0800 Subject: [PATCH 01/13] Basic Tenant deployment script Signed-off-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com> --- testing/basic-tenant.sh | 77 ++++++++++++++++++++++++++++++++++++++++ testing/kind-config.yaml | 9 +++++ 2 files changed, 86 insertions(+) create mode 100644 testing/basic-tenant.sh create mode 100644 testing/kind-config.yaml diff --git a/testing/basic-tenant.sh b/testing/basic-tenant.sh new file mode 100644 index 00000000000..ff106ee9d69 --- /dev/null +++ b/testing/basic-tenant.sh @@ -0,0 +1,77 @@ +#!/bin/bash + +# This script requires: kubectl, kind, jq + +#set -e + +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 :; do + waitdone=$(kubectl -n tenant-lite get pods -o json | jq '.items | length') + 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=tenant-lite" \ + --timeout=300s + +echo "Build passes basic tenant creation" + +# Check MinIO is accessible + +waitdone=0 +totalwait=0 +while :; do + waitdone=$(kubectl -n tenant-lite get pods -o json | jq '.items | length') + 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 + +# 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 From 814f21ca5eea9737c0ac50ab1fc456a18276894c Mon Sep 17 00:00:00 2001 From: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com> Date: Mon, 3 Jan 2022 15:00:53 -0800 Subject: [PATCH 02/13] Update testing/basic-tenant.sh Co-authored-by: Harshavardhana --- testing/basic-tenant.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testing/basic-tenant.sh b/testing/basic-tenant.sh index ff106ee9d69..fee383d937a 100644 --- a/testing/basic-tenant.sh +++ b/testing/basic-tenant.sh @@ -33,7 +33,7 @@ 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 :; do +while true; do waitdone=$(kubectl -n tenant-lite get pods -o json | jq '.items | length') if [ "$waitdone" -ne 0 ]; then echo "Found $waitdone pods" From 99e3268885a1509d6cefddf95d528432180e7ca2 Mon Sep 17 00:00:00 2001 From: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com> Date: Mon, 3 Jan 2022 15:00:57 -0800 Subject: [PATCH 03/13] Update testing/basic-tenant.sh Co-authored-by: Harshavardhana --- testing/basic-tenant.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testing/basic-tenant.sh b/testing/basic-tenant.sh index fee383d937a..55cccaa3fb8 100644 --- a/testing/basic-tenant.sh +++ b/testing/basic-tenant.sh @@ -59,7 +59,7 @@ echo "Build passes basic tenant creation" waitdone=0 totalwait=0 -while :; do +while true; do waitdone=$(kubectl -n tenant-lite get pods -o json | jq '.items | length') if [ "$waitdone" -ne 0 ]; then echo "Found $waitdone pods" From 4f6b78e926dfc76769ccddcb6fd7154e6144c243 Mon Sep 17 00:00:00 2001 From: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com> Date: Mon, 3 Jan 2022 15:01:08 -0800 Subject: [PATCH 04/13] Update testing/basic-tenant.sh Co-authored-by: Harshavardhana --- testing/basic-tenant.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testing/basic-tenant.sh b/testing/basic-tenant.sh index 55cccaa3fb8..f1ceba2902f 100644 --- a/testing/basic-tenant.sh +++ b/testing/basic-tenant.sh @@ -67,7 +67,7 @@ while true; do fi sleep 5 totalwait=$((totalwait + 5)) - if [ "$totalwait" -gt 300 ]; then + if [ "$totalwait" -gt 305 ]; then echo "Tenant never created statefulset after 5 minutes" try false fi From ed3b9ee6a374159077496c14eb8c2a77ee7be9ff Mon Sep 17 00:00:00 2001 From: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com> Date: Mon, 3 Jan 2022 15:01:14 -0800 Subject: [PATCH 05/13] Update testing/basic-tenant.sh Co-authored-by: Harshavardhana --- testing/basic-tenant.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testing/basic-tenant.sh b/testing/basic-tenant.sh index f1ceba2902f..a6164b60f9e 100644 --- a/testing/basic-tenant.sh +++ b/testing/basic-tenant.sh @@ -68,7 +68,7 @@ while true; do sleep 5 totalwait=$((totalwait + 5)) if [ "$totalwait" -gt 305 ]; then - echo "Tenant never created statefulset after 5 minutes" + echo "Unable to create tenant after 5 minutes, exiting." try false fi done From e9685c5841997b940aeeab3ff8eb1c8b46db996d Mon Sep 17 00:00:00 2001 From: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com> Date: Mon, 3 Jan 2022 15:01:38 -0800 Subject: [PATCH 06/13] Update testing/basic-tenant.sh Co-authored-by: Harshavardhana --- testing/basic-tenant.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testing/basic-tenant.sh b/testing/basic-tenant.sh index a6164b60f9e..6e64796dffa 100644 --- a/testing/basic-tenant.sh +++ b/testing/basic-tenant.sh @@ -60,7 +60,7 @@ echo "Build passes basic tenant creation" waitdone=0 totalwait=0 while true; do - waitdone=$(kubectl -n tenant-lite get pods -o json | jq '.items | length') + waitdone=$(kubectl -n tenant-lite get pods -l v1.min.io/tenant=tenant-lite --no-headers | wc -l) if [ "$waitdone" -ne 0 ]; then echo "Found $waitdone pods" break From d0647252e06101226ecc32da080993f3ff4ff1ea Mon Sep 17 00:00:00 2001 From: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com> Date: Mon, 3 Jan 2022 15:01:45 -0800 Subject: [PATCH 07/13] Update testing/basic-tenant.sh Co-authored-by: Harshavardhana --- testing/basic-tenant.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/testing/basic-tenant.sh b/testing/basic-tenant.sh index 6e64796dffa..62d8db80b99 100644 --- a/testing/basic-tenant.sh +++ b/testing/basic-tenant.sh @@ -5,6 +5,7 @@ #set -e yell() { echo "$0: $*" >&2; } + die() { yell "$*" (kind delete cluster || true ) && exit 111 From c416b22f543f6e734d5619135c12215b2c5448c4 Mon Sep 17 00:00:00 2001 From: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com> Date: Mon, 3 Jan 2022 15:01:54 -0800 Subject: [PATCH 08/13] Update testing/basic-tenant.sh Co-authored-by: Harshavardhana --- testing/basic-tenant.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/testing/basic-tenant.sh b/testing/basic-tenant.sh index 62d8db80b99..c9cbf96d5dc 100644 --- a/testing/basic-tenant.sh +++ b/testing/basic-tenant.sh @@ -10,6 +10,7 @@ die() { yell "$*" (kind delete cluster || true ) && exit 111 } + try() { "$@" || die "cannot $*"; } try kind create cluster --config kind-config.yaml From 23e31509627b6f12eec09633c1ae028351006825 Mon Sep 17 00:00:00 2001 From: cniackz Date: Tue, 4 Jan 2022 14:02:15 -0600 Subject: [PATCH 09/13] to fix the node label --- testing/basic-tenant.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/testing/basic-tenant.sh b/testing/basic-tenant.sh index c9cbf96d5dc..128ccfa6f13 100644 --- a/testing/basic-tenant.sh +++ b/testing/basic-tenant.sh @@ -52,7 +52,7 @@ 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=tenant-lite" \ + --selector="v1.min.io/tenant=storage-lite" \ --timeout=300s echo "Build passes basic tenant creation" @@ -62,7 +62,7 @@ echo "Build passes basic tenant creation" waitdone=0 totalwait=0 while true; do - waitdone=$(kubectl -n tenant-lite get pods -l v1.min.io/tenant=tenant-lite --no-headers | wc -l) + 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 From cdf38579a891a286c834abdb8443cd2f100be326 Mon Sep 17 00:00:00 2001 From: cniackz Date: Tue, 4 Jan 2022 15:20:05 -0600 Subject: [PATCH 10/13] to execute the testing script in github actions --- .github/workflows/bash.yml | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 .github/workflows/bash.yml diff --git a/.github/workflows/bash.yml b/.github/workflows/bash.yml new file mode 100644 index 00000000000..a7f04fab986 --- /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: [ main ] + pull_request: + branches: [ main ] + + # 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" From 62828116779ee781eb5e7808cc3ed5bb9baade22 Mon Sep 17 00:00:00 2001 From: cniackz Date: Tue, 4 Jan 2022 15:32:27 -0600 Subject: [PATCH 11/13] To add the copyright and remove the use of jq for simplicity --- testing/basic-tenant.sh | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/testing/basic-tenant.sh b/testing/basic-tenant.sh index 128ccfa6f13..c1d146972d5 100644 --- a/testing/basic-tenant.sh +++ b/testing/basic-tenant.sh @@ -1,8 +1,20 @@ #!/bin/bash -# This script requires: kubectl, kind, jq - -#set -e +# 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; } @@ -36,7 +48,7 @@ echo "Waiting for the tenant statefulset, this indicates the tenant is being ful waitdone=0 totalwait=0 while true; do - waitdone=$(kubectl -n tenant-lite get pods -o json | jq '.items | length') + 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 From ba0ce2f1fcec68af181cbe942a6329efdde9a7bc Mon Sep 17 00:00:00 2001 From: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com> Date: Tue, 4 Jan 2022 15:43:12 -0800 Subject: [PATCH 12/13] Update .github/workflows/bash.yml --- .github/workflows/bash.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/bash.yml b/.github/workflows/bash.yml index a7f04fab986..af4ff4fed6b 100644 --- a/.github/workflows/bash.yml +++ b/.github/workflows/bash.yml @@ -6,7 +6,7 @@ name: Bash on: # Triggers the workflow on push or pull request events but only for the main branch push: - branches: [ main ] + branches: [ master ] pull_request: branches: [ main ] From b130de4c9c74cc4dabf26588dad33f73504d4a7e Mon Sep 17 00:00:00 2001 From: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com> Date: Tue, 4 Jan 2022 15:43:17 -0800 Subject: [PATCH 13/13] Update .github/workflows/bash.yml --- .github/workflows/bash.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/bash.yml b/.github/workflows/bash.yml index af4ff4fed6b..e2a24e991b6 100644 --- a/.github/workflows/bash.yml +++ b/.github/workflows/bash.yml @@ -8,7 +8,7 @@ on: push: branches: [ master ] pull_request: - branches: [ main ] + branches: [ master ] # Allows you to run this workflow manually from the Actions tab workflow_dispatch: