Skip to content

Commit

Permalink
K8SPSMDB-1098 fix tls-issue-cert-manager test (#1627)
Browse files Browse the repository at this point in the history
* K8SPSMDB-1098 fix tls-issue-cert-manager test

* fix liveness test

* fix liveness

* Update e2e-tests/liveness/run

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
  • Loading branch information
hors and github-actions[bot] authored Aug 23, 2024
1 parent d1bda8d commit c2b95d9
Show file tree
Hide file tree
Showing 9 changed files with 13 additions and 13 deletions.
4 changes: 4 additions & 0 deletions e2e-tests/functions
Original file line number Diff line number Diff line change
Expand Up @@ -632,6 +632,7 @@ compare_generation() {
compare_kubectl() {
local resource="$1"
local postfix="$2"
local skip_generation_check="$3"
local expected_result=${test_dir}/compare/${resource//\//_}${postfix}.yml
local new_result="${tmp_dir}/${resource//\//_}.yml"

Expand Down Expand Up @@ -693,6 +694,9 @@ compare_kubectl() {
yq -i eval 'del(.metadata.generation)' ${new_result}
fi
fi
if [ -n "$skip_generation_check" ]; then
yq -i eval 'del(.metadata.generation)' ${new_result}
fi
diff -u "$expected_result" "$new_result"
}

Expand Down
10 changes: 6 additions & 4 deletions e2e-tests/liveness/run
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,11 @@ spinup_psmdb ${cluster}-rs0 $test_dir/conf/${cluster}-rs0.yml
desc 'check if statefulset created with expected config'
compare_kubectl "statefulset/${cluster}-rs0"

# There should be some failed liveness checks during the password change.
desc 'change MONGODB_CLUSTER_MONITOR_PASSWORD'
patch_secret "some-users" "MONGODB_CLUSTER_MONITOR_PASSWORD" "$newpassencrypted"
# There should be some failed liveness checks due to wrong optoins in command
set +e
kubectl exec -it $cluster-rs0-0 -- bash -c '/opt/percona/mongodb-healthcheck k8s liveness --ssl'
set -e

sleep 20
wait_for_running "${cluster}-rs0" "3"

Expand All @@ -33,7 +35,7 @@ if [[ $current_log_file != "1" ]]; then
fi

rotated_log_files=$(kubectl_bin exec -it $cluster-rs0-0 -- bash -c 'ls /data/db/mongod-data/logs' | grep -c "mongodb-healthcheck-.*\.log\.gz")
if [[ $rotated_log_files != "1" ]]; then
if [[ $rotated_log_files -lt "1" ]]; then
echo "mongodb-healthcheck.log doesn't exist"
exit 1
fi
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ apiVersion: apps/v1
kind: StatefulSet
metadata:
annotations: {}
generation: 7
labels:
app.kubernetes.io/component: cfg
app.kubernetes.io/instance: some-name
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ apiVersion: apps/v1
kind: StatefulSet
metadata:
annotations: {}
generation: 7
labels:
app.kubernetes.io/component: cfg
app.kubernetes.io/instance: some-name
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ apiVersion: apps/v1
kind: StatefulSet
metadata:
annotations: {}
generation: 7
labels:
app.kubernetes.io/component: mongos
app.kubernetes.io/instance: some-name
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ apiVersion: apps/v1
kind: StatefulSet
metadata:
annotations: {}
generation: 7
labels:
app.kubernetes.io/component: mongos
app.kubernetes.io/instance: some-name
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ apiVersion: apps/v1
kind: StatefulSet
metadata:
annotations: {}
generation: 8
labels:
app.kubernetes.io/component: mongod
app.kubernetes.io/instance: some-name
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ apiVersion: apps/v1
kind: StatefulSet
metadata:
annotations: {}
generation: 8
labels:
app.kubernetes.io/component: mongod
app.kubernetes.io/instance: some-name
Expand Down
6 changes: 3 additions & 3 deletions e2e-tests/tls-issue-cert-manager/run
Original file line number Diff line number Diff line change
Expand Up @@ -138,9 +138,9 @@ main() {
unpause_cluster "$cluster"
wait_for_cluster_state "${cluster}" "ready"

compare_kubectl statefulset/${cluster}-rs0 "-tls-disabled"
compare_kubectl statefulset/${cluster}-cfg "-tls-disabled"
compare_kubectl statefulset/${cluster}-mongos "-tls-disabled"
compare_kubectl statefulset/${cluster}-rs0 "-tls-disabled" "skip_generation_check"
compare_kubectl statefulset/${cluster}-cfg "-tls-disabled" "skip_generation_check"
compare_kubectl statefulset/${cluster}-mongos "-tls-disabled" "skip_generation_check"

destroy "$namespace"
desc 'test passed'
Expand Down

0 comments on commit c2b95d9

Please sign in to comment.