diff --git a/core/Cargo.toml b/core/Cargo.toml index f9b9d32a..4d3ecd15 100644 --- a/core/Cargo.toml +++ b/core/Cargo.toml @@ -53,6 +53,7 @@ windows = { version = "0.44.0", features = [ [features] garbage_collect = [] +eap = [] [lib] name = "mongo_odbc_core" diff --git a/core/src/conn.rs b/core/src/conn.rs index 91367a46..c5e044b4 100644 --- a/core/src/conn.rs +++ b/core/src/conn.rs @@ -170,15 +170,33 @@ impl MongoConnection { let type_of_cluster = runtime.block_on(async { determine_cluster_type(&client).await })?; match type_of_cluster { - MongoClusterType::AtlasDataFederation | MongoClusterType::Enterprise => {} + MongoClusterType::AtlasDataFederation => {} + MongoClusterType::Enterprise => { + #[cfg(not(feature = "eap"))] + return Err(Error::UnsupportedClusterConfiguration( + "Unsupported cluster type. The driver is intended for use with MongoDB Atlas Data Federation." + .to_string(), + )); + } MongoClusterType::Community => { // Community edition is not supported + #[cfg(not(feature = "eap"))] + return Err(Error::UnsupportedClusterConfiguration( + "Community edition detected. The driver is intended for use with MongoDB Atlas Data Federation." + .to_string(), + )); + #[cfg(feature = "eap")] return Err(Error::UnsupportedClusterConfiguration( "Community edition detected. The driver is intended for use with MongoDB Enterprise edition or Atlas Data Federation.".to_string(), )); } MongoClusterType::UnknownTarget => { // Unknown cluster type is not supported + #[cfg(not(feature = "eap"))] + return Err(Error::UnsupportedClusterConfiguration( + "Unknown cluster/target type detected. The driver is intendended for use with MongoDB Atlas Data Federation".to_string(), + )); + #[cfg(feature = "eap")] return Err(Error::UnsupportedClusterConfiguration( "Unknown cluster/target type detected. The driver is intended for use with MongoDB Enterprise edition or Atlas Data Federation.".to_string(), )); diff --git a/evergreen.yml b/evergreen.yml index 9ef6c8e5..8b908be9 100644 --- a/evergreen.yml +++ b/evergreen.yml @@ -31,8 +31,46 @@ modules: include: - filename: evergreen/configs/mongodb_util.yml module: sql-engines-common-test-infra + - filename: evergreen/eap.yml # tasks related to eap snapshot builds + +variables: + - &check_and_allow_for_eap_build + command: shell.exec + type: test + params: + shell: bash + working_dir: mongosql-odbc-driver + script: | + ${PREPARE_SHELL} + if [ "${FEATURE_FLAGS}" != "eap" ]; then + echo "FEATURE_FLAGS (${"FEATURE_FLAGS}) is not 'eap'. Stopping task execution." + curl -d '{"status":"success", "should_continue": false}' -H "Content-Type: application/json" -X POST localhost:2285/task_status + else + echo "FEATURE_FLAGS is 'eap'. Allowing task execution to continue." + fi + - &check_and_allow_for_non_eap_build + command: shell.exec + type: test + params: + shell: bash + working_dir: mongosql-odbc-driver + script: | + ${PREPARE_SHELL} + if [ "${FEATURE_FLAGS}" == "eap" ]; then + echo "FEATURE_FLAGS (${FEATURE_FLAGS}) is 'eap'. Stopping task execution." + curl -d '{"status":"success", "should_continue": false}' -H "Content-Type: application/json" -X POST localhost:2285/task_status + else + echo "FEATURE_FLAGS is not 'eap'. Allowing task execution to continue." + fi + functions: + "check and allow for eap build": + - *check_and_allow_for_eap_build + + "check and allow for non-eap build": + - *check_and_allow_for_non_eap_build + "generate third party licenses": - command: subprocess.exec params: @@ -88,105 +126,15 @@ functions: sql-engines-common-test-infra: ${sql-engines-common-test-infra_rev} "generate expansions": - - command: shell.exec + - command: subprocess.exec params: - shell: bash + binary: bash working_dir: mongosql-odbc-driver - script: | - PROJECT_DIRECTORY="$(pwd)" - export CARGO_NET_GIT_FETCH_WITH_CLI=true - export INSTALLED_ODBC_PATH="$PWD/installed_odbc/install" - export LD_LIBRARY_PATH="$INSTALLED_ODBC_PATH/lib" - if [ "Windows_NT" == "$OS" ]; then - export PATH="$HOME/.rustup/bin:$HOME/.cargo/bin:$LD_LIBRARY_PATH:$PATH" - else - export PATH="$HOME/.cargo/bin:$LD_LIBRARY_PATH:$PATH" - fi - export DUMP_FOLDER=dumps - export LOCAL_DUMP_ORIGINAL_REG_VAL=local_dump_original_value.reg - export MONGOODBC_DEBUGGING_INFO_ARCHIVE=crashDebuggingInfo - export SCRIPT_FOLDER=resources - export COMPLIANCE_REPORT_NAME="mongo-odbc-driver_compliance_report.md" - export STATIC_CODE_ANALYSIS_NAME="mongo-odbc-driver.sast.sarif" - if [[ "${triggered_by_git_tag}" != "" ]]; then - export RELEASE_VERSION=$(echo ${triggered_by_git_tag} | sed s/v// ) - else - export RELEASE_VERSION=snapshot - fi - export MSI_FILENAME="mongoodbc-eap-$RELEASE_VERSION.msi" - export UBUNTU_FILENAME="mongoodbc-eap-$RELEASE_VERSION.tar.gz" - - COMMON_TEST_INFRA_DIR="$PROJECT_DIRECTORY/sql-engines-common-test-infra" - DRIVERS_TOOLS="$PROJECT_DIRECTORY/evergreen/drivers-tools" - MONGO_ORCHESTRATION_HOME="$DRIVERS_TOOLS/.evergreen/orchestration" - MONGODB_BINARIES="$DRIVERS_TOOLS/mongodb/bin" - - cat < expansions.yml - RELEASE_VERSION: "$RELEASE_VERSION" - MSI_FILENAME: "$MSI_FILENAME" - UBUNTU_FILENAME: "$UBUNTU_FILENAME" - WINDOWS_INSTALLER_PATH: "eap/mongosql-odbc-driver/windows/$RELEASE_VERSION/release/$MSI_FILENAME" - UBUNTU2204_INSTALLER_PATH: "eap/mongosql-odbc-driver/ubuntu2204/$RELEASE_VERSION/release/$UBUNTU_FILENAME" - COMPLIANCE_REPORT_NAME: "$COMPLIANCE_REPORT_NAME" - STATIC_CODE_ANALYSIS_NAME: "$STATIC_CODE_ANALYSIS_NAME" - DRIVERS_TOOLS: "$DRIVERS_TOOLS" - common_test_infra_dir: "$COMMON_TEST_INFRA_DIR" - script_dir: "$COMMON_TEST_INFRA_DIR/evergreen/scripts" - MONGO_ORCHESTRATION_HOME: "$DRIVERS_TOOLS/.evergreen/orchestration" - prepare_shell: | - set -o errexit - export RELEASE_VERSION="$RELEASE_VERSION" - export MSI_FILENAME="$MSI_FILENAME" - export UBUNTU_FILENAME="$UBUNTU_FILENAME" - export WINDOWS_INSTALLER_PATH="$WINDOWS_INSTALLER_PATH" - export UBUNTU2204_INSTALLER_PATH="$UBUNTU2204_INSTALLER_PATH" - export PATH="$PATH" - export CARGO_NET_GIT_FETCH_WITH_CLI="$CARGO_NET_GIT_FETCH_WITH_CLI" - export LOCAL_MDB_PORT_COM=${local_mdb_port_com} - export LOCAL_MDB_PORT_ENT=${local_mdb_port_ent} - export LOCAL_MDB_USER=${local_mdb_user} - export LOCAL_MDB_PWD=${local_mdb_pwd} - export ADF_TEST_LOCAL_USER="${adf_test_local_user}" - export ADF_TEST_LOCAL_PWD="${adf_test_local_pwd}" - export ADF_TEST_LOCAL_AUTH_DB="${adf_test_local_auth_db}" - export ADF_TEST_LOCAL_HOST="${adf_test_local_host}" - export MDB_TEST_LOCAL_PORT="${mdb_test_local_port}" - export ADF_TEST_LOCAL_DB="${adf_test_local_db}" - export ADF_TEST_URI="${adf_test_uri}" - export SRV_TEST_DB="${srv_test_db}" - export SRV_TEST_AUTH_DB="${srv_test_auth_db}" - export SRV_TEST_HOST="${srv_test_host}" - export SRV_TEST_USER="${srv_test_user}" - export SRV_TEST_PWD="${srv_test_pwd}" - export SCRIPT_FOLDER="$SCRIPT_FOLDER" - export SCRIPT_DIR="$(pwd)/$SCRIPT_FOLDER" - export SBOM_DIR="sbom_tools" - export SBOM_LICENSES="mongo-odbc-driver.licenses.cdx.json" - export SBOM_VULN="mongo-odbc-driver.merge.grype.cdx.json" - export SBOM_FINAL="mongo-odbc-driver.full.cdx.json" - export COMPLIANCE_REPORT_NAME="$COMPLIANCE_REPORT_NAME" - export STATIC_CODE_ANALYSIS_NAME="$STATIC_CODE_ANALYSIS_NAME" - export ALLOW_VULNS="${AllowVulns}" - - # Common test infra variables - export PROJECT_DIRECTORY="$PROJECT_DIRECTORY" - export DRIVERS_TOOLS="$DRIVERS_TOOLS" - export MONGO_ORCHESTRATION_HOME="$MONGO_ORCHESTRATION_HOME" - export MONGODB_BINARIES="$MONGODB_BINARIES" - export COMMON_TEST_INFRA_DIR="$COMMON_TEST_INFRA_DIR" - - # Windows variables - export LOCAL_DUMP_ORIGINAL_REG_VAL="$LOCAL_DUMP_ORIGINAL_REG_VAL" - export DUMP_FOLDER="$DUMP_FOLDER" - export DUMP_PATH="$(pwd)/$DUMP_FOLDER" - export MONGOODBC_DEBUGGING_INFO_ARCHIVE=$MONGOODBC_DEBUGGING_INFO_ARCHIVE - - # Non-Windows variables - export INSTALLED_ODBC_PATH="$INSTALLED_ODBC_PATH" - export LD_LIBRARY_PATH="$LD_LIBRARY_PATH" - export LIBRARY_PATH="$LD_LIBRARY_PATH" - export ODBCSYSINI="$(pwd)"/setup - EOT + env: + triggered_by_git_tag: ${triggered_by_git_tag} + args: + - "./evergreen/create-expansions.sh" + add_expansions_to_env: true - command: expansions.update params: file: mongosql-odbc-driver/expansions.yml @@ -198,6 +146,7 @@ functions: repo: mongohouse expansion_name: github_token + "install rust toolchain": - command: shell.exec params: @@ -710,9 +659,13 @@ functions: working_dir: mongosql-odbc-driver script: | ${prepare_shell} - - # Compile release build - cargo build --release + # Compile release build with features if needed + # if FEATURE_FLAGS is not empty, build with features + if [[ "$FEATURE_FLAGS" != "" ]]; then + cargo build --release --features $FEATURE_FLAGS + else + cargo build --release + fi # Verify the version is the expected one from the driver perspective too cargo test api::get_info_tests::unit::driver_ver -- --nocapture @@ -726,8 +679,12 @@ functions: script: | ${prepare_shell} - # Compile debug build - cargo build + # Compile release build with features if needed + if [[ "$FEATURE_FLAGS" != "" ]]; then + cargo build --features $FEATURE_FLAGS + else + cargo build + fi "compile ubuntu with asan": - command: shell.exec @@ -742,7 +699,11 @@ functions: export RUSTFLAGS="-Z sanitizer=address" - cargo build --target x86_64-unknown-linux-gnu + if [[ "$FEATURE_FLAGS" != "" ]]; then + cargo build --target x86_64-unknown-linux-gnu --features $FEATURE_FLAGS + else + cargo build --target x86_64-unknown-linux-gnu + fi "compile release with debug info": - command: shell.exec @@ -753,7 +714,12 @@ functions: ${prepare_shell} echo "env $(env)" # Build a release driver with debug information - cargo build --release + if [[ "$FEATURE_FLAGS" != "" ]]; then + cargo build --release --features $FEATURE_FLAGS + else + cargo build --release + fi + export DRIVER_LIB_PATH=$PWD/target/release cat <> expansions.yml @@ -787,7 +753,12 @@ functions: script: | ${prepare_shell} # Compile debug build - cargo build --features definitions/iodbc,cstr/utf32 + if [[ "$FEATURE_FLAGS" != "" ]]; then + cargo build --features definitions/iodbc,cstr/utf32,$FEATURE_FLAGS + else + cargo build --features definitions/iodbc,cstr/utf32 + fi + "compile macos release with debug info": - command: shell.exec @@ -799,7 +770,11 @@ functions: ${prepare_shell} echo "env $(env)" # Build a release driver with debug information - cargo build --features definitions/iodbc,cstr/utf32 --release + if [[ "$FEATURE_FLAGS" != "" ]]; then + cargo build --release --features definitions/iodbc,cstr/utf32,$FEATURE_FLAGS + else + cargo build --release --features definitions/iodbc,cstr/utf32 + fi export DRIVER_LIB_PATH=$PWD/target/release cat <> expansions.yml export DRIVER_LIB_PATH="$DRIVER_LIB_PATH" @@ -832,7 +807,7 @@ functions: # TODO: Delete the following line prior to merging back into master cp ./THIRD_PARTY_LICENSES.txt ./README.md installer/msi cd installer/msi - if [ "$RELEASE_VERSION" == "snapshot" ]; then + if [[ "$RELEASE_VERSION" == "snapshot" || "$RELEASE_VERSION" == "snapshot-eap" ]]; then MINOR_VERSION="0.1" VERSION_LABEL="0.1.0" else @@ -1410,7 +1385,7 @@ functions: echo "****** ls -l ./target/debug/deps *******" ls -l ./target/debug/deps echo "****************************************" - # The execution termimated with a segfault + # The execution terminated with a segfault if [ $EXITCODE -eq 139 ]; then # Compress the sources and pdbs so that we'll have everything for debugging available in Evergreen after a run SOURCES_FOLDERS=$(find $(pwd) -path '*/src' | tr '\n' ' ') @@ -1543,7 +1518,8 @@ functions: working_dir: mongosql-odbc-driver script: | ${prepare_shell} - cargo test mongosqltranslate_tests -- --nocapture + cargo build --release --features eap + cargo test mongosqltranslate_tests --features eap -- --nocapture "run ubuntu cluster type integration tests": - command: shell.exec @@ -1563,27 +1539,36 @@ functions: # Start MongoDB instances ./resources/start_local_mdb.sh $mdb_version_com $mdb_version_ent $arch - - # Enterprise test + # Enterprise test no eap cargo test --features cluster_type_tests -- cluster_type::test_determine_cluster_type_enterprise_succeeds --nocapture - ENTERPRISE_EXITCODE=$? + ENTERPRISE_NO_MSQL_EXITCODE=$? + # Enterprise test eap + cargo test --features cluster_type_tests, eap -- cluster_type::test_determine_cluster_type_enterprise_succeeds --nocapture + ENTERPRISE_MSQL_EXITCODE=$? + + # Enterprise test with eap # Community test cargo test --features cluster_type_tests -- cluster_type::test_determine_cluster_type_community_fails --nocapture - COMMUNITY_EXITCODE=$? + COMMUNITY_NO_MSQL_EXITCODE=$? + # Community test with eap + cargo test --features cluster_type_tests, eap -- cluster_type::test_determine_cluster_type_community_fails --nocapture + COMMUNITY_MSQL_EXITCODE=$? # Stop MongoDB instances pkill mongod - if [ $ENTERPRISE_EXITCODE -eq 0 ] && [ $COMMUNITY_EXITCODE -eq 0 ]; then + if [ $ENTERPRISE_NO_MSQL_EXITCODE -eq 0 ] && [ $ENTERPRISE_MSQL_EXITCODE -eq 0 ] && [ $COMMUNITY_NO_MSQL_EXITCODE -eq 0 ] && [ $COMMUNITY_MSQL_EXITCODE -eq 0 ] ; then OVERALL_EXITCODE=0 else OVERALL_EXITCODE=1 fi echo "Cluster test results:" - echo "Enterprise test exit code: $ENTERPRISE_EXITCODE" - echo "Community test exit code: $COMMUNITY_EXITCODE" + echo "Enterprise no mongosql test exit code: $ENTERPRISE_NO_MSQL_EXITCODE" + echo "Enterprise mongosql test exit code: $ENTERPRISE_MSQL_EXITCODE" + echo "Community no mongosql test exit code: $COMMUNITY_NO_MSQL_EXITCODE" + echo "Community mongosql test exit code: $COMMUNITY_MSQL_EXITCODE" echo "Overall exit code: $OVERALL_EXITCODE" set -e @@ -1657,7 +1642,7 @@ functions: export RUST_BACKTRACE=1 # Start a local ADF - $COMMON_TEST_INFRA_DIR/test-environment/run_adf.sh start && + $COMMON_TEST_INFRA_DIR/test-environment/run_adf.sh start && cargo run --bin data_loader && # Run integration tests with macos @@ -1806,7 +1791,7 @@ functions: cargo run --bin data_loader && cargo test --package integration_test --lib test_runner --features integration_test/result_set EXITCODE=$? - # The execution termimated with a segfault + # The execution terminated with a segfault if [ $EXITCODE -eq 139 ]; then # Compress the sources and pdbs so that we'll have everything for debugging available in Evergreen after a run SOURCES_FOLDERS=$(find $(pwd) -path '*/src' | tr '\n' ' ') @@ -2238,6 +2223,7 @@ tasks: depends_on: - name: trace-artifacts commands: + - func: "check and allow for non-eap build" - func: "update download center feed" - name: release @@ -2363,6 +2349,11 @@ buildvariants: - name: windows-test-integration-group - name: windows-test-result-set-group - name: sign + - name: compile-eap + - name: windows-windows-test-unit-group-eap + - name: windows-test-integration-group-eap + - name: windows-test-result-set-group-eap + - name: sign-eap run_on: ubuntu2204-large - name: ubuntu2204 @@ -2373,11 +2364,16 @@ buildvariants: - sql-engines-common-test-infra tasks: - name: compile + - name: compile-eap - name: unit-test + - name: unit-test-eap - name: integration-test + - name: integration-test-eap - name: result-set-test + - name: result-set-test-eap - name: asan-unit-tests - name: sign + - name: sign-eap - name: macos display_name: "macOS" @@ -2406,6 +2402,7 @@ buildvariants: - name: make-odbc-docs - name: release - name: snapshot + - name: snapshot-eap # - name: trace-artifacts # - name: download-center-update # - name: ssdlc-artifacts-release diff --git a/evergreen/create-expansions.sh b/evergreen/create-expansions.sh new file mode 100644 index 00000000..9c7d380a --- /dev/null +++ b/evergreen/create-expansions.sh @@ -0,0 +1,132 @@ +# common test infra begin +if [ "Windows_NT" == "$OS" ]; then + export PROJECT_DIRECTORY=$(cygpath -m "$(pwd)") +else + export PROJECT_DIRECTORY="$(pwd)" +fi +export COMMON_TEST_INFRA_DIR="$PROJECT_DIRECTORY/sql-engines-common-test-infra" +export DRIVERS_TOOLS="$PROJECT_DIRECTORY/evergreen/drivers-tools" +export MONGO_ORCHESTRATION_HOME="$DRIVERS_TOOLS/.evergreen/orchestration" +export MONGODB_BINARIES="$DRIVERS_TOOLS/mongodb/bin" +export CARGO_NET_GIT_FETCH_WITH_CLI=true +# common test infra end +export INSTALLED_ODBC_PATH="$PWD/installed_odbc/install" +export LD_LIBRARY_PATH="$INSTALLED_ODBC_PATH/lib" +if [ "Windows_NT" == "$OS" ]; then + export PATH="$HOME/.rustup/bin:$HOME/.cargo/bin:$LD_LIBRARY_PATH:$PATH" +else + export PATH="$HOME/.cargo/bin:$LD_LIBRARY_PATH:$PATH" +fi +export DUMP_FOLDER=dumps +export LOCAL_DUMP_ORIGINAL_REG_VAL=local_dump_original_value.reg +export MONGOODBC_DEBUGGING_INFO_ARCHIVE=crashDebuggingInfo +export SCRIPT_FOLDER=resources +export COMPLIANCE_REPORT_NAME="mongo-odbc-driver_compliance_report.md" +export STATIC_CODE_ANALYSIS_NAME="mongo-odbc-driver.sast.sarif" +export FEATURE_FLAGS="" +export PRODUCT_NAME="mongoodbc" +export PATH_PREFIX="" + +echo "snapshot-eap: ${snapshot-eap}" + +if [[ "${triggered_by_git_tag}" != "" ]]; then + export RELEASE_VERSION=$(echo ${triggered_by_git_tag} | sed s/v//) + + # Check if this is a beta tag or snapshot-eap is set to true + if [[ "${triggered_by_git_tag}" == *"beta"* || "${snapshot-eap}" == "true" ]]; then + export FEATURE_FLAGS="eap" + export PRODUCT_NAME="mongoodbc-eap" + export PATH_PREFIX="eap/" + fi +else + # If not a tag, we are in a snapshot build. We need to see if we're in beta mode or not + # and set the release version to either snapshot or snapshot-eap + if [[ "${snapshot-eap}" == "true" ]]; then + export RELEASE_VERSION="snapshot-eap" + export FEATURE_FLAGS="eap" + export PRODUCT_NAME="mongoodbc-eap" + echo "Building EAP version" + else + export RELEASE_VERSION="snapshot" + fi +fi + +export MSI_FILENAME="$PRODUCT_NAME-$RELEASE_VERSION.msi" +export UBUNTU_FILENAME="$PRODUCT_NAME-$RELEASE_VERSION.tar.gz" + +cat <expansions.yml +RELEASE_VERSION: "$RELEASE_VERSION" +FEATURE_FLAGS: "$FEATURE_FLAGS" +PATH_PREFIX: "$PATH_PREFIX" +PRODUCT_NAME: "$PRODUCT_NAME" +MSI_FILENAME: "$MSI_FILENAME" +UBUNTU_FILENAME: "$UBUNTU_FILENAME" +WINDOWS_INSTALLER_PATH: "mongosql-odbc-driver/windows/$RELEASE_VERSION/release/$MSI_FILENAME" +UBUNTU2204_INSTALLER_PATH: "mongosql-odbc-driver/ubuntu2204/$RELEASE_VERSION/release/$UBUNTU_FILENAME" +COMPLIANCE_REPORT_NAME: "$COMPLIANCE_REPORT_NAME" +STATIC_CODE_ANALYSIS_NAME: "$STATIC_CODE_ANALYSIS_NAME" +PROJECT_DIRECTORY: "$(pwd)" +DRIVERS_TOOLS: "$DRIVERS_TOOLS" +common_test_infra_dir: "$COMMON_TEST_INFRA_DIR" +script_dir: "$COMMON_TEST_INFRA_DIR/evergreen/scripts" +MONGO_ORCHESTRATION_HOME: "$DRIVERS_TOOLS/.evergreen/orchestration" +MONGODB_BINARIES: "$MONGODB_BINARIES" +prepare_shell: | + set -o errexit + export RELEASE_VERSION="$RELEASE_VERSION" + export FEATURE_FLAGS="$FEATURE_FLAGS" + export PATH_PREFIX="$PATH_PREFIX" + export PRODUCT_NAME="$PRODUCT_NAME" + export MSI_FILENAME="$MSI_FILENAME" + export UBUNTU_FILENAME="$UBUNTU_FILENAME" + export WINDOWS_INSTALLER_PATH="$WINDOWS_INSTALLER_PATH" + export UBUNTU2204_INSTALLER_PATH="$UBUNTU2204_INSTALLER_PATH" + export PATH="$PATH" + export CARGO_NET_GIT_FETCH_WITH_CLI="$CARGO_NET_GIT_FETCH_WITH_CLI" + export LOCAL_MDB_PORT_COM=${local_mdb_port_com} + export LOCAL_MDB_PORT_ENT=${local_mdb_port_ent} + export LOCAL_MDB_USER=${local_mdb_user} + export LOCAL_MDB_PWD=${local_mdb_pwd} + export ADF_TEST_LOCAL_USER="${adf_test_local_user}" + export ADF_TEST_LOCAL_PWD="${adf_test_local_pwd}" + export ADF_TEST_LOCAL_AUTH_DB="${adf_test_local_auth_db}" + export ADF_TEST_LOCAL_HOST="${adf_test_local_host}" + export MDB_TEST_LOCAL_PORT="${mdb_test_local_port}" + export ADF_TEST_LOCAL_DB="${adf_test_local_db}" + export ADF_TEST_URI="${adf_test_uri}" + export SRV_TEST_DB="${srv_test_db}" + export SRV_TEST_AUTH_DB="${srv_test_auth_db}" + export SRV_TEST_HOST="${srv_test_host}" + export SRV_TEST_USER="${srv_test_user}" + export SRV_TEST_PWD="${srv_test_pwd}" + export SCRIPT_FOLDER="$SCRIPT_FOLDER" + export SCRIPT_DIR="$(pwd)/$SCRIPT_FOLDER" + export SBOM_DIR="sbom_tools" + export SBOM_LICENSES="mongo-odbc-driver.licenses.cdx.json" + export SBOM_VULN="mongo-odbc-driver.merge.grype.cdx.json" + export SBOM_FINAL="mongo-odbc-driver.full.cdx.json" + export COMPLIANCE_REPORT_NAME="$COMPLIANCE_REPORT_NAME" + export STATIC_CODE_ANALYSIS_NAME="$STATIC_CODE_ANALYSIS_NAME" + export ALLOW_VULNS="${AllowVulns}" + + # Windows variables + export LOCAL_DUMP_ORIGINAL_REG_VAL="$LOCAL_DUMP_ORIGINAL_REG_VAL" + export DUMP_FOLDER="$DUMP_FOLDER" + export DUMP_PATH="$(pwd)/$DUMP_FOLDER" + export MONGOODBC_DEBUGGING_INFO_ARCHIVE=$MONGOODBC_DEBUGGING_INFO_ARCHIVE + + # Non-Windows variables + export INSTALLED_ODBC_PATH="$INSTALLED_ODBC_PATH" + export LD_LIBRARY_PATH="$LD_LIBRARY_PATH" + export LIBRARY_PATH="$LD_LIBRARY_PATH" + export ODBCSYSINI="$(pwd)"/setup + + # Common test infra variables + export PROJECT_DIRECTORY="$PROJECT_DIRECTORY" + export DRIVERS_TOOLS="$DRIVERS_TOOLS" + export MONGO_ORCHESTRATION_HOME="$MONGO_ORCHESTRATION_HOME" + export MONGODB_BINARIES="$MONGODB_BINARIES" + export COMMON_TEST_INFRA_DIR="$COMMON_TEST_INFRA_DIR" +EOT + +cat expansions.yml diff --git a/evergreen/eap.yml b/evergreen/eap.yml new file mode 100644 index 00000000..bf6dc69f --- /dev/null +++ b/evergreen/eap.yml @@ -0,0 +1,358 @@ +functions: + "upload eap release": + - command: s3.get + params: + aws_key: ${aws_key} + aws_secret: ${aws_secret} + remote_file: mongosql-odbc-driver/artifacts/docs/MongoDB_ODBC_Guide.pdf + local_file: mongosql-odbc-driver/release/docs/MongoDB_ODBC_Guide.pdf + bucket: mciuploads + - command: s3.put + params: + aws_key: ${release_aws_key} + aws_secret: ${release_aws_secret} + local_file: mongosql-odbc-driver/release/docs/MongoDB_ODBC_Guide.pdf + remote_file: ${PATH_PREFIX}mongosql-odbc-driver/docs/MongoDB_ODBC_Guide.pdf + bucket: translators-connectors-releases + permissions: public-read + skip_existing: false + content_type: application/pdf + - command: s3.get + params: + aws_key: ${aws_key} + aws_secret: ${aws_secret} + remote_file: mongosql-odbc-driver/artifacts/${version_id}/windows-64/release/mongoodbc-signed.msi + local_file: mongosql-odbc-driver/release/mongoodbc-signed.msi + bucket: mciuploads + - command: s3.put + params: + aws_key: ${release_aws_key} + aws_secret: ${release_aws_secret} + local_file: mongosql-odbc-driver/release/mongoodbc-signed.msi + remote_file: ${PATH_PREFIX}${WINDOWS_INSTALLER_PATH} + bucket: translators-connectors-releases + permissions: public-read + content_type: application/octet-stream + display_name: ${MSI_FILENAME} + - command: s3.get + params: + aws_key: ${aws_key} + aws_secret: ${aws_secret} + remote_file: mongosql-odbc-driver/artifacts/${version_id}/windows-64/release/mongoodbc-signed.msi.sha256 + local_file: mongosql-odbc-driver/release/mongoodbc-signed.msi.sha256 + bucket: mciuploads + - command: s3.put + params: + aws_key: ${release_aws_key} + aws_secret: ${release_aws_secret} + local_file: mongosql-odbc-driver/release/mongoodbc-signed.msi.sha256 + remote_file: ${PATH_PREFIX}${WINDOWS_INSTALLER_PATH}.sha256 + bucket: translators-connectors-releases + permissions: public-read + content_type: application/octet-stream + display_name: ${MSI_FILENAME}.sha256 + - command: s3.get + params: + aws_key: ${aws_key} + aws_secret: ${aws_secret} + remote_file: mongosql-odbc-driver/artifacts/${version_id}/windows-64/release/atsql.dll + local_file: mongosql-odbc-driver/release/atsql.dll + bucket: mciuploads + - command: s3.put + params: + aws_key: ${release_aws_key} + aws_secret: ${release_aws_secret} + local_file: mongosql-odbc-driver/release/atsql.dll + remote_file: ${PATH_PREFIX}mongosql-odbc-driver/windows/${RELEASE_VERSION}/release/atsql.dll + bucket: translators-connectors-releases + permissions: public-read + content_type: application/octet-stream + - command: s3.get + params: + aws_key: ${aws_key} + aws_secret: ${aws_secret} + remote_file: mongosql-odbc-driver/artifacts/${version_id}/windows-64/release/atsqls.dll + local_file: mongosql-odbc-driver/release/atsqls.dll + bucket: mciuploads + - command: s3.put + params: + aws_key: ${release_aws_key} + aws_secret: ${release_aws_secret} + local_file: mongosql-odbc-driver/release/atsqls.dll + remote_file: ${PATH_PREFIX}mongosql-odbc-driver/windows/${RELEASE_VERSION}/release/atsqls.dll + bucket: translators-connectors-releases + permissions: public-read + content_type: application/octet-stream + - command: s3.get + params: + aws_key: ${aws_key} + aws_secret: ${aws_secret} + remote_file: mongosql-odbc-driver/artifacts/${version_id}/windows-64/release/atsql.pdb + local_file: mongosql-odbc-driver/release/atsql.pdb + bucket: mciuploads + - command: s3.put + params: + aws_key: ${release_aws_key} + aws_secret: ${release_aws_secret} + local_file: mongosql-odbc-driver/release/atsql.pdb + remote_file: ${PATH_PREFIX}mongosql-odbc-driver/windows/${RELEASE_VERSION}/release/atsql.pdb + bucket: translators-connectors-releases + permissions: public-read + content_type: application/octet-stream + - command: s3.get + params: + aws_key: ${aws_key} + aws_secret: ${aws_secret} + remote_file: mongosql-odbc-driver/artifacts/${version_id}/ubuntu2204/release/${UBUNTU_FILENAME} + local_file: mongosql-odbc-driver/target/release/${UBUNTU_FILENAME} + bucket: mciuploads + permissions: public-read + content_type: application/octet-stream + - command: s3.put + params: + aws_key: ${release_aws_key} + aws_secret: ${release_aws_secret} + local_file: mongosql-odbc-driver/target/release/${UBUNTU_FILENAME} + remote_file: ${PATH_PREFIX}${UBUNTU2204_INSTALLER_PATH} + bucket: translators-connectors-releases + permissions: public-read + content_type: application/octet-stream + - command: s3.get + params: + aws_key: ${aws_key} + aws_secret: ${aws_secret} + remote_file: mongosql-odbc-driver/artifacts/${version_id}/ubuntu2204/release/${UBUNTU_FILENAME}.sig + local_file: mongosql-odbc-driver/target/release/${UBUNTU_FILENAME}.sig + bucket: mciuploads + permissions: public-read + content_type: application/octet-stream + - command: s3.put + params: + aws_key: ${release_aws_key} + aws_secret: ${release_aws_secret} + local_file: mongosql-odbc-driver/target/release/${UBUNTU_FILENAME}.sig + remote_file: ${PATH_PREFIX}mongosql-odbc-driver/ubuntu2204/${RELEASE_VERSION}/release/${UBUNTU_FILENAME}.sig + bucket: translators-connectors-releases + permissions: public-read + content_type: application/octet-stream + - command: s3.get + params: + aws_key: ${aws_key} + aws_secret: ${aws_secret} + remote_file: mongosql-odbc-driver/artifacts/${version_id}/ubuntu2204/release/libatsql.so + local_file: mongosql-odbc-driver/target/release/libatsql.so + bucket: mciuploads + permissions: public-read + content_type: application/octet-stream + - command: s3.put + params: + aws_key: ${release_aws_key} + aws_secret: ${release_aws_secret} + local_file: mongosql-odbc-driver/target/release/libatsql.so + remote_file: ${PATH_PREFIX}mongosql-odbc-driver/ubuntu2204/${RELEASE_VERSION}/release/libatsql.so + bucket: translators-connectors-releases + permissions: public-read + content_type: application/octet-stream + +tasks: + - name: snapshot-eap + depends_on: + - name: compile-eap + variant: "*" + - name: clippy + variant: "*" + - name: rustfmt + variant: "*" + - name: unit-test-eap + variant: ".release-variant" + - name: integration-test-eap + variant: ".release-variant" + - name: result-set-test-eap + variant: ".release-variant" + - name: sign-eap + variant: ".release-variant" + commands: + - func: "upload eap release" + + - name: compile-eap + commands: + - func: "generate expansions" + vars: + snapshot-eap: "true" + - func: "install iODBC" + variants: [macos, macos-arm] + - func: "install rust toolchain" + variants: [ubuntu2204, windows-64, macos, macos-arm] + - func: "install unix odbc" + variants: [ubuntu2204] + - func: "set and check packages version" + - func: "generate third party licenses" + variants: [ubuntu2204, windows-64, macos, macos-arm] + - func: "compile ubuntu and win release" + variants: [ubuntu2204, windows-64] + - func: "build msi" + variants: [windows-64] + - func: "tar linux artifacts" + variants: [ubuntu2204] + - func: "mciuploads release artifacts" + + - name: unit-test-eap + depends_on: + - compile-eap + commands: + - func: "install rust toolchain" + variants: [ubuntu2204, windows-64, macos, macos-arm] + - func: "install iODBC" + variants: [macos, macos-arm] + - func: "install unix odbc" + variants: [ubuntu2204] + - func: "run windows unit tests" + variants: [windows-64] + - func: "run ubuntu unit tests" + variants: [ubuntu2204] + - func: "run ubuntu rfc8252_http_server tests" + variants: [ubuntu2204] + - func: "run macos unit tests" + variants: [macos, macos-arm] + + - name: integration-test-eap + depends_on: + - name: compile-eap + commands: + - func: "install rust toolchain" + variants: [ubuntu2204, windows-64, macos, macos-arm] + - func: "install iODBC" + variants: [macos, macos-arm] + - func: "install unix odbc" + variants: [ubuntu2204] + - func: "compile release with debug info" + variants: [ubuntu2204] + - func: "compile macos release with debug info" + variants: [macos, macos-arm] + - func: "setup driver with UnixODBC" + variants: [ubuntu2204] + - func: "setup driver with iODBC" + variants: [macos, macos-arm] + - func: "prepare resources" + variants: [windows-64, ubuntu2204] + - func: "update orchestrator mongod port" + variants: [windows-64, ubuntu2204] + - func: "bootstrap mongo-orchestration" + variants: [windows-64, ubuntu2204] + - func: "generate sql-engines github token" + variants: [windows-64, ubuntu2204] + - func: "run ubuntu integration tests" + variants: [ubuntu2204] + - func: "run ubuntu cluster type integration tests" + variants: [ubuntu2204] + - func: "run ubuntu mongosqltranslate integration tests" + variants: [ubuntu2204] + # Commenting out because the following task only detects + # memory leaks in the tests + # - func: "run asan integration tests" + # variants: [ ubuntu2204 ] + - func: "run windows integration tests" + variants: [windows-64] + - func: "run macos integration tests" + variants: [macos, macos-arm] + + # disabled macos result-set-tests as part of SQL-1688 + - name: result-set-test-eap + depends_on: + - name: compile-eap + commands: + - func: "install rust toolchain" + variants: [ubuntu2204, windows-64, macos, macos-arm] + # - func: "install iODBC" + # variants: [macos, macos-arm] + - func: "install unix odbc" + variants: [ubuntu2204] + - func: "compile release with debug info" + variants: [ubuntu2204] + # - func: "compile macos release with debug info" + # variants: [macos, macos-arm] + - func: "setup driver with UnixODBC" + variants: [ubuntu2204] + # - func: "setup driver with iODBC" + # variants: [macos, macos-arm] + - func: "prepare resources" + variants: [windows-64, ubuntu2204] + - func: "update orchestrator mongod port" + variants: [windows-64, ubuntu2204] + - func: "bootstrap mongo-orchestration" + variants: [windows-64, ubuntu2204] + - func: "generate sql-engines github token" + variants: [windows-64, ubuntu2204] + - func: "run windows result set test" + variants: [windows-64] + - func: "run ubuntu result-set tests" + variants: [ubuntu2204] + # - func: "run macos result-set tests" + # variants: [macos, macos-arm] + # Commenting out because the following task only detects + # memory leaks in the tests + # - func: "run asan result-set tests" + # variants: [ ubuntu2204 ] + + - name: sign-eap + allowed_requesters: ["ad_hoc", "github_tag"] + depends_on: + - name: compile-eap + commands: + - func: "fetch for windows sign" + variants: [windows-64] + - func: "fetch for ubuntu sign" + variants: [ubuntu2204] + - func: "sign windows" + variants: [windows-64] + - func: "sign ubuntu and verify signature" + variants: [ubuntu2204] + - func: "upload signed windows artifacts" + variants: [windows-64] + - func: "upload ubuntu sig file" + variants: [ubuntu2204] + +task_groups: + - name: windows-windows-test-unit-group-eap + setup_group_can_fail_task: false + setup_group: + - func: "fetch source" + - func: "generate expansions" + vars: + snapshot-eap: "true" + tasks: + - unit-test-eap + + - name: windows-test-integration-group-eap + setup_group_can_fail_task: false + setup_group: + - func: "fetch source" + - func: "generate expansions" + vars: + snapshot-eap: "true" + - func: "download artifact" + - func: "setup driver on Windows" + - func: "setup crash dump collection" + teardown_group: + - func: "upload crash debugging info" + - func: "clean-up driver on Windows" + - func: "clean-up crash dump collection" + tasks: + - integration-test-eap + + - name: windows-test-result-set-group-eap + setup_group_can_fail_task: false + setup_group: + - func: "fetch source" + - func: "generate expansions" + vars: + snapshot-eap: "true" + - func: "download artifact" + - func: "setup driver on Windows" + - func: "setup crash dump collection" + teardown_group: + - func: "upload crash debugging info" + - func: "clean-up driver on Windows" + - func: "clean-up crash dump collection" + tasks: + - result-set-test-eap diff --git a/integration_test/Cargo.toml b/integration_test/Cargo.toml index a3c29c99..3fdcbef6 100644 --- a/integration_test/Cargo.toml +++ b/integration_test/Cargo.toml @@ -23,10 +23,17 @@ tailcall = "1.0" # Do NOT change these features without consulting with other team members. # The features are used to control the behavior of tokio. Tokio is unsafe to use # across ABI boundaries in any other runtime but current_thread -tokio = { workspace = true, features = ["rt", "sync", "io-util", "macros", "net"] } +tokio = { workspace = true, features = [ + "rt", + "sync", + "io-util", + "macros", + "net", +] } [features] cluster_type_tests = [] result_set = [] evergreen_tests = [] +eap = [] diff --git a/integration_test/src/bin/data_loader.rs b/integration_test/src/bin/data_loader.rs index 73953ef1..31d4de7e 100644 --- a/integration_test/src/bin/data_loader.rs +++ b/integration_test/src/bin/data_loader.rs @@ -88,11 +88,23 @@ async fn main() -> Result<()> { "mongodb://localhost:{}", env::var("MDB_TEST_LOCAL_PORT").expect("MDB_TEST_LOCAL_PORT is not set") ); + println!( + "mdb_test_local_port: {}", + env::var("MDB_TEST_LOCAL_PORT").unwrap() + ); let adf_url = format!( "mongodb://{}:{}@localhost", env::var("ADF_TEST_LOCAL_USER").expect("ADF_TEST_LOCAL_USER is not set"), env::var("ADF_TEST_LOCAL_PWD").expect("ADF_TEST_LOCAL_PWD is not set") ); + println!( + "adf_test_local_user: {}", + env::var("ADF_TEST_LOCAL_USER").unwrap() + ); + println!( + "adf_test_local_pwd: {}", + env::var("ADF_TEST_LOCAL_PWD").unwrap() + ); // Step 1: Read data files let test_data = read_data_files(TEST_DATA_DIRECTORY)?; diff --git a/integration_test/tests/cluster_type_test.rs b/integration_test/tests/cluster_type_test.rs index 9a0c0041..ef6b150e 100644 --- a/integration_test/tests/cluster_type_test.rs +++ b/integration_test/tests/cluster_type_test.rs @@ -74,8 +74,15 @@ mod cluster_type { "Expected an error for community edition, but got success" ); if let Err(e) = result { + assert!(e.contains("Unsupported cluster configuration")); + #[cfg(not(feature = "eap"))] + assert!( + e.contains("The driver is intended for use with MongoDB Atlas Data Federation"), + "Unexpected error message for community edition: {}", + e + ); + #[cfg(feature = "eap")] assert!( - e.contains("Unsupported cluster configuration: Community edition detected") && e.contains("The driver is intended for use with MongoDB Enterprise edition or Atlas Data Federation"), "Unexpected error message for community edition: {}", e @@ -86,6 +93,12 @@ mod cluster_type { #[tokio::test] async fn test_determine_cluster_type_enterprise_succeeds() { let result = run_cluster_type_test(PortType::Enterprise).await; + #[cfg(not(feature = "eap"))] + assert!( + result.is_err(), + "Expected an error for enterprise edition, but got success" + ); + #[cfg(feature = "eap")] assert!( result.is_ok(), "Expected success with enterprise edition, but got an error: {result:?}"