Skip to content

Commit 08b5778

Browse files
authored
CXX-2297 add connect.sh and Atlas Serverless connectivity test (#833)
1 parent 6c7faac commit 08b5778

File tree

2 files changed

+81
-23
lines changed

2 files changed

+81
-23
lines changed

.evergreen/connect.sh

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
#!/bin/bash
2+
3+
set -o errexit
4+
set -o pipefail
5+
6+
LIB_DIR=${LIB_DIR:-"lib"}
7+
BUILD_TYPE=${BUILD_TYPE:-"Debug"}
8+
9+
print_usage_and_exit () {
10+
echo "Error: $1"
11+
cat << EOF
12+
connect.sh runs the connect example with a MongoDB URI.
13+
14+
Example usage:
15+
MONGOC_INSTALL_PREFIX=/Users/kevin.albertson/install/mongo-c-driver-1.18.0 \\
16+
MONGOCXX_INSTALL_PREFIX=/Users/kevin.albertson/install/mongo-cxx-driver-dev \\
17+
LIB_DIR="lib" \\
18+
BUILD_TYPE="Debug" \\
19+
BUILD_DIR=$(pwd)/cmake-build \\
20+
URI="mongodb://localhost:27017/?" \\
21+
./.evergreen/connect.sh
22+
EOF
23+
exit 1;
24+
}
25+
26+
if [ -z "$URI" ]; then
27+
print_usage_and_exit "URI is a required environment variable."
28+
fi
29+
if [ -z "$MONGOC_INSTALL_PREFIX" ]; then
30+
print_usage_and_exit "MONGOC_INSTALL_PREFIX is a required environment variable."
31+
fi
32+
if [ -z "$MONGOCXX_INSTALL_PREFIX" ]; then
33+
print_usage_and_exit "MONGOCXX_INSTALL_PREFIX is a required environment variable."
34+
fi
35+
if [ -z "$BUILD_DIR" ]; then
36+
print_usage_and_exit "BUILD_DIR is a required environment variable."
37+
fi
38+
39+
# Use PATH / LD_LIBRARY_PATH / DYLD_LIBRARY_PATH to inform the tests where to find
40+
# mongoc library dependencies on Windows / Linux / Mac OS, respectively.
41+
export PATH=$PATH:$MONGOC_INSTALL_PREFIX/bin
42+
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$MONGOC_INSTALL_PREFIX/$LIB_DIR/
43+
export DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH:$MONGOC_INSTALL_PREFIX/$LIB_DIR/
44+
45+
# Windows also needs to be informed where to find mongocxx library dependencies.
46+
export PATH=$PATH:$BUILD_DIR/src/bsoncxx/$BUILD_TYPE
47+
export PATH=$PATH:$BUILD_DIR/src/mongocxx/$BUILD_TYPE
48+
export PATH=$PATH:$MONGOCXX_INSTALL_PREFIX/bin
49+
50+
if [ "Windows_NT" == "$OS" ]; then
51+
$BUILD_DIR/examples/mongocxx/$BUILD_TYPE/connect.exe "$URI"
52+
else
53+
$BUILD_DIR/examples/mongocxx/connect "$URI"
54+
fi

.mci.yml

Lines changed: 27 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -471,32 +471,35 @@ functions:
471471
shell: bash
472472
working_dir: "mongo-cxx-driver"
473473
script: |
474-
set -o errexit
475-
set -o pipefail
476-
export PATH="${extra_path}:$PATH"
477-
cd build
478-
export PREFIX=$(pwd)/../../mongoc
474+
set -o xtrace
479475
480-
# Use PATH / LD_LIBRARY_PATH / DYLD_LIBRARY_PATH to inform the tests where to find
481-
# mongoc library dependencies on Windows / Linux / Mac OS, respectively.
482-
# Additionally, on Windows, we also need to inform the tests where to find
483-
# mongocxx library dependencies.
484-
if [ -n "${lib_dir}" ]; then
485-
export LD_LIBRARY_PATH=.:$PREFIX/${lib_dir}/
486-
export DYLD_LIBRARY_PATH=.:$PREFIX/${lib_dir}/
487-
else
488-
export LD_LIBRARY_PATH=.:$PREFIX/lib/
489-
export DYLD_LIBRARY_PATH=.:$PREFIX/lib/
490-
fi
491-
export PATH=$(pwd)/src/bsoncxx/${build_type}:$(pwd)/src/mongocxx/${build_type}:$PREFIX/bin:$(pwd)/install/bin:$PATH
476+
export MONGOC_INSTALL_PREFIX=$(pwd)/../mongoc
477+
export MONGOCXX_INSTALL_PREFIX=$(pwd)/build/install
478+
export LIB_DIR=${lib_dir}
479+
export BUILD_TYPE=${build_type}
480+
export BUILD_DIR=$(pwd)/build
481+
export URI="mongodb://bob:pwd123@localhost"
482+
./.evergreen/connect.sh
483+
484+
"test atlas connectivity":
485+
- command: shell.exec
486+
params:
487+
shell: bash
488+
working_dir: "mongo-cxx-driver"
489+
silent: true
490+
script: |
491+
set -o xtrace
492492
493-
URI="mongodb://bob:pwd123@localhost"
493+
export MONGOC_INSTALL_PREFIX=$(pwd)/../mongoc
494+
export MONGOCXX_INSTALL_PREFIX=$(pwd)/build/install
495+
export LIB_DIR=${lib_dir}
496+
export BUILD_TYPE=${build_type}
497+
export BUILD_DIR=$(pwd)/build
494498
495-
if [ "Windows_NT" == "$OS" ]; then
496-
./examples/mongocxx/${build_type}/connect.exe "$URI"
497-
else
498-
./examples/mongocxx/connect "$URI"
499-
fi
499+
# The atlas_serverless_uri expansion is set in the Evergreen project settings.
500+
export URI="${atlas_serverless_uri}"
501+
502+
./.evergreen/connect.sh
500503
501504
"backtrace":
502505
- command: shell.exec
@@ -626,6 +629,7 @@ tasks:
626629
- func: "install_c_driver"
627630
- func: "compile"
628631
- func: "test auth"
632+
- func: "test atlas connectivity"
629633

630634
- name: compile_and_test_with_static_libs
631635
commands:

0 commit comments

Comments
 (0)