Skip to content

Commit

Permalink
functions - fix run_mongo and run_mongos for collecting k8s logs
Browse files Browse the repository at this point in the history
  • Loading branch information
tplavcic committed Oct 20, 2023
1 parent dc207e0 commit 8216629
Showing 1 changed file with 16 additions and 8 deletions.
24 changes: 16 additions & 8 deletions e2e-tests/functions
Original file line number Diff line number Diff line change
Expand Up @@ -705,11 +705,15 @@ run_mongo() {
local suffix=${4:-.svc.cluster.local}
local client_container=$(kubectl_bin get pods --selector=name=psmdb-client -o 'jsonpath={.items[].metadata.name}')
local mongo_flag="$5"
local replica_set=$(echo "$uri" | sed -r 's/.*\-(rs[0-9]|cfg)(\.|-).*/\1/')

kubectl_bin exec ${client_container} -- \
bash -c "printf '$command\n' | mongo $driver://$uri$suffix/admin?ssl=false\&replicaSet=$replica_set $mongo_flag"
local replica_set=$(echo "$uri" | grep -oE '\-(rs[0-9]|cfg)(\.|-)' | sed 's/^.//;s/.$//')

if [[ ${FUNCNAME[1]} == "collect_k8s_logs" ]]; then
kubectl exec ${client_container} -- \
bash -c "printf '$command\n' | mongo $driver://$uri$suffix/admin?ssl=false\&replicaSet=$replica_set $mongo_flag"
else
kubectl_bin exec ${client_container} -- \
bash -c "printf '$command\n' | mongo $driver://$uri$suffix/admin?ssl=false\&replicaSet=$replica_set $mongo_flag"
fi
}

run_mongo_tls() {
Expand All @@ -719,11 +723,15 @@ run_mongo_tls() {
local suffix=${4:-.svc.cluster.local}
local client_container=$(kubectl_bin get pods --selector=name=psmdb-client -o 'jsonpath={.items[].metadata.name}')
local mongo_flag="$5"
local replica_set=$(echo "$uri" | sed -r 's/.*\-(rs[0-9]|cfg)(\.|-).*/\1/')

kubectl_bin exec ${client_container} -- \
bash -c "printf '$command\n' | mongo $driver://$uri$suffix/admin?replicaSet=$replica_set --tls --tlsCAFile /etc/mongodb-ssl/ca.crt --tlsCertificateKeyFile /tmp/tls.pem --tlsAllowInvalidHostnames $mongo_flag"
local replica_set=$(echo "$uri" | grep -oE '\-(rs[0-9]|cfg)(\.|-)' | sed 's/^.//;s/.$//')

if [[ ${FUNCNAME[1]} == "collect_k8s_logs" ]]; then
kubectl exec ${client_container} -- \
bash -c "printf '$command\n' | mongo $driver://$uri$suffix/admin?replicaSet=$replica_set --tls --tlsCAFile /etc/mongodb-ssl/ca.crt --tlsCertificateKeyFile /tmp/tls.pem --tlsAllowInvalidHostnames $mongo_flag"
else
kubectl_bin exec ${client_container} -- \
bash -c "printf '$command\n' | mongo $driver://$uri$suffix/admin?replicaSet=$replica_set --tls --tlsCAFile /etc/mongodb-ssl/ca.crt --tlsCertificateKeyFile /tmp/tls.pem --tlsAllowInvalidHostnames $mongo_flag"
fi
}

run_mongos() {
Expand Down

0 comments on commit 8216629

Please # to comment.