From f1a836f6dc86b9cc7892d114f37c57c5cfd2745b Mon Sep 17 00:00:00 2001 From: Kevin Albertson Date: Wed, 29 Sep 2021 17:41:28 -0400 Subject: [PATCH 1/5] CXX-2297 add connect.sh --- .evergreen/connect.sh | 41 +++++++++++++++++++++++++++++++++++++++++ .mci.yml | 34 +++++++++------------------------- 2 files changed, 50 insertions(+), 25 deletions(-) create mode 100755 .evergreen/connect.sh diff --git a/.evergreen/connect.sh b/.evergreen/connect.sh new file mode 100755 index 0000000000..e8c0c9f498 --- /dev/null +++ b/.evergreen/connect.sh @@ -0,0 +1,41 @@ +#!/bin/bash + +set -o errexit +set -o pipefail + +LIB_DIR=${LIB_DIR:-"lib"} +BUILD_TYPE=${BUILD_TYPE:-"Debug"} + +if [ -z "$URI" ]; then + echo "URI is a required environment variable."; + exit 1; +fi +if [ -z "$MONGOC_INSTALL_PREFIX" ]; then + echo "MONGOC_INSTALL_PREFIX is a required environment variable."; + exit 1; +fi +if [ -z "$MONGOCXX_INSTALL_PREFIX" ]; then + echo "MONGOCXX_INSTALL_PREFIX is a required environment variable."; + exit 1; +fi +if [ -z "$BUILD_DIR" ]; then + echo "BUILD_DIR is a required environment variable."; + exit 1; +fi + +# Use PATH / LD_LIBRARY_PATH / DYLD_LIBRARY_PATH to inform the tests where to find +# mongoc library dependencies on Windows / Linux / Mac OS, respectively. +export PATH=$PATH:$MONGOC_INSTALL_PREFIX/bin +export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$MONGOC_INSTALL_PREFIX/$LIB_DIR/ +export DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH:$MONGOC_INSTALL_PREFIX/$LIB_DIR/ + +# Windows also needs to be informed where to find mongocxx library dependencies. +export PATH=$PATH:$BUILD_DIR/src/bsoncxx/$BUILD_TYPE +export PATH=$PATH:$BUILD_DIR/src/mongocxx/$BUILD_TYPE +export PATH=$PATH:$MONGOCXX_INSTALL_PREFIX/bin + +if [ "Windows_NT" == "$OS" ]; then + $BUILD_DIR/examples/mongocxx/$BUILD_TYPE/connect.exe "$URI" +else + $BUILD_DIR/examples/mongocxx/connect "$URI" +fi \ No newline at end of file diff --git a/.mci.yml b/.mci.yml index e9698d5a28..f5e947188f 100644 --- a/.mci.yml +++ b/.mci.yml @@ -471,32 +471,14 @@ functions: shell: bash working_dir: "mongo-cxx-driver" script: | - set -o errexit - set -o pipefail - export PATH="${extra_path}:$PATH" - cd build - export PREFIX=$(pwd)/../../mongoc - - # Use PATH / LD_LIBRARY_PATH / DYLD_LIBRARY_PATH to inform the tests where to find - # mongoc library dependencies on Windows / Linux / Mac OS, respectively. - # Additionally, on Windows, we also need to inform the tests where to find - # mongocxx library dependencies. - if [ -n "${lib_dir}" ]; then - export LD_LIBRARY_PATH=.:$PREFIX/${lib_dir}/ - export DYLD_LIBRARY_PATH=.:$PREFIX/${lib_dir}/ - else - export LD_LIBRARY_PATH=.:$PREFIX/lib/ - export DYLD_LIBRARY_PATH=.:$PREFIX/lib/ - fi - export PATH=$(pwd)/src/bsoncxx/${build_type}:$(pwd)/src/mongocxx/${build_type}:$PREFIX/bin:$(pwd)/install/bin:$PATH + set -o xtrace - URI="mongodb://bob:pwd123@localhost" - - if [ "Windows_NT" == "$OS" ]; then - ./examples/mongocxx/${build_type}/connect.exe "$URI" - else - ./examples/mongocxx/connect "$URI" - fi + export URI="mongodb://bob:pwd123@localhost" + export MONGOC_INSTALL_PREFIX=$(pwd)/../mongoc + export MONGOCXX_INSTALL_PREFIX=$(pwd)/build/install + export LIB_DIR=${lib_dir} + export BUILD_TYPE=${build_type} + ./.evergreen/connect.sh "backtrace": - command: shell.exec @@ -626,6 +608,8 @@ tasks: - func: "install_c_driver" - func: "compile" - func: "test auth" + vars: + URI:"mongodb://bob:pwd123@localhost" - name: compile_and_test_with_static_libs commands: From dec636911a1d7f60403e97a83c078451ed056805 Mon Sep 17 00:00:00 2001 From: Kevin Albertson Date: Wed, 29 Sep 2021 17:43:25 -0400 Subject: [PATCH 2/5] fix .mci.yml spacing --- .evergreen/connect.sh | 2 +- .mci.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.evergreen/connect.sh b/.evergreen/connect.sh index e8c0c9f498..1ea64e64c7 100755 --- a/.evergreen/connect.sh +++ b/.evergreen/connect.sh @@ -38,4 +38,4 @@ if [ "Windows_NT" == "$OS" ]; then $BUILD_DIR/examples/mongocxx/$BUILD_TYPE/connect.exe "$URI" else $BUILD_DIR/examples/mongocxx/connect "$URI" -fi \ No newline at end of file +fi diff --git a/.mci.yml b/.mci.yml index f5e947188f..3886caef1b 100644 --- a/.mci.yml +++ b/.mci.yml @@ -609,7 +609,7 @@ tasks: - func: "compile" - func: "test auth" vars: - URI:"mongodb://bob:pwd123@localhost" + URI: "mongodb://bob:pwd123@localhost" - name: compile_and_test_with_static_libs commands: From 5f6720c021a79f092597336ab9c3e26ffd7a1513 Mon Sep 17 00:00:00 2001 From: Kevin Albertson Date: Wed, 29 Sep 2021 18:41:38 -0400 Subject: [PATCH 3/5] add missing BUILD_DIR --- .mci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.mci.yml b/.mci.yml index 3886caef1b..dcc85a4ec2 100644 --- a/.mci.yml +++ b/.mci.yml @@ -478,6 +478,7 @@ functions: export MONGOCXX_INSTALL_PREFIX=$(pwd)/build/install export LIB_DIR=${lib_dir} export BUILD_TYPE=${build_type} + export BUILD_DIR=$(pwd)/build ./.evergreen/connect.sh "backtrace": From 5d4a23d4d9edad8d640140fd955f4fa26f40d63b Mon Sep 17 00:00:00 2001 From: Kevin Albertson Date: Thu, 30 Sep 2021 21:11:00 -0400 Subject: [PATCH 4/5] add serverless function --- .mci.yml | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/.mci.yml b/.mci.yml index dcc85a4ec2..8da7379e48 100644 --- a/.mci.yml +++ b/.mci.yml @@ -473,12 +473,32 @@ functions: script: | set -o xtrace + export MONGOC_INSTALL_PREFIX=$(pwd)/../mongoc + export MONGOCXX_INSTALL_PREFIX=$(pwd)/build/install + export LIB_DIR=${lib_dir} + export BUILD_TYPE=${build_type} + export BUILD_DIR=$(pwd)/build export URI="mongodb://bob:pwd123@localhost" + ./.evergreen/connect.sh + + "test atlas connectivity": + - command: shell.exec + params: + shell: bash + working_dir: "mongo-cxx-driver" + silent: true + script: | + set -o xtrace + export MONGOC_INSTALL_PREFIX=$(pwd)/../mongoc export MONGOCXX_INSTALL_PREFIX=$(pwd)/build/install export LIB_DIR=${lib_dir} export BUILD_TYPE=${build_type} export BUILD_DIR=$(pwd)/build + + # The atlas_serverless_uri expansion is set in the Evergreen project settings. + export URI="${atlas_serverless_uri}" + ./.evergreen/connect.sh "backtrace": @@ -609,8 +629,7 @@ tasks: - func: "install_c_driver" - func: "compile" - func: "test auth" - vars: - URI: "mongodb://bob:pwd123@localhost" + - func: "test atlas connectivity" - name: compile_and_test_with_static_libs commands: From 8156166217ed44621aba7a64c60b332d4ce6b273 Mon Sep 17 00:00:00 2001 From: Kevin Albertson Date: Fri, 1 Oct 2021 13:43:11 -0400 Subject: [PATCH 5/5] add usage to connect.sh --- .evergreen/connect.sh | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/.evergreen/connect.sh b/.evergreen/connect.sh index 1ea64e64c7..8d4bbbc442 100755 --- a/.evergreen/connect.sh +++ b/.evergreen/connect.sh @@ -6,21 +6,34 @@ set -o pipefail LIB_DIR=${LIB_DIR:-"lib"} BUILD_TYPE=${BUILD_TYPE:-"Debug"} -if [ -z "$URI" ]; then - echo "URI is a required environment variable."; +print_usage_and_exit () { + echo "Error: $1" + cat << EOF + connect.sh runs the connect example with a MongoDB URI. + + Example usage: + MONGOC_INSTALL_PREFIX=/Users/kevin.albertson/install/mongo-c-driver-1.18.0 \\ + MONGOCXX_INSTALL_PREFIX=/Users/kevin.albertson/install/mongo-cxx-driver-dev \\ + LIB_DIR="lib" \\ + BUILD_TYPE="Debug" \\ + BUILD_DIR=$(pwd)/cmake-build \\ + URI="mongodb://localhost:27017/?" \\ + ./.evergreen/connect.sh +EOF exit 1; +} + +if [ -z "$URI" ]; then + print_usage_and_exit "URI is a required environment variable." fi if [ -z "$MONGOC_INSTALL_PREFIX" ]; then - echo "MONGOC_INSTALL_PREFIX is a required environment variable."; - exit 1; + print_usage_and_exit "MONGOC_INSTALL_PREFIX is a required environment variable." fi if [ -z "$MONGOCXX_INSTALL_PREFIX" ]; then - echo "MONGOCXX_INSTALL_PREFIX is a required environment variable."; - exit 1; + print_usage_and_exit "MONGOCXX_INSTALL_PREFIX is a required environment variable." fi if [ -z "$BUILD_DIR" ]; then - echo "BUILD_DIR is a required environment variable."; - exit 1; + print_usage_and_exit "BUILD_DIR is a required environment variable." fi # Use PATH / LD_LIBRARY_PATH / DYLD_LIBRARY_PATH to inform the tests where to find