1
- region= " us-central1-a"
2
- testUrlPrefix= " https://percona-jenkins-artifactory-public.s3.amazonaws.com/cloud-pg-operator"
3
- tests= []
1
+ region = ' us-central1-a'
2
+ testUrlPrefix = " https://percona-jenkins-artifactory-public.s3.amazonaws.com/cloud-pg-operator"
3
+ tests = []
4
4
5
5
void createCluster (String CLUSTER_SUFFIX ) {
6
6
withCredentials([string(credentialsId : ' GCP_PROJECT_ID' , variable : ' GCP_PROJECT' ), file(credentialsId : ' gcloud-key-file' , variable : ' CLIENT_SECRET_FILE' )]) {
7
7
sh """
8
- NODES_NUM=3
9
8
export KUBECONFIG=/tmp/$CLUSTER_NAME -${ CLUSTER_SUFFIX}
9
+ gcloud auth activate-service-account --key-file $CLIENT_SECRET_FILE
10
+ gcloud config set project $GCP_PROJECT
10
11
ret_num=0
11
12
while [ \$ {ret_num} -lt 15 ]; do
12
13
ret_val=0
13
- gcloud auth activate-service-account --key-file $CLIENT_SECRET_FILE
14
- gcloud config set project $GCP_PROJECT
15
- gcloud container clusters list --filter $CLUSTER_NAME -${ CLUSTER_SUFFIX} --zone $region --format='csv[no-heading](name)' | xargs gcloud container clusters delete --zone $region --quiet || true
16
- gcloud container clusters create --zone $region $CLUSTER_NAME -${ CLUSTER_SUFFIX} --cluster-version=1.30 --machine-type=n1-standard-4 --preemptible --disk-size 30 --num-nodes=\$ NODES_NUM --network=jenkins-vpc --subnetwork=jenkins-${ CLUSTER_SUFFIX} --no-enable-autoupgrade --cluster-ipv4-cidr=/21 --labels delete-cluster-after-hours=6 --enable-ip-alias && \
14
+ gcloud container clusters list --filter $CLUSTER_NAME -${ CLUSTER_SUFFIX} --zone ${ region} --format='csv[no-heading](name)' | xargs gcloud container clusters delete --zone ${ region} --quiet || true
15
+ gcloud container clusters create $CLUSTER_NAME -${ CLUSTER_SUFFIX} \
16
+ --preemptible \
17
+ --zone=${ region} \
18
+ --machine-type='n1-standard-4' \
19
+ --cluster-version='1.30' \
20
+ --num-nodes=3 \
21
+ --labels='delete-cluster-after-hours=6' \
22
+ --disk-size=30 \
23
+ --network=jenkins-vpc \
24
+ --subnetwork=jenkins-${ CLUSTER_SUFFIX} \
25
+ --cluster-ipv4-cidr=/21 \
26
+ --enable-ip-alias \
27
+ --no-enable-autoupgrade \
28
+ --monitoring=NONE \
29
+ --logging=NONE \
30
+ --no-enable-managed-prometheus \
31
+ --quiet && \
17
32
kubectl create clusterrolebinding cluster-admin-binding --clusterrole cluster-admin --user jenkins@"$GCP_PROJECT ".iam.gserviceaccount.com || ret_val=\$ ?
18
33
if [ \$ {ret_val} -eq 0 ]; then break; fi
19
34
ret_num=\$ ((ret_num + 1))
20
35
done
21
36
if [ \$ {ret_num} -eq 15 ]; then
22
- gcloud container clusters list --filter $CLUSTER_NAME -${ CLUSTER_SUFFIX} --zone $region --format='csv[no-heading](name)' | xargs gcloud container clusters delete --zone $region --quiet || true
37
+ gcloud container clusters list --filter $CLUSTER_NAME -${ CLUSTER_SUFFIX} --zone ${ region} --format='csv[no-heading](name)' | xargs gcloud container clusters delete --zone ${ region} --quiet || true
23
38
exit 1
24
39
fi
25
40
"""
@@ -41,7 +56,7 @@ void shutdownCluster(String CLUSTER_SUFFIX) {
41
56
kubectl delete pods --all -n \$ namespace --force --grace-period=0 || true
42
57
done
43
58
kubectl get svc --all-namespaces || true
44
- gcloud container clusters delete --zone $region $CLUSTER_NAME -${ CLUSTER_SUFFIX}
59
+ gcloud container clusters delete --zone ${ region} $CLUSTER_NAME -${ CLUSTER_SUFFIX}
45
60
"""
46
61
}
47
62
}
@@ -65,7 +80,7 @@ void deleteOldClusters(String FILTER) {
65
80
break
66
81
fi
67
82
done
68
- gcloud container clusters delete --async --zone $region --quiet \$ GKE_CLUSTER || true
83
+ gcloud container clusters delete --async --zone ${ region} --quiet \$ GKE_CLUSTER || true
69
84
done
70
85
fi
71
86
"""
@@ -120,7 +135,7 @@ void markPassedTests() {
120
135
121
136
for (int i= 0 ; i< tests. size(); i++ ) {
122
137
def testName = tests[i][" name" ]
123
- def file= " ${ env.GIT_BRANCH} -${ env.GIT_SHORT_COMMIT} -$testName "
138
+ def file = " ${ env.GIT_BRANCH} -${ env.GIT_SHORT_COMMIT} -$testName "
124
139
def retFileExists = sh(script : " aws s3api head-object --bucket percona-jenkins-artifactory --key ${ JOB_NAME} /${ env.GIT_SHORT_COMMIT} /${ file} >/dev/null 2>&1" , returnStatus : true )
125
140
126
141
if (retFileExists == 0 ) {
@@ -149,26 +164,48 @@ void printKubernetesStatus(String LOCATION, String CLUSTER_SUFFIX) {
149
164
"""
150
165
}
151
166
152
- TestsReport = ' | Test name | Status |\r\n | ------------- | ------------- |'
167
+ String formatTime (def time ) {
168
+ if (! time || time == " N/A" ) return " N/A"
169
+
170
+ try {
171
+ def totalSeconds = time as Double
172
+ def hours = (totalSeconds / 3600 ) as Integer
173
+ def minutes = ((totalSeconds % 3600 ) / 60 ) as Integer
174
+ def seconds = (totalSeconds % 60 ) as Integer
175
+
176
+ return String . format(" %02d:%02d:%02d" , hours, minutes, seconds)
177
+
178
+ } catch (Exception e) {
179
+ println (" Error converting time: ${ e.message} " )
180
+ return time. toString()
181
+ }
182
+ }
183
+
184
+ TestsReport = ' | Test Name | Result | Time |\r\n | ----------- | -------- | ------ |'
153
185
TestsReportXML = ' <testsuite name=\\ "PG\\ ">\n '
154
186
155
187
void makeReport () {
156
- def wholeTestAmount= tests. size()
188
+ def wholeTestAmount = tests. size()
157
189
def startedTestAmount = 0
190
+ def totalTestTime = 0
158
191
159
192
for (int i= 0 ; i< tests. size(); i++ ) {
160
193
def testName = tests[i][" name" ]
161
194
def testResult = tests[i][" result" ]
162
195
def testTime = tests[i][" time" ]
163
196
def testUrl = " ${ testUrlPrefix} /${ env.GIT_BRANCH} /${ env.GIT_SHORT_COMMIT} /${ testName} .log"
164
197
198
+ if (testTime instanceof Number ) {
199
+ totalTestTime + = testTime
200
+ }
201
+
165
202
if (tests[i][" result" ] != " skipped" ) {
166
203
startedTestAmount++
167
204
}
168
- TestsReport = TestsReport + " \r\n | " + testName + " | [" + testResult + " ](" + testUrl + " ) |"
205
+ TestsReport = TestsReport + " \r\n | " + testName + " | [" + testResult + " ](" + testUrl + " ) | " + formatTime(testTime) + " |"
169
206
TestsReportXML = TestsReportXML + ' <testcase name=\\ "' + testName + ' \\ " time=\\ "' + testTime + ' \\ "><' + testResult + ' /></testcase>\n '
170
207
}
171
- TestsReport = TestsReport + " \r\n | We run $startedTestAmount out of $wholeTestAmount |"
208
+ TestsReport = TestsReport + " \r\n | We run $startedTestAmount out of $wholeTestAmount | | " + formatTime(totalTestTime) + " |"
172
209
TestsReportXML = TestsReportXML + ' </testsuite>\n '
173
210
174
211
sh """
@@ -244,10 +281,10 @@ void runTest(Integer TEST_ID) {
244
281
245
282
void prepareNode () {
246
283
sh """
247
- sudo curl -s -L -o /usr/local/bin/kubectl https://dl.k8s.io/release/\$ (curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl && sudo chmod +x /usr/local/bin/kubectl
284
+ sudo curl -sLo /usr/local/bin/kubectl https://dl.k8s.io/release/\$ (curl -sL https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl && sudo chmod +x /usr/local/bin/kubectl
248
285
kubectl version --client --output=yaml
249
286
250
- curl -fsSL https://get.helm.sh/helm-v3.12 .3-linux-amd64.tar.gz | sudo tar -C /usr/local/bin --strip-components 1 -xzf - linux-amd64/helm
287
+ curl -fsSL https://get.helm.sh/helm-v3.18 .3-linux-amd64.tar.gz | sudo tar -C /usr/local/bin --strip-components 1 -xzf - linux-amd64/helm
251
288
252
289
sudo curl -fsSL https://github.com/mikefarah/yq/releases/download/v4.44.1/yq_linux_amd64 -o /usr/local/bin/yq && sudo chmod +x /usr/local/bin/yq
253
290
sudo curl -fsSL https://github.com/jqlang/jq/releases/download/jq-1.7.1/jq-linux64 -o /usr/local/bin/jq && sudo chmod +x /usr/local/bin/jq
@@ -258,8 +295,8 @@ void prepareNode() {
258
295
259
296
kubectl krew install assert
260
297
261
- # v0.17 .0 kuttl version
262
- kubectl krew install --manifest-url https://raw.githubusercontent.com/kubernetes-sigs/krew-index/336ef83542fd2f783bfa2c075b24599e834dcc77 /plugins/kuttl.yaml
298
+ # v0.22 .0 kuttl version
299
+ kubectl krew install --manifest-url https://raw.githubusercontent.com/kubernetes-sigs/krew-index/02d5befb2bc9554fdcd8386b8bfbed2732d6802e /plugins/kuttl.yaml
263
300
echo \$ (kubectl kuttl --version) is installed
264
301
265
302
sudo tee /etc/yum.repos.d/google-cloud-sdk.repo << EOF
0 commit comments