1- region= " us-central1-a"
2- testUrlPrefix= " https://percona-jenkins-artifactory-public.s3.amazonaws.com/cloud-pxc-operator"
3- tests= []
1+ region = " us-central1-a"
2+ testUrlPrefix = " https://percona-jenkins-artifactory-public.s3.amazonaws.com/cloud-pxc-operator"
3+ tests = []
44
55void createCluster (String CLUSTER_SUFFIX ) {
66 withCredentials([string(credentialsId : ' GCP_PROJECT_ID' , variable : ' GCP_PROJECT' ), file(credentialsId : ' gcloud-key-file' , variable : ' CLIENT_SECRET_FILE' )]) {
77 sh """
8- NODES_NUM=3
98 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
1011 ret_num=0
1112 while [ \$ {ret_num} -lt 15 ]; do
1213 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=c2d-standard-4 \
19+ --cluster-version=1.31 \
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+ --workload-pool=cloud-dev-112233.svc.id.goog \
32+ --quiet && \
1733 kubectl create clusterrolebinding cluster-admin-binding --clusterrole cluster-admin --user jenkins@"$GCP_PROJECT ".iam.gserviceaccount.com || ret_val=\$ ?
1834 if [ \$ {ret_val} -eq 0 ]; then break; fi
1935 ret_num=\$ ((ret_num + 1))
2036 done
2137 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
38+ 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
2339 exit 1
2440 fi
2541 """
@@ -41,7 +57,7 @@ void shutdownCluster(String CLUSTER_SUFFIX) {
4157 kubectl delete pods --all -n \$ namespace --force --grace-period=0 || true
4258 done
4359 kubectl get svc --all-namespaces || true
44- gcloud container clusters delete --zone $region $CLUSTER_NAME -${ CLUSTER_SUFFIX}
60+ gcloud container clusters delete --zone ${ region} $CLUSTER_NAME -${ CLUSTER_SUFFIX}
4561 """
4662 }
4763}
@@ -65,7 +81,7 @@ void deleteOldClusters(String FILTER) {
6581 break
6682 fi
6783 done
68- gcloud container clusters delete --async --zone $region --quiet \$ GKE_CLUSTER || true
84+ gcloud container clusters delete --async --zone ${ region} --quiet \$ GKE_CLUSTER || true
6985 done
7086 fi
7187 """
@@ -149,26 +165,48 @@ void printKubernetesStatus(String LOCATION, String CLUSTER_SUFFIX) {
149165 """
150166}
151167
152- TestsReport = ' | Test name | Status |\r\n | ------------- | ------------- |'
168+ String formatTime (def time ) {
169+ if (! time || time == " N/A" ) return " N/A"
170+
171+ try {
172+ def totalSeconds = time as Double
173+ def hours = (totalSeconds / 3600 ) as Integer
174+ def minutes = ((totalSeconds % 3600 ) / 60 ) as Integer
175+ def seconds = (totalSeconds % 60 ) as Integer
176+
177+ return String . format(" %02d:%02d:%02d" , hours, minutes, seconds)
178+
179+ } catch (Exception e) {
180+ println (" Error converting time: ${ e.message} " )
181+ return time. toString()
182+ }
183+ }
184+
185+ TestsReport = ' | Test Name | Result | Time |\r\n | ----------- | -------- | ------ |'
153186TestsReportXML = ' <testsuite name=\\ "PXC\\ ">\n '
154187
155188void makeReport () {
156- def wholeTestAmount= tests. size()
189+ def wholeTestAmount = tests. size()
157190 def startedTestAmount = 0
191+ def totalTestTime = 0
158192
159193 for (int i= 0 ; i< tests. size(); i++ ) {
160194 def testNameWithMysqlVersion = tests[i][" name" ] + " -" + tests[i][" mysql_ver" ]. replace(" ." , " -" )
161195 def testResult = tests[i][" result" ]
162196 def testTime = tests[i][" time" ]
163197 def testUrl = " ${ testUrlPrefix} /${ env.GIT_BRANCH} /${ env.GIT_SHORT_COMMIT} /${ testNameWithMysqlVersion} .log"
164198
199+ if (testTime instanceof Number ) {
200+ totalTestTime + = testTime
201+ }
202+
165203 if (tests[i][" result" ] != " skipped" ) {
166204 startedTestAmount++
167205 }
168- TestsReport = TestsReport + " \r\n | " + testNameWithMysqlVersion + " | [" + tests[i][ " result " ] + " ](" + testUrl + " ) |"
206+ TestsReport = TestsReport + " \r\n | " + testNameWithMysqlVersion + " | [" + testResult + " ](" + testUrl + " ) | " + formatTime(testTime) + " |"
169207 TestsReportXML = TestsReportXML + ' <testcase name=\\ "' + testNameWithMysqlVersion + ' \\ " time=\\ "' + testTime + ' \\ "><' + testResult + ' /></testcase>\n '
170208 }
171- TestsReport = TestsReport + " \r\n | We run $startedTestAmount out of $wholeTestAmount |"
209+ TestsReport = TestsReport + " \r\n | We run $startedTestAmount out of $wholeTestAmount | | " + formatTime(totalTestTime) + " |"
172210 TestsReportXML = TestsReportXML + ' </testsuite>\n '
173211
174212 sh """
@@ -247,10 +285,10 @@ void runTest(Integer TEST_ID) {
247285
248286void prepareNode () {
249287 sh """
250- 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
288+ sudo curl -sLo /usr/local/bin/kubectl https://dl.k8s.io/release/\$ (curl -Ls https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl && sudo chmod +x /usr/local/bin/kubectl
251289 kubectl version --client --output=yaml
252290
253- 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
291+ 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
254292
255293 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
256294 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
0 commit comments