Add list of tenants integration test (#1722)

This commit is contained in:
Cesar Celis Hernandez
2022-03-15 23:13:33 -04:00
committed by GitHub
parent b29f6a1640
commit cc43b3c743
5 changed files with 501 additions and 2 deletions

94
.github/workflows/common.sh vendored Executable file
View File

@@ -0,0 +1,94 @@
#!/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 <http://www.gnu.org/licenses/>
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
echo "kind: Cluster" > kind-config.yaml
echo "apiVersion: kind.x-k8s.io/v1alpha4" >> kind-config.yaml
echo "nodes:" >> kind-config.yaml
echo " - role: control-plane" >> kind-config.yaml
echo " - role: worker" >> kind-config.yaml
echo " - role: worker" >> kind-config.yaml
echo " - role: worker" >> kind-config.yaml
echo " - role: worker" >> kind-config.yaml
try kind create cluster --config kind-config.yaml
echo "Kind is ready"
try kubectl get nodes
}
function install_operator() {
echo "Installing Current Operator"
# TODO: Compile the current branch and create an overlay to use that image version
try kubectl apply -k "${SCRIPT_DIR}/../../portal-ui/tests/scripts/resources"
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."
}

71
.github/workflows/deploy-tenant.sh vendored Executable file
View File

@@ -0,0 +1,71 @@
#!/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 <http://www.gnu.org/licenses/>
# This script requires: kubectl, kind
SCRIPT_DIR=$(dirname "$0")
export SCRIPT_DIR
source "${SCRIPT_DIR}/common.sh"
function install_tenant() {
echo "Installing lite tenant"
try kubectl apply -k "${SCRIPT_DIR}/../../portal-ui/tests/scripts/tenant"
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"
}
function main() {
destroy_kind
setup_kind
install_operator
install_tenant
check_tenant_status tenant-lite storage-lite
kubectl -n minio-operator port-forward svc/console 9090 &
}
main "$@"

View File

@@ -15,6 +15,56 @@ concurrency:
cancel-in-progress: true
jobs:
operator-api-tests:
name: Operator API Tests
needs:
- lint-job
- no-warnings-and-make-assets
- reuse-golang-dependencies
- vulnerable-dependencies-checks
runs-on: ubuntu-latest
strategy:
matrix:
go-version: [ 1.17.x ]
steps:
- name: Set up Go ${{ matrix.go-version }} on ${{ matrix.os }}
uses: actions/setup-go@v2
with:
go-version: ${{ matrix.go-version }}
id: go
- uses: actions/checkout@v2
- uses: actions/cache@v2
name: Go Mod Cache
with:
path: |
~/.cache/go-build
~/go/pkg/mod
key: ${{ runner.os }}-go-${{ 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}/.github/workflows/deploy-tenant.sh"
echo "start ---> make test-operator-integration";
make test-operator-integration;
- uses: actions/cache@v2
id: coverage-cache-operator
name: Coverage Cache Operator
with:
path: |
./operator-integration/coverage/
key: ${{ runner.os }}-coverage-2-operator-${{ github.run_id }}
lint-job:
name: Checking Lint
runs-on: ${{ matrix.os }}
@@ -702,6 +752,8 @@ jobs:
needs:
- integration-tests
- test-restapi-on-go
- operator-api-tests
- test-pkg-on-go
runs-on: ${{ matrix.os }}
strategy:
matrix:
@@ -736,6 +788,14 @@ jobs:
./integration/coverage/
key: ${{ runner.os }}-coverage-2-${{ github.run_id }}
- uses: actions/cache@v2
id: coverage-cache-operator
name: Coverage Cache Operator
with:
path: |
./operator-integration/coverage/
key: ${{ runner.os }}-coverage-2-operator-${{ github.run_id }}
- uses: actions/cache@v2
id: coverage-cache-restapi
name: Coverage Cache RestAPI
@@ -763,14 +823,14 @@ jobs:
echo "go build gocoverage.go"
go build gocovmerge.go
echo "put together the outs for final coverage resolution"
./gocovmerge ../integration/coverage/system.out ../restapi/coverage/coverage.out ../pkg/coverage/coverage-pkg.out > all.out
./gocovmerge ../integration/coverage/system.out ../restapi/coverage/coverage.out ../pkg/coverage/coverage-pkg.out ../operator-integration/coverage/operator-api.out > all.out
echo "grep to obtain the result"
go tool cover -func=all.out | grep total > tmp2
result=`cat tmp2 | awk 'END {print $3}'`
result=${result%\%}
echo "result:"
echo $result
threshold=50.4
threshold=50.5
if (( $(echo "$result >= $threshold" |bc -l) )); then
echo "It is equal or greater than threshold, passed!"
else