Skip to content

Commit e995968

Browse files
authored
Merge branch 'main' into K8SPXC-1647
2 parents 50717e8 + 37c06c5 commit e995968

36 files changed

+391
-135
lines changed

.e2eignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,5 @@ LICENSE
99
operator.png
1010
kubernetes.svg
1111
.e2eignore
12-
release_versions
12+
release_versions
13+
.snyk

.github/CODEOWNERS

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
* @hors @egegunes @pooknull @nmarukovich @gkech
2-
/e2e-tests/ @ptankov @jvpasinatto @eleo007
3-
Jenkinsfile @ptankov @jvpasinatto @eleo007
2+
/e2e-tests/ @jvpasinatto @eleo007 @valmiranogueira
3+
Jenkinsfile @jvpasinatto @eleo007 @valmiranogueira

.github/workflows/reviewdog.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ jobs:
1010
with:
1111
go-version: '1.23'
1212
- name: golangci-lint
13-
uses: golangci/golangci-lint-action@v7
13+
uses: golangci/golangci-lint-action@v8
1414
with:
1515
version: latest
1616
only-new-issues: true

.github/workflows/scan.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ jobs:
3131
./e2e-tests/build
3232
3333
- name: Run Trivy vulnerability scanner image (linux/arm64)
34-
uses: aquasecurity/trivy-action@0.30.0
34+
uses: aquasecurity/trivy-action@0.31.0
3535
with:
3636
image-ref: '${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.sha }}-arm64'
3737
format: 'table'
@@ -50,7 +50,7 @@ jobs:
5050
./e2e-tests/build
5151
5252
- name: Run Trivy vulnerability scanner image (linux/amd64)
53-
uses: aquasecurity/trivy-action@0.30.0
53+
uses: aquasecurity/trivy-action@0.31.0
5454
with:
5555
image-ref: '${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.sha }}-amd64'
5656
format: 'table'

.snyk

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#SNYK - percona/percona-xtradb-cluster-operator
2+
3+
exclude:
4+
global:
5+
- e2e-tests/**
6+
7+
version: v1.25.0
8+
ignore: {}
9+
patch: {}

Jenkinsfile

Lines changed: 55 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,41 @@
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

55
void 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| ----------- | -------- | ------ |'
153186
TestsReportXML = '<testsuite name=\\"PXC\\">\n'
154187

155188
void 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

248286
void 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

build/haproxy_add_pxc_nodes.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ function main() {
134134
option srvtcpka
135135
balance roundrobin
136136
option external-check
137-
external-check command /usr/local/bin/check_pxc.sh
137+
external-check command /opt/percona/haproxy_check_pxc.sh
138138
EOF
139139
(
140140
IFS=$'\n'
@@ -157,7 +157,7 @@ function main() {
157157
fi
158158

159159
if [ -n "$main_node" ]; then
160-
if /usr/local/bin/check_pxc.sh '' '' "$main_node"; then
160+
if /opt/percona/haproxy_check_pxc.sh '' '' "$main_node"; then
161161
for backup_server in "${NODE_LIST_BACKUP[@]}"; do
162162
log "shutdown sessions server $backup_server | socat stdio ${SOCKET}"
163163
echo "shutdown sessions server $backup_server" | socat stdio "${SOCKET}"

e2e-tests/functions

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ create_namespace() {
130130
destroy_chaos_mesh
131131
desc 'cleaned up all old namespaces'
132132
kubectl_bin get ns \
133-
| egrep -v "^kube-|^default$|Terminating|pxc-operator|openshift|^NAME" \
133+
| egrep -v "^kube-|^default|Terminating|pxc-operator|openshift|^gke-|^gmp-|^NAME" \
134134
| awk '{print$1}' \
135135
| xargs kubectl delete ns &
136136
fi

e2e-tests/haproxy/run

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,9 @@ main() {
6868
wait_cluster_consistency "$cluster" 3 3
6969
check_haproxy_writer
7070

71-
desc 'check for passwords leak'
72-
check_passwords_leak
71+
# Temporarily skipping this check
72+
#desc 'check for passwords leak'
73+
#check_passwords_leak
7374

7475
desc 'delete active writer and checking all haproxy pods still point to the same writer'
7576
desc 'fail pxc-pod-0 pod for 60s'

e2e-tests/init-deploy/run

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,9 @@ compare_mysql_cmd "select-1" "SELECT * from myApp.myApp;" "-h $cluster3-pxc-1.$c
112112
compare_mysql_cmd "select-1" "SELECT * from myApp.myApp;" "-h $cluster3-pxc-2.$cluster3-pxc -uroot -proot_password"
113113
compare_mysql_cmd "max_allowed_packet-2" "SELECT @@max_allowed_packet;" "-h $cluster3-pxc-0.$cluster3-pxc -uroot -proot_password"
114114

115-
desc 'check for passwords leak'
116-
check_passwords_leak
115+
# Temporarily skipping this check
116+
#desc 'check for passwords leak'
117+
#check_passwords_leak
117118

118119
kubectl_bin delete -f $test_dir/conf/$cluster3.yml
119120
destroy $namespace

0 commit comments

Comments
 (0)