diff --git a/.evergreen/config_generator/components/mongohouse.py b/.evergreen/config_generator/components/mongohouse.py deleted file mode 100644 index 8a5e7cfad8..0000000000 --- a/.evergreen/config_generator/components/mongohouse.py +++ /dev/null @@ -1,90 +0,0 @@ -from shrub.v3.evg_build_variant import BuildVariant -from shrub.v3.evg_command import EvgCommandType, ec2_assume_role -from shrub.v3.evg_task import EvgTask, EvgTaskRef - -from config_generator.components.funcs.compile import Compile -from config_generator.components.funcs.fetch_c_driver_source import FetchCDriverSource -from config_generator.components.funcs.setup import Setup -from config_generator.etc.distros import find_large_distro -from config_generator.etc.function import Function, merge_defns -from config_generator.etc.utils import bash_exec - -TAG = 'mongohouse' - - -class BuildMongohouse(Function): - name = 'build_mongohouse' - commands = [ - ec2_assume_role(role_arn='${aws_test_secrets_role}'), - bash_exec( - include_expansions_in_env=['AWS_ACCESS_KEY_ID', 'AWS_SECRET_ACCESS_KEY', 'AWS_SESSION_TOKEN'], - command_type=EvgCommandType.SETUP, - script="""\ - if [ ! -d "drivers-evergreen-tools" ]; then - git clone https://github.com/mongodb-labs/drivers-evergreen-tools.git - fi - cd drivers-evergreen-tools - export DRIVERS_TOOLS=$(pwd) - - .evergreen/atlas_data_lake/pull-mongohouse-image.sh - """, - ), - ] - - -class RunMongohouse(Function): - name = 'run_mongohouse' - commands = bash_exec( - command_type=EvgCommandType.SETUP, - script="""\ - cd drivers-evergreen-tools - export DRIVERS_TOOLS=$(pwd) - - .evergreen/atlas_data_lake/run-mongohouse-image.sh - """, - ) - - -class TestMongohouse(Function): - name = 'test_mongohouse' - commands = bash_exec( - command_type=EvgCommandType.TEST, - working_dir='mongo-cxx-driver', - include_expansions_in_env=['distro_id'], - script='.evergreen/scripts/test-mongohouse.sh', - ) - - -def functions(): - return merge_defns( - BuildMongohouse.defn(), - RunMongohouse.defn(), - TestMongohouse.defn(), - ) - - -def tasks(): - distro_name = 'ubuntu2204' # `docker` is not available on RHEL distros by default. - distro = find_large_distro(distro_name) - - return [ - EvgTask( - name='test_mongohouse', - tags=[TAG, distro_name], - run_on=distro.name, - commands=[ - Setup.call(), - FetchCDriverSource.call(), - Compile.call(build_type='Release', vars={'ENABLE_TESTS': 'ON'}), - BuildMongohouse.call(), - RunMongohouse.call(), - TestMongohouse.call(), - ], - ), - ] - - -def variants(): - return [ - BuildVariant(name='mongohouse', display_name='Mongohouse', tasks=[EvgTaskRef(name=f'.{TAG}')]), - ] diff --git a/.evergreen/generated_configs/functions.yml b/.evergreen/generated_configs/functions.yml index f3f45a068e..5687a34e55 100644 --- a/.evergreen/generated_configs/functions.yml +++ b/.evergreen/generated_configs/functions.yml @@ -200,28 +200,6 @@ functions: local_file: rpm.tar.gz permissions: public-read remote_file: mongo-cxx-driver/${branch_name}/${revision}/${version_id}/${build_id}/${execution}/rpm-packages.tar.gz - build_mongohouse: - - command: ec2.assume_role - params: - role_arn: ${aws_test_secrets_role} - - command: subprocess.exec - type: setup - params: - binary: bash - include_expansions_in_env: - - AWS_ACCESS_KEY_ID - - AWS_SECRET_ACCESS_KEY - - AWS_SESSION_TOKEN - args: - - -c - - | - if [ ! -d "drivers-evergreen-tools" ]; then - git clone https://github.com/mongodb-labs/drivers-evergreen-tools.git - fi - cd drivers-evergreen-tools - export DRIVERS_TOOLS=$(pwd) - - .evergreen/atlas_data_lake/pull-mongohouse-image.sh check augmented sbom: - command: ec2.assume_role type: setup @@ -482,18 +460,6 @@ functions: python -u kms_http_server.py --ca_file ../x509gen/ca.pem --cert_file ../x509gen/server.pem --port 9002 --require_client_cert & python -u kms_kmip_server.py & echo "Starting mock KMS servers... done." - run_mongohouse: - command: subprocess.exec - type: setup - params: - binary: bash - args: - - -c - - | - cd drivers-evergreen-tools - export DRIVERS_TOOLS=$(pwd) - - .evergreen/atlas_data_lake/run-mongohouse-image.sh set-cache-dir: - command: subprocess.exec type: setup @@ -619,17 +585,6 @@ functions: export LD_LIBRARY_PATH=$(pwd)/../mongoc/lib ./build/src/mongocxx/test/test_driver "atlas search indexes prose tests" - test_mongohouse: - command: subprocess.exec - type: test - params: - binary: bash - working_dir: mongo-cxx-driver - include_expansions_in_env: - - distro_id - args: - - -c - - .evergreen/scripts/test-mongohouse.sh uninstall-check: command: subprocess.exec type: test diff --git a/.evergreen/generated_configs/tasks.yml b/.evergreen/generated_configs/tasks.yml index fa7dce5a1c..26e5237825 100644 --- a/.evergreen/generated_configs/tasks.yml +++ b/.evergreen/generated_configs/tasks.yml @@ -13877,19 +13877,6 @@ tasks: BSONCXX_POLYFILL: impls CXX_STANDARD: 17 - func: upload scan artifacts - - name: test_mongohouse - run_on: ubuntu2204-large - tags: [mongohouse, ubuntu2204] - commands: - - func: setup - - func: fetch_c_driver_source - - func: compile - vars: - ENABLE_TESTS: "ON" - build_type: Release - - func: build_mongohouse - - func: run_mongohouse - - func: test_mongohouse - name: uninstall-check-macos-14-arm64-clang-debug-shared run_on: macos-14-arm64 tags: [uninstall-check, macos-14-arm64, clang, debug, shared] diff --git a/.evergreen/generated_configs/variants.yml b/.evergreen/generated_configs/variants.yml index 2a89a295a4..9875ceb0fc 100644 --- a/.evergreen/generated_configs/variants.yml +++ b/.evergreen/generated_configs/variants.yml @@ -68,10 +68,6 @@ buildvariants: display_name: macro-guards-matrix tasks: - name: .macro-guards - - name: mongohouse - display_name: Mongohouse - tasks: - - name: .mongohouse - name: packaging display_name: Linux Distro Packaging tasks: diff --git a/.evergreen/scripts/test-mongohouse.sh b/.evergreen/scripts/test-mongohouse.sh deleted file mode 100755 index a9e8bae047..0000000000 --- a/.evergreen/scripts/test-mongohouse.sh +++ /dev/null @@ -1,45 +0,0 @@ -#!/usr/bin/env bash - -set -o errexit -set -o pipefail - -echo "Waiting for mongohouse to start..." -wait_for_mongohouse() { - for _ in $(seq 300); do - # Exit code 7: "Failed to connect to host". - if - curl -s -m 1 "localhost:${1:?}" - (("$?" != 7)) - then - return 0 - else - sleep 1 - fi - done - echo "Could not detect mongohouse on port ${1:?}" 1>&2 - return 1 -} -wait_for_mongohouse 27017 || exit -echo "Waiting for mongohouse to start... done." -pgrep mongohouse - -cd build -export PREFIX -PREFIX="$(pwd)/../../mongoc" - -# Use LD_LIBRARY_PATH to inform the tests where to find dependencies on Linux. -# This task only runs on Linux. -if [[ "${distro_id:?}" == rhel* ]]; then - export LD_LIBRARY_PATH=".:${PREFIX:?}/lib64" -else - export LD_LIBRARY_PATH=".:${PREFIX:?}/lib" -fi - -export MONGOHOUSE_TESTS_PATH -MONGOHOUSE_TESTS_PATH="$(pwd)/../data/mongohouse" - -export RUN_MONGOHOUSE_TESTS=ON - -ulimit -c unlimited || true - -./src/mongocxx/test/test_mongohouse_specs diff --git a/src/mongocxx/test/CMakeLists.txt b/src/mongocxx/test/CMakeLists.txt index daf41f5ebf..627de5cb43 100644 --- a/src/mongocxx/test/CMakeLists.txt +++ b/src/mongocxx/test/CMakeLists.txt @@ -108,7 +108,6 @@ set(mongocxx_test_sources_extra spec/command_monitoring.cpp spec/crud.cpp spec/gridfs.cpp - spec/mongohouse.cpp spec/read_write_concern.cpp spec/retryable-reads.cpp spec/transactions.cpp @@ -164,9 +163,6 @@ target_link_libraries(test_retryable_reads_specs PRIVATE spec_test_common client add_executable(test_read_write_concern_specs spec/read_write_concern.cpp) target_link_libraries(test_read_write_concern_specs PRIVATE spec_test_common client_helpers) -add_executable(test_mongohouse_specs spec/mongohouse.cpp) -target_link_libraries(test_mongohouse_specs PRIVATE spec_test_common client_helpers) - add_executable(test_unified_format_specs spec/unified_tests/operations.cpp spec/unified_tests/runner.cpp) target_link_libraries(test_unified_format_specs PRIVATE spec_test_common client_helpers) @@ -207,7 +203,6 @@ set_property( test_gridfs_specs test_instance test_logging - test_mongohouse_specs test_read_write_concern_specs test_retryable_reads_specs test_transactions_specs @@ -245,12 +240,6 @@ foreach(test_name add_test(NAME ${test_name} COMMAND test_${test_name} --reporter compact --allow-running-no-tests) endforeach() -# Adding this as a test will run it as part of the RUN_TESTS command in MSVC. -# Do not add, since we only test mongohouse on Linux. -if(0) - add_test(NAME mongohouse_specs COMMAND test_mongohouse_specs ${test_args}) -endif() - set_property(TEST crud_specs APPEND PROPERTY ENVIRONMENT "CRUD_LEGACY_TESTS_PATH=${DATA_SOURCE_DIR}/crud/legacy" ) diff --git a/src/mongocxx/test/spec/mongohouse.cpp b/src/mongocxx/test/spec/mongohouse.cpp deleted file mode 100644 index 93de4d171f..0000000000 --- a/src/mongocxx/test/spec/mongohouse.cpp +++ /dev/null @@ -1,184 +0,0 @@ -// Copyright 2009-present MongoDB, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include -#include -#include -#include -#include - -#include -#include - -#include - -#include -#include -#include - -namespace { - -using namespace bsoncxx::stdx; -using namespace bsoncxx::string; -using namespace mongocxx::spec; - -using bsoncxx::builder::basic::kvp; -using bsoncxx::builder::basic::make_document; - -// Set serverSelectionTryOnce to false; ADL starts up in the background, and may not be -// ready to receive connections yet when the test begins running. -std::string const kMongohouseURI = "mongodb://mhuser:pencil@localhost/?serverSelectionTryOnce=false"; - -void run_mongohouse_tests_in_file(std::string test_path) { - return run_crud_tests_in_file(test_path, uri{kMongohouseURI}); -} - -// Test that the driver properly constructs and issues a killCursors command to Atlas Data Lake. -void test_kill_cursors() { - options::client client_opts; - apm_checker apm_checker; - client_opts.apm_opts(apm_checker.get_apm_opts(false)); - client client{uri{kMongohouseURI}, client_opts}; - - // Issue a query that will leave a cursor open on the server. - options::find find_opts; - find_opts.batch_size(2); - find_opts.limit(3); - - bsoncxx::types::bson_value::value cursor_id_val{bsoncxx::types::bson_value::view{}}; - std::string cursor_ns; - bool find_command_found = false; - - { - auto cursor = client["test"]["driverdata"].find({}, find_opts); - - // Call begin() to run the find on the server. - cursor.begin(); - - // Observe the CommandSucceededEvent event for the find command. - for (auto&& doc : apm_checker) { - auto event = doc.view(); - if (event.find("command_succeeded_event") == event.end()) { - continue; - } - - if (event["command_succeeded_event"]["command_name"].get_string().value != - bsoncxx::stdx::string_view{"find"}) { - continue; - } - - // Grab cursor information. - auto reply = event["command_succeeded_event"]["reply"].get_document(); - auto cursor_doc = reply.view()["cursor"].get_document(); - cursor_id_val = cursor_doc.view()["id"].get_owning_value(); - cursor_ns = std::string(cursor_doc.view()["ns"].get_string().value); - - find_command_found = true; - - break; - } - - REQUIRE(find_command_found); - - apm_checker.clear(); - - // Destroy the cursor with scope end. - } - - bool cmd_started_validated = false; - bool cmd_succeeded_validated = false; - - // Observe events for the killCursors command. - for (auto&& doc : apm_checker) { - auto event = doc.view(); - - // Use the command started event for killCursors to validate cursor info. - if (event.find("command_started_event") != event.end()) { - if (event["command_started_event"]["command_name"].get_string().value != - bsoncxx::stdx::string_view{"killCursors"}) { - continue; - } - - // Validate namespace - auto db = event["command_started_event"]["database_name"].get_string().value; - auto coll = event["command_started_event"]["command"]["killCursors"].get_string().value; - std::string cmd_ns(db); - cmd_ns += "."; - cmd_ns += std::string(coll); - - if (cmd_ns != cursor_ns) { - continue; - } - - auto cursors_killed = event["command_started_event"]["command"]["cursors"].get_array().value; - - if (std::find(cursors_killed.cbegin(), cursors_killed.cend(), cursor_id_val.view()) != - cursors_killed.cend()) { - cmd_started_validated = true; - } - } - - // Use the command succeeded event to confirm that the cursor was killed. - if (event.find("command_succeeded_event") != event.end()) { - if (event["command_succeeded_event"]["command_name"].get_string().value != - bsoncxx::stdx::string_view{"killCursors"}) { - continue; - } - - auto cursors_killed_elem = event["command_succeeded_event"]["reply"]["cursorsKilled"]; - auto cursors_killed_val = cursors_killed_elem.get_value(); - auto cursors_killed_arr = cursors_killed_val.get_array(); - auto cursors_killed = cursors_killed_arr.value; - - if (std::find(cursors_killed.cbegin(), cursors_killed.cend(), cursor_id_val.view()) != - cursors_killed.cend()) { - cmd_succeeded_validated = true; - } - } - } - - REQUIRE(cmd_started_validated); - REQUIRE(cmd_succeeded_validated); -} - -// Test that the driver can establish a connection with Atlas Data Lake without authentication. -// For these tests, create a MongoClient using a valid connection string without auth -// credentials and execute a ping command. -void test_connection_without_auth() { - client client{uri{}, test_util::add_test_server_api()}; - client["admin"].run_command(make_document(kvp("ping", 1))); -} - -// Test that the driver can establish a connection with Atlas Data Lake with authentication. -// For these tests, create a MongoClient using a valid connection string with SCRAM-SHA-1 -// and credentials from the drivers-evergreen-tools ADL configuration and execute a ping -// command. Repeat this test using SCRAM-SHA-256. -void test_auth_with_scram_sha() { - client client1{uri{"mongodb://mhuser:pencil@localhost/?authMechanism=SCRAM-SHA-1"}}; - client1["admin"].run_command(make_document(kvp("ping", 1))); - - client client256{uri{"mongodb://mhuser:pencil@localhost/?authMechanism=SCRAM-SHA-256"}}; - client256["admin"].run_command(make_document(kvp("ping", 1))); -} - -TEST_CASE("Test mongohouse", "[mongohouse]") { - run_tests_in_suite("MONGOHOUSE_TESTS_PATH", &run_mongohouse_tests_in_file); - - // Run prose tests - test_kill_cursors(); - test_connection_without_auth(); - test_auth_with_scram_sha(); -} - -} // namespace diff --git a/src/mongocxx/test/spec/unified_tests/runner.cpp b/src/mongocxx/test/spec/unified_tests/runner.cpp index fc255edd31..3997576554 100644 --- a/src/mongocxx/test/spec/unified_tests/runner.cpp +++ b/src/mongocxx/test/spec/unified_tests/runner.cpp @@ -271,19 +271,7 @@ bool compatible_with_server(bsoncxx::array::element const& requirement) { return equals_server_topology(topologies); if (auto const server_params = requirement["serverParameters"]) { - document::value actual = make_document(); - try { - actual = test_util::get_server_params(); - } catch (operation_exception const& e) { - // Mongohouse does not support getParameter, so if we get an error from - // getParameter, exit this logic early and skip the test. - std::string const message = e.what(); - if (message.find("command getParameter is unsupported") != std::string::npos) { - return false; - } - - throw e; - } + document::value const actual = test_util::get_server_params(); for (auto const& kvp : server_params.get_document().view()) { auto const param = kvp.key(); diff --git a/src/mongocxx/test/spec/util.cpp b/src/mongocxx/test/spec/util.cpp index 3887d10402..9f834fb68c 100644 --- a/src/mongocxx/test/spec/util.cpp +++ b/src/mongocxx/test/spec/util.cpp @@ -126,16 +126,6 @@ bool check_if_skip_spec_test_impl(document::view test, std::string& reason) { return true; } - { - auto const run_mongohouse_tests = std::getenv("RUN_MONGOHOUSE_TESTS"); - - if (run_mongohouse_tests && std::string(run_mongohouse_tests) == "ON") { - // mongohoused does not return `version` field in response to serverStatus. - // Exit early to run the test. - return false; - } - } - auto const server_version = test_util::get_server_version(); auto const topology = test_util::get_topology();