Skip to content

Commit a62922a

Browse files
committed
Add collect_k8s_logs into tests and add pod describe
1 parent 35b4a22 commit a62922a

File tree

26 files changed

+56
-4
lines changed
  • e2e-tests
    • arbiter
    • balancer
    • cross-site-sharded
    • data-at-rest-encryption
    • data-sharded
    • default-cr
    • demand-backup-physical-sharded
    • demand-backup-physical
    • demand-backup-sharded
    • demand-backup
    • expose-sharded
    • init-deploy
    • mongod-major-upgrade-sharded
    • mongod-major-upgrade
    • monitoring-2-0
    • multi-cluster-service
    • rs-shard-migration
    • self-healing-chaos
    • service-per-pod
    • smart-update
    • split-horizon
    • tls-issue-cert-manager
    • upgrade-sharded
    • upgrade
    • version-service

26 files changed

+56
-4
lines changed

e2e-tests/arbiter/run

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ check_cr_config() {
3131
if [[ $(kubectl_bin get pod \
3232
--selector=statefulset.kubernetes.io/pod-name="${cluster}-arbiter-0" \
3333
-o jsonpath='{.items[*].status.containerStatuses[?(@.name == "mongod-arbiter")].restartCount}') -gt 0 ]]; then
34+
collect_k8s_logs
3435
echo "Something went wrong with arbiter. Exiting..."
3536
exit 1
3637
fi

e2e-tests/balancer/run

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ check_balancer() {
1515
| grep -E -v "Percona Server for MongoDB|connecting to:|Implicit session:|versions do not match|Error saving history file:|bye")
1616

1717
if [[ $balancer_running != "$expected" ]]; then
18+
collect_k8s_logs
1819
echo "Unexpected output from \"db.adminCommand({balancerStatus: 1}).mode\": $balancer_running"
1920
echo "Expected $expected"
2021
exit 1

e2e-tests/cross-site-sharded/run

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ for i in "rs0" "rs1"; do
8181
done
8282

8383
if [[ $shards -lt 2 ]]; then
84+
collect_k8s_logs
8485
echo "data is only on some of the shards, maybe sharding is not working"
8586
exit 1
8687
fi

e2e-tests/data-at-rest-encryption/run

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ encrypted_cluster_log=$(kubectl_bin logs some-name-rs0-0 -c mongod -n $namespace
8383

8484
echo "$encrypted_cluster_log"
8585
if [ -z "$encrypted_cluster_log" ]; then
86+
collect_k8s_logs
8687
echo "Cluster is not encrypted"
8788
exit 1
8889
fi
@@ -99,6 +100,7 @@ until [ "$retry" -ge 10 ]; do
99100
echo "Cluster is not encrypted already"
100101
break
101102
elif [ $retry == 15 ]; then
103+
collect_k8s_logs
102104
echo "Max retry count $retry reached. Cluster is still encrypted"
103105
exit 1
104106
else

e2e-tests/data-sharded/run

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ check_rs_proper_component_deletion() {
1717
until [[ $(kubectl_bin get sts -l app.kubernetes.io/instance=${cluster},app.kubernetes.io/replset=${rs_name} -ojson | jq '.items | length') -eq 0 ]]; do
1818
let retry+=1
1919
if [ $retry -ge 70 ]; then
20+
collect_k8s_logs
2021
sts_count=$(kubectl_bin get sts -l app.kubernetes.io/instance=${cluster},app.kubernetes.io/replset=${rs_name} -ojson | jq '.items | length')
2122
echo "Replset $rs_name not properly removed, expected sts count of 0 but got $sts_count. Exiting after $retry tries..."
2223
exit 1
@@ -115,6 +116,7 @@ main() {
115116
done
116117

117118
if [[ $shards -lt 3 ]]; then
119+
collect_k8s_logs
118120
echo "data is only on some of the shards, maybe sharding is not working"
119121
exit 1
120122
fi
@@ -125,6 +127,7 @@ main() {
125127
"clusterAdmin:clusterAdmin123456@$cluster-mongos.$namespace" "mongodb" ".svc.cluster.local" \
126128
"--tlsCertificateKeyFile /tmp/tls.pem --tlsCAFile /etc/mongodb-ssl/ca.crt --tls")
127129
if ! echo $res | grep -q '"ok" : 1'; then
130+
collect_k8s_logs
128131
echo "app database not dropped. Exiting.."
129132
exit 1
130133
fi

e2e-tests/default-cr/run

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ function stop_cluster() {
2727
let passed_time="${passed_time}+${sleep_time}"
2828
sleep ${sleep_time}
2929
if [[ ${passed_time} -gt ${max_wait_time} ]]; then
30+
collect_k8s_logs
3031
echo "We've been waiting for cluster stop for too long. Exiting..."
3132
exit 1
3233
fi

e2e-tests/demand-backup-physical-sharded/run

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ run_recovery_check() {
3838
wait_restore "${backup_name}" "${cluster}" "ready" "0" "900"
3939
kubectl_bin get psmdb ${cluster} -o yaml
4040
if [ $(kubectl_bin get psmdb ${cluster} -o yaml | yq '.metadata.annotations."percona.com/resync-pbm"') == null ]; then
41+
collect_k8s_logs
4142
echo "psmdb/${cluster} should be annotated with percona.com/resync-pbm after a physical restore"
4243
exit 1
4344
fi
@@ -52,6 +53,7 @@ check_exported_mongos_service_endpoint() {
5253
local host=$1
5354

5455
if [ "$host" != "$(kubectl_bin get psmdb $cluster -o=jsonpath='{.status.host}')" ]; then
56+
collect_k8s_logs
5557
echo "Exported host is not correct after the restore"
5658
exit 1
5759
fi
@@ -80,6 +82,7 @@ wait_cluster_consistency ${cluster}
8082
lbEndpoint=$(kubectl_bin get svc $cluster-mongos -o=jsonpath='{.status}' \
8183
| jq -r 'select(.loadBalancer != null and .loadBalancer.ingress != null and .loadBalancer.ingress != []) | .loadBalancer.ingress[0][]')
8284
if [ -z $lbEndpoint ]; then
85+
collect_k8s_logs
8386
echo "mongos service not exported correctly"
8487
exit 1
8588
fi

e2e-tests/demand-backup-physical/run

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ run_recovery_check() {
3838
wait_restore "${backup_name}" "${cluster}" "ready" "0" "900"
3939
kubectl_bin get psmdb ${cluster} -o yaml
4040
if [ $(kubectl_bin get psmdb ${cluster} -o yaml | yq '.metadata.annotations."percona.com/resync-pbm"') == null ]; then
41+
collect_k8s_logs
4142
echo "psmdb/${cluster} should be annotated with percona.com/resync-pbm after a physical restore"
4243
exit 1
4344
fi

e2e-tests/demand-backup-sharded/run

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,7 @@ backup_exists=$(kubectl_bin run -i --rm aws-cli --image=perconalab/awscli --rest
166166
/usr/bin/aws --endpoint-url http://minio-service:9000 s3 ls s3://operator-testing/ \
167167
| grep -c ${backup_dest_minio}_ | cat)
168168
if [[ $backup_exists -eq 1 ]]; then
169+
collect_k8s_logs
169170
echo "Backup was not removed from bucket -- minio"
170171
exit 1
171172
fi

e2e-tests/demand-backup/run

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@ backup_exists=$(kubectl_bin run -i --rm aws-cli --image=perconalab/awscli --rest
135135
/usr/bin/aws --endpoint-url http://minio-service:9000 s3 ls s3://operator-testing/ \
136136
| grep -c ${backup_dest_minio} | cat)
137137
if [[ $backup_exists -eq 1 ]]; then
138+
collect_k8s_logs
138139
echo "Backup was not removed from bucket -- minio"
139140
exit 1
140141
fi
@@ -170,6 +171,7 @@ backup_exists=$(kubectl_bin run -i --rm aws-cli --image=perconalab/awscli --rest
170171
/usr/bin/aws --endpoint-url http://minio-service:9000 s3 ls s3://operator-testing/ \
171172
| grep -c ${backup_dest_minio} | cat)
172173
if [[ $backup_exists -eq 1 ]]; then
174+
collect_k8s_logs
173175
echo "Backup was not removed from bucket -- minio"
174176
exit 1
175177
fi

0 commit comments

Comments
 (0)