Skip to content

Commit

Permalink
Test for server connection in EVG tests (#443)
Browse files Browse the repository at this point in the history
  • Loading branch information
blink1073 authored Jun 24, 2024
1 parent 8c948a2 commit a68e056
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 1 deletion.
3 changes: 3 additions & 0 deletions .evergreen/atlas/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,6 @@ SCRIPT_DIR=$(dirname ${BASH_SOURCE[0]})
. $SCRIPT_DIR/../handle-paths.sh

. $SCRIPT_DIR/setup-atlas-cluster.sh "$@"

source $SCRIPT_DIR/secrets-export.sh
. ${DRIVERS_TOOLS}/.evergreen/check-connection.sh
12 changes: 12 additions & 0 deletions .evergreen/check-connection.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/usr/bin/env bash

set -eu

SCRIPT_DIR=$(dirname ${BASH_SOURCE[0]})
. $SCRIPT_DIR/handle-paths.sh

if [ ! -f "${MONGODB_BINARIES}/mongosh" ]; then
bash -c "source ${DRIVERS_TOOLS}/.evergreen/download-mongodb.sh && download_and_extract_mongosh"
fi

${MONGODB_BINARIES}/mongosh "${MONGODB_URI}" --eval "db.runCommand({\"ping\":1})" --&serverSelectionTimeoutMS=10000
6 changes: 6 additions & 0 deletions .evergreen/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,12 @@ functions:
ENTRYPOINT: /root/test-entrypoint.sh
args:
- ${DRIVERS_TOOLS}/.evergreen/docker/run-server.sh
- command: subprocess.exec
type: test
params:
binary: bash
args:
- ${DRIVERS_TOOLS}/.evergreen/check-connection.sh
- command: subprocess.exec
type: test
params:
Expand Down
7 changes: 6 additions & 1 deletion .evergreen/download-mongodb.sh
Original file line number Diff line number Diff line change
Expand Up @@ -726,7 +726,11 @@ download_and_extract_package ()
download_and_extract_mongosh ()
{
MONGOSH_DOWNLOAD_URL=$1
EXTRACT_MONGOSH=$2
EXTRACT_MONGOSH=${2:-"tar zxf"}

if [ -z "$MONGOSH_DOWNLOAD_URL" ]; then
get_mongodb_download_url_for $(get_distro) latest false
fi

if [ -n "$MONGODB_BINARY_ROOT" ]; then
cd $MONGODB_BINARY_ROOT
Expand All @@ -741,6 +745,7 @@ download_and_extract_mongosh ()

rm -f mongosh.tgz
mv mongosh-* mongosh
mkdir -p mongodb/bin
mv mongosh/bin/* mongodb/bin
rm -rf mongosh
chmod -R +x mongodb/bin
Expand Down
4 changes: 4 additions & 0 deletions .evergreen/serverless/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,7 @@ SCRIPT_DIR=$(dirname ${BASH_SOURCE[0]})
. $SCRIPT_DIR/../handle-paths.sh

. $SCRIPT_DIR/create-instance.sh

source ${SCRIPT_DIR}/secrets-export.sh
export MONGODB_URI=$SERVERLESS_URI
. ${DRIVERS_TOOLS}/.evergreen/check-connection.sh

0 comments on commit a68e056

Please sign in to comment.