Skip to content

Commit 52512c0

Browse files
authored
To repair the Operator API Tests & Operator UI Tests (#2292)
1 parent 989f041 commit 52512c0

File tree

3 files changed

+105
-158
lines changed

3 files changed

+105
-158
lines changed

.github/workflows/jobs.yaml

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ jobs:
172172

173173
strategy:
174174
matrix:
175-
go-version: [ 1.18.x, 1.19.x ]
175+
go-version: [ 1.18.x ]
176176

177177
steps:
178178

@@ -184,6 +184,19 @@ jobs:
184184

185185
- uses: actions/checkout@v2
186186

187+
# To build operator image, we need to clone the repository first
188+
- name: clone https://github.com/minio/operator
189+
uses: actions/checkout@master
190+
with:
191+
192+
# Repository name with owner. For example, actions/checkout
193+
# Default: ${{ github.repository }}
194+
repository: minio/operator
195+
196+
# Relative path under $GITHUB_WORKSPACE to place the repository
197+
# To have two repositories under the same test
198+
path: 'operator_repository'
199+
187200
- uses: actions/cache@v2
188201
name: Go Mod Cache
189202
with:
@@ -1093,7 +1106,7 @@ jobs:
10931106
runs-on: ${{ matrix.os }}
10941107
strategy:
10951108
matrix:
1096-
go-version: [ 1.18.x, 1.19.x ]
1109+
go-version: [ 1.18.x ]
10971110
os: [ ubuntu-latest ]
10981111
steps:
10991112
- name: Set up Go ${{ matrix.go-version }} on ${{ matrix.os }}
@@ -1105,6 +1118,19 @@ jobs:
11051118
- name: Check out code into the Go module directory
11061119
uses: actions/checkout@v2
11071120

1121+
# To build operator image, we need to clone the repository first
1122+
- name: clone https://github.com/minio/operator
1123+
uses: actions/checkout@master
1124+
with:
1125+
1126+
# Repository name with owner. For example, actions/checkout
1127+
# Default: ${{ github.repository }}
1128+
repository: minio/operator
1129+
1130+
# Relative path under $GITHUB_WORKSPACE to place the repository
1131+
# To have two repositories under the same test
1132+
path: 'operator_repository'
1133+
11081134
- name: Read .nvmrc
11091135
id: node_version
11101136
run: echo ::set-output name=NVMRC::$(cat .nvmrc)

portal-ui/tests/scripts/operator.sh

Lines changed: 2 additions & 153 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@
1313

1414
SCRIPT_DIR=$(dirname "$0")
1515
export SCRIPT_DIR
16-
source "${SCRIPT_DIR}/common.sh"
16+
source "${SCRIPT_DIR}/common.sh" # This is common.sh for TestCafe Tests
17+
source "${GITHUB_WORKSPACE}/tests/common.sh" # This is common.sh for k8s tests.
1718

1819
## this enables :dev tag for minio/operator container image.
1920
CI="true"
@@ -26,158 +27,6 @@ sudo chmod +x /usr/local/bin/kubectl
2627
sudo curl -#L "https://dl.min.io/client/mc/release/linux-amd64/mc" -o /usr/local/bin/mc
2728
sudo chmod +x /usr/local/bin/mc
2829

29-
yell() { echo "$0: $*" >&2; }
30-
31-
die() {
32-
yell "$*"
33-
(kind delete cluster || true ) && exit 111
34-
}
35-
36-
try() { "$@" || die "cannot $*"; }
37-
38-
function setup_kind() {
39-
# TODO once feature is added: https://github.com/kubernetes-sigs/kind/issues/1300
40-
echo "kind: Cluster" > kind-config.yaml
41-
echo "apiVersion: kind.x-k8s.io/v1alpha4" >> kind-config.yaml
42-
echo "nodes:" >> kind-config.yaml
43-
echo " - role: control-plane" >> kind-config.yaml
44-
echo " - role: worker" >> kind-config.yaml
45-
echo " - role: worker" >> kind-config.yaml
46-
echo " - role: worker" >> kind-config.yaml
47-
echo " - role: worker" >> kind-config.yaml
48-
try kind create cluster --config kind-config.yaml
49-
echo "Kind is ready"
50-
try kubectl get nodes
51-
}
52-
53-
function install_operator() {
54-
55-
echo "Installing Current Operator from kustomization.yaml"
56-
try kubectl apply -k "${SCRIPT_DIR}/resources"
57-
58-
echo "key, value for pod selector in kustomize test"
59-
key=name
60-
value=minio-operator
61-
62-
# Reusing the wait for both, Kustomize and Helm
63-
echo "Waiting for k8s api"
64-
sleep 10
65-
66-
echo "wait for the app=console to be present -> One Pod"
67-
wait_for_resource minio-operator console app
68-
69-
echo "wait for the name=minio-operator to be present -> Two Pods"
70-
wait_for_resource minio-operator $value $key
71-
72-
echo "Waiting for Operator Pods to come online (3m timeout)"
73-
try kubectl wait --namespace minio-operator \
74-
--for=condition=ready pod \
75-
--selector $key=$value \
76-
--timeout=180s
77-
78-
echo "start - get data to verify proper image is being used"
79-
kubectl get pods --namespace minio-operator
80-
kubectl describe pods -n minio-operator | grep Image
81-
echo "end - get data to verify proper image is being used"
82-
}
83-
84-
function destroy_kind() {
85-
kind delete cluster
86-
}
87-
88-
function wait_for_resource() {
89-
waitdone=0
90-
totalwait=0
91-
echo "command to wait on:"
92-
command_to_wait="kubectl -n $1 get pods -l $3=$2 --no-headers"
93-
echo $command_to_wait
94-
95-
while true; do
96-
waitdone=$($command_to_wait | wc -l)
97-
if [ "$waitdone" -ne 0 ]; then
98-
echo "Found $waitdone pods"
99-
break
100-
fi
101-
sleep 5
102-
totalwait=$((totalwait + 5))
103-
if [ "$totalwait" -gt 305 ]; then
104-
echo "Unable to get resource after 5 minutes, exiting."
105-
try false
106-
fi
107-
done
108-
}
109-
110-
function check_tenant_status() {
111-
# Check MinIO is accessible
112-
key=v1.min.io/tenant
113-
if [ $# -ge 3 ]; then
114-
echo "Third argument provided, then set key value"
115-
key=$3
116-
else
117-
echo "No third argument provided, using default key"
118-
fi
119-
120-
wait_for_resource $1 $2 $key
121-
122-
echo "Waiting for pods to be ready. (5m timeout)"
123-
124-
if [ $# -ge 4 ]; then
125-
echo "Fourth argument provided, then get secrets from helm"
126-
USER=$(kubectl get secret minio1-secret -o jsonpath="{.data.accesskey}" | base64 --decode)
127-
PASSWORD=$(kubectl get secret minio1-secret -o jsonpath="{.data.secretkey}" | base64 --decode)
128-
else
129-
echo "No fourth argument provided, using default USER and PASSWORD"
130-
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')
131-
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')
132-
fi
133-
134-
try kubectl wait --namespace $1 \
135-
--for=condition=ready pod \
136-
--selector=$key=$2 \
137-
--timeout=300s
138-
139-
echo "Tenant is created successfully, proceeding to validate 'mc admin info minio/'"
140-
141-
if [ "$4" = "helm" ]; then
142-
# File: operator/helm/tenant/values.yaml
143-
# Content: s3.bucketDNS: false
144-
echo "In helm values by default bucketDNS.s3 is disabled, skipping mc validation on helm test"
145-
else
146-
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/;"
147-
fi
148-
149-
echo "Done."
150-
}
151-
152-
# Install tenant function is being used by deploy-tenant and check-prometheus
153-
function install_tenant() {
154-
155-
namespace=tenant-lite
156-
key=v1.min.io/tenant
157-
value=storage-lite
158-
echo "Installing lite tenant"
159-
160-
try kubectl apply -k "${SCRIPT_DIR}/tenant-lite"
161-
162-
echo "Waiting for the tenant statefulset, this indicates the tenant is being fulfilled"
163-
echo $namespace
164-
echo $value
165-
echo $key
166-
wait_for_resource $namespace $value $key
167-
168-
echo "Waiting for tenant pods to come online (5m timeout)"
169-
try kubectl wait --namespace $namespace \
170-
--for=condition=ready pod \
171-
--selector $key=$value \
172-
--timeout=300s
173-
174-
echo "Wait for Prometheus PVC to be bound"
175-
while [[ $(kubectl get pvc storage-lite-prometheus-storage-lite-prometheus-0 -n tenant-lite -o 'jsonpath={..status.phase}') != "Bound" ]]; do echo "waiting for PVC status" && sleep 1 && kubectl get pvc -A; done
176-
177-
echo "Build passes basic tenant creation"
178-
179-
}
180-
18130
__init__() {
18231
export TIMESTAMP=$(date "+%s")
18332
echo $TIMESTAMP > portal-ui/tests/constants/timestamp.txt

tests/common.sh

Lines changed: 75 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,31 @@ function setup_kind() {
3838
}
3939

4040
function install_operator() {
41-
echo "Installing Current Operator"
4241

43-
# TODO: Compile the current branch and create an overlay to use that image version
44-
try kubectl apply -k "${SCRIPT_DIR}/../portal-ui/tests/scripts/resources"
42+
echo " "
43+
echo "==================Compile Operator:====================="
44+
echo " Change Directory to: $GITHUB_WORKSPACE/operator_repository"
45+
cd "$GITHUB_WORKSPACE/operator_repository"
46+
echo " Compile Operator: make docker"
47+
make docker # It will generate: docker.io/minio/operator:dev
48+
echo " Load minio/operator:dev image to the cluster"
49+
kind load docker-image minio/operator:dev
50+
51+
echo " Value of image before:"
52+
yq '.spec.template.spec.containers[0].image' "${GITHUB_WORKSPACE}/operator_repository/resources/base/deployment.yaml"
53+
54+
echo " Change image of template from v4.4.28 to dev"
55+
yq e -i '.spec.template.spec.containers[0].image = "minio/operator:dev"' "${GITHUB_WORKSPACE}/operator_repository/resources/base/deployment.yaml"
56+
57+
echo " Value of image after:"
58+
yq '.spec.template.spec.containers[0].image' "${GITHUB_WORKSPACE}/operator_repository/resources/base/deployment.yaml"
59+
60+
cd $GITHUB_WORKSPACE # Back to the workspace
61+
echo "========================================================"
62+
echo " "
63+
64+
echo "Installing Latest Operator"
65+
try kubectl apply -k "${GITHUB_WORKSPACE}/operator_repository/resources"
4566

4667
echo "Waiting for k8s api"
4768
sleep 10
@@ -92,3 +113,54 @@ function check_tenant_status() {
92113

93114
echo "Done."
94115
}
116+
117+
function wait_for_resource() {
118+
waitdone=0
119+
totalwait=0
120+
echo "command to wait on:"
121+
command_to_wait="kubectl -n $1 get pods -l $3=$2 --no-headers"
122+
echo $command_to_wait
123+
124+
while true; do
125+
waitdone=$($command_to_wait | wc -l)
126+
if [ "$waitdone" -ne 0 ]; then
127+
echo "Found $waitdone pods"
128+
break
129+
fi
130+
sleep 5
131+
totalwait=$((totalwait + 5))
132+
if [ "$totalwait" -gt 305 ]; then
133+
echo "Unable to get resource after 5 minutes, exiting."
134+
try false
135+
fi
136+
done
137+
}
138+
139+
# Install tenant function is being used by deploy-tenant and check-prometheus
140+
function install_tenant() {
141+
142+
namespace=tenant-lite
143+
key=v1.min.io/tenant
144+
value=storage-lite
145+
echo "Installing lite tenant"
146+
147+
try kubectl apply -k "${SCRIPT_DIR}/tenant-lite"
148+
149+
echo "Waiting for the tenant statefulset, this indicates the tenant is being fulfilled"
150+
echo $namespace
151+
echo $value
152+
echo $key
153+
wait_for_resource $namespace $value $key
154+
155+
echo "Waiting for tenant pods to come online (5m timeout)"
156+
try kubectl wait --namespace $namespace \
157+
--for=condition=ready pod \
158+
--selector $key=$value \
159+
--timeout=300s
160+
161+
echo "Wait for Prometheus PVC to be bound"
162+
while [[ $(kubectl get pvc storage-lite-prometheus-storage-lite-prometheus-0 -n tenant-lite -o 'jsonpath={..status.phase}') != "Bound" ]]; do echo "waiting for PVC status" && sleep 1 && kubectl get pvc -A; done
163+
164+
echo "Build passes basic tenant creation"
165+
166+
}

0 commit comments

Comments
 (0)