Skip to content

Commit

Permalink
Test exported mongos service endpoint withing
Browse files Browse the repository at this point in the history
demand-backup-physical-sharded test.
  • Loading branch information
inelpandzic committed Sep 5, 2023
1 parent 6a120d3 commit 7aaf4e5
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ spec:
cpu: 100m
memory: 0.1G
expose:
exposeType: ClusterIP
exposeType: LoadBalancer
configsvrReplSet:
affinity:
antiAffinityTopologyKey: none
Expand Down
19 changes: 19 additions & 0 deletions e2e-tests/demand-backup-physical-sharded/run
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,15 @@ run_recovery_check() {
set -o xtrace
}

check_exported_mongos_service_endpoint() {
local host=$1

if [ "$host" != "$(kubectl_bin get psmdb $cluster -o=jsonpath='{.status.host}')" ]; then
echo "Exported host is not correct after the restore"
exit 1
fi
}

create_infra "${namespace}"

deploy_minio
Expand All @@ -68,6 +77,13 @@ wait_for_running ${cluster}-cfg 3
wait_for_running ${cluster}-mongos 3
wait_cluster_consistency ${cluster}

lbEndpoint=$(kubectl_bin get svc $cluster-mongos -o=jsonpath='{.status}' \
| jq -r 'select(.loadBalancer != null and .loadBalancer.ingress != null and .loadBalancer.ingress != []) | .loadBalancer.ingress[0].ip')
if [ -z $lbEndpoint ]; then
echo "mongos service not exported correctly"
exit 1
fi

run_mongos \
'db.createUser({user:"myApp",pwd:"myPass",roles:[{db:"myApp",role:"readWrite"}]})' \
"userAdmin:userAdmin123456@${cluster}-mongos.${namespace}"
Expand Down Expand Up @@ -102,18 +118,21 @@ if [ -z "$SKIP_BACKUPS_TO_AWS_GCP_AZURE" ]; then
echo 'check backup and restore -- aws-s3'
run_restore ${backup_name_aws} "_restore_sharded"
run_recovery_check ${backup_name_aws} "_restore_sharded"
check_exported_mongos_service_endpoint "$lbEndpoint"

echo "drop collection"
run_mongos 'use myApp\n db.test.drop()' "myApp:myPass@${cluster}-mongos.${namespace}"
echo 'check backup and restore -- gcp-cs'
run_restore ${backup_name_gcp} "_restore_sharded"
run_recovery_check ${backup_name_gcp} "_restore_sharded"
check_exported_mongos_service_endpoint "$lbEndpoint"

echo "drop collection"
run_mongos 'use myApp\n db.test.drop()' "myApp:myPass@${cluster}-mongos.${namespace}"
echo 'check backup and restore -- azure-blob'
run_restore ${backup_name_azure} "_restore_sharded"
run_recovery_check ${backup_name_azure} "_restore_sharded"
check_exported_mongos_service_endpoint "$lbEndpoint"
fi

echo "drop collection"
Expand Down
4 changes: 3 additions & 1 deletion e2e-tests/demand-backup-sharded/conf/some-name-rs0.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,9 @@ spec:
replication:
localPingThresholdMs: 15
expose:
exposeType: LoadBalancer
exposeType: ClusterIP
loadBalancerSourceRanges:
- 10.0.0.0/8
sidecars:
- image: busybox
command: ["/bin/sh"]
Expand Down
19 changes: 0 additions & 19 deletions e2e-tests/demand-backup-sharded/run
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,6 @@ check_data() {
done
}

check_exported_mongos_service_endpoint() {
local host=$1

if [ "$host" != "$(kubectl_bin get psmdb $cluster -o=jsonpath='{.status.host}')" ]; then
echo "Exported host is not correct after the restore"
exit 1
fi
}

create_infra "$namespace"

deploy_minio
Expand Down Expand Up @@ -74,13 +65,6 @@ wait_for_running $cluster-mongos 3

compare_kubectl statefulset/$cluster-mongos "-secret"

lbEndpoint=$(kubectl_bin get svc $cluster-mongos -o=jsonpath='{.status}' \
| jq -r 'select(.loadBalancer != null and .loadBalancer.ingress != null and .loadBalancer.ingress != []) | .loadBalancer.ingress[0].ip')
if [ -z $lbEndpoint ]; then
echo "mongos service not exported correctly"
exit 1
fi

desc 'write data, read from all'
run_mongos \
'db.createUser({user:"myApp",pwd:"myPass",roles:[{db:"myApp",role:"readWrite"},{db:"myApp1",role:"readWrite"},{db:"myApp2",role:"readWrite"}]})' \
Expand Down Expand Up @@ -137,7 +121,6 @@ if [ -z "$SKIP_BACKUPS_TO_AWS_GCP_AZURE" ]; then
check_data "-2nd"
run_restore "$backup_name_aws"
wait_restore "$backup_name_aws" "$cluster"
check_exported_mongos_service_endpoint "$lbEndpoint"
check_data

desc 'check backup and restore -- gcp-cs'
Expand All @@ -149,7 +132,6 @@ if [ -z "$SKIP_BACKUPS_TO_AWS_GCP_AZURE" ]; then
check_data "-2nd"
run_restore "$backup_name_gcp"
wait_restore "$backup_name_gcp" "$cluster"
check_exported_mongos_service_endpoint "$lbEndpoint"
check_data

desc 'check backup and restore -- azure-blob'
Expand All @@ -161,7 +143,6 @@ if [ -z "$SKIP_BACKUPS_TO_AWS_GCP_AZURE" ]; then
check_data "-2nd"
run_restore "$backup_name_azure"
wait_restore "$backup_name_azure" "$cluster"
check_exported_mongos_service_endpoint "$lbEndpoint"
check_data
fi

Expand Down

0 comments on commit 7aaf4e5

Please sign in to comment.