From 020f0f64473ed8985610445470df758b28656f88 Mon Sep 17 00:00:00 2001 From: vector-of-bool Date: Wed, 8 Sep 2021 22:45:04 -0600 Subject: [PATCH 01/52] warn-as-error implicit functions --- CMakeLists.txt | 2 ++ build/cmake/MongoC-Warnings.cmake | 32 +++++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+) create mode 100644 build/cmake/MongoC-Warnings.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 2ca69adc995..9ced8734439 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -79,6 +79,8 @@ set (CMAKE_MODULE_PATH include (InstallRequiredSystemLibraries) include (GNUInstallDirs) +include(MongoC-Warnings) + # Enable CCache, if possible include (CCache) # Link with LLD, if possible diff --git a/build/cmake/MongoC-Warnings.cmake b/build/cmake/MongoC-Warnings.cmake new file mode 100644 index 00000000000..9e4d1cdb3a4 --- /dev/null +++ b/build/cmake/MongoC-Warnings.cmake @@ -0,0 +1,32 @@ +#[[ + Define additional compile options, conditional on the compiler being used. + Each option should be prefixed by `gnu-like:` or `msvc:`. Those options will be + enabled for GCC/Clang or MSVC respectively. + + These options are attached to the source directory and its children. +]] +function (mongoc_add_platform_compile_options) + foreach (opt IN LISTS ARGV) + if (NOT opt MATCHES "^(gnu-like|msvc):(.*)") + message (SEND_ERROR "Invalid option '${opt}' (Should be prefixed by 'msvc:' or 'gnu-like:'") + continue () + endif () + set (is_gnu_like "$") + set (is_msvc "$") + if (CMAKE_MATCH_1 STREQUAL "gnu") + add_compile_options ("$<${is_gnu_like}:${CMAKE_MATCH_2}>") + else () + add_compile_options ("$<${is_msvc}:${CMAKE_MATCH_2}>") + endif () + endforeach () +endfunction () + +# Warnings that should always be unconditional hard errors, as the code is +# inherently broken +mongoc_add_platform_compile_options ( + # Implicit function or variable declarations + gnu-like:-Werror=implicit msvc:/we4013 msvc:/we4431 + # Missing return types/statements + gnu-like:-Werror=return-type msvc:/we4716 + ) + From 106a3d81d0fde7e4ac84a18afc34ca0c56172f3b Mon Sep 17 00:00:00 2001 From: vector-of-bool Date: Wed, 8 Sep 2021 22:51:29 -0600 Subject: [PATCH 02/52] Some implicit fn decls --- build/cmake/MongoC-Warnings.cmake | 2 +- src/common/common-thread-private.h | 2 +- src/kms-message/src/kms_port.c | 7 ++++++- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/build/cmake/MongoC-Warnings.cmake b/build/cmake/MongoC-Warnings.cmake index 9e4d1cdb3a4..b360569a976 100644 --- a/build/cmake/MongoC-Warnings.cmake +++ b/build/cmake/MongoC-Warnings.cmake @@ -13,7 +13,7 @@ function (mongoc_add_platform_compile_options) endif () set (is_gnu_like "$") set (is_msvc "$") - if (CMAKE_MATCH_1 STREQUAL "gnu") + if (CMAKE_MATCH_1 STREQUAL "gnu-like") add_compile_options ("$<${is_gnu_like}:${CMAKE_MATCH_2}>") else () add_compile_options ("$<${is_msvc}:${CMAKE_MATCH_2}>") diff --git a/src/common/common-thread-private.h b/src/common/common-thread-private.h index 7e3e81c0083..6794fc502c0 100644 --- a/src/common/common-thread-private.h +++ b/src/common/common-thread-private.h @@ -108,7 +108,7 @@ typedef struct { unsigned(__stdcall _function_name) (void *(_arg_name)) #define BSON_THREAD_FUN_TYPE(_function_name) \ unsigned(__stdcall * _function_name) (void *) -#define BSON_THREAD_RETURN return +#define BSON_THREAD_RETURN return 0 #endif /* Functions that require definitions get the common prefix (_mongoc for diff --git a/src/kms-message/src/kms_port.c b/src/kms-message/src/kms_port.c index 58f7e39ed45..af9ea822a3f 100644 --- a/src/kms-message/src/kms_port.c +++ b/src/kms-message/src/kms_port.c @@ -15,8 +15,13 @@ */ #include "kms_port.h" + +#include +#include + #if defined(_WIN32) -char * kms_strndup (const char *src, size_t len) +char * +kms_strndup (const char *src, size_t len) { char *dst = (char *) malloc (len + 1); if (!dst) { From c2f5eadec7319900f1693ce318581032bf245c6d Mon Sep 17 00:00:00 2001 From: vector-of-bool Date: Thu, 9 Sep 2021 13:32:12 -0600 Subject: [PATCH 03/52] More warnings-as-errors --- build/cmake/MongoC-Warnings.cmake | 14 ++++++++++++-- src/libbson/CMakeLists.txt | 7 ++----- src/libmongoc/tests/TestSuite.c | 3 ++- src/libmongoc/tests/mock_server/request.c | 6 +++--- src/libmongoc/tests/test-conveniences.c | 2 +- src/libmongoc/tests/test-conveniences.h | 2 +- src/libmongoc/tests/test-mongoc-async.c | 2 +- src/libmongoc/tests/test-mongoc-bulk.c | 3 ++- .../tests/test-mongoc-client-side-encryption.c | 2 +- src/libmongoc/tests/test-mongoc-cluster.c | 4 ++-- src/libmongoc/tests/test-mongoc-collection.c | 4 ++-- src/libmongoc/tests/test-mongoc-handshake.c | 2 +- src/libmongoc/tests/test-mongoc-mongohouse.c | 9 ++++----- src/libmongoc/tests/test-mongoc-read-prefs.c | 4 ++-- src/libmongoc/tests/test-mongoc-topology.c | 12 ++++++------ src/libmongoc/tests/test-mongoc-uri.c | 8 ++++---- src/libmongoc/tests/test-mongoc-write-commands.c | 2 +- src/libmongoc/tests/test-mongoc-write-concern.c | 2 +- src/libmongoc/tests/unified/util.c | 4 ++-- 19 files changed, 50 insertions(+), 42 deletions(-) diff --git a/build/cmake/MongoC-Warnings.cmake b/build/cmake/MongoC-Warnings.cmake index b360569a976..07bf10dfb26 100644 --- a/build/cmake/MongoC-Warnings.cmake +++ b/build/cmake/MongoC-Warnings.cmake @@ -22,11 +22,21 @@ function (mongoc_add_platform_compile_options) endfunction () # Warnings that should always be unconditional hard errors, as the code is -# inherently broken +# almost definitely broken mongoc_add_platform_compile_options ( # Implicit function or variable declarations gnu-like:-Werror=implicit msvc:/we4013 msvc:/we4431 # Missing return types/statements gnu-like:-Werror=return-type msvc:/we4716 - ) + # Incompatible pointer types + gnu-like:-Werror=incompatible-pointer-types msvc:/we4113 + # Integral/pointer conversions + gnu-like:-Werror=int-conversion msvc:/we4047 + # Discarding qualifiers + gnu-like:-Werror=discarded-qualifiers msvc:/we4090 + # Definite use of uninitialized value + gnu-like:-Werror=uninitialized msvc:/we4700 + # Aside: Disable CRT insecurity warnings + msvc:/D_CRT_SECURE_NO_WARNINGS + ) diff --git a/src/libbson/CMakeLists.txt b/src/libbson/CMakeLists.txt index 00842baa633..047212e81b1 100644 --- a/src/libbson/CMakeLists.txt +++ b/src/libbson/CMakeLists.txt @@ -100,9 +100,10 @@ else () set (BSON_HAVE_STRLCPY 1) endif () +CHECK_INCLUDE_FILE (stdbool.h BSON_HAVE_STDBOOL_H) + if (MSVC) set (BSON_HAVE_CLOCK_GETTIME 0) - set (BSON_HAVE_STDBOOL_H 0) set (BSON_HAVE_STRNLEN 0) set (BSON_HAVE_SYSCALL_TID 0) else () @@ -114,10 +115,6 @@ else () if (NOT BSON_HAVE_STRNLEN) set (BSON_HAVE_STRNLEN 0) endif () - CHECK_INCLUDE_FILE (stdbool.h BSON_HAVE_STDBOOL_H) - if (NOT BSON_HAVE_STDBOOL_H) - set (BSON_HAVE_STDBOOL_H 0) - endif () CHECK_SYMBOL_EXISTS (SYS_gettid sys/syscall.h BSON_HAVE_SYSCALL_TID) check_symbol_exists (syscall unistd.h _TMP_HAVE_SYSCALL) if (NOT BSON_HAVE_SYSCALL_TID OR NOT _TMP_HAVE_SYSCALL OR APPLE OR ANDROID) diff --git a/src/libmongoc/tests/TestSuite.c b/src/libmongoc/tests/TestSuite.c index 340b40a40a2..f047a7effcd 100644 --- a/src/libmongoc/tests/TestSuite.c +++ b/src/libmongoc/tests/TestSuite.c @@ -444,7 +444,8 @@ _print_getlasterror_win (const char *msg) NULL, GetLastError (), MAKELANGID (LANG_NEUTRAL, SUBLANG_DEFAULT), - &err_msg, + /* FormatMessage is weird about this param. */ + (LPTSTR) &err_msg, 0, NULL); diff --git a/src/libmongoc/tests/mock_server/request.c b/src/libmongoc/tests/mock_server/request.c index 3821d3565fb..a28ab330662 100644 --- a/src/libmongoc/tests/mock_server/request.c +++ b/src/libmongoc/tests/mock_server/request.c @@ -613,14 +613,14 @@ request_matches_msg (const request_t *request, bool request_matches_msgv (const request_t *request, uint32_t flags, va_list *args) { - const bson_t **docs; + bson_t **docs; size_t n_docs, allocated; bool r; n_docs = 0; allocated = 1; docs = bson_malloc (allocated * sizeof (bson_t *)); - while ((docs[n_docs] = va_arg (*args, const bson_t *))) { + while ((docs[n_docs] = va_arg (*args, bson_t *))) { n_docs++; if (n_docs == allocated) { allocated = bson_next_power_of_two (allocated + 1); @@ -628,7 +628,7 @@ request_matches_msgv (const request_t *request, uint32_t flags, va_list *args) } } - r = request_matches_msg (request, flags, docs, n_docs); + r = request_matches_msg (request, flags, (const bson_t **) docs, n_docs); bson_free (docs); return r; } diff --git a/src/libmongoc/tests/test-conveniences.c b/src/libmongoc/tests/test-conveniences.c index 94c662d21c7..4540e469895 100644 --- a/src/libmongoc/tests/test-conveniences.c +++ b/src/libmongoc/tests/test-conveniences.c @@ -60,7 +60,7 @@ test_conveniences_init () void -test_conveniences_cleanup () +test_conveniences_cleanup (void) { int i; bson_t *doc; diff --git a/src/libmongoc/tests/test-conveniences.h b/src/libmongoc/tests/test-conveniences.h index 870fb29338f..d2a3b1fa199 100644 --- a/src/libmongoc/tests/test-conveniences.h +++ b/src/libmongoc/tests/test-conveniences.h @@ -39,7 +39,7 @@ test_conveniences_init (); * Called automatically at process exit. */ void -test_conveniences_cleanup (); +test_conveniences_cleanup (void); /* Return a bson_t representation from a single-quoted JSON string, with * possible printf format directives. diff --git a/src/libmongoc/tests/test-mongoc-async.c b/src/libmongoc/tests/test-mongoc-async.c index 4289328544a..a212f03d82b 100644 --- a/src/libmongoc/tests/test-mongoc-async.c +++ b/src/libmongoc/tests/test-mongoc-async.c @@ -326,7 +326,7 @@ test_hello_delay_initializer (mongoc_async_cmd_t *acmd) } static void -test_hello_delay () +test_hello_delay (void) { /* test that a delayed cmd works. */ mock_server_t *server = mock_server_with_auto_hello (WIRE_VERSION_MAX); diff --git a/src/libmongoc/tests/test-mongoc-bulk.c b/src/libmongoc/tests/test-mongoc-bulk.c index c0b1805bad6..3d883cf167f 100644 --- a/src/libmongoc/tests/test-mongoc-bulk.c +++ b/src/libmongoc/tests/test-mongoc-bulk.c @@ -3476,7 +3476,8 @@ _test_numerous (bool ordered) TEST_NUMEROUS (remove_one (bulk, doc), "{'q': {'_id': 1}, 'limit': 1}"); TEST_NUMEROUS (replace_one (bulk, doc, tmp_bson ("{}"), false), "{'q': {'_id': 1}, 'u': {}}"); - TEST_NUMEROUS (update_one (bulk, doc, tmp_bson ("{'$set': {'x': 1}}"), NULL), + TEST_NUMEROUS ( + update_one (bulk, doc, tmp_bson ("{'$set': {'x': 1}}"), false), "{'q': {'_id': 1}, 'u': {'$set': {'x': 1}}}"); TEST_NUMEROUS (update_many_with_opts ( bulk, doc, tmp_bson ("{'$set': {'x': 1}}"), NULL, NULL), diff --git a/src/libmongoc/tests/test-mongoc-client-side-encryption.c b/src/libmongoc/tests/test-mongoc-client-side-encryption.c index 35c8eb90bfb..eee351380b4 100644 --- a/src/libmongoc/tests/test-mongoc-client-side-encryption.c +++ b/src/libmongoc/tests/test-mongoc-client-side-encryption.c @@ -2079,7 +2079,7 @@ _test_multi_threaded (bool external_key_vault) } static void -test_multi_threaded () +test_multi_threaded (void *ctx_unused) { _test_multi_threaded (true); _test_multi_threaded (false); diff --git a/src/libmongoc/tests/test-mongoc-cluster.c b/src/libmongoc/tests/test-mongoc-cluster.c index 17aed5ad96c..d724100ff34 100644 --- a/src/libmongoc/tests/test-mongoc-cluster.c +++ b/src/libmongoc/tests/test-mongoc-cluster.c @@ -1544,13 +1544,13 @@ _test_cluster_command_error (bool use_op_msg) } static void -test_cluster_command_error_op_msg () +test_cluster_command_error_op_msg (void) { _test_cluster_command_error (true); } static void -test_cluster_command_error_op_query () +test_cluster_command_error_op_query (void) { _test_cluster_command_error (false); } diff --git a/src/libmongoc/tests/test-mongoc-collection.c b/src/libmongoc/tests/test-mongoc-collection.c index d6fb40731d0..fe74f3408b4 100644 --- a/src/libmongoc/tests/test-mongoc-collection.c +++ b/src/libmongoc/tests/test-mongoc-collection.c @@ -282,7 +282,7 @@ _batch_size_test (bson_t *pipeline, } static void -test_aggregate_with_batch_size () +test_aggregate_with_batch_size (void) { bson_t *pipeline_dollar_out; bson_t *pipeline_dollar_merge; @@ -1687,7 +1687,7 @@ test_index (void) } static void -test_index_w_write_concern () +test_index_w_write_concern (void) { mongoc_collection_t *collection; mongoc_database_t *database; diff --git a/src/libmongoc/tests/test-mongoc-handshake.c b/src/libmongoc/tests/test-mongoc-handshake.c index bdeae2d8e36..d7b14b41b59 100644 --- a/src/libmongoc/tests/test-mongoc-handshake.c +++ b/src/libmongoc/tests/test-mongoc-handshake.c @@ -740,7 +740,7 @@ _get_bit (char *config_str, uint32_t bit) } void -test_handshake_platform_config () +test_handshake_platform_config (void) { /* Parse the config string, and check that it matches the defined flags. */ char *config_str = _mongoc_handshake_get_config_hex_string (); diff --git a/src/libmongoc/tests/test-mongoc-mongohouse.c b/src/libmongoc/tests/test-mongoc-mongohouse.c index adb15f85b6b..93ed0956538 100644 --- a/src/libmongoc/tests/test-mongoc-mongohouse.c +++ b/src/libmongoc/tests/test-mongoc-mongohouse.c @@ -151,7 +151,6 @@ cmd_succeeded_cb (const mongoc_apm_command_succeeded_t *event) /* Store cursor information from our initial find. */ if (strcmp (cmd, "find") == 0) { - BSON_ASSERT (!test->parsed_cursor); bson_iter_init (&iter, reply); @@ -163,7 +162,7 @@ cmd_succeeded_cb (const mongoc_apm_command_succeeded_t *event) BSON_ASSERT (bson_iter_find_descendant (&iter, "cursor.ns", &child_iter)); BSON_ASSERT (BSON_ITER_HOLDS_UTF8 (&child_iter)); - test->cursor_ns = bson_strdup(bson_iter_utf8(&child_iter, NULL)); + test->cursor_ns = bson_strdup (bson_iter_utf8 (&child_iter, NULL)); BSON_ASSERT (NULL != test->cursor_ns); test->parsed_cursor = true; @@ -194,7 +193,7 @@ cmd_succeeded_cb (const mongoc_apm_command_succeeded_t *event) /* Test that the driver properly constructs and issues a killCursors command to * ADL. */ static void -test_mongohouse_kill_cursors () +test_mongohouse_kill_cursors (void *ctx_unused) { mongoc_apm_callbacks_t *callbacks; mongoc_collection_t *coll; @@ -273,7 +272,7 @@ _run_ping_test (const char *connection_string) /* Test that the driver can establish a connection to ADL with authentication. Test both SCRAM-SHA-1 and SCRAM-SHA-256. */ static void -test_mongohouse_auth () +test_mongohouse_auth (void *ctx_unused) { /* SCRAM-SHA-1 */ _run_ping_test ( @@ -286,7 +285,7 @@ test_mongohouse_auth () /* Test that the driver can connect to ADL without authentication. */ static void -test_mongohouse_no_auth () +test_mongohouse_no_auth (void *ctx_unused) { _run_ping_test ("mongodb://localhost:27017"); } diff --git a/src/libmongoc/tests/test-mongoc-read-prefs.c b/src/libmongoc/tests/test-mongoc-read-prefs.c index 5aff346881a..7d0c4ad1e65 100644 --- a/src/libmongoc/tests/test-mongoc-read-prefs.c +++ b/src/libmongoc/tests/test-mongoc-read-prefs.c @@ -1053,7 +1053,7 @@ aggregate (mongoc_collection_t *collection, mongoc_read_prefs_t *prefs) /* direct connection to a secondary requires read pref primaryPreferred to * avoid "not primary" error from server */ static void -test_op_msg_direct_secondary () +test_op_msg_direct_secondary (void) { _test_op_msg_direct_connection ( false /* is_mongos */, @@ -1075,7 +1075,7 @@ test_op_msg_direct_secondary () /* direct connection to mongos must not auto-add read pref primaryPreferred */ static void -test_op_msg_direct_mongos () +test_op_msg_direct_mongos (void) { _test_op_msg_direct_connection (true /* is_mongos */, find, diff --git a/src/libmongoc/tests/test-mongoc-topology.c b/src/libmongoc/tests/test-mongoc-topology.c index dd373968978..1c3566f73de 100644 --- a/src/libmongoc/tests/test-mongoc-topology.c +++ b/src/libmongoc/tests/test-mongoc-topology.c @@ -1734,7 +1734,7 @@ cluster_time_fmt (int t) } static void -test_cluster_time_updated_during_handshake () +test_cluster_time_updated_during_handshake (void) { mock_server_t *server; mongoc_uri_t *uri; @@ -2031,7 +2031,7 @@ test_last_server_removed_warning (void) } static void -test_request_scan_on_error () +test_request_scan_on_error (void) { #define TEST_POOLED(msg, should_scan, should_mark_unknown, server_err) \ _test_request_scan_on_error ( \ @@ -2295,13 +2295,13 @@ _test_hello_versioned_api (bool pooled) } static void -test_hello_versioned_api_single () +test_hello_versioned_api_single (void) { _test_hello_versioned_api (false); } static void -test_hello_versioned_api_pooled () +test_hello_versioned_api_pooled (void) { _test_hello_versioned_api (true); } @@ -2435,13 +2435,13 @@ _test_hello_ok (bool pooled) } static void -test_hello_ok_single () +test_hello_ok_single (void) { _test_hello_ok (false); } static void -test_hello_ok_pooled () +test_hello_ok_pooled (void) { _test_hello_ok (true); } diff --git a/src/libmongoc/tests/test-mongoc-uri.c b/src/libmongoc/tests/test-mongoc-uri.c index 2a40b0bab5a..a5c0c6fc24f 100644 --- a/src/libmongoc/tests/test-mongoc-uri.c +++ b/src/libmongoc/tests/test-mongoc-uri.c @@ -1930,7 +1930,7 @@ test_mongoc_uri_tls_ssl (const char *tls, } static void -test_mongoc_uri_tls () +test_mongoc_uri_tls (void) { bson_error_t err = {0}; mongoc_uri_t *uri; @@ -1990,7 +1990,7 @@ test_mongoc_uri_tls () } static void -test_mongoc_uri_ssl () +test_mongoc_uri_ssl (void) { mongoc_uri_t *uri; @@ -2644,7 +2644,7 @@ test_mongoc_uri_int_options (void) } static void -test_one_tls_option_enables_tls () +test_one_tls_option_enables_tls (void) { const char *opts[] = {MONGOC_URI_TLS "=true", MONGOC_URI_TLSCERTIFICATEKEYFILE "=file.pem", @@ -2684,7 +2684,7 @@ test_one_tls_option_enables_tls () } static void -test_casing_options () +test_casing_options (void) { mongoc_uri_t* uri; bson_error_t error; diff --git a/src/libmongoc/tests/test-mongoc-write-commands.c b/src/libmongoc/tests/test-mongoc-write-commands.c index 77acaee3fcd..bf0fda81307 100644 --- a/src/libmongoc/tests/test-mongoc-write-commands.c +++ b/src/libmongoc/tests/test-mongoc-write-commands.c @@ -280,7 +280,7 @@ test_bypass_command_started (const mongoc_apm_command_started_t *event) } static void -test_bypass_not_sent () +test_bypass_not_sent (void) { mongoc_collection_t *collection; mongoc_bulk_operation_t *bulk; diff --git a/src/libmongoc/tests/test-mongoc-write-concern.c b/src/libmongoc/tests/test-mongoc-write-concern.c index 2e667cd689c..b6a9d940983 100644 --- a/src/libmongoc/tests/test-mongoc-write-concern.c +++ b/src/libmongoc/tests/test-mongoc-write-concern.c @@ -563,7 +563,7 @@ test_write_concern_unacknowledged (void) /* In the next insert_many, before CDRIVER-2902 was fixed, we would read that * old reply. */ r = mongoc_collection_insert_many (coll, docs, 2, NULL, &reply, &error); - bson_free (docs); + bson_free ((void *) docs); ASSERT_OR_PRINT (r, error); /* The replies are distinguished by the insertedCount. */ diff --git a/src/libmongoc/tests/unified/util.c b/src/libmongoc/tests/unified/util.c index 51d4ec9db37..f71d40ed769 100644 --- a/src/libmongoc/tests/unified/util.c +++ b/src/libmongoc/tests/unified/util.c @@ -80,12 +80,12 @@ bson_copy_and_sort (const bson_t *in) i++; } - qsort (keys, nkeys, sizeof (const char *), cmp_key); + qsort ((void *) keys, nkeys, sizeof (const char *), cmp_key); for (i = 0; i < nkeys; i++) { BSON_ASSERT (bson_iter_init_find (&iter, in, keys[i])); BSON_APPEND_VALUE (out, keys[i], bson_iter_value (&iter)); } - bson_free (keys); + bson_free ((void *) keys); return out; } From b6523018807a7fc5000f732e4200fec7832980e7 Mon Sep 17 00:00:00 2001 From: vector-of-bool Date: Thu, 28 Oct 2021 12:42:51 -0600 Subject: [PATCH 04/52] MSVC fixes --- src/libbson/src/bson/bson-macros.h | 26 ++++++++++++------------ src/libmongoc/src/mongoc/mongoc-shared.c | 1 + src/libmongoc/tests/test-mongoc-shared.c | 2 +- 3 files changed, 15 insertions(+), 14 deletions(-) diff --git a/src/libbson/src/bson/bson-macros.h b/src/libbson/src/bson/bson-macros.h index cd41a8f1360..c59297fca06 100644 --- a/src/libbson/src/bson/bson-macros.h +++ b/src/libbson/src/bson/bson-macros.h @@ -166,8 +166,8 @@ #else #define BSON_ALIGNED_BEGIN(_N) #define BSON_ALIGNED_END(_N) \ - __attribute__ ( \ - (aligned ((_N) > BSON_ALIGN_OF_PTR ? BSON_ALIGN_OF_PTR : (_N)))) + __attribute__ (( \ + aligned ((_N) > BSON_ALIGN_OF_PTR ? BSON_ALIGN_OF_PTR : (_N)))) #endif #endif @@ -196,18 +196,18 @@ abort (); \ } \ } while (0) - + /* Used for asserting parameters to provide a more precise error message */ -#define BSON_ASSERT_PARAM(param) \ - do { \ - if ((BSON_UNLIKELY (param == NULL))) { \ - fprintf (stderr, \ - "The parameter: %s, in function %s, cannot be NULL\n", \ - #param, \ - BSON_FUNC); \ - abort (); \ - } \ - } while (0) +#define BSON_ASSERT_PARAM(param) \ + do { \ + if ((BSON_UNLIKELY (param == NULL))) { \ + fprintf (stderr, \ + "The parameter: %s, in function %s, cannot be NULL\n", \ + #param, \ + BSON_FUNC); \ + abort (); \ + } \ + } while (0) /* obsolete macros, preserved for compatibility */ #define BSON_STATIC_ASSERT(s) BSON_STATIC_ASSERT_ (s, __LINE__) diff --git a/src/libmongoc/src/mongoc/mongoc-shared.c b/src/libmongoc/src/mongoc/mongoc-shared.c index 5f7ac5a96a3..3178ba1418e 100644 --- a/src/libmongoc/src/mongoc/mongoc-shared.c +++ b/src/libmongoc/src/mongoc/mongoc-shared.c @@ -38,6 +38,7 @@ static bson_once_t g_shared_ptr_mtx_init_once = BSON_ONCE_INIT; static BSON_ONCE_FUN (_init_mtx) { bson_mutex_init (&g_shared_ptr_mtx); + BSON_ONCE_RETURN; } static void diff --git a/src/libmongoc/tests/test-mongoc-shared.c b/src/libmongoc/tests/test-mongoc-shared.c index 635490e9746..5a9614009a9 100644 --- a/src/libmongoc/tests/test-mongoc-shared.c +++ b/src/libmongoc/tests/test-mongoc-shared.c @@ -34,7 +34,7 @@ my_value_free_v (void *ptr) } static void -test_simple () +test_simple (void) { int destroyed_value = 0; mongoc_shared_ptr ptr = MONGOC_SHARED_PTR_NULL; From 34ddd13ce936ec635b565fe2b404cb5b84c34e6c Mon Sep 17 00:00:00 2001 From: vector-of-bool Date: Thu, 28 Oct 2021 12:56:33 -0600 Subject: [PATCH 05/52] More warnings, and fixes for C-only warnings --- build/cmake/MongoC-Warnings.cmake | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/build/cmake/MongoC-Warnings.cmake b/build/cmake/MongoC-Warnings.cmake index 07bf10dfb26..4cfbd91ae42 100644 --- a/build/cmake/MongoC-Warnings.cmake +++ b/build/cmake/MongoC-Warnings.cmake @@ -15,25 +15,29 @@ function (mongoc_add_platform_compile_options) set (is_msvc "$") if (CMAKE_MATCH_1 STREQUAL "gnu-like") add_compile_options ("$<${is_gnu_like}:${CMAKE_MATCH_2}>") - else () + elseif (CMAKE_MATCH_1 STREQUAL "msvc") add_compile_options ("$<${is_msvc}:${CMAKE_MATCH_2}>") + else () + message (SEND_ERROR "Invalid option to mongoc_add_platform_compile_options(): '${opt}'") endif () endforeach () endfunction () +set(is_c_lang "$") + # Warnings that should always be unconditional hard errors, as the code is # almost definitely broken mongoc_add_platform_compile_options ( # Implicit function or variable declarations - gnu-like:-Werror=implicit msvc:/we4013 msvc:/we4431 + gnu-like:$<${is_c_lang}:-Werror=implicit> msvc:/we4013 msvc:/we4431 # Missing return types/statements gnu-like:-Werror=return-type msvc:/we4716 # Incompatible pointer types - gnu-like:-Werror=incompatible-pointer-types msvc:/we4113 + gnu-like:$<${is_c_lang}:-Werror=incompatible-pointer-types> msvc:/we4113 # Integral/pointer conversions - gnu-like:-Werror=int-conversion msvc:/we4047 + gnu-like:$<${is_c_lang}:-Werror=int-conversion> msvc:/we4047 # Discarding qualifiers - gnu-like:-Werror=discarded-qualifiers msvc:/we4090 + gnu-like:$<${is_c_lang}:-Werror=discarded-qualifiers> msvc:/we4090 # Definite use of uninitialized value gnu-like:-Werror=uninitialized msvc:/we4700 From b42e60453fd9ad450822ff22c0cb757717467e4a Mon Sep 17 00:00:00 2001 From: vector-of-bool Date: Mon, 8 Nov 2021 14:15:19 -0700 Subject: [PATCH 06/52] return-type now always on --- build/maintainer-flags.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/build/maintainer-flags.txt b/build/maintainer-flags.txt index 0f9c74d8571..7bd34de31e4 100644 --- a/build/maintainer-flags.txt +++ b/build/maintainer-flags.txt @@ -10,7 +10,6 @@ -Wno-strict-aliasing -Wno-uninitialized -Wredundant-decls --Wreturn-type -Wshadow -Wswitch-default -Wswitch-enum From 5c1f02724b4dde8fd46f639272b6181cf226b019 Mon Sep 17 00:00:00 2001 From: vector-of-bool Date: Wed, 10 Nov 2021 19:30:21 +0000 Subject: [PATCH 07/52] Older-fashioned genex for CMake compatibility --- build/cmake/MongoC-Warnings.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/cmake/MongoC-Warnings.cmake b/build/cmake/MongoC-Warnings.cmake index 4cfbd91ae42..a361713d8d5 100644 --- a/build/cmake/MongoC-Warnings.cmake +++ b/build/cmake/MongoC-Warnings.cmake @@ -11,7 +11,7 @@ function (mongoc_add_platform_compile_options) message (SEND_ERROR "Invalid option '${opt}' (Should be prefixed by 'msvc:' or 'gnu-like:'") continue () endif () - set (is_gnu_like "$") + set (is_gnu_like "$,$,$>") set (is_msvc "$") if (CMAKE_MATCH_1 STREQUAL "gnu-like") add_compile_options ("$<${is_gnu_like}:${CMAKE_MATCH_2}>") From 26deb3f1a6dfddd3d78a8e0a3f14d9dd9375378b Mon Sep 17 00:00:00 2001 From: vector-of-bool Date: Wed, 10 Nov 2021 22:42:09 +0000 Subject: [PATCH 08/52] Conditional COMPILE_LANGUAGE usage --- build/cmake/MongoC-Warnings.cmake | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/build/cmake/MongoC-Warnings.cmake b/build/cmake/MongoC-Warnings.cmake index a361713d8d5..a2bed2843a8 100644 --- a/build/cmake/MongoC-Warnings.cmake +++ b/build/cmake/MongoC-Warnings.cmake @@ -23,7 +23,14 @@ function (mongoc_add_platform_compile_options) endforeach () endfunction () -set(is_c_lang "$") +if (CMAKE_VERSION VERSION_LESS 3.3) + # On older CMake versions, we'll just always pass the warning options, even + # if the generate warnings for the C++ check file + set (is_c_lang "1") +else () + # $ is only valid in CMake 3.3+ + set (is_c_lang "$") +endif () # Warnings that should always be unconditional hard errors, as the code is # almost definitely broken From ae4dcee4a7454522df8b344c770198a01ff2d8db Mon Sep 17 00:00:00 2001 From: vector-of-bool Date: Tue, 16 Nov 2021 15:21:17 -0700 Subject: [PATCH 09/52] Pull unified spec tests from DRIVERS-823 --- .../aggregate-write-readPreference.json | 460 ++++++++++++++++++ .../db-aggregate-write-readPreference.json | 446 +++++++++++++++++ 2 files changed, 906 insertions(+) create mode 100644 src/libmongoc/tests/json/crud/unified/aggregate-write-readPreference.json create mode 100644 src/libmongoc/tests/json/crud/unified/db-aggregate-write-readPreference.json diff --git a/src/libmongoc/tests/json/crud/unified/aggregate-write-readPreference.json b/src/libmongoc/tests/json/crud/unified/aggregate-write-readPreference.json new file mode 100644 index 00000000000..bc887e83cbc --- /dev/null +++ b/src/libmongoc/tests/json/crud/unified/aggregate-write-readPreference.json @@ -0,0 +1,460 @@ +{ + "description": "aggregate-write-readPreference", + "schemaVersion": "1.4", + "runOnRequirements": [ + { + "minServerVersion": "3.6", + "topologies": [ + "replicaset", + "sharded", + "load-balanced" + ] + } + ], + "_yamlAnchors": { + "readConcern": { + "level": "local" + }, + "writeConcern": { + "w": 1 + } + }, + "createEntities": [ + { + "client": { + "id": "client0", + "observeEvents": [ + "commandStartedEvent" + ], + "uriOptions": { + "readConcernLevel": "local", + "w": 1 + } + } + }, + { + "database": { + "id": "database0", + "client": "client0", + "databaseName": "db0" + } + }, + { + "collection": { + "id": "collection0", + "database": "database0", + "collectionName": "coll0", + "collectionOptions": { + "readPreference": { + "mode": "secondaryPreferred", + "maxStalenessSeconds": 600 + } + } + } + }, + { + "collection": { + "id": "collection1", + "database": "database0", + "collectionName": "coll1" + } + } + ], + "initialData": [ + { + "collectionName": "coll0", + "databaseName": "db0", + "documents": [ + { + "_id": 1, + "x": 11 + }, + { + "_id": 2, + "x": 22 + }, + { + "_id": 3, + "x": 33 + } + ] + }, + { + "collectionName": "coll1", + "databaseName": "db0", + "documents": [] + } + ], + "tests": [ + { + "description": "Aggregate with $out includes read preference for 5.0+ server", + "runOnRequirements": [ + { + "minServerVersion": "5.0", + "serverless": "forbid" + } + ], + "operations": [ + { + "object": "collection0", + "name": "aggregate", + "arguments": { + "pipeline": [ + { + "$match": { + "_id": { + "$gt": 1 + } + } + }, + { + "$sort": { + "x": 1 + } + }, + { + "$out": "coll1" + } + ] + } + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [ + { + "commandStartedEvent": { + "command": { + "aggregate": "coll0", + "pipeline": [ + { + "$match": { + "_id": { + "$gt": 1 + } + } + }, + { + "$sort": { + "x": 1 + } + }, + { + "$out": "coll1" + } + ], + "$readPreference": { + "mode": "secondaryPreferred", + "maxStalenessSeconds": 600 + }, + "readConcern": { + "level": "local" + }, + "writeConcern": { + "w": 1 + } + } + } + } + ] + } + ], + "outcome": [ + { + "collectionName": "coll1", + "databaseName": "db0", + "documents": [ + { + "_id": 2, + "x": 22 + }, + { + "_id": 3, + "x": 33 + } + ] + } + ] + }, + { + "description": "Aggregate with $out omits read preference for pre-5.0 server", + "runOnRequirements": [ + { + "minServerVersion": "4.2", + "maxServerVersion": "4.4.99", + "serverless": "forbid" + } + ], + "operations": [ + { + "object": "collection0", + "name": "aggregate", + "arguments": { + "pipeline": [ + { + "$match": { + "_id": { + "$gt": 1 + } + } + }, + { + "$sort": { + "x": 1 + } + }, + { + "$out": "coll1" + } + ] + } + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [ + { + "commandStartedEvent": { + "command": { + "aggregate": "coll0", + "pipeline": [ + { + "$match": { + "_id": { + "$gt": 1 + } + } + }, + { + "$sort": { + "x": 1 + } + }, + { + "$out": "coll1" + } + ], + "$readPreference": { + "$$exists": false + }, + "readConcern": { + "level": "local" + }, + "writeConcern": { + "w": 1 + } + } + } + } + ] + } + ], + "outcome": [ + { + "collectionName": "coll1", + "databaseName": "db0", + "documents": [ + { + "_id": 2, + "x": 22 + }, + { + "_id": 3, + "x": 33 + } + ] + } + ] + }, + { + "description": "Aggregate with $merge includes read preference for 5.0+ server", + "runOnRequirements": [ + { + "minServerVersion": "5.0" + } + ], + "operations": [ + { + "object": "collection0", + "name": "aggregate", + "arguments": { + "pipeline": [ + { + "$match": { + "_id": { + "$gt": 1 + } + } + }, + { + "$sort": { + "x": 1 + } + }, + { + "$merge": { + "into": "coll1" + } + } + ] + } + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [ + { + "commandStartedEvent": { + "command": { + "aggregate": "coll0", + "pipeline": [ + { + "$match": { + "_id": { + "$gt": 1 + } + } + }, + { + "$sort": { + "x": 1 + } + }, + { + "$merge": { + "into": "coll1" + } + } + ], + "$readPreference": { + "mode": "secondaryPreferred", + "maxStalenessSeconds": 600 + }, + "readConcern": { + "level": "local" + }, + "writeConcern": { + "w": 1 + } + } + } + } + ] + } + ], + "outcome": [ + { + "collectionName": "coll1", + "databaseName": "db0", + "documents": [ + { + "_id": 2, + "x": 22 + }, + { + "_id": 3, + "x": 33 + } + ] + } + ] + }, + { + "description": "Aggregate with $merge omits read preference for pre-5.0 server", + "runOnRequirements": [ + { + "minServerVersion": "4.2", + "maxServerVersion": "4.4.99" + } + ], + "operations": [ + { + "object": "collection0", + "name": "aggregate", + "arguments": { + "pipeline": [ + { + "$match": { + "_id": { + "$gt": 1 + } + } + }, + { + "$sort": { + "x": 1 + } + }, + { + "$merge": { + "into": "coll1" + } + } + ] + } + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [ + { + "commandStartedEvent": { + "command": { + "aggregate": "coll0", + "pipeline": [ + { + "$match": { + "_id": { + "$gt": 1 + } + } + }, + { + "$sort": { + "x": 1 + } + }, + { + "$merge": { + "into": "coll1" + } + } + ], + "$readPreference": { + "$$exists": false + }, + "readConcern": { + "level": "local" + }, + "writeConcern": { + "w": 1 + } + } + } + } + ] + } + ], + "outcome": [ + { + "collectionName": "coll1", + "databaseName": "db0", + "documents": [ + { + "_id": 2, + "x": 22 + }, + { + "_id": 3, + "x": 33 + } + ] + } + ] + } + ] +} diff --git a/src/libmongoc/tests/json/crud/unified/db-aggregate-write-readPreference.json b/src/libmongoc/tests/json/crud/unified/db-aggregate-write-readPreference.json new file mode 100644 index 00000000000..2a81282de81 --- /dev/null +++ b/src/libmongoc/tests/json/crud/unified/db-aggregate-write-readPreference.json @@ -0,0 +1,446 @@ +{ + "description": "db-aggregate-write-readPreference", + "schemaVersion": "1.4", + "runOnRequirements": [ + { + "minServerVersion": "3.6", + "topologies": [ + "replicaset" + ], + "serverless": "forbid" + } + ], + "_yamlAnchors": { + "readConcern": { + "level": "local" + }, + "writeConcern": { + "w": 1 + } + }, + "createEntities": [ + { + "client": { + "id": "client0", + "observeEvents": [ + "commandStartedEvent" + ], + "uriOptions": { + "readConcernLevel": "local", + "w": 1 + } + } + }, + { + "database": { + "id": "database0", + "client": "client0", + "databaseName": "db0", + "databaseOptions": { + "readPreference": { + "mode": "secondaryPreferred", + "maxStalenessSeconds": 600 + } + } + } + }, + { + "collection": { + "id": "collection0", + "database": "database0", + "collectionName": "coll0" + } + } + ], + "initialData": [ + { + "collectionName": "coll0", + "databaseName": "db0", + "documents": [] + } + ], + "tests": [ + { + "description": "Database-level aggregate with $out includes read preference for 5.0+ server", + "runOnRequirements": [ + { + "minServerVersion": "5.0", + "serverless": "forbid" + } + ], + "operations": [ + { + "object": "database0", + "name": "aggregate", + "arguments": { + "pipeline": [ + { + "$listLocalSessions": {} + }, + { + "$limit": 1 + }, + { + "$addFields": { + "_id": 1 + } + }, + { + "$project": { + "_id": 1 + } + }, + { + "$out": "coll0" + } + ] + } + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [ + { + "commandStartedEvent": { + "command": { + "aggregate": 1, + "pipeline": [ + { + "$listLocalSessions": {} + }, + { + "$limit": 1 + }, + { + "$addFields": { + "_id": 1 + } + }, + { + "$project": { + "_id": 1 + } + }, + { + "$out": "coll0" + } + ], + "$readPreference": { + "mode": "secondaryPreferred", + "maxStalenessSeconds": 600 + }, + "readConcern": { + "level": "local" + }, + "writeConcern": { + "w": 1 + } + } + } + } + ] + } + ], + "outcome": [ + { + "collectionName": "coll0", + "databaseName": "db0", + "documents": [ + { + "_id": 1 + } + ] + } + ] + }, + { + "description": "Database-level aggregate with $out omits read preference for pre-5.0 server", + "runOnRequirements": [ + { + "minServerVersion": "4.2", + "maxServerVersion": "4.4.99", + "serverless": "forbid" + } + ], + "operations": [ + { + "object": "database0", + "name": "aggregate", + "arguments": { + "pipeline": [ + { + "$listLocalSessions": {} + }, + { + "$limit": 1 + }, + { + "$addFields": { + "_id": 1 + } + }, + { + "$project": { + "_id": 1 + } + }, + { + "$out": "coll0" + } + ] + } + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [ + { + "commandStartedEvent": { + "command": { + "aggregate": 1, + "pipeline": [ + { + "$listLocalSessions": {} + }, + { + "$limit": 1 + }, + { + "$addFields": { + "_id": 1 + } + }, + { + "$project": { + "_id": 1 + } + }, + { + "$out": "coll0" + } + ], + "$readPreference": { + "$$exists": false + }, + "readConcern": { + "level": "local" + }, + "writeConcern": { + "w": 1 + } + } + } + } + ] + } + ], + "outcome": [ + { + "collectionName": "coll0", + "databaseName": "db0", + "documents": [ + { + "_id": 1 + } + ] + } + ] + }, + { + "description": "Database-level aggregate with $merge includes read preference for 5.0+ server", + "runOnRequirements": [ + { + "minServerVersion": "5.0" + } + ], + "operations": [ + { + "object": "database0", + "name": "aggregate", + "arguments": { + "pipeline": [ + { + "$listLocalSessions": {} + }, + { + "$limit": 1 + }, + { + "$addFields": { + "_id": 1 + } + }, + { + "$project": { + "_id": 1 + } + }, + { + "$merge": { + "into": "coll0" + } + } + ] + } + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [ + { + "commandStartedEvent": { + "command": { + "aggregate": 1, + "pipeline": [ + { + "$listLocalSessions": {} + }, + { + "$limit": 1 + }, + { + "$addFields": { + "_id": 1 + } + }, + { + "$project": { + "_id": 1 + } + }, + { + "$merge": { + "into": "coll0" + } + } + ], + "$readPreference": { + "mode": "secondaryPreferred", + "maxStalenessSeconds": 600 + }, + "readConcern": { + "level": "local" + }, + "writeConcern": { + "w": 1 + } + } + } + } + ] + } + ], + "outcome": [ + { + "collectionName": "coll0", + "databaseName": "db0", + "documents": [ + { + "_id": 1 + } + ] + } + ] + }, + { + "description": "Database-level aggregate with $merge omits read preference for pre-5.0 server", + "runOnRequirements": [ + { + "minServerVersion": "4.2", + "maxServerVersion": "4.4.99" + } + ], + "operations": [ + { + "object": "database0", + "name": "aggregate", + "arguments": { + "pipeline": [ + { + "$listLocalSessions": {} + }, + { + "$limit": 1 + }, + { + "$addFields": { + "_id": 1 + } + }, + { + "$project": { + "_id": 1 + } + }, + { + "$merge": { + "into": "coll0" + } + } + ] + } + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [ + { + "commandStartedEvent": { + "command": { + "aggregate": 1, + "pipeline": [ + { + "$listLocalSessions": {} + }, + { + "$limit": 1 + }, + { + "$addFields": { + "_id": 1 + } + }, + { + "$project": { + "_id": 1 + } + }, + { + "$merge": { + "into": "coll0" + } + } + ], + "$readPreference": { + "$$exists": false + }, + "readConcern": { + "level": "local" + }, + "writeConcern": { + "w": 1 + } + } + } + } + ] + } + ], + "outcome": [ + { + "collectionName": "coll0", + "databaseName": "db0", + "documents": [ + { + "_id": 1 + } + ] + } + ] + } + ] +} From 565578026b02fff49dbce5590486a35b44811fd5 Mon Sep 17 00:00:00 2001 From: vector-of-bool Date: Tue, 16 Nov 2021 15:21:17 -0700 Subject: [PATCH 10/52] Conditional test registration --- src/libbson/tests/test-bson-corpus.c | 2 +- src/libmongoc/tests/TestSuite.c | 8 ++- src/libmongoc/tests/json-test.c | 22 ++++++-- src/libmongoc/tests/json-test.h | 11 ++-- src/libmongoc/tests/test-libmongoc.c | 10 ---- src/libmongoc/tests/test-libmongoc.h | 3 - .../tests/test-mongoc-change-stream.c | 11 ++-- .../tests/test-mongoc-client-session.c | 6 +- .../test-mongoc-client-side-encryption.c | 6 +- .../tests/test-mongoc-command-monitoring.c | 12 ++-- .../tests/test-mongoc-connection-uri.c | 15 ++--- src/libmongoc/tests/test-mongoc-crud.c | 17 +++--- src/libmongoc/tests/test-mongoc-dns.c | 22 +++----- .../tests/test-mongoc-gridfs-bucket.c | 5 +- .../tests/test-mongoc-max-staleness.c | 6 +- src/libmongoc/tests/test-mongoc-mongohouse.c | 7 +-- .../tests/test-mongoc-read-write-concern.c | 17 +++--- .../tests/test-mongoc-retryable-reads.c | 6 +- .../tests/test-mongoc-retryable-writes.c | 6 +- .../tests/test-mongoc-sdam-monitoring.c | 10 ++-- src/libmongoc/tests/test-mongoc-sdam.c | 56 +++++++++---------- .../tests/test-mongoc-server-selection.c | 13 ++--- .../tests/test-mongoc-transactions.c | 10 ++-- .../tests/test-mongoc-versioned-api.c | 11 ++-- src/libmongoc/tests/unified/runner.c | 23 ++++---- src/libmongoc/tests/unified/runner.h | 2 +- 26 files changed, 143 insertions(+), 174 deletions(-) diff --git a/src/libbson/tests/test-bson-corpus.c b/src/libbson/tests/test-bson-corpus.c index 7fbd4e28972..fa579efc573 100644 --- a/src/libbson/tests/test-bson-corpus.c +++ b/src/libbson/tests/test-bson-corpus.c @@ -325,6 +325,6 @@ void test_bson_corpus_install (TestSuite *suite) { install_json_test_suite_with_check ( - suite, BSON_JSON_DIR "/bson_corpus", test_bson_corpus_cb); + suite, BSON_JSON_DIR, "bson_corpus", test_bson_corpus_cb); TestSuite_Add (suite, "/bson_corpus/prose_1", test_bson_corpus_prose_1); } diff --git a/src/libmongoc/tests/TestSuite.c b/src/libmongoc/tests/TestSuite.c index 05887056a4d..3cab39a6661 100644 --- a/src/libmongoc/tests/TestSuite.c +++ b/src/libmongoc/tests/TestSuite.c @@ -353,6 +353,10 @@ _V_TestSuite_AddFull (TestSuite *suite, Test *test; Test *iter; + if (suite->ctest_run && (0 != strcmp (suite->ctest_run, name))) { + return NULL; + } + test = (Test *) calloc (1, sizeof *test); test->name = bson_strdup (name); test->func = func; @@ -393,7 +397,9 @@ _TestSuite_AddMockServerTest (TestSuite *suite, test = _V_TestSuite_AddFull (suite, name, (TestFuncWC) func, NULL, NULL, ap); va_end (ap); - _TestSuite_AddCheck (test, TestSuite_CheckMockServerAllowed, name); + if (test) { + _TestSuite_AddCheck (test, TestSuite_CheckMockServerAllowed, name); + } } diff --git a/src/libmongoc/tests/json-test.c b/src/libmongoc/tests/json-test.c index 91bc129c9c2..01886d8eb5f 100644 --- a/src/libmongoc/tests/json-test.c +++ b/src/libmongoc/tests/json-test.c @@ -1884,7 +1884,8 @@ _skip_if_unsupported (const char *test_name, bson_t *original) */ void _install_json_test_suite_with_check (TestSuite *suite, - const char *dir_path, + const char *base, + const char *subdir, test_hook callback, ...) { @@ -1895,9 +1896,21 @@ _install_json_test_suite_with_check (TestSuite *suite, char *skip_json; char *ext; va_list ap; + char joined[PATH_MAX]; + char resolved[PATH_MAX]; + + snprintf (joined, PATH_MAX, "%s/%s", base, subdir); + ASSERT (realpath (joined, resolved)); + + if (suite->ctest_run) { + const char *found = strstr (suite->ctest_run, subdir); + if (found != suite->ctest_run && found != suite->ctest_run + 1) { + return; + } + } num_tests = - collect_tests_from_dir (&test_paths[0], dir_path, 0, MAX_NUM_TESTS); + collect_tests_from_dir (&test_paths[0], resolved, 0, MAX_NUM_TESTS); for (i = 0; i < num_tests; i++) { test = get_bson_from_json_file (test_paths[i]); @@ -1940,9 +1953,10 @@ _install_json_test_suite_with_check (TestSuite *suite, */ void install_json_test_suite (TestSuite *suite, - const char *dir_path, + const char *base, + const char *subdir, test_hook callback) { install_json_test_suite_with_check ( - suite, dir_path, callback, TestSuite_CheckLive); + suite, base, subdir, callback, TestSuite_CheckLive); } diff --git a/src/libmongoc/tests/json-test.h b/src/libmongoc/tests/json-test.h index 90978b42341..669e9b3f824 100644 --- a/src/libmongoc/tests/json-test.h +++ b/src/libmongoc/tests/json-test.h @@ -102,17 +102,20 @@ json_test_config_cleanup (json_test_config_t *config); void _install_json_test_suite_with_check (TestSuite *suite, - const char *dir_path, + const char *base, + const char *subdir, test_hook callback, ...); void install_json_test_suite (TestSuite *suite, - const char *dir_path, + const char *base, + const char *subdir, test_hook callback); -#define install_json_test_suite_with_check(_suite, _dir_path, ...) \ - _install_json_test_suite_with_check (_suite, _dir_path, __VA_ARGS__, NULL) +#define install_json_test_suite_with_check(_suite, _base, _subdir, ...) \ + _install_json_test_suite_with_check ( \ + _suite, _base, _subdir, __VA_ARGS__, NULL) void set_uri_opts_from_bson (mongoc_uri_t *uri, const bson_t *opts); diff --git a/src/libmongoc/tests/test-libmongoc.c b/src/libmongoc/tests/test-libmongoc.c index b15a2a48c4c..e8da36aaf6c 100644 --- a/src/libmongoc/tests/test-libmongoc.c +++ b/src/libmongoc/tests/test-libmongoc.c @@ -2659,16 +2659,6 @@ test_framework_skip_if_no_setenv (void) return 1; } -void -test_framework_resolve_path (const char *path, char *resolved) -{ - if (!realpath (path, resolved)) { - MONGOC_ERROR ("Cannot resolve path %s\n", path); - MONGOC_ERROR ("Run test-libmongoc in repository root directory.\n"); - ASSERT (false); - } -} - bool test_framework_is_serverless (void) { diff --git a/src/libmongoc/tests/test-libmongoc.h b/src/libmongoc/tests/test-libmongoc.h index 7df9fe0089d..ef00c5d1dee 100644 --- a/src/libmongoc/tests/test-libmongoc.h +++ b/src/libmongoc/tests/test-libmongoc.h @@ -237,9 +237,6 @@ test_framework_skip_if_no_client_side_encryption (void); int test_framework_skip_if_time_sensitive (void); -void -test_framework_resolve_path (const char *path, char *resolved); - int test_framework_skip_if_no_aws (void); diff --git a/src/libmongoc/tests/test-mongoc-change-stream.c b/src/libmongoc/tests/test-mongoc-change-stream.c index 58db4c04a36..5436cb786f2 100644 --- a/src/libmongoc/tests/test-mongoc-change-stream.c +++ b/src/libmongoc/tests/test-mongoc-change-stream.c @@ -33,7 +33,7 @@ request_t *_request = mock_server_receives_command ( \ server, \ "db", \ - MONGOC_QUERY_SECONDARY_OK, \ + MONGOC_QUERY_SECONDARY_OK, \ "{ 'killCursors' : 'coll', 'cursors' : [ " #cursor_id " ] }"); \ mock_server_replies_simple (_request, \ "{ 'cursorsKilled': [ " #cursor_id " ] }"); \ @@ -1766,7 +1766,7 @@ change_stream_spec_after_test_cb (json_test_ctx_t *test_ctx, const bson_t *test) } /* iterate over the change stream, and verify that the document exists. - */ + */ for (i = 0; i < num_iterations; i++) { char *key = bson_strdup_printf ("%d", i); ret = _iterate_until_error_or_event ( @@ -1782,7 +1782,7 @@ change_stream_spec_after_test_cb (json_test_ctx_t *test_ctx, const bson_t *test) } /* check that everything in the "result.success" array is contained in - * our captured changes. */ + * our captured changes. */ while (bson_iter_next (&expected_iter)) { bson_t expected_doc; match_ctx_t match_ctx = {{0}}; @@ -2610,7 +2610,6 @@ prose_test_18 (void) void test_change_stream_install (TestSuite *suite) { - char resolved[PATH_MAX]; TestSuite_AddMockServerTest ( suite, "/change_stream/pipeline", test_change_stream_pipeline); @@ -2774,6 +2773,6 @@ test_change_stream_install (TestSuite *suite) TestSuite_AddMockServerTest ( suite, "/change_streams/prose_test_18", prose_test_18); - test_framework_resolve_path (JSON_DIR "/change_streams/legacy", resolved); - install_json_test_suite (suite, resolved, &test_change_stream_spec_cb); + install_json_test_suite ( + suite, JSON_DIR, "change_streams", &test_change_stream_spec_cb); } diff --git a/src/libmongoc/tests/test-mongoc-client-session.c b/src/libmongoc/tests/test-mongoc-client-session.c index 9763f957677..b3dea857ecf 100644 --- a/src/libmongoc/tests/test-mongoc-client-session.c +++ b/src/libmongoc/tests/test-mongoc-client-session.c @@ -2795,8 +2795,6 @@ test_sessions_snapshot_prose_test_1 (void *ctx) void test_session_install (TestSuite *suite) { - char resolved[PATH_MAX]; - TestSuite_Add (suite, "/Session/opts/clone", test_session_opts_clone); TestSuite_Add (suite, "/Session/opts/causal_consistency_and_snapshot", @@ -3151,9 +3149,9 @@ test_session_install (TestSuite *suite) false, false); - ASSERT (realpath (JSON_DIR "/sessions/legacy", resolved)); install_json_test_suite_with_check (suite, - resolved, + JSON_DIR, + "sessions/legacy", test_sessions_spec_cb, test_framework_skip_if_no_sessions); diff --git a/src/libmongoc/tests/test-mongoc-client-side-encryption.c b/src/libmongoc/tests/test-mongoc-client-side-encryption.c index 35c8eb90bfb..87d09ba735d 100644 --- a/src/libmongoc/tests/test-mongoc-client-side-encryption.c +++ b/src/libmongoc/tests/test-mongoc-client-side-encryption.c @@ -2426,12 +2426,10 @@ test_framework_skip_kms_tls_tests (void) void test_client_side_encryption_install (TestSuite *suite) { - char resolved[PATH_MAX]; - - ASSERT (realpath (JSON_DIR "/client_side_encryption", resolved)); install_json_test_suite_with_check ( suite, - resolved, + JSON_DIR, + "client_side_encryption", test_client_side_encryption_cb, test_framework_skip_if_no_client_side_encryption); /* Prose tests from the spec. */ diff --git a/src/libmongoc/tests/test-mongoc-command-monitoring.c b/src/libmongoc/tests/test-mongoc-command-monitoring.c index 6b48b9b6ce3..dd32a6284cf 100644 --- a/src/libmongoc/tests/test-mongoc-command-monitoring.c +++ b/src/libmongoc/tests/test-mongoc-command-monitoring.c @@ -104,13 +104,11 @@ test_command_monitoring_cb (bson_t *scenario) static void test_all_spec_tests (TestSuite *suite) { - char resolved[PATH_MAX]; - - run_unified_tests (suite, JSON_DIR "/command_monitoring/unified"); - - test_framework_resolve_path (JSON_DIR "/command_monitoring/legacy", - resolved); - install_json_test_suite (suite, resolved, &test_command_monitoring_cb); + run_unified_tests (suite, JSON_DIR, "command_monitoring/unified"); + install_json_test_suite (suite, + JSON_DIR, + "command_monitoring/legacy", + &test_command_monitoring_cb); } diff --git a/src/libmongoc/tests/test-mongoc-connection-uri.c b/src/libmongoc/tests/test-mongoc-connection-uri.c index e43b1217226..4f852563b67 100644 --- a/src/libmongoc/tests/test-mongoc-connection-uri.c +++ b/src/libmongoc/tests/test-mongoc-connection-uri.c @@ -355,16 +355,11 @@ test_connection_uri_cb (bson_t *scenario) static void test_all_spec_tests (TestSuite *suite) { - char resolved[PATH_MAX]; - - test_framework_resolve_path (JSON_DIR "/uri-options", resolved); - install_json_test_suite (suite, resolved, &test_connection_uri_cb); - - test_framework_resolve_path (JSON_DIR "/connection_uri", resolved); - install_json_test_suite (suite, resolved, &test_connection_uri_cb); - - test_framework_resolve_path (JSON_DIR "/auth", resolved); - install_json_test_suite (suite, resolved, &test_connection_uri_cb); + install_json_test_suite ( + suite, JSON_DIR, "uri-options", &test_connection_uri_cb); + install_json_test_suite ( + suite, JSON_DIR, "connection_uri", &test_connection_uri_cb); + install_json_test_suite (suite, JSON_DIR, "auth", &test_connection_uri_cb); } diff --git a/src/libmongoc/tests/test-mongoc-crud.c b/src/libmongoc/tests/test-mongoc-crud.c index 53b8d536062..0db82ce7209 100644 --- a/src/libmongoc/tests/test-mongoc-crud.c +++ b/src/libmongoc/tests/test-mongoc-crud.c @@ -33,22 +33,19 @@ test_crud_cb (bson_t *scenario) static void test_all_spec_tests (TestSuite *suite) { - char resolved[PATH_MAX]; - - test_framework_resolve_path (JSON_DIR "/crud/legacy", resolved); - install_json_test_suite_with_check (suite, - resolved, + JSON_DIR, + "crud/legacy", &test_crud_cb, test_framework_skip_if_no_crypto, TestSuite_CheckLive); /* Read/write concern spec tests use the same format. */ - test_framework_resolve_path (JSON_DIR "/read_write_concern/operation", - resolved); - - install_json_test_suite_with_check ( - suite, resolved, &test_crud_cb, TestSuite_CheckLive); + install_json_test_suite_with_check (suite, + JSON_DIR, + "read_write_concern/operation", + &test_crud_cb, + TestSuite_CheckLive); } static void diff --git a/src/libmongoc/tests/test-mongoc-dns.c b/src/libmongoc/tests/test-mongoc-dns.c index dbeff729293..9dfefa54b7b 100644 --- a/src/libmongoc/tests/test-mongoc-dns.c +++ b/src/libmongoc/tests/test-mongoc-dns.c @@ -393,23 +393,19 @@ test_null_error_pointer (void *ctx) static void test_all_spec_tests (TestSuite *suite) { - char resolved[PATH_MAX]; - - test_framework_resolve_path ( - JSON_DIR "/initial_dns_seedlist_discovery/replica-set", resolved); install_json_test_suite_with_check (suite, - resolved, + JSON_DIR, + "initial_dns_seedlist_discovery", test_dns, test_dns_check_replset, test_framework_skip_if_no_crypto); - - test_framework_resolve_path ( - JSON_DIR "/initial_dns_seedlist_discovery/load-balanced", resolved); - install_json_test_suite_with_check (suite, - resolved, - test_dns, - test_dns_check_loadbalanced, - test_framework_skip_if_no_crypto); + install_json_test_suite_with_check ( + suite, + JSON_DIR, + "initial_dns_seedlist_discovery/load-balanced", + test_dns, + test_dns_check_loadbalanced, + test_framework_skip_if_no_crypto); } extern bool diff --git a/src/libmongoc/tests/test-mongoc-gridfs-bucket.c b/src/libmongoc/tests/test-mongoc-gridfs-bucket.c index 1de57e78657..f392d8d109e 100644 --- a/src/libmongoc/tests/test-mongoc-gridfs-bucket.c +++ b/src/libmongoc/tests/test-mongoc-gridfs-bucket.c @@ -877,10 +877,7 @@ test_gridfs_cb (bson_t *scenario) static void test_all_spec_tests (TestSuite *suite) { - char resolved[PATH_MAX]; - - test_framework_resolve_path (JSON_DIR "/gridfs", resolved); - install_json_test_suite (suite, resolved, &test_gridfs_cb); + install_json_test_suite (suite, JSON_DIR, "gridfs", &test_gridfs_cb); } static void diff --git a/src/libmongoc/tests/test-mongoc-max-staleness.c b/src/libmongoc/tests/test-mongoc-max-staleness.c index 68470e0253b..445847463db 100644 --- a/src/libmongoc/tests/test-mongoc-max-staleness.c +++ b/src/libmongoc/tests/test-mongoc-max-staleness.c @@ -346,10 +346,8 @@ test_last_write_date_absent_pooled (void *ctx) static void test_all_spec_tests (TestSuite *suite) { - char resolved[PATH_MAX]; - - test_framework_resolve_path (JSON_DIR "/max_staleness", resolved); - install_json_test_suite (suite, resolved, &test_server_selection_logic_cb); + install_json_test_suite ( + suite, JSON_DIR, "max_staleness", &test_server_selection_logic_cb); } void diff --git a/src/libmongoc/tests/test-mongoc-mongohouse.c b/src/libmongoc/tests/test-mongoc-mongohouse.c index adb15f85b6b..9e43f769561 100644 --- a/src/libmongoc/tests/test-mongoc-mongohouse.c +++ b/src/libmongoc/tests/test-mongoc-mongohouse.c @@ -295,12 +295,9 @@ test_mongohouse_no_auth () void test_mongohouse_install (TestSuite *suite) { - char resolved[PATH_MAX]; - - test_framework_resolve_path (JSON_DIR "/mongohouse", resolved); - install_json_test_suite_with_check (suite, - resolved, + JSON_DIR, + "mongohouse", &test_mongohouse_cb, test_framework_skip_if_no_mongohouse); diff --git a/src/libmongoc/tests/test-mongoc-read-write-concern.c b/src/libmongoc/tests/test-mongoc-read-write-concern.c index 7239825c9b6..fde378e2582 100644 --- a/src/libmongoc/tests/test-mongoc-read-write-concern.c +++ b/src/libmongoc/tests/test-mongoc-read-write-concern.c @@ -233,13 +233,12 @@ test_rw_concern_document (bson_t *scenario) void test_read_write_concern_install (TestSuite *suite) { - char resolved[PATH_MAX]; - - ASSERT ( - realpath (JSON_DIR "/read_write_concern/connection-string", resolved)); - install_json_test_suite (suite, resolved, &test_rw_concern_uri); - - test_framework_resolve_path (JSON_DIR "/read_write_concern/document", - resolved); - install_json_test_suite (suite, resolved, &test_rw_concern_document); + install_json_test_suite (suite, + JSON_DIR, + "read_write_concern/connection-string", + &test_rw_concern_uri); + install_json_test_suite (suite, + JSON_DIR, + "read_write_concern/document", + &test_rw_concern_document); } diff --git a/src/libmongoc/tests/test-mongoc-retryable-reads.c b/src/libmongoc/tests/test-mongoc-retryable-reads.c index c37d4c2cd09..fa74d0c8f62 100644 --- a/src/libmongoc/tests/test-mongoc-retryable-reads.c +++ b/src/libmongoc/tests/test-mongoc-retryable-reads.c @@ -282,11 +282,9 @@ test_retry_reads_off (void *ctx) static void test_all_spec_tests (TestSuite *suite) { - char resolved[PATH_MAX]; - - test_framework_resolve_path (JSON_DIR "/retryable_reads", resolved); install_json_test_suite_with_check (suite, - resolved, + JSON_DIR, + "retryable_reads", test_retryable_reads_cb, TestSuite_CheckLive, test_framework_skip_if_no_failpoint, diff --git a/src/libmongoc/tests/test-mongoc-retryable-writes.c b/src/libmongoc/tests/test-mongoc-retryable-writes.c index e1e4f5fbfcc..46a48f46348 100644 --- a/src/libmongoc/tests/test-mongoc-retryable-writes.c +++ b/src/libmongoc/tests/test-mongoc-retryable-writes.c @@ -574,11 +574,9 @@ test_unsupported_storage_engine_error (void) static void test_all_spec_tests (TestSuite *suite) { - char resolved[PATH_MAX]; - - test_framework_resolve_path (JSON_DIR "/retryable_writes", resolved); install_json_test_suite_with_check (suite, - resolved, + JSON_DIR, + "retryable_writes", test_retryable_writes_cb, test_framework_skip_if_no_crypto, test_framework_skip_if_slow); diff --git a/src/libmongoc/tests/test-mongoc-sdam-monitoring.c b/src/libmongoc/tests/test-mongoc-sdam-monitoring.c index 1e9b42c900d..2ac4f0786b9 100644 --- a/src/libmongoc/tests/test-mongoc-sdam-monitoring.c +++ b/src/libmongoc/tests/test-mongoc-sdam-monitoring.c @@ -538,12 +538,10 @@ test_sdam_monitoring_cb (bson_t *test) static void test_all_spec_tests (TestSuite *suite) { - char resolved[PATH_MAX]; - - ASSERT (realpath (JSON_DIR "/server_discovery_and_monitoring/monitoring", - resolved)); - - install_json_test_suite (suite, resolved, &test_sdam_monitoring_cb); + install_json_test_suite (suite, + JSON_DIR, + "server_discovery_and_monitoring/monitoring", + &test_sdam_monitoring_cb); } static void diff --git a/src/libmongoc/tests/test-mongoc-sdam.c b/src/libmongoc/tests/test-mongoc-sdam.c index c69360a2fbc..b7c17182997 100644 --- a/src/libmongoc/tests/test-mongoc-sdam.c +++ b/src/libmongoc/tests/test-mongoc-sdam.c @@ -536,47 +536,45 @@ test_sdam_integration_cb (bson_t *scenario) static void test_all_spec_tests (TestSuite *suite) { - char resolved[PATH_MAX]; - /* Single */ - ASSERT ( - realpath (JSON_DIR "/server_discovery_and_monitoring/single", resolved)); - install_json_test_suite (suite, resolved, &test_sdam_cb); + install_json_test_suite ( + suite, JSON_DIR, "server_discovery_and_monitoring/single", &test_sdam_cb); /* Replica set */ - test_framework_resolve_path (JSON_DIR "/server_discovery_and_monitoring/rs", - resolved); - install_json_test_suite (suite, resolved, &test_sdam_cb); + install_json_test_suite ( + suite, JSON_DIR, "server_discovery_and_monitoring/rs", &test_sdam_cb); /* Sharded */ - ASSERT ( - realpath (JSON_DIR "/server_discovery_and_monitoring/sharded", resolved)); - install_json_test_suite (suite, resolved, &test_sdam_cb); + install_json_test_suite (suite, + JSON_DIR, + "server_discovery_and_monitoring/sharded", + &test_sdam_cb); - ASSERT ( - realpath (JSON_DIR "/server_discovery_and_monitoring/errors", resolved)); - install_json_test_suite (suite, resolved, &test_sdam_cb); + install_json_test_suite ( + suite, JSON_DIR, "server_discovery_and_monitoring/errors", &test_sdam_cb); /* Tests not in official Server Discovery And Monitoring Spec */ - ASSERT (realpath (JSON_DIR "/server_discovery_and_monitoring/supplemental", - resolved)); - install_json_test_suite (suite, resolved, &test_sdam_cb); + install_json_test_suite (suite, + JSON_DIR, + "server_discovery_and_monitoring/supplemental", + &test_sdam_cb); /* Integration tests. */ - ASSERT (realpath (JSON_DIR "/server_discovery_and_monitoring/integration", - resolved)); /* The integration tests configure retryable writes, which requires crypto. */ - install_json_test_suite_with_check (suite, - resolved, - &test_sdam_integration_cb, - TestSuite_CheckLive, - test_framework_skip_if_no_crypto, - test_framework_skip_if_slow); - - ASSERT (realpath (JSON_DIR "/server_discovery_and_monitoring/load-balanced", - resolved)); - install_json_test_suite (suite, resolved, &test_sdam_cb); + install_json_test_suite_with_check ( + suite, + JSON_DIR, + "server_discovery_and_monitoring/integration", + &test_sdam_integration_cb, + TestSuite_CheckLive, + test_framework_skip_if_no_crypto, + test_framework_skip_if_slow); + + install_json_test_suite (suite, + JSON_DIR, + "server_discovery_and_monitoring/load-balanced", + &test_sdam_cb); } static void diff --git a/src/libmongoc/tests/test-mongoc-server-selection.c b/src/libmongoc/tests/test-mongoc-server-selection.c index f18b6b87a53..3ac661c3d66 100644 --- a/src/libmongoc/tests/test-mongoc-server-selection.c +++ b/src/libmongoc/tests/test-mongoc-server-selection.c @@ -53,16 +53,15 @@ test_rtt_calculation_cb (bson_t *test) static void test_all_spec_tests (TestSuite *suite) { - char resolved[PATH_MAX]; - /* RTT calculation */ - test_framework_resolve_path (JSON_DIR "/server_selection/rtt", resolved); - install_json_test_suite (suite, resolved, &test_rtt_calculation_cb); + install_json_test_suite ( + suite, JSON_DIR, "server_selection/rtt", &test_rtt_calculation_cb); /* SS logic */ - test_framework_resolve_path (JSON_DIR "/server_selection/server_selection", - resolved); - install_json_test_suite (suite, resolved, &test_server_selection_logic_cb); + install_json_test_suite (suite, + JSON_DIR, + "server_selection/server_selection", + &test_server_selection_logic_cb); } void diff --git a/src/libmongoc/tests/test-mongoc-transactions.c b/src/libmongoc/tests/test-mongoc-transactions.c index 7ae7662ee13..c0a8d069623 100644 --- a/src/libmongoc/tests/test-mongoc-transactions.c +++ b/src/libmongoc/tests/test-mongoc-transactions.c @@ -1170,18 +1170,16 @@ test_max_commit_time_ms_is_reset (void *ctx) void test_transactions_install (TestSuite *suite) { - char resolved[PATH_MAX]; - - ASSERT (realpath (JSON_DIR "/transactions/legacy", resolved)); install_json_test_suite_with_check (suite, - resolved, + JSON_DIR, + "transactions/legacy", test_transactions_cb, test_framework_skip_if_no_txns, test_framework_skip_if_slow); - test_framework_resolve_path (JSON_DIR "/with_transaction", resolved); install_json_test_suite_with_check (suite, - resolved, + JSON_DIR, + "with_transaction", test_transactions_cb, test_framework_skip_if_no_txns, test_framework_skip_if_slow); diff --git a/src/libmongoc/tests/test-mongoc-versioned-api.c b/src/libmongoc/tests/test-mongoc-versioned-api.c index 15baea13af8..05ad7fc74f3 100644 --- a/src/libmongoc/tests/test-mongoc-versioned-api.c +++ b/src/libmongoc/tests/test-mongoc-versioned-api.c @@ -125,10 +125,11 @@ _test_mongoc_server_api_client_pool (void) BSON_ASSERT (client->api->version == MONGOC_SERVER_API_V1); ASSERT (!mongoc_client_set_server_api (client, api, &error)); - ASSERT_ERROR_CONTAINS (error, - MONGOC_ERROR_CLIENT, - MONGOC_ERROR_CLIENT_API_FROM_POOL, - "Cannot set server api on a client checked out from a pool"); + ASSERT_ERROR_CONTAINS ( + error, + MONGOC_ERROR_CLIENT, + MONGOC_ERROR_CLIENT_API_FROM_POOL, + "Cannot set server api on a client checked out from a pool"); mongoc_client_pool_push (pool, client); mongoc_client_pool_destroy (pool); @@ -176,7 +177,7 @@ _test_mongoc_server_api_client_pool_once (void) void test_client_versioned_api_install (TestSuite *suite) { - run_unified_tests (suite, JSON_DIR "/versioned_api"); + run_unified_tests (suite, JSON_DIR, "versioned_api"); TestSuite_Add ( suite, "/VersionedApi/client", _test_mongoc_server_api_client); diff --git a/src/libmongoc/tests/unified/runner.c b/src/libmongoc/tests/unified/runner.c index 9f0aa36c7ec..00c558fedd4 100644 --- a/src/libmongoc/tests/unified/runner.c +++ b/src/libmongoc/tests/unified/runner.c @@ -1656,14 +1656,11 @@ run_one_test_file (bson_t *bson) } void -run_unified_tests (TestSuite *suite, const char *path) +run_unified_tests (TestSuite *suite, const char *base, const char *subdir) { - char resolved[PATH_MAX]; - - ASSERT (realpath (path, resolved)); - install_json_test_suite_with_check (suite, - resolved, + base, + subdir, &run_one_test_file, TestSuite_CheckLive, test_framework_skip_if_no_crypto); @@ -1672,17 +1669,17 @@ run_unified_tests (TestSuite *suite, const char *path) void test_install_unified (TestSuite *suite) { - run_unified_tests (suite, JSON_DIR "/unified"); + run_unified_tests (suite, JSON_DIR, "unified"); - run_unified_tests (suite, JSON_DIR "/crud/unified"); + run_unified_tests (suite, JSON_DIR, "crud/unified"); - run_unified_tests (suite, JSON_DIR "/transactions/unified"); + run_unified_tests (suite, JSON_DIR, "transactions/unified"); - run_unified_tests (suite, JSON_DIR "/collection-management"); + run_unified_tests (suite, JSON_DIR, "collection-management"); - run_unified_tests (suite, JSON_DIR "/sessions/unified"); + run_unified_tests (suite, JSON_DIR, "sessions/unified"); - run_unified_tests (suite, JSON_DIR "/change_streams/unified"); + run_unified_tests (suite, JSON_DIR, "change_streams/unified"); - run_unified_tests (suite, JSON_DIR "/load_balancers"); + run_unified_tests (suite, JSON_DIR, "load_balancers"); } diff --git a/src/libmongoc/tests/unified/runner.h b/src/libmongoc/tests/unified/runner.h index d6e77343693..f111f6b24e1 100644 --- a/src/libmongoc/tests/unified/runner.h +++ b/src/libmongoc/tests/unified/runner.h @@ -72,6 +72,6 @@ register_failpoint (test_t *test, /* Run a directory of test files through the unified test runner. */ void -run_unified_tests (TestSuite *suite, const char *path); +run_unified_tests (TestSuite *suite, const char *base, const char *subdir); #endif /* UNIFIED_RUNNER_H */ From e5acd6454a1a6f61b3e9c478125440623eace6d0 Mon Sep 17 00:00:00 2001 From: vector-of-bool Date: Tue, 16 Nov 2021 22:29:13 +0000 Subject: [PATCH 11/52] Fixed differing warning options between GNU and Clang --- build/cmake/MongoC-Warnings.cmake | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/build/cmake/MongoC-Warnings.cmake b/build/cmake/MongoC-Warnings.cmake index a2bed2843a8..6874c6c5989 100644 --- a/build/cmake/MongoC-Warnings.cmake +++ b/build/cmake/MongoC-Warnings.cmake @@ -7,14 +7,20 @@ ]] function (mongoc_add_platform_compile_options) foreach (opt IN LISTS ARGV) - if (NOT opt MATCHES "^(gnu-like|msvc):(.*)") + if (NOT opt MATCHES "^(gnu-like|gnu|clang|msvc):(.*)") message (SEND_ERROR "Invalid option '${opt}' (Should be prefixed by 'msvc:' or 'gnu-like:'") continue () endif () - set (is_gnu_like "$,$,$>") + set (is_gnu "$") + set (is_clang "$,$>") + set (is_gnu_like "$") set (is_msvc "$") if (CMAKE_MATCH_1 STREQUAL "gnu-like") add_compile_options ("$<${is_gnu_like}:${CMAKE_MATCH_2}>") + elseif (CMAKE_MATCH_1 STREQUAL gnu) + add_compile_options ("$<${is_gnu}:${CMAKE_MATCH_2}>") + elseif (CMAKE_MATCH_1 STREQUAL clang) + add_compile_options ("$<${is_clang}:${CMAKE_MATCH_2}>") elseif (CMAKE_MATCH_1 STREQUAL "msvc") add_compile_options ("$<${is_msvc}:${CMAKE_MATCH_2}>") else () @@ -44,7 +50,9 @@ mongoc_add_platform_compile_options ( # Integral/pointer conversions gnu-like:$<${is_c_lang}:-Werror=int-conversion> msvc:/we4047 # Discarding qualifiers - gnu-like:$<${is_c_lang}:-Werror=discarded-qualifiers> msvc:/we4090 + gnu:$<${is_c_lang}:-Werror=discarded-qualifiers> + clang:$<${is_c_lang}:-Werror=ignored-qualifiers> + msvc:/we4090 # Definite use of uninitialized value gnu-like:-Werror=uninitialized msvc:/we4700 From 0984e341eafad07149dc07b743c51a0ec6d65291 Mon Sep 17 00:00:00 2001 From: vector-of-bool Date: Thu, 18 Nov 2021 22:03:10 +0000 Subject: [PATCH 12/52] Allow readPreference:secondary with $merge and $out. --- src/libmongoc/src/mongoc/mongoc-aggregate.c | 9 +- .../src/mongoc/mongoc-change-stream.c | 8 +- src/libmongoc/src/mongoc/mongoc-client.c | 9 +- .../src/mongoc/mongoc-cluster-private.h | 11 +++ src/libmongoc/src/mongoc/mongoc-cluster.c | 10 +- src/libmongoc/src/mongoc/mongoc-collection.c | 8 +- .../src/mongoc/mongoc-cursor-private.h | 5 + src/libmongoc/src/mongoc/mongoc-cursor.c | 29 ++++-- .../mongoc-topology-description-private.h | 6 +- .../src/mongoc/mongoc-topology-description.c | 94 +++++++++++++++---- src/libmongoc/tests/test-mongoc-cluster.c | 4 +- src/libmongoc/tests/test-mongoc-topology.c | 8 +- 12 files changed, 151 insertions(+), 50 deletions(-) diff --git a/src/libmongoc/src/mongoc/mongoc-aggregate.c b/src/libmongoc/src/mongoc/mongoc-aggregate.c index 9b07817901e..376ea2bcf97 100644 --- a/src/libmongoc/src/mongoc/mongoc-aggregate.c +++ b/src/libmongoc/src/mongoc/mongoc-aggregate.c @@ -276,12 +276,9 @@ _mongoc_aggregate (mongoc_client_t *client, has_write_key = _has_write_key (&iter); } - if (has_write_key && cursor->read_prefs->mode != MONGOC_READ_PRIMARY) { - mongoc_read_prefs_destroy (cursor->read_prefs); - cursor->read_prefs = mongoc_read_prefs_new (MONGOC_READ_PRIMARY); - MONGOC_WARNING ("$out or $merge stage specified. Overriding read " - "preference to primary."); - } + /* This has an important effect on server selection when + * readPreferences=secondary. Keep track of this fact for later use. */ + cursor->is_aggr_with_write_stage = has_write_key; /* server id isn't enough. ensure we're connected & know wire version */ server_stream = _mongoc_cursor_fetch_stream (cursor); diff --git a/src/libmongoc/src/mongoc/mongoc-change-stream.c b/src/libmongoc/src/mongoc/mongoc-change-stream.c index 533496cf66c..b712c0cf3c6 100644 --- a/src/libmongoc/src/mongoc/mongoc-change-stream.c +++ b/src/libmongoc/src/mongoc/mongoc-change-stream.c @@ -279,8 +279,12 @@ _make_cursor (mongoc_change_stream_t *stream) goto cleanup; } - server_stream = mongoc_cluster_stream_for_reads ( - &stream->client->cluster, stream->read_prefs, cs, &reply, &stream->err); + server_stream = mongoc_cluster_stream_for_reads (&stream->client->cluster, + stream->read_prefs, + cs, + &reply, + NOT_AGGR_WITH_WRITE_STAGE, + &stream->err); if (!server_stream) { bson_destroy (&stream->err_doc); bson_copy_to (&reply, &stream->err_doc); diff --git a/src/libmongoc/src/mongoc/mongoc-client.c b/src/libmongoc/src/mongoc/mongoc-client.c index 00e889c4143..e882c49e2ca 100644 --- a/src/libmongoc/src/mongoc/mongoc-client.c +++ b/src/libmongoc/src/mongoc/mongoc-client.c @@ -1807,6 +1807,7 @@ _mongoc_client_retryable_read_command_with_stream ( parts->read_prefs, parts->assembled.session, NULL, + NOT_AGGR_WITH_WRITE_STAGE, &ignored_error); if (retry_server_stream && retry_server_stream->sd->max_wire_version >= @@ -1894,8 +1895,8 @@ mongoc_client_command_simple (mongoc_client_t *client, * configuration. The generic command method SHOULD allow an optional read * preference argument." */ - server_stream = - mongoc_cluster_stream_for_reads (cluster, read_prefs, NULL, reply, error); + server_stream = mongoc_cluster_stream_for_reads ( + cluster, read_prefs, NULL, reply, NOT_AGGR_WITH_WRITE_STAGE, error); if (server_stream) { ret = _mongoc_client_command_with_stream ( @@ -2054,8 +2055,8 @@ _mongoc_client_command_with_opts (mongoc_client_t *client, server_stream = mongoc_cluster_stream_for_writes (cluster, cs, reply_ptr, error); } else { - server_stream = - mongoc_cluster_stream_for_reads (cluster, prefs, cs, reply_ptr, error); + server_stream = mongoc_cluster_stream_for_reads ( + cluster, prefs, cs, reply_ptr, NOT_AGGR_WITH_WRITE_STAGE, error); } if (!server_stream) { diff --git a/src/libmongoc/src/mongoc/mongoc-cluster-private.h b/src/libmongoc/src/mongoc/mongoc-cluster-private.h index 8cfde4407b2..9ad72bc7012 100644 --- a/src/libmongoc/src/mongoc/mongoc-cluster-private.h +++ b/src/libmongoc/src/mongoc/mongoc-cluster-private.h @@ -105,6 +105,16 @@ mongoc_cluster_try_recv (mongoc_cluster_t *cluster, mongoc_server_stream_t *server_stream, bson_error_t *error); +/** + * @brief Flag telling whether an aggregate operation has a write stage or not + */ +typedef enum aggr_with_write_stage_flag { + /** The operation is not an aggregate with a write stage */ + NOT_AGGR_WITH_WRITE_STAGE, + /** The intended operation is an aggregate with a write stage */ + AGGR_WITH_WRITE_STAGE +} aggr_with_write_stage_flag; + /** * @brief Obtain a server stream appropriate for read operations on the * cluster. @@ -122,6 +132,7 @@ mongoc_cluster_stream_for_reads (mongoc_cluster_t *cluster, const mongoc_read_prefs_t *read_prefs, mongoc_client_session_t *cs, bson_t *reply, + aggr_with_write_stage_flag with_write_stage, bson_error_t *error); /** diff --git a/src/libmongoc/src/mongoc/mongoc-cluster.c b/src/libmongoc/src/mongoc/mongoc-cluster.c index 5b1993f9318..2d0a1d66f95 100644 --- a/src/libmongoc/src/mongoc/mongoc-cluster.c +++ b/src/libmongoc/src/mongoc/mongoc-cluster.c @@ -2799,6 +2799,7 @@ mongoc_cluster_stream_for_reads (mongoc_cluster_t *cluster, const mongoc_read_prefs_t *read_prefs, mongoc_client_session_t *cs, bson_t *reply, + aggr_with_write_stage_flag with_write_stage, bson_error_t *error) { const mongoc_read_prefs_t *prefs_override = read_prefs; @@ -2808,7 +2809,14 @@ mongoc_cluster_stream_for_reads (mongoc_cluster_t *cluster, } return _mongoc_cluster_stream_for_optype ( - cluster, MONGOC_SS_READ, prefs_override, cs, reply, error); + cluster, + with_write_stage == NOT_AGGR_WITH_WRITE_STAGE + ? MONGOC_SS_READ + : MONGOC_SS_AGGREGATE_WITH_WRITE, + prefs_override, + cs, + reply, + error); } mongoc_server_stream_t * diff --git a/src/libmongoc/src/mongoc/mongoc-collection.c b/src/libmongoc/src/mongoc/mongoc-collection.c index 0c04a542d84..fa24e9a9152 100644 --- a/src/libmongoc/src/mongoc/mongoc-collection.c +++ b/src/libmongoc/src/mongoc/mongoc-collection.c @@ -861,8 +861,12 @@ mongoc_collection_estimated_document_count ( BSON_ASSERT_PARAM (coll); - server_stream = mongoc_cluster_stream_for_reads ( - &coll->client->cluster, read_prefs, NULL, reply, error); + server_stream = mongoc_cluster_stream_for_reads (&coll->client->cluster, + read_prefs, + NULL, + reply, + NOT_AGGR_WITH_WRITE_STAGE, + error); if (opts && bson_has_field (opts, "sessionId")) { bson_set_error (error, diff --git a/src/libmongoc/src/mongoc/mongoc-cursor-private.h b/src/libmongoc/src/mongoc/mongoc-cursor-private.h index e8bddeab5fa..f4f3641478d 100644 --- a/src/libmongoc/src/mongoc/mongoc-cursor-private.h +++ b/src/libmongoc/src/mongoc/mongoc-cursor-private.h @@ -25,6 +25,7 @@ #include "mongoc-buffer-private.h" #include "mongoc-rpc-private.h" #include "mongoc-server-stream-private.h" +#include "mongoc-cluster-private.h" BSON_BEGIN_DECLS @@ -131,6 +132,10 @@ struct _mongoc_cursor_t { mongoc_read_prefs_t *read_prefs; mongoc_write_concern_t *write_concern; + /** Whether this cursor corresponds to an aggregate command that contains a + * writing-stage */ + aggr_with_write_stage_flag is_aggr_with_write_stage; + bool explicit_session; mongoc_client_session_t *client_session; diff --git a/src/libmongoc/src/mongoc/mongoc-cursor.c b/src/libmongoc/src/mongoc/mongoc-cursor.c index 1314cd8e119..b22248f1f3a 100644 --- a/src/libmongoc/src/mongoc/mongoc-cursor.c +++ b/src/libmongoc/src/mongoc/mongoc-cursor.c @@ -251,6 +251,7 @@ _mongoc_cursor_new_with_opts (mongoc_client_t *client, cursor->client = client; cursor->state = UNPRIMED; cursor->client_generation = client->generation; + cursor->is_aggr_with_write_stage = NOT_AGGR_WITH_WRITE_STAGE; bson_init (&cursor->opts); bson_init (&cursor->error_doc); @@ -662,11 +663,13 @@ _mongoc_cursor_fetch_stream (mongoc_cursor_t *cursor) &reply, &cursor->error); } else { - server_stream = mongoc_cluster_stream_for_reads (&cursor->client->cluster, - cursor->read_prefs, - cursor->client_session, - &reply, - &cursor->error); + server_stream = + mongoc_cluster_stream_for_reads (&cursor->client->cluster, + cursor->read_prefs, + cursor->client_session, + &reply, + cursor->is_aggr_with_write_stage, + &cursor->error); if (server_stream) { cursor->server_id = server_stream->sd->id; @@ -1070,11 +1073,17 @@ _mongoc_cursor_run_command (mongoc_cursor_t *cursor, mongoc_server_stream_cleanup (server_stream); - server_stream = mongoc_cluster_stream_for_reads (&cursor->client->cluster, - cursor->read_prefs, - cursor->client_session, - reply, - &cursor->error); + BSON_ASSERT (cursor->is_aggr_with_write_stage == + NOT_AGGR_WITH_WRITE_STAGE && + "Cannot attempt a retry on an aggregate operation that " + "contains write stages"); + server_stream = + mongoc_cluster_stream_for_reads (&cursor->client->cluster, + cursor->read_prefs, + cursor->client_session, + reply, + NOT_AGGR_WITH_WRITE_STAGE, + &cursor->error); if (server_stream && server_stream->sd->max_wire_version >= WIRE_VERSION_RETRY_READS) { diff --git a/src/libmongoc/src/mongoc/mongoc-topology-description-private.h b/src/libmongoc/src/mongoc/mongoc-topology-description-private.h index e5fb572ed57..bae0652b818 100644 --- a/src/libmongoc/src/mongoc/mongoc-topology-description-private.h +++ b/src/libmongoc/src/mongoc/mongoc-topology-description-private.h @@ -62,7 +62,11 @@ struct _mongoc_topology_description_t { void *apm_context; }; -typedef enum { MONGOC_SS_READ, MONGOC_SS_WRITE } mongoc_ss_optype_t; +typedef enum { + MONGOC_SS_READ, + MONGOC_SS_WRITE, + MONGOC_SS_AGGREGATE_WITH_WRITE +} mongoc_ss_optype_t; void mongoc_topology_description_init (mongoc_topology_description_t *description, diff --git a/src/libmongoc/src/mongoc/mongoc-topology-description.c b/src/libmongoc/src/mongoc/mongoc-topology-description.c index c121fcdb3f8..e4a923a0093 100644 --- a/src/libmongoc/src/mongoc/mongoc-topology-description.c +++ b/src/libmongoc/src/mongoc/mongoc-topology-description.c @@ -648,6 +648,57 @@ _mongoc_topology_description_validate_max_staleness ( return true; } +static bool +_check_any_server_less_than_wire_version_13 (const void *sd_, + void *any_too_old_) +{ + const mongoc_server_description_t *sd = sd_; + bool *any_too_old = any_too_old_; + if (sd->max_wire_version < 13) { + *any_too_old = true; + } + return true; +} + +/** + * @brief Calculate the read mode that we should be using, based on what was + * requested and what is available in the topology. + * + * Per the CRUD spec, if the requested read mode is *not* primary, and *any* + * server in the topology has a wire version <13, we must override the read + * mode preference with "primary." Wire version 13 indicates support on a + * secondary server for using aggregate pipelines that contain writing stages + * (i.e. '$out' and '$merge'). + */ +static mongoc_read_mode_t +_calc_effective_read_mode (const mongoc_topology_description_t *td, + mongoc_ss_optype_t optype, + mongoc_read_mode_t requested_read_mode) +{ + if (requested_read_mode == MONGOC_READ_PRIMARY || + requested_read_mode == MONGOC_READ_PRIMARY_PREFERRED) { + return requested_read_mode; + } + switch (optype) { + case MONGOC_SS_WRITE: + BSON_ASSERT (false && "Unexpected optype for _calc_effective_read_mode"); + abort (); + case MONGOC_SS_READ: + return requested_read_mode; + case MONGOC_SS_AGGREGATE_WITH_WRITE: { + bool any_too_old = false; + mongoc_set_for_each_const (mc_tpld_servers_const (td), + _check_any_server_less_than_wire_version_13, + &any_too_old); + if (any_too_old) { + return MONGOC_READ_PRIMARY; + } + return requested_read_mode; + } + } + BSON_UNREACHABLE ( + "Invalid mongoc_ss_optype_t for _calc_effective_read_mode()"); +} /* *------------------------------------------------------------------------- @@ -677,11 +728,14 @@ mongoc_topology_description_suitable_servers ( const mongoc_set_t *td_servers = mc_tpld_servers_const (topology); int64_t nearest = -1; int i; - mongoc_read_mode_t read_mode = mongoc_read_prefs_get_mode (read_pref); + const mongoc_read_mode_t given_read_mode = + mongoc_read_prefs_get_mode (read_pref); + const mongoc_read_mode_t effective_read_mode = + _calc_effective_read_mode (topology, optype, given_read_mode); candidates = bson_malloc0 (sizeof (*candidates) * td_servers->items_len); - data.read_mode = read_mode; + data.read_mode = effective_read_mode; data.topology_type = topology->type; data.primary = NULL; data.candidates = candidates; @@ -694,7 +748,7 @@ mongoc_topology_description_suitable_servers ( const mongoc_server_description_t *server = mongoc_set_get_item_const (td_servers, 0); if (_mongoc_topology_description_server_is_candidate ( - server->type, read_mode, topology->type)) { + server->type, data.read_mode, topology->type)) { _mongoc_array_append_val (set, server); } else { TRACE ( @@ -710,11 +764,13 @@ mongoc_topology_description_suitable_servers ( * Find suitable servers based on read mode */ if (topology->type == MONGOC_TOPOLOGY_RS_NO_PRIMARY || topology->type == MONGOC_TOPOLOGY_RS_WITH_PRIMARY) { - if (optype == MONGOC_SS_READ) { + switch (optype) { + case MONGOC_SS_AGGREGATE_WITH_WRITE: + case MONGOC_SS_READ: { mongoc_set_for_each_const ( td_servers, _mongoc_replica_set_read_suitable_cb, &data); - if (read_mode == MONGOC_READ_PRIMARY) { + if (data.read_mode == MONGOC_READ_PRIMARY) { if (data.primary) { _mongoc_array_append_val (set, data.primary); } @@ -722,12 +778,12 @@ mongoc_topology_description_suitable_servers ( goto DONE; } - if (read_mode == MONGOC_READ_PRIMARY_PREFERRED && data.primary) { + if (data.read_mode == MONGOC_READ_PRIMARY_PREFERRED && data.primary) { _mongoc_array_append_val (set, data.primary); goto DONE; } - if (read_mode == MONGOC_READ_SECONDARY_PREFERRED) { + if (data.read_mode == MONGOC_READ_SECONDARY_PREFERRED) { /* try read_mode SECONDARY */ _mongoc_try_mode_secondary ( set, topology, read_pref, local_threshold_ms); @@ -740,7 +796,7 @@ mongoc_topology_description_suitable_servers ( goto DONE; } - if (read_mode == MONGOC_READ_SECONDARY) { + if (data.read_mode == MONGOC_READ_SECONDARY) { for (i = 0; i < data.candidates_len; i++) { if (candidates[i] && candidates[i]->type != MONGOC_SERVER_RS_SECONDARY) { @@ -762,17 +818,19 @@ mongoc_topology_description_suitable_servers ( mongoc_server_description_filter_tags ( data.candidates, data.candidates_len, read_pref); - } else if (topology->type == MONGOC_TOPOLOGY_RS_WITH_PRIMARY) { - /* includes optype == MONGOC_SS_WRITE as the exclusion of the above if - */ - mongoc_set_for_each_const ( - td_servers, - _mongoc_topology_description_has_primary_cb, - (mongoc_server_description_t *) &data.primary); - if (data.primary) { - _mongoc_array_append_val (set, data.primary); - goto DONE; + } break; + case MONGOC_SS_WRITE: { + if (topology->type == MONGOC_TOPOLOGY_RS_WITH_PRIMARY) { + mongoc_set_for_each_const ( + td_servers, + _mongoc_topology_description_has_primary_cb, + &data.primary); + if (data.primary) { + _mongoc_array_append_val (set, data.primary); + goto DONE; + } } + } break; } } diff --git a/src/libmongoc/tests/test-mongoc-cluster.c b/src/libmongoc/tests/test-mongoc-cluster.c index 09922be7c38..ef7d4ea17a8 100644 --- a/src/libmongoc/tests/test-mongoc-cluster.c +++ b/src/libmongoc/tests/test-mongoc-cluster.c @@ -25,8 +25,8 @@ server_id_for_reads (mongoc_cluster_t *cluster) mongoc_server_stream_t *server_stream; uint32_t id; - server_stream = - mongoc_cluster_stream_for_reads (cluster, NULL, NULL, NULL, &error); + server_stream = mongoc_cluster_stream_for_reads ( + cluster, NULL, NULL, NULL, NOT_AGGR_WITH_WRITE_STAGE, &error); ASSERT_OR_PRINT (server_stream, error); id = server_stream->sd->id; diff --git a/src/libmongoc/tests/test-mongoc-topology.c b/src/libmongoc/tests/test-mongoc-topology.c index 871c5b10b04..981e08467eb 100644 --- a/src/libmongoc/tests/test-mongoc-topology.c +++ b/src/libmongoc/tests/test-mongoc-topology.c @@ -181,7 +181,7 @@ test_topology_client_creation (void) /* ensure that we are sharing streams with the client */ server_stream = mongoc_cluster_stream_for_reads ( - &client_a->cluster, NULL, NULL, NULL, &error); + &client_a->cluster, NULL, NULL, NULL, NOT_AGGR_WITH_WRITE_STAGE, &error); ASSERT_OR_PRINT (server_stream, error); node = mongoc_topology_scanner_get_node (client_a->topology->scanner, @@ -486,7 +486,7 @@ _test_topology_invalidate_server (bool pooled) /* call explicitly */ server_stream = mongoc_cluster_stream_for_reads ( - &client->cluster, NULL, NULL, NULL, &error); + &client->cluster, NULL, NULL, NULL, NOT_AGGR_WITH_WRITE_STAGE, &error); ASSERT_OR_PRINT (server_stream, error); sd = server_stream->sd; id = server_stream->sd->id; @@ -587,7 +587,7 @@ test_invalid_cluster_node (void *ctx) /* load stream into cluster */ server_stream = mongoc_cluster_stream_for_reads ( - &client->cluster, NULL, NULL, NULL, &error); + &client->cluster, NULL, NULL, NULL, NOT_AGGR_WITH_WRITE_STAGE, &error); ASSERT_OR_PRINT (server_stream, error); id = server_stream->sd->id; mongoc_server_stream_cleanup (server_stream); @@ -658,7 +658,7 @@ test_max_wire_version_race_condition (void *ctx) /* load stream into cluster */ server_stream = mongoc_cluster_stream_for_reads ( - &client->cluster, NULL, NULL, NULL, &error); + &client->cluster, NULL, NULL, NULL, NOT_AGGR_WITH_WRITE_STAGE, &error); ASSERT_OR_PRINT (server_stream, error); id = server_stream->sd->id; mongoc_server_stream_cleanup (server_stream); From d27ca8457f850ec7f3406c32ee57b550bc87f9a1 Mon Sep 17 00:00:00 2001 From: vector-of-bool Date: Wed, 1 Dec 2021 11:10:55 -0700 Subject: [PATCH 13/52] Fix trace log variable reference --- .../src/mongoc/mongoc-topology-description.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/src/libmongoc/src/mongoc/mongoc-topology-description.c b/src/libmongoc/src/mongoc/mongoc-topology-description.c index e4a923a0093..e03a68c6373 100644 --- a/src/libmongoc/src/mongoc/mongoc-topology-description.c +++ b/src/libmongoc/src/mongoc/mongoc-topology-description.c @@ -755,7 +755,7 @@ mongoc_topology_description_suitable_servers ( "Rejected [%s] [%s] for read mode [%s] with topology type Single", mongoc_server_description_type (server), server->host.host_and_port, - _mongoc_read_mode_as_str (read_mode)); + _mongoc_read_mode_as_str (effective_read_mode)); } goto DONE; } @@ -803,7 +803,7 @@ mongoc_topology_description_suitable_servers ( TRACE ("Rejected [%s] [%s] for mode [%s] with RS topology", mongoc_server_description_type (candidates[i]), candidates[i]->host.host_and_port, - _mongoc_read_mode_as_str (read_mode)); + _mongoc_read_mode_as_str (effective_read_mode)); candidates[i] = NULL; } } @@ -824,7 +824,7 @@ mongoc_topology_description_suitable_servers ( mongoc_set_for_each_const ( td_servers, _mongoc_topology_description_has_primary_cb, - &data.primary); + (void *) &data.primary); if (data.primary) { _mongoc_array_append_val (set, data.primary); goto DONE; @@ -1914,7 +1914,6 @@ transition_t gSDAMTransitionTable NULL, _mongoc_topology_description_check_if_has_primary}}; -#ifdef MONGOC_TRACE /* *-------------------------------------------------------------------------- * @@ -1932,9 +1931,9 @@ transition_t gSDAMTransitionTable *-------------------------------------------------------------------------- */ static const char * -_mongoc_topology_description_type (mongoc_topology_description_t *topology) +_tpld_type_str (mongoc_topology_description_type_t type) { - switch (topology->type) { + switch (type) { case MONGOC_TOPOLOGY_UNKNOWN: return "Unknown"; case MONGOC_TOPOLOGY_SHARDED: @@ -1953,7 +1952,6 @@ _mongoc_topology_description_type (mongoc_topology_description_t *topology) return "Invalid"; } } -#endif /* @@ -2173,12 +2171,12 @@ mongoc_topology_description_handle_hello ( if (gSDAMTransitionTable[sd->type][topology->type]) { TRACE ("Topology description %s handling server description %s", - _mongoc_topology_description_type (topology), + _tpld_type_str (topology->type), mongoc_server_description_type (sd)); gSDAMTransitionTable[sd->type][topology->type](topology, sd); } else { TRACE ("Topology description %s ignoring server description %s", - _mongoc_topology_description_type (topology), + _tpld_type_str (topology->type), mongoc_server_description_type (sd)); } From 75667538df5c8f5fd4bcff7a184c3fa80a4acdd8 Mon Sep 17 00:00:00 2001 From: vector-of-bool Date: Thu, 2 Dec 2021 22:03:03 +0000 Subject: [PATCH 14/52] Initial support for automatic server test fixtures --- CMakeLists.txt | 3 + build/cmake/FindMongoDB.cmake | 271 ++++++++++++++++++++++++++++++++++ build/cmake/LoadTests.cmake | 36 +++-- build/cmake/mdb-ctrl.cmake | 64 ++++++++ 4 files changed, 364 insertions(+), 10 deletions(-) create mode 100644 build/cmake/FindMongoDB.cmake create mode 100644 build/cmake/mdb-ctrl.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 2ca69adc995..6b9b5de7fff 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -84,6 +84,9 @@ include (CCache) # Link with LLD, if possible include (LLDLinker) +find_package (MongoDB) +mongodb_setup_fixtures () + set (BUILD_VERSION "0.0.0" CACHE STRING "Library version (for both libbson and libmongoc)") include (ParseVersion) diff --git a/build/cmake/FindMongoDB.cmake b/build/cmake/FindMongoDB.cmake new file mode 100644 index 00000000000..dcbd99773b1 --- /dev/null +++ b/build/cmake/FindMongoDB.cmake @@ -0,0 +1,271 @@ +if (MongoDB_FIND_COMPONENTS) + message (SEND_ERROR "FindMongoDB does not take any components") +endif () + +include (FindPackageHandleStandardArgs) + +define_property (GLOBAL PROPERTY MONGODB_FOUND_VERSIONS + BRIEF_DOCS "Versions of MongoDB that have been found" + FULL_DOCS "List of versions of MongoDB server executables that have been found" + ) + +set(MONGODB_DEFAULT_TEST_FIXTURE_VERSIONS + "ALL" CACHE STRING + "List of MongoDB server versions against which to generate default test fixtures" + ) + +function (_get_mongod_version mongod_exe) + # Create an ident for the filepath, since cache variables need to be cleanly named + string (MAKE_C_IDENTIFIER "${mongod_exe}" mongod_exe_id) + # The outupt from the executable will be cached in this variable: + set (_cache_var "_MONGOD_EXE_${mongod_exe_id}_VERSION_OUTPUT") + # If we haven't run it, execute it now: + if (NOT DEFINED "${_cache_var}") + message (STATUS "Checking mongod executable: ${mongod_exe}") + execute_process ( + COMMAND "${mongod_exe}" --version + TIMEOUT 1 + OUTPUT_VARIABLE out + RESULT_VARIABLE retc + ) + if (retc) + # Execution failed, for some reason. Probably not a valid executable? + message (STATUS "Ignoring failing executable: ${mongod_exe}") + set ("${_cache_var}" FAIL CACHE INTERNAL "Failure from ${mongod_exe}") + else () + # Escape the output, since cache variables cannot have some characters + string (REPLACE "$" "$dollar" out "${out}") + string (REPLACE "\n" "$newline" out "${out}") + # Define a cache variable so that we don't need to run the executable every time + set ("${_cache_var}" "${out}" + CACHE INTERNAL "Output from: ${mongod_exe} --version") + endif () + endif () + # Get the output from --version for the given executable + set (_version_output "${${_cache_var}}") + if (_version_output STREQUAL "FAIL") + # This executable didn't succeed when executed with --version + return () + endif () + # The version output was escaped when stored in the cache + string (REPLACE "$newline" "\n" _version_output "${_version_output}") + string (REPLACE "$dollar" "$" _version_output "${_version_output}") + if (_version_output MATCHES [["version": "([0-9]+\.[0-9]+\.[0-9])((-[0-9a-zA-Z]+)([^"]*))?",]]) + # Match newer versions' output + set (version "${CMAKE_MATCH_1}${CMAKE_MATCH_3}") + elseif (_version_output MATCHES [[db version v([0-9]+\.[0-9]+\.[0-9]+)]]) + # Match older versions' output + set (version "${CMAKE_MATCH_1}") + else () + # Didn't understand the output of this one + message (WARNING "Unknown version output (from ${mongod_exe}): ${_version_output}") + return () + endif () + # Define a property to store the path for this version + set (_version_var "MONGODB_${version}_PATH") + get_property (already GLOBAL PROPERTY "${_version_var}") + if (already) + # We've already found an executable for this version + return () + endif () + # Define that property + define_property (GLOBAL PROPERTY "${_version_var}" + BRIEF_DOCS "Path for MongoDB ${version} Server" + FULL_DOCS "Absolute path to the server executable for MongoDB version ${version}" + ) + set_property (GLOBAL PROPERTY "${_version_var}" "${mongod_exe}") + # Append to the global list of versions that we have found + set_property (GLOBAL APPEND PROPERTY MONGODB_FOUND_VERSIONS "${version}") +endfunction () + +macro (_scan_for_mdb bindir extension) + set (__bindir "${bindir}") + set (__ext "${extension}") + get_filename_component (candidate "${__bindir}/mongod${__ext}" ABSOLUTE) + if (EXISTS "${candidate}") + _get_mongod_version ("${candidate}") + endif () +endmacro () + +function (_mongodb_find) + # Check if the user has 'm' installed: + if (DEFINED ENV{M_PREFIX}) + set (m_prefix "$ENV{M_PREFIX}") + else () + set (m_prefix "/usr/local") + endif () + + # Glob each version that is installed by 'm' + file (GLOB m_version_dirs "${m_prefix}/m/versions/*/bin") + + # Collect all paths from the environment + set (env_path "$ENV{PATH}") + if (NOT WIN32) + string (REPLACE ":" ";" env_path "$ENV{PATH}") + endif () + # Remove dups + set (paths ${m_version_dirs} ${env_path}) + list (REMOVE_DUPLICATES paths) + + # Scan for executables + foreach (bindir IN LISTS paths) + if (DEFINED ENV{PATHEXT}) + foreach (ext IN LISTS ENV{PATHEXT}) + _scan_for_mdb ("${bindir}" "${ext}") + endforeach () + else () + _scan_for_mdb ("${bindir}" "") + endif () + endforeach () + + get_property (found GLOBAL PROPERTY MONGODB_FOUND_VERSIONS) + set (new_found "${found}") + list (REMOVE_ITEM new_found ~~~ ${_MDB_PREVIOUSLY_FOUND_VERSIONS}) + if (new_found) + set_property (GLOBAL PROPERTY MONGODB_FOUND_VERSIONS "${new_found}") + message (STATUS "The following MongoDB server executable versions were found:") + foreach (version IN LISTS new_found) + get_property (path GLOBAL PROPERTY "MONGODB_${version}_PATH") + message (STATUS " - ${version}:") + message (STATUS " ${path}") + endforeach () + set (MongoDB_FOUND TRUE PARENT_SCOPE) + endif () + set (_MDB_PREVIOUSLY_FOUND_VERSIONS "${found}" CACHE INTERNAL "") +endfunction () + +_mongodb_find () + +#[[ + Generate CTest test fixtures for every MongoDB version that has been found, as + determined by the MONGODB_FOUND_VERSIONS global property. The generated fixtures + are named as 'default-' for each '' that was found. +]] +function (mongodb_setup_fixtures) + set (versions ${MONGODB_DEFAULT_TEST_FIXTURE_VERSIONS}) + if (versions STREQUAL "ALL") + get_cmake_property (versions MONGODB_FOUND_VERSIONS) + endif () + foreach (ver IN LISTS versions) + mongodb_create_fixture ( + "default-${ver}" + AUTOUSE + VERSION "${ver}" + SERVER_ARGS --setParameter enableTestCommands=1 + ) + endforeach () +endfunction () + +#[[ + Create a CTest test fixture that will start, stop, and clean up a MongoDB server + instance for other tests. + + mongodb_create_fixture( + + VERSION + [PORT_VARIABLE ] + [SERVER_ARGS ...] + ) + + and are the only required arguments. VERSION must specify a + MongoDB server version that has a known path. There must be a + MONGODB__PATH global property that defines the path to a mongod + executable file. These global properties are set by the FindMongoDB.cmake + module when it is first imported. The list of available versions can be + found in the MONGODB_FOUND_VERSIONS global property. + + is an output variable name. Each generated fixture uses a different + TCP port when listening so that fixtures can execute in parallel without contending. + This variable will be set in the caller's scope to the integer TCP port that will + be used by the test fixture. + + ... is a list of command-line arguments to supply to the server when it is + started. This can be any option *except* '--fork', '--port', '--dbpath', '--logpath', + or '--pidfilepath', all of which are already specified for the test fixture. + + The fixture can then be associated with tests via the FIXTURES_REQUIRED + test property. +]] +function (mongodb_create_fixture name) + cmake_parse_arguments (ARG + "AUTOUSE" + "PORT_VARIABLE;VERSION" + "SERVER_ARGS" + ${ARGN} + ) + if (NOT ARG_VERSION) + message (SEND_ERROR "A VERSION is required") + return () + endif () + get_cmake_property (path "MONGODB_${ARG_VERSION}_PATH") + if (NOT path) + message (SEND_ERROR "Cannot create a test fixture for MongoDB version ${ARG_VERSION}, which is not found") + endif () + get_cmake_property (port "_MDB_UNUSED_PORT") + math (EXPR next "${port} + 3") + set_property (GLOBAL PROPERTY _MDB_UNUSED_PORT "${next}") + add_test (NAME mdb/fixture/${name}/setup + COMMAND "${CMAKE_COMMAND}" + -D "FIXTURE_NAME=${name}" + -D "RUNDIR=${PROJECT_BINARY_DIR}" + -D "MDB_EXE=${path}" + -D MDB_PORT=${port} + -D DO=START + -D "SERVER_ARGS=${ARG_SERVER_ARGS}" + -P ${_MDB_SCRIPT_DIR}/mdb-ctrl.cmake + ) + add_test (NAME mdb/fixture/${name}/cleanup + COMMAND "${CMAKE_COMMAND}" + -D "FIXTURE_NAME=${name}" + -D "RUNDIR=${PROJECT_BINARY_DIR}" + -D "MDB_EXE=${path}" + -D DO=STOP + -P ${_MDB_SCRIPT_DIR}/mdb-ctrl.cmake + ) + set_property (TEST mdb/fixture/${name}/setup PROPERTY FIXTURES_SETUP "${name}") + set_property (TEST mdb/fixture/${name}/cleanup PROPERTY FIXTURES_CLEANUP "${name}") + set_property ( + TEST mdb/fixture/${name}/setup mdb/fixture/${name}/cleanup + PROPERTY TIMEOUT 10) + if (ARG_PORT_VARIABLE) + set ("${ARG_PORT_VARIABLE}" "${port}") + endif () + set_property (TARGET _mdb-test-meta + APPEND PROPERTY _CONTENT + "# Test fixture '${name}'" + "set(_fxt [[${name}]])" + "list(APPEND _MDB_TEST_FIXTURES [[${name}]])" + "set(\"_MDB_FIXTURE_\${_fxt}_PORT\" ${port})" + ) + if (ARG_AUTOUSE) + set_property (GLOBAL APPEND PROPERTY MDB_TEST_AUTOUSE_FIXTURES "${name}") + set_property (TARGET _mdb-test-meta + APPEND PROPERTY _CONTENT + "list(APPEND _MDB_TEST_FIXTURES_AUTO_USE [[${name}]])" + ) + endif () +endfunction () + +include (CMakeParseArguments) + +set (_MDB_SCRIPT_DIR "${CMAKE_CURRENT_LIST_DIR}") +set_property (GLOBAL PROPERTY _MDB_UNUSED_PORT 51231) +set_property (GLOBAL PROPERTY MDB_TEST_AUTOUSE_FIXTURES "") + +if (NOT TARGET _mdb-test-meta) + add_custom_target (_mdb-test-meta) + file (GENERATE + OUTPUT "${PROJECT_BINARY_DIR}/MongoDB-CTestData.cmake" + CONTENT "$,\n>\n") + set_property(TARGET _mdb-test-meta + PROPERTY _CONTENT + [[# THIS FILE IS GENERATED. DO NOT EDIT.]] + "set(_MDB_TEST_FIXTURES)" + "set(_MDB_TEST_FIXTURES_AUTO_USE)\n" + ) + set_property (DIRECTORY APPEND PROPERTY TEST_INCLUDE_FILES "${PROJECT_BINARY_DIR}/MongoDB-CTestData.cmake") +endif () + +get_cmake_property(versions MONGODB_FOUND_VERSIONS) +string(REPLACE ";" ", " versions "${versions}") +message(STATUS "MongoDB versions ${versions} are available for test fixtures") diff --git a/build/cmake/LoadTests.cmake b/build/cmake/LoadTests.cmake index d310899fedb..cb5135a66cf 100644 --- a/build/cmake/LoadTests.cmake +++ b/build/cmake/LoadTests.cmake @@ -26,17 +26,10 @@ endif () # Split lines on newlines string (REPLACE "\n" ";" lines "${tests_out}") -# Generate the test definitions -foreach (line IN LISTS lines) - if (NOT line MATCHES "^/") - # Only generate if the line begins with `/`, which all tests should. - continue () - endif () - # The new test name is prefixed with 'mongoc' - set (test "mongoc${line}") +function (_register_test name ctest_run) # Define the test. Use `--ctest-run` to tell it that CTest is in control. - add_test ("${test}" "${TEST_LIBMONGOC_EXE}" --ctest-run "${line}") - set_tests_properties ("${test}" PROPERTIES + add_test ("${name}" "${TEST_LIBMONGOC_EXE}" --ctest-run "${line}" ${ARGN}) + set_tests_properties ("${name}" PROPERTIES # test-libmongoc expects to execute in the root of the source directory WORKING_DIRECTORY "${SRC_ROOT}" # If a test emits '@@ctest-skipped@@', this tells us that the test is @@ -45,4 +38,27 @@ foreach (line IN LISTS lines) # 45 seconds of timeout on each test. TIMEOUT 45 ) +endfunction () + +# Generate the test definitions +foreach (line IN LISTS lines) + if (NOT line MATCHES "^/") + # Only generate if the line begins with `/`, which all tests should. + continue () + endif () + # The new test name is prefixed with 'mongoc' + set (test "mongoc${line}") + if (NOT _MDB_TEST_FIXTURES_AUTO_USE) + _register_test ("${test}" "${line}") + else () + foreach (fxt IN LISTS _MDB_TEST_FIXTURES_AUTO_USE) + set (qualname "${fxt}/${test}") + _register_test ("${qualname}" "${line}") + set_tests_properties ("${qualname}" PROPERTIES + FIXTURES_REQUIRED "${fxt}" + RESOURCE_LOCK "${fxt}" + ENVIRONMENT "MONGOC_TEST_URI=mongodb://localhost:${_MDB_FIXTURE_${fxt}_PORT}" + ) + endforeach () + endif () endforeach () diff --git a/build/cmake/mdb-ctrl.cmake b/build/cmake/mdb-ctrl.cmake new file mode 100644 index 00000000000..5fc0a08275f --- /dev/null +++ b/build/cmake/mdb-ctrl.cmake @@ -0,0 +1,64 @@ +# Fixture properties: +get_filename_component (__fixture_dir "${RUNDIR}/_test-db/${FIXTURE_NAME}" ABSOLUTE) +set (__mongod_exe "${MDB_EXE}") + +# Start up a clean MongoDB server in the fixture directory. Existing data will be deleted. +function (_start port server_argv) + if (IS_DIRECTORY "${__fixture_dir}" + AND NOT EXISTS "${__fixture_dir}/stopped.stamp") + _try_stop (_) + endif () + file (REMOVE_RECURSE "${__fixture_dir}") + file (MAKE_DIRECTORY "${__fixture_dir}/data") + execute_process ( + COMMAND "${__mongod_exe}" + ${server_argv} + --port "${port}" + --pidfilepath "${__fixture_dir}/mdb.pid" + --fork + --verbose + --logpath "${__fixture_dir}/server.log" + --dbpath "${__fixture_dir}/data" + RESULT_VARIABLE retc + ) + if (retc) + message (SEND_ERROR "Failed to start the MongoDB server [${retc}]") + _stop () + endif () + file (REMOVE "${__fixture_dir}/stopped.stamp") +endfunction () + +# Try to stop the fixture server, but not a hard-error if it fails +function (_try_stop okvar) + execute_process( + COMMAND "${__mongod_exe}" ${server_argv} + --pidfilepath "${__fixture_dir}/mdb.pid" + --dbpath "${__fixture_dir}/data" + --shutdown + RESULT_VARIABLE retc + ) + if (retc) + message (STATUS "Failed to stop the MongoDB server [${retc}]") + set ("${okvar}" FALSE PARENT_SCOPE) + else () + set ("${okvar}" TRUE PARENT_SCOPE) + file (WRITE "${__fixture_dir}/stopped.stamp") + endif () +endfunction () + +# Stop the fixture server, or fail the test +function (_stop) + _try_stop (did_stop) + if (NOT did_stop) + message (FATAL_ERROR "Failed to stop the MongoDB server") + endif () +endfunction () + +# Pick the action +if (DO STREQUAL "START") + _start ("${MDB_PORT}" "${SERVER_ARGS}") +elseif (DO STREQUAL "STOP") + _stop () +else () + message (FATAL_ERROR "mdb-ctrl.cmake requires a DO action of 'START' or 'STOP'") +endif () From f1be019a04b0d1f9ec439ab614deac3af7304c37 Mon Sep 17 00:00:00 2001 From: vector-of-bool Date: Fri, 3 Dec 2021 01:10:28 +0000 Subject: [PATCH 15/52] Pass around the effectively chosen read mode used in server selection back to the command builder --- src/libmongoc/src/mongoc/mongoc-client.c | 18 ++++++---- src/libmongoc/src/mongoc/mongoc-cluster.c | 13 ++++--- src/libmongoc/src/mongoc/mongoc-cmd.c | 18 +++++++++- .../src/mongoc/mongoc-cursor-private.h | 7 ++++ src/libmongoc/src/mongoc/mongoc-cursor.c | 8 +++++ .../src/mongoc/mongoc-server-stream-private.h | 4 +++ .../src/mongoc/mongoc-server-stream.c | 1 + .../mongoc-topology-description-private.h | 2 ++ .../src/mongoc/mongoc-topology-description.c | 33 ++++++++++++----- .../src/mongoc/mongoc-topology-private.h | 10 ++++++ src/libmongoc/src/mongoc/mongoc-topology.c | 27 +++++++++----- src/libmongoc/tests/json-test.c | 5 +-- .../tests/mock_server/future-functions.c | 1 + src/libmongoc/tests/test-mongoc-bulk.c | 4 +-- .../tests/test-mongoc-client-session.c | 2 +- src/libmongoc/tests/test-mongoc-client.c | 2 +- src/libmongoc/tests/test-mongoc-cursor.c | 7 ++-- src/libmongoc/tests/test-mongoc-dns.c | 1 + .../tests/test-mongoc-max-staleness.c | 11 +++--- .../tests/test-mongoc-primary-stepdown.c | 35 +++++++++++++------ .../tests/test-mongoc-retryable-reads.c | 6 ++-- .../tests/test-mongoc-retryable-writes.c | 2 +- .../tests/test-mongoc-topology-reconcile.c | 2 +- src/libmongoc/tests/test-mongoc-topology.c | 4 +-- .../tests/test-mongoc-transactions.c | 2 +- 25 files changed, 163 insertions(+), 62 deletions(-) diff --git a/src/libmongoc/src/mongoc/mongoc-client.c b/src/libmongoc/src/mongoc/mongoc-client.c index e882c49e2ca..b70d48d6e6e 100644 --- a/src/libmongoc/src/mongoc/mongoc-client.c +++ b/src/libmongoc/src/mongoc/mongoc-client.c @@ -2603,8 +2603,12 @@ mongoc_client_kill_cursor (mongoc_client_t *client, int64_t cursor_id) } /* see if there's a known writable server - do no I/O or retries */ - selected_server = mongoc_topology_description_select ( - td.ptr, MONGOC_SS_WRITE, read_prefs, topology->local_threshold_msec); + selected_server = + mongoc_topology_description_select (td.ptr, + MONGOC_SS_WRITE, + read_prefs, + NULL /* chosen read mode */, + topology->local_threshold_msec); if (selected_server) { server_id = selected_server->id; @@ -2867,7 +2871,8 @@ mongoc_client_select_server (mongoc_client_t *client, return NULL; } - sd = mongoc_topology_select (client->topology, optype, prefs, error); + sd = mongoc_topology_select ( + client->topology, optype, prefs, NULL /* chosen read mode */, error); if (!sd) { return NULL; } @@ -2879,7 +2884,8 @@ mongoc_client_select_server (mongoc_client_t *client, /* check failed, retry once */ mongoc_server_description_destroy (sd); - sd = mongoc_topology_select (client->topology, optype, prefs, error); + sd = mongoc_topology_select ( + client->topology, optype, prefs, NULL /* chosen read mode */, error); if (sd) { return sd; } @@ -3014,8 +3020,8 @@ _mongoc_client_end_sessions (mongoc_client_t *client) while (!mongoc_server_session_pool_is_empty (t->session_pool)) { prefs = mongoc_read_prefs_new (MONGOC_READ_PRIMARY_PREFERRED); - server_id = - mongoc_topology_select_server_id (t, MONGOC_SS_READ, prefs, &error); + server_id = mongoc_topology_select_server_id ( + t, MONGOC_SS_READ, prefs, NULL /* chosen read mode */, &error); mongoc_read_prefs_destroy (prefs); if (!server_id) { diff --git a/src/libmongoc/src/mongoc/mongoc-cluster.c b/src/libmongoc/src/mongoc/mongoc-cluster.c index 2d0a1d66f95..434f77b464a 100644 --- a/src/libmongoc/src/mongoc/mongoc-cluster.c +++ b/src/libmongoc/src/mongoc/mongoc-cluster.c @@ -2707,6 +2707,7 @@ _mongoc_cluster_select_server_id (mongoc_client_session_t *cs, mongoc_topology_t *topology, mongoc_ss_optype_t optype, const mongoc_read_prefs_t *read_prefs, + mongoc_read_mode_t *chosen_read_mode, bson_error_t *error) { uint32_t server_id; @@ -2715,14 +2716,14 @@ _mongoc_cluster_select_server_id (mongoc_client_session_t *cs, server_id = cs->server_id; if (!server_id) { server_id = mongoc_topology_select_server_id ( - topology, optype, read_prefs, error); + topology, optype, read_prefs, chosen_read_mode, error); if (server_id) { _mongoc_client_session_pin (cs, server_id); } } } else { - server_id = - mongoc_topology_select_server_id (topology, optype, read_prefs, error); + server_id = mongoc_topology_select_server_id ( + topology, optype, read_prefs, chosen_read_mode, error); /* Transactions Spec: Additionally, any non-transaction operation using a * pinned ClientSession MUST unpin the session and the operation MUST * perform normal server selection. */ @@ -2763,13 +2764,14 @@ _mongoc_cluster_stream_for_optype (mongoc_cluster_t *cluster, mongoc_server_stream_t *server_stream; uint32_t server_id; mongoc_topology_t *topology = cluster->client->topology; + mongoc_read_mode_t chosen_read_mode = (mongoc_read_mode_t) 0; ENTRY; BSON_ASSERT (cluster); server_id = _mongoc_cluster_select_server_id ( - cs, topology, optype, read_prefs, error); + cs, topology, optype, read_prefs, &chosen_read_mode, error); if (!server_id) { _mongoc_bson_init_with_transient_txn_error (cs, reply); @@ -2779,7 +2781,7 @@ _mongoc_cluster_stream_for_optype (mongoc_cluster_t *cluster, if (!mongoc_cluster_check_interval (cluster, server_id)) { /* Server Selection Spec: try once more */ server_id = _mongoc_cluster_select_server_id ( - cs, topology, optype, read_prefs, error); + cs, topology, optype, read_prefs, &chosen_read_mode, error); if (!server_id) { _mongoc_bson_init_with_transient_txn_error (cs, reply); @@ -2790,6 +2792,7 @@ _mongoc_cluster_stream_for_optype (mongoc_cluster_t *cluster, /* connect or reconnect to server if necessary */ server_stream = _mongoc_cluster_stream_for_server ( cluster, server_id, true /* reconnect_ok */, cs, reply, error); + server_stream->effective_read_mode = chosen_read_mode; RETURN (server_stream); } diff --git a/src/libmongoc/src/mongoc/mongoc-cmd.c b/src/libmongoc/src/mongoc/mongoc-cmd.c index 47813ff958a..9754e3da19c 100644 --- a/src/libmongoc/src/mongoc/mongoc-cmd.c +++ b/src/libmongoc/src/mongoc/mongoc-cmd.c @@ -473,6 +473,13 @@ _mongoc_cmd_parts_assemble_mongos (mongoc_cmd_parts_t *parts, hedge = mongoc_read_prefs_get_hedge (parts->read_prefs); } + if (server_stream->effective_read_mode != (mongoc_read_mode_t) 0) { + /* Server selection may have overriden the read mode used to generate this + * server stream. This has effects on the body of the message that we send + * to the server */ + mode = server_stream->effective_read_mode; + } + /* Server Selection Spec says: * * For mode 'primary', drivers MUST NOT set the secondaryOk wire protocol @@ -818,6 +825,7 @@ mongoc_cmd_parts_assemble (mongoc_cmd_parts_t *parts, const char *cmd_name; bool is_get_more; const mongoc_read_prefs_t *prefs_ptr; + mongoc_read_mode_t mode = (mongoc_read_mode_t) 0; bool ret = false; ENTRY; @@ -876,6 +884,14 @@ mongoc_cmd_parts_assemble (mongoc_cmd_parts_t *parts, prefs_ptr = parts->read_prefs; } + mode = mongoc_read_prefs_get_mode (prefs_ptr); + if (server_stream->effective_read_mode != (mongoc_read_mode_t) 0) { + /* Server selection may have overriden the read mode used to generate this + * server stream. This has effects on the body of the message that we send + * to the server */ + mode = server_stream->effective_read_mode; + } + if (server_stream->sd->max_wire_version >= WIRE_VERSION_OP_MSG) { if (!bson_has_field (parts->body, "$db")) { BSON_APPEND_UTF8 (&parts->extra, "$db", parts->assembled.db_name); @@ -890,7 +906,7 @@ mongoc_cmd_parts_assemble (mongoc_cmd_parts_t *parts, "Read preference in a transaction must be primary"); GOTO (done); } - } else if (!IS_PREF_PRIMARY (prefs_ptr) && + } else if (mode != MONGOC_READ_PRIMARY && server_type != MONGOC_SERVER_STANDALONE) { /* "Type Standalone: clients MUST NOT send the read preference to the * server" */ diff --git a/src/libmongoc/src/mongoc/mongoc-cursor-private.h b/src/libmongoc/src/mongoc/mongoc-cursor-private.h index f4f3641478d..4e3133f0d09 100644 --- a/src/libmongoc/src/mongoc/mongoc-cursor-private.h +++ b/src/libmongoc/src/mongoc/mongoc-cursor-private.h @@ -132,6 +132,13 @@ struct _mongoc_cursor_t { mongoc_read_prefs_t *read_prefs; mongoc_write_concern_t *write_concern; + /** If the cursor was created for an operation that might have overridden the + * user's read preferences' read mode, the actually-used read mode will be + * stored here. Otherwise, this is zero. This value should be restored to + * server_stream objects that are created from this cursor when the stream + * was created using the memoized 'server_id' of the cursor. */ + mongoc_read_mode_t effective_read_mode; + /** Whether this cursor corresponds to an aggregate command that contains a * writing-stage */ aggr_with_write_stage_flag is_aggr_with_write_stage; diff --git a/src/libmongoc/src/mongoc/mongoc-cursor.c b/src/libmongoc/src/mongoc/mongoc-cursor.c index b22248f1f3a..d7c4131ba99 100644 --- a/src/libmongoc/src/mongoc/mongoc-cursor.c +++ b/src/libmongoc/src/mongoc/mongoc-cursor.c @@ -655,6 +655,8 @@ _mongoc_cursor_fetch_stream (mongoc_cursor_t *cursor) ENTRY; if (cursor->server_id) { + /* We already did server selection once before. Reuse the prior + * selection to create a new stream in a new stream. */ server_stream = mongoc_cluster_stream_for_server (&cursor->client->cluster, cursor->server_id, @@ -662,6 +664,9 @@ _mongoc_cursor_fetch_stream (mongoc_cursor_t *cursor) cursor->client_session, &reply, &cursor->error); + /* Also restore the effective read mode that was used on that prior + * selection */ + server_stream->effective_read_mode = cursor->effective_read_mode; } else { server_stream = mongoc_cluster_stream_for_reads (&cursor->client->cluster, @@ -672,7 +677,10 @@ _mongoc_cursor_fetch_stream (mongoc_cursor_t *cursor) &cursor->error); if (server_stream) { + /* Remember the selected server_id and the effective read mode so that + * we can re-create an equivalent server_stream at a later time */ cursor->server_id = server_stream->sd->id; + cursor->effective_read_mode = server_stream->effective_read_mode; } } diff --git a/src/libmongoc/src/mongoc/mongoc-server-stream-private.h b/src/libmongoc/src/mongoc/mongoc-server-stream-private.h index 6a1c61ddce6..fa053d50166 100644 --- a/src/libmongoc/src/mongoc/mongoc-server-stream-private.h +++ b/src/libmongoc/src/mongoc/mongoc-server-stream-private.h @@ -34,6 +34,10 @@ typedef struct _mongoc_server_stream_t { mongoc_server_description_t *sd; /* owned */ bson_t cluster_time; /* owned */ mongoc_stream_t *stream; /* borrowed */ + /** If the stream was created in a way that may have overwritten the user's + * readPreference, the effective read mode is stored here, otherwise this is + * just zero. */ + mongoc_read_mode_t effective_read_mode; } mongoc_server_stream_t; diff --git a/src/libmongoc/src/mongoc/mongoc-server-stream.c b/src/libmongoc/src/mongoc/mongoc-server-stream.c index 305db509095..52aa36fc9c6 100644 --- a/src/libmongoc/src/mongoc/mongoc-server-stream.c +++ b/src/libmongoc/src/mongoc/mongoc-server-stream.c @@ -37,6 +37,7 @@ mongoc_server_stream_new (const mongoc_topology_description_t *td, bson_copy_to (&td->cluster_time, &server_stream->cluster_time); server_stream->sd = sd; /* becomes owned */ server_stream->stream = stream; /* merely borrowed */ + server_stream->effective_read_mode = (mongoc_read_mode_t) 0; return server_stream; } diff --git a/src/libmongoc/src/mongoc/mongoc-topology-description-private.h b/src/libmongoc/src/mongoc/mongoc-topology-description-private.h index bae0652b818..516a13e8bfd 100644 --- a/src/libmongoc/src/mongoc/mongoc-topology-description-private.h +++ b/src/libmongoc/src/mongoc/mongoc-topology-description-private.h @@ -112,6 +112,7 @@ mongoc_topology_description_select ( const mongoc_topology_description_t *description, mongoc_ss_optype_t optype, const mongoc_read_prefs_t *read_pref, + mongoc_read_mode_t *chosen_read_mode, int64_t local_threshold_ms); mongoc_server_description_t * @@ -146,6 +147,7 @@ mongoc_topology_description_suitable_servers ( mongoc_ss_optype_t optype, const mongoc_topology_description_t *topology, const mongoc_read_prefs_t *read_pref, + mongoc_read_mode_t *chosen_read_mode, size_t local_threshold_ms); bool diff --git a/src/libmongoc/src/mongoc/mongoc-topology-description.c b/src/libmongoc/src/mongoc/mongoc-topology-description.c index e03a68c6373..a3faa823e55 100644 --- a/src/libmongoc/src/mongoc/mongoc-topology-description.c +++ b/src/libmongoc/src/mongoc/mongoc-topology-description.c @@ -484,6 +484,7 @@ static void _mongoc_try_mode_secondary (mongoc_array_t *set, /* OUT */ const mongoc_topology_description_t *topology, const mongoc_read_prefs_t *read_pref, + mongoc_read_mode_t *chosen_read_mode, size_t local_threshold_ms) { mongoc_read_prefs_t *secondary; @@ -491,8 +492,12 @@ _mongoc_try_mode_secondary (mongoc_array_t *set, /* OUT */ secondary = mongoc_read_prefs_copy (read_pref); mongoc_read_prefs_set_mode (secondary, MONGOC_READ_SECONDARY); - mongoc_topology_description_suitable_servers ( - set, MONGOC_SS_READ, topology, secondary, local_threshold_ms); + mongoc_topology_description_suitable_servers (set, + MONGOC_SS_READ, + topology, + secondary, + chosen_read_mode, + local_threshold_ms); mongoc_read_prefs_destroy (secondary); } @@ -720,6 +725,7 @@ mongoc_topology_description_suitable_servers ( mongoc_ss_optype_t optype, const mongoc_topology_description_t *topology, const mongoc_read_prefs_t *read_pref, + mongoc_read_mode_t *chosen_read_mode, size_t local_threshold_ms) { mongoc_suitable_data_t data; @@ -733,6 +739,10 @@ mongoc_topology_description_suitable_servers ( const mongoc_read_mode_t effective_read_mode = _calc_effective_read_mode (topology, optype, given_read_mode); + if (chosen_read_mode) { + *chosen_read_mode = effective_read_mode; + } + candidates = bson_malloc0 (sizeof (*candidates) * td_servers->items_len); data.read_mode = effective_read_mode; @@ -786,7 +796,7 @@ mongoc_topology_description_suitable_servers ( if (data.read_mode == MONGOC_READ_SECONDARY_PREFERRED) { /* try read_mode SECONDARY */ _mongoc_try_mode_secondary ( - set, topology, read_pref, local_threshold_ms); + set, topology, read_pref, chosen_read_mode, local_threshold_ms); /* otherwise fall back to primary */ if (!set->len && data.primary) { @@ -930,6 +940,7 @@ mongoc_topology_description_select ( const mongoc_topology_description_t *topology, mongoc_ss_optype_t optype, const mongoc_read_prefs_t *read_pref, + mongoc_read_mode_t *chosen_read_mode, int64_t local_threshold_ms) { mongoc_array_t suitable_servers; @@ -952,8 +963,12 @@ mongoc_topology_description_select ( _mongoc_array_init (&suitable_servers, sizeof (mongoc_server_description_t *)); - mongoc_topology_description_suitable_servers ( - &suitable_servers, optype, topology, read_pref, local_threshold_ms); + mongoc_topology_description_suitable_servers (&suitable_servers, + optype, + topology, + read_pref, + chosen_read_mode, + local_threshold_ms); if (suitable_servers.len != 0) { rand_n = _mongoc_rand_simple ((unsigned *) &topology->rand_seed); sd = _mongoc_array_index (&suitable_servers, @@ -2225,8 +2240,8 @@ mongoc_topology_description_has_readable_server ( } /* local threshold argument doesn't matter */ - return mongoc_topology_description_select (td, MONGOC_SS_READ, prefs, 0) != - NULL; + return mongoc_topology_description_select ( + td, MONGOC_SS_READ, prefs, NULL, 0) != NULL; } /* @@ -2252,8 +2267,8 @@ mongoc_topology_description_has_writable_server ( return false; } - return mongoc_topology_description_select (td, MONGOC_SS_WRITE, NULL, 0) != - NULL; + return mongoc_topology_description_select ( + td, MONGOC_SS_WRITE, NULL, NULL, 0) != NULL; } /* diff --git a/src/libmongoc/src/mongoc/mongoc-topology-private.h b/src/libmongoc/src/mongoc/mongoc-topology-private.h index d7168540980..4743e9c8de9 100644 --- a/src/libmongoc/src/mongoc/mongoc-topology-private.h +++ b/src/libmongoc/src/mongoc/mongoc-topology-private.h @@ -234,6 +234,10 @@ mongoc_topology_compatible (const mongoc_topology_description_t *td, * @param topology The topology to inspect and/or update. * @param optype The operation that is intended to be performed. * @param read_prefs The read preferences for the command. + * @param chosen_read_mode An option output parameter. If server selection might + * need to override the caller's read preferences' read mode, the actually-used + * read mode will be written to this pointer. If no overriding takes place, then + * the pointed-to value remains unchanged. * @param error An output parameter for any error information. * @return mongoc_server_description_t* A copy of the topology's server * description that matches the request, or NULL if there is no such server. @@ -247,6 +251,7 @@ mongoc_server_description_t * mongoc_topology_select (mongoc_topology_t *topology, mongoc_ss_optype_t optype, const mongoc_read_prefs_t *read_prefs, + mongoc_read_mode_t *chosen_read_mode, bson_error_t *error); /** @@ -258,6 +263,10 @@ mongoc_topology_select (mongoc_topology_t *topology, * @param topology The topology to inspect and/or update. * @param optype The operation that is intended to be performed. * @param read_prefs The read preferences for the command. + * @param chosen_read_mode An option output parameter. If server selection might + * need to override the caller's read preferences' read mode, the actually-used + * read mode will be written to this pointer. If no overriding takes place, then + * the pointed-to value remains unchanged. * @param error An output parameter for any error information. * @return uint32_t A non-zero integer ID of the server description. In case of * error, sets `error` and returns zero. @@ -268,6 +277,7 @@ uint32_t mongoc_topology_select_server_id (mongoc_topology_t *topology, mongoc_ss_optype_t optype, const mongoc_read_prefs_t *read_prefs, + mongoc_read_mode_t *chosen_read_mode, bson_error_t *error); /** diff --git a/src/libmongoc/src/mongoc/mongoc-topology.c b/src/libmongoc/src/mongoc/mongoc-topology.c index 0b6e2b73794..15881843e48 100644 --- a/src/libmongoc/src/mongoc/mongoc-topology.c +++ b/src/libmongoc/src/mongoc/mongoc-topology.c @@ -957,10 +957,11 @@ mongoc_server_description_t * mongoc_topology_select (mongoc_topology_t *topology, mongoc_ss_optype_t optype, const mongoc_read_prefs_t *read_prefs, + mongoc_read_mode_t *chosen_read_mode, bson_error_t *error) { - uint32_t server_id = - mongoc_topology_select_server_id (topology, optype, read_prefs, error); + uint32_t server_id = mongoc_topology_select_server_id ( + topology, optype, read_prefs, chosen_read_mode, error); if (server_id) { /* new copy of the server description */ @@ -1000,8 +1001,12 @@ _mongoc_topology_select_server_id_loadbalanced (mongoc_topology_t *topology, mc_tpld_modify_commit (tdmod); mc_tpld_renew_ref (&td, topology); } - selected_server = mongoc_topology_description_select ( - td.ptr, MONGOC_SS_WRITE, NULL /* read prefs */, 0 /* local threshold */); + selected_server = + mongoc_topology_description_select (td.ptr, + MONGOC_SS_WRITE, + NULL /* read prefs */, + NULL /* chosen read mode */, + 0 /* local threshold */); if (!selected_server) { _mongoc_server_selection_error ( @@ -1079,6 +1084,7 @@ uint32_t mongoc_topology_select_server_id (mongoc_topology_t *topology, mongoc_ss_optype_t optype, const mongoc_read_prefs_t *read_prefs, + mongoc_read_mode_t *chosen_read_mode, bson_error_t *error) { static const char *timeout_msg = @@ -1194,7 +1200,7 @@ mongoc_topology_select_server_id (mongoc_topology_t *topology, } selected_server = mongoc_topology_description_select ( - td.ptr, optype, read_prefs, local_threshold_ms); + td.ptr, optype, read_prefs, chosen_read_mode, local_threshold_ms); if (selected_server) { server_id = selected_server->id; @@ -1240,7 +1246,7 @@ mongoc_topology_select_server_id (mongoc_topology_t *topology, } selected_server = mongoc_topology_description_select ( - td.ptr, optype, read_prefs, local_threshold_ms); + td.ptr, optype, read_prefs, chosen_read_mode, local_threshold_ms); if (selected_server) { server_id = selected_server->id; @@ -1256,7 +1262,7 @@ mongoc_topology_select_server_id (mongoc_topology_t *topology, * occurred while we were waiting on the lock. */ mc_tpld_renew_ref (&td, topology); selected_server = mongoc_topology_description_select ( - td.ptr, optype, read_prefs, local_threshold_ms); + td.ptr, optype, read_prefs, chosen_read_mode, local_threshold_ms); if (selected_server) { server_id = selected_server->id; bson_mutex_unlock (&topology->tpld_modification_mtx); @@ -1525,8 +1531,11 @@ _mongoc_topology_pop_server_session (mongoc_topology_t *topology, if (!loadbalanced && timeout == MONGOC_NO_SESSIONS) { /* if needed, connect and check for session timeout again */ if (!mongoc_topology_description_has_data_node (td.ptr)) { - if (!mongoc_topology_select_server_id ( - topology, MONGOC_SS_READ, NULL, error)) { + if (!mongoc_topology_select_server_id (topology, + MONGOC_SS_READ, + NULL /* read prefs */, + NULL /* chosen read mode */, + error)) { ss = NULL; goto done; } diff --git a/src/libmongoc/tests/json-test.c b/src/libmongoc/tests/json-test.c index 01886d8eb5f..a9d9a7fac1c 100644 --- a/src/libmongoc/tests/json-test.c +++ b/src/libmongoc/tests/json-test.c @@ -502,6 +502,7 @@ test_server_selection_logic_cb (bson_t *test) op, &topology, read_prefs, + NULL, MONGOC_TOPOLOGY_LOCAL_THRESHOLD_MS); /* check each server in expected_servers is in selected_servers */ @@ -1178,7 +1179,7 @@ execute_test (const json_test_config_t *config, /* Select a primary for testing */ server_id = mongoc_topology_select_server_id ( - client->topology, MONGOC_SS_WRITE, NULL, &error); + client->topology, MONGOC_SS_WRITE, NULL, NULL, &error); ASSERT_OR_PRINT (server_id, error); json_test_ctx_init (&ctx, test, client, db, collection, config); @@ -1759,7 +1760,7 @@ run_json_general_test (const json_test_config_t *config) /* clean up in case a previous test aborted */ server_id = mongoc_topology_select_server_id ( - client->topology, MONGOC_SS_WRITE, NULL, &error); + client->topology, MONGOC_SS_WRITE, NULL, NULL, &error); ASSERT_OR_PRINT (server_id, error); deactivate_fail_points (client, server_id); r = mongoc_client_command_with_opts (client, diff --git a/src/libmongoc/tests/mock_server/future-functions.c b/src/libmongoc/tests/mock_server/future-functions.c index 7ce05552798..0ca6271f3b8 100644 --- a/src/libmongoc/tests/mock_server/future-functions.c +++ b/src/libmongoc/tests/mock_server/future-functions.c @@ -1034,6 +1034,7 @@ BSON_THREAD_FUN (background_mongoc_topology_select, data) future_value_get_mongoc_topology_ptr (future_get_param (future, 0)), future_value_get_mongoc_ss_optype_t (future_get_param (future, 1)), future_value_get_const_mongoc_read_prefs_ptr (future_get_param (future, 2)), + NULL /* chosen read mode, unused here */, future_value_get_bson_error_ptr (future_get_param (future, 3)) )); diff --git a/src/libmongoc/tests/test-mongoc-bulk.c b/src/libmongoc/tests/test-mongoc-bulk.c index 1fb50ec7cce..e3fe24c3f98 100644 --- a/src/libmongoc/tests/test-mongoc-bulk.c +++ b/src/libmongoc/tests/test-mongoc-bulk.c @@ -4099,8 +4099,8 @@ server_id_for_read_mode (mongoc_client_t *client, mongoc_read_mode_t read_mode) uint32_t server_id; prefs = mongoc_read_prefs_new (read_mode); - sd = - mongoc_topology_select (client->topology, MONGOC_SS_READ, prefs, &error); + sd = mongoc_topology_select ( + client->topology, MONGOC_SS_READ, prefs, NULL, &error); ASSERT_OR_PRINT (sd, error); server_id = sd->id; diff --git a/src/libmongoc/tests/test-mongoc-client-session.c b/src/libmongoc/tests/test-mongoc-client-session.c index b3dea857ecf..5541f78f192 100644 --- a/src/libmongoc/tests/test-mongoc-client-session.c +++ b/src/libmongoc/tests/test-mongoc-client-session.c @@ -190,7 +190,7 @@ _test_session_pool_timeout (bool pooled) * trigger discovery */ server_id = mongoc_topology_select_server_id ( - client->topology, MONGOC_SS_READ, NULL, &error); + client->topology, MONGOC_SS_READ, NULL, NULL, &error); ASSERT_OR_PRINT (server_id, error); /* diff --git a/src/libmongoc/tests/test-mongoc-client.c b/src/libmongoc/tests/test-mongoc-client.c index 5eb749df1b6..95620b49d92 100644 --- a/src/libmongoc/tests/test-mongoc-client.c +++ b/src/libmongoc/tests/test-mongoc-client.c @@ -2146,7 +2146,7 @@ test_recovering (void *ctx) read_mode++) { mongoc_read_prefs_set_mode (prefs, read_mode); BSON_ASSERT (!mongoc_topology_select ( - client->topology, MONGOC_SS_READ, prefs, &error)); + client->topology, MONGOC_SS_READ, prefs, NULL, &error)); } mongoc_read_prefs_destroy (prefs); diff --git a/src/libmongoc/tests/test-mongoc-cursor.c b/src/libmongoc/tests/test-mongoc-cursor.c index e3d8f8c243d..eb9878d2ba2 100644 --- a/src/libmongoc/tests/test-mongoc-cursor.c +++ b/src/libmongoc/tests/test-mongoc-cursor.c @@ -1001,7 +1001,8 @@ _test_cursor_new_from_command (const char *cmd_json, r = (0 != mongoc_bulk_operation_execute (bulk, NULL, &error)); ASSERT_OR_PRINT (r, error); - sd = mongoc_topology_select (client->topology, MONGOC_SS_READ, NULL, &error); + sd = mongoc_topology_select ( + client->topology, MONGOC_SS_READ, NULL, NULL, &error); ASSERT_OR_PRINT (sd, error); server_id = sd->id; @@ -1448,8 +1449,8 @@ server_id_for_read_mode (mongoc_client_t *client, mongoc_read_mode_t read_mode) uint32_t server_id; prefs = mongoc_read_prefs_new (read_mode); - sd = - mongoc_topology_select (client->topology, MONGOC_SS_READ, prefs, &error); + sd = mongoc_topology_select ( + client->topology, MONGOC_SS_READ, prefs, NULL, &error); ASSERT_OR_PRINT (sd, error); server_id = sd->id; diff --git a/src/libmongoc/tests/test-mongoc-dns.c b/src/libmongoc/tests/test-mongoc-dns.c index 9dfefa54b7b..1ddee07a104 100644 --- a/src/libmongoc/tests/test-mongoc-dns.c +++ b/src/libmongoc/tests/test-mongoc-dns.c @@ -377,6 +377,7 @@ test_null_error_pointer (void *ctx) ASSERT (!mongoc_topology_select_server_id (client->topology, MONGOC_SS_READ, NULL /* read prefs */, + NULL /* chosen read mode */, NULL /* error */)); mongoc_client_destroy (client); diff --git a/src/libmongoc/tests/test-mongoc-max-staleness.c b/src/libmongoc/tests/test-mongoc-max-staleness.c index 445847463db..1d3b61a7ada 100644 --- a/src/libmongoc/tests/test-mongoc-max-staleness.c +++ b/src/libmongoc/tests/test-mongoc-max-staleness.c @@ -248,8 +248,8 @@ _test_last_write_date (bool pooled) ASSERT_OR_PRINT (r, error); _mongoc_usleep (1000 * 1000); - s0 = - mongoc_topology_select (client->topology, MONGOC_SS_WRITE, NULL, &error); + s0 = mongoc_topology_select ( + client->topology, MONGOC_SS_WRITE, NULL, NULL, &error); ASSERT_OR_PRINT (s0, error); _mongoc_usleep (1000 * 1000); @@ -258,8 +258,8 @@ _test_last_write_date (bool pooled) ASSERT_OR_PRINT (r, error); _mongoc_usleep (1000 * 1000); - s1 = - mongoc_topology_select (client->topology, MONGOC_SS_WRITE, NULL, &error); + s1 = mongoc_topology_select ( + client->topology, MONGOC_SS_WRITE, NULL, NULL, &error); ASSERT_OR_PRINT (s1, error); ASSERT_CMPINT64 (s1->last_write_date_ms, !=, (int64_t) -1); @@ -312,7 +312,8 @@ _test_last_write_date_absent (bool pooled) client = test_framework_new_default_client (); } - sd = mongoc_topology_select (client->topology, MONGOC_SS_READ, NULL, &error); + sd = mongoc_topology_select ( + client->topology, MONGOC_SS_READ, NULL, NULL, &error); ASSERT_OR_PRINT (sd, error); /* lastWriteDate absent */ diff --git a/src/libmongoc/tests/test-mongoc-primary-stepdown.c b/src/libmongoc/tests/test-mongoc-primary-stepdown.c index c6371df75ed..d4a77e7ee73 100644 --- a/src/libmongoc/tests/test-mongoc-primary-stepdown.c +++ b/src/libmongoc/tests/test-mongoc-primary-stepdown.c @@ -143,8 +143,11 @@ test_getmore_iteration (mongoc_client_t *client) /* Store the primary ID. After step down, the primary may be a different * server. We must execute serverStatus against the same server to check * connection counts. */ - primary_id = mongoc_topology_select_server_id ( - client->topology, MONGOC_SS_WRITE, NULL /* read prefs */, &error); + primary_id = mongoc_topology_select_server_id (client->topology, + MONGOC_SS_WRITE, + NULL /* read prefs */, + NULL /* chosen read mode */, + &error); ASSERT_OR_PRINT (primary_id, error); conn_count = _connection_count (client, primary_id); @@ -217,8 +220,11 @@ test_not_primary_keep_pool (mongoc_client_t *client) /* Store the primary ID. After step down, the primary may be a different * server. We must execute serverStatus against the same server to check * connection counts. */ - primary_id = mongoc_topology_select_server_id ( - client->topology, MONGOC_SS_WRITE, NULL /* read prefs */, &error); + primary_id = mongoc_topology_select_server_id (client->topology, + MONGOC_SS_WRITE, + NULL /* read prefs */, + NULL /* chosen read mode */, + &error); ASSERT_OR_PRINT (primary_id, error); conn_count = _connection_count (client, primary_id); res = mongoc_database_command_simple ( @@ -283,8 +289,11 @@ test_not_primary_reset_pool (mongoc_client_t *client) /* Store the primary ID. After step down, the primary may be a different * server. We must execute serverStatus against the same server to check * connection counts. */ - primary_id = mongoc_topology_select_server_id ( - client->topology, MONGOC_SS_WRITE, NULL /* read prefs */, &error); + primary_id = mongoc_topology_select_server_id (client->topology, + MONGOC_SS_WRITE, + NULL /* read prefs */, + NULL /* chosen read mode */, + &error); ASSERT_OR_PRINT (primary_id, error); conn_count = _connection_count (client, primary_id); res = mongoc_database_command_simple ( @@ -353,8 +362,11 @@ test_shutdown_reset_pool (mongoc_client_t *client) /* Store the primary ID. After step down, the primary may be a different * server. We must execute serverStatus against the same server to check * connection counts. */ - primary_id = mongoc_topology_select_server_id ( - client->topology, MONGOC_SS_WRITE, NULL /* read prefs */, &error); + primary_id = mongoc_topology_select_server_id (client->topology, + MONGOC_SS_WRITE, + NULL /* read prefs */, + NULL /* chosen read mode */, + &error); ASSERT_OR_PRINT (primary_id, error); conn_count = _connection_count (client, primary_id); res = mongoc_database_command_simple ( @@ -420,8 +432,11 @@ test_interrupted_shutdown_reset_pool (mongoc_client_t *client) /* Store the primary ID. After step down, the primary may be a different * server. We must execute serverStatus against the same server to check * connection counts. */ - primary_id = mongoc_topology_select_server_id ( - client->topology, MONGOC_SS_WRITE, NULL /* read prefs */, &error); + primary_id = mongoc_topology_select_server_id (client->topology, + MONGOC_SS_WRITE, + NULL /* read prefs */, + NULL /* chosen read mode */, + &error); ASSERT_OR_PRINT (primary_id, error); conn_count = _connection_count (client, primary_id); res = mongoc_database_command_simple ( diff --git a/src/libmongoc/tests/test-mongoc-retryable-reads.c b/src/libmongoc/tests/test-mongoc-retryable-reads.c index fa74d0c8f62..57c2d657208 100644 --- a/src/libmongoc/tests/test-mongoc-retryable-reads.c +++ b/src/libmongoc/tests/test-mongoc-retryable-reads.c @@ -100,7 +100,7 @@ test_cmd_helpers (void *ctx) /* clean up in case a previous test aborted */ server_id = mongoc_topology_select_server_id ( - client->topology, MONGOC_SS_WRITE, NULL, &error); + client->topology, MONGOC_SS_WRITE, NULL, NULL, &error); ASSERT_OR_PRINT (server_id, error); deactivate_fail_points (client, server_id); @@ -185,7 +185,7 @@ test_cmd_helpers (void *ctx) /* read/write agnostic command_simple_with_server_id helper must not retry. */ server_id = mongoc_topology_select_server_id ( - client->topology, MONGOC_SS_WRITE, NULL, &error); + client->topology, MONGOC_SS_WRITE, NULL, NULL, &error); ASSERT_OR_PRINT (server_id, error); _set_failpoint (client); ASSERT (!mongoc_client_command_simple_with_server_id ( @@ -245,7 +245,7 @@ test_retry_reads_off (void *ctx) /* clean up in case a previous test aborted */ server_id = mongoc_topology_select_server_id ( - client->topology, MONGOC_SS_WRITE, NULL, &error); + client->topology, MONGOC_SS_WRITE, NULL, NULL, &error); ASSERT_OR_PRINT (server_id, error); deactivate_fail_points (client, server_id); diff --git a/src/libmongoc/tests/test-mongoc-retryable-writes.c b/src/libmongoc/tests/test-mongoc-retryable-writes.c index 46a48f46348..480599282cc 100644 --- a/src/libmongoc/tests/test-mongoc-retryable-writes.c +++ b/src/libmongoc/tests/test-mongoc-retryable-writes.c @@ -150,7 +150,7 @@ test_command_with_opts (void *ctx) /* clean up in case a previous test aborted */ server_id = mongoc_topology_select_server_id ( - client->topology, MONGOC_SS_WRITE, NULL, &error); + client->topology, MONGOC_SS_WRITE, NULL, NULL, &error); ASSERT_OR_PRINT (server_id, error); deactivate_fail_points (client, server_id); diff --git a/src/libmongoc/tests/test-mongoc-topology-reconcile.c b/src/libmongoc/tests/test-mongoc-topology-reconcile.c index 950e8ed73e8..8300b9cecbb 100644 --- a/src/libmongoc/tests/test-mongoc-topology-reconcile.c +++ b/src/libmongoc/tests/test-mongoc-topology-reconcile.c @@ -71,7 +71,7 @@ selects_server (mongoc_client_t *client, bool result; sd = mongoc_topology_select ( - client->topology, MONGOC_SS_READ, read_prefs, &error); + client->topology, MONGOC_SS_READ, read_prefs, NULL, &error); if (!sd) { fprintf (stderr, "%s\n", error.message); diff --git a/src/libmongoc/tests/test-mongoc-topology.c b/src/libmongoc/tests/test-mongoc-topology.c index 981e08467eb..b3a02004954 100644 --- a/src/libmongoc/tests/test-mongoc-topology.c +++ b/src/libmongoc/tests/test-mongoc-topology.c @@ -714,7 +714,7 @@ test_cooldown_standalone (void) /* second selection doesn't try to call hello: we're in cooldown */ start = bson_get_monotonic_time (); sd = mongoc_topology_select ( - client->topology, MONGOC_SS_READ, primary_pref, &error); + client->topology, MONGOC_SS_READ, primary_pref, NULL, &error); BSON_ASSERT (!sd); /* waited less than 500ms (minHeartbeatFrequencyMS), in fact * didn't wait at all since all nodes are in cooldown */ @@ -2009,7 +2009,7 @@ test_last_server_removed_warning (void) capture_logs (true); description = mongoc_topology_select ( - client->topology, MONGOC_SS_READ, read_prefs, &error); + client->topology, MONGOC_SS_READ, read_prefs, NULL, &error); ASSERT_CAPTURED_LOG ("topology", MONGOC_LOG_LEVEL_WARNING, "Last server removed from topology"); diff --git a/src/libmongoc/tests/test-mongoc-transactions.c b/src/libmongoc/tests/test-mongoc-transactions.c index c0a8d069623..2c3809576f9 100644 --- a/src/libmongoc/tests/test-mongoc-transactions.c +++ b/src/libmongoc/tests/test-mongoc-transactions.c @@ -949,7 +949,7 @@ test_selected_server_is_pinned_to_mongos (void *ctx) BSON_ASSERT (0 == mongoc_client_session_get_server_id (session)); expected_id = mongoc_topology_select_server_id ( - client->topology, MONGOC_SS_WRITE, NULL, &error); + client->topology, MONGOC_SS_WRITE, NULL, NULL, &error); ASSERT_OR_PRINT (expected_id, error); /* session should still be unpinned */ From 493db9b26d7c27a866bd2f0d9ed864688868f4e6 Mon Sep 17 00:00:00 2001 From: vector-of-bool Date: Fri, 3 Dec 2021 21:04:43 +0000 Subject: [PATCH 16/52] effective read mode for a write operation is null --- src/libmongoc/src/mongoc/mongoc-topology-description.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/libmongoc/src/mongoc/mongoc-topology-description.c b/src/libmongoc/src/mongoc/mongoc-topology-description.c index 78de6f0da13..04a06ec5d92 100644 --- a/src/libmongoc/src/mongoc/mongoc-topology-description.c +++ b/src/libmongoc/src/mongoc/mongoc-topology-description.c @@ -687,8 +687,7 @@ _calc_effective_read_mode (const mongoc_topology_description_t *td, } switch (optype) { case MONGOC_SS_WRITE: - BSON_ASSERT (false && "Unexpected optype for _calc_effective_read_mode"); - abort (); + return (mongoc_read_mode_t) 0; case MONGOC_SS_READ: return requested_read_mode; case MONGOC_SS_AGGREGATE_WITH_WRITE: { From 556f12154b8e0c643248ff2829d0cfb0e61d408c Mon Sep 17 00:00:00 2001 From: vector-of-bool Date: Fri, 3 Dec 2021 21:05:05 +0000 Subject: [PATCH 17/52] Fix null deref when failing to recreate a server stream from a removed server --- src/libmongoc/src/mongoc/mongoc-cluster.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/libmongoc/src/mongoc/mongoc-cluster.c b/src/libmongoc/src/mongoc/mongoc-cluster.c index 434f77b464a..f46dd976f13 100644 --- a/src/libmongoc/src/mongoc/mongoc-cluster.c +++ b/src/libmongoc/src/mongoc/mongoc-cluster.c @@ -2792,7 +2792,9 @@ _mongoc_cluster_stream_for_optype (mongoc_cluster_t *cluster, /* connect or reconnect to server if necessary */ server_stream = _mongoc_cluster_stream_for_server ( cluster, server_id, true /* reconnect_ok */, cs, reply, error); - server_stream->effective_read_mode = chosen_read_mode; + if (server_stream) { + server_stream->effective_read_mode = chosen_read_mode; + } RETURN (server_stream); } From f725afa6ccaf144e0e70d3cfd7313eb44cc33ed4 Mon Sep 17 00:00:00 2001 From: vector-of-bool Date: Fri, 3 Dec 2021 21:10:16 +0000 Subject: [PATCH 18/52] test_aggregate_is_sent_to_primary_w_dollar_out is no longer applicable --- src/libmongoc/tests/test-mongoc-collection.c | 56 -------------------- 1 file changed, 56 deletions(-) diff --git a/src/libmongoc/tests/test-mongoc-collection.c b/src/libmongoc/tests/test-mongoc-collection.c index 77e57e842c2..947f4bb836f 100644 --- a/src/libmongoc/tests/test-mongoc-collection.c +++ b/src/libmongoc/tests/test-mongoc-collection.c @@ -3292,56 +3292,6 @@ test_aggregate_server_id_option (void *ctx) mongoc_client_destroy (client); } -static void -test_aggregate_is_sent_to_primary_w_dollar_out (void *ctx) -{ - mongoc_client_t *client; - mongoc_cursor_t *cursor; - bson_error_t error; - bson_t *pipeline; - mongoc_collection_t *collection; - mongoc_read_prefs_t *read_prefs; - const bson_t *doc = NULL; - - capture_logs (true); - - client = test_framework_new_default_client (); - BSON_ASSERT (client); - - pipeline = tmp_bson ("{ 'pipeline': [ { '$out' : 'coll2' } ] }"); - collection = mongoc_client_get_collection (client, "test", "coll"); - read_prefs = mongoc_read_prefs_new (MONGOC_READ_PRIMARY); - - cursor = mongoc_collection_aggregate ( - collection, MONGOC_QUERY_SECONDARY_OK, pipeline, NULL, read_prefs); - - ASSERT (cursor); - BSON_ASSERT (!mongoc_cursor_next (cursor, &doc)); - BSON_ASSERT (!mongoc_cursor_error (cursor, &error)); - - mongoc_cursor_destroy (cursor); - mongoc_read_prefs_destroy (read_prefs); - - read_prefs = mongoc_read_prefs_new (MONGOC_READ_SECONDARY); - cursor = mongoc_collection_aggregate ( - collection, MONGOC_QUERY_SECONDARY_OK, pipeline, NULL, read_prefs); - - ASSERT (cursor); - BSON_ASSERT (!mongoc_cursor_next (cursor, &doc)); - BSON_ASSERT (!mongoc_cursor_error (cursor, &error)); - - ASSERT_CAPTURED_LOG ("mongoc_collection_aggregate", - MONGOC_LOG_LEVEL_WARNING, - "Overriding read preference to primary."); - - capture_logs (false); - - mongoc_cursor_destroy (cursor); - mongoc_client_destroy (client); - mongoc_collection_destroy (collection); - mongoc_read_prefs_destroy (read_prefs); -} - static void test_validate (void *ctx) @@ -6649,12 +6599,6 @@ test_collection_install (TestSuite *suite) TestSuite_AddMockServerTest (suite, "/Collection/aggregate_with_batch_size", test_aggregate_with_batch_size); - TestSuite_AddFull (suite, - "/Collection/aggregate_is_sent_to_primary_w_dollar_out", - test_aggregate_is_sent_to_primary_w_dollar_out, - NULL, - NULL, - test_framework_skip_if_not_replset); TestSuite_AddFull (suite, "/Collection/fam/no_error_on_retry", test_fam_no_error_on_retry, From c7713d0433f952157ad42338697f8991c615bb69 Mon Sep 17 00:00:00 2001 From: vector-of-bool Date: Fri, 3 Dec 2021 21:27:14 +0000 Subject: [PATCH 19/52] Fix missing param to stream_for_reads --- src/libmongoc/tests/test-mongoc-cyrus.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libmongoc/tests/test-mongoc-cyrus.c b/src/libmongoc/tests/test-mongoc-cyrus.c index d2e61af75ca..362cfa65354 100644 --- a/src/libmongoc/tests/test-mongoc-cyrus.c +++ b/src/libmongoc/tests/test-mongoc-cyrus.c @@ -75,7 +75,7 @@ test_sasl_canonicalize_hostname (void *ctx) client = test_framework_new_default_client (); ss = mongoc_cluster_stream_for_reads ( - &client->cluster, NULL, NULL, NULL, &error); + &client->cluster, NULL, NULL, NULL, NULL, &error); ASSERT_OR_PRINT (ss, error); BSON_ASSERT (_mongoc_sasl_get_canonicalized_name ( From 6bf1d02538198f812a6653bd9898a6a1eec848f5 Mon Sep 17 00:00:00 2001 From: vector-of-bool Date: Fri, 3 Dec 2021 21:41:02 +0000 Subject: [PATCH 20/52] Wrong param type --- src/libmongoc/tests/test-mongoc-cyrus.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libmongoc/tests/test-mongoc-cyrus.c b/src/libmongoc/tests/test-mongoc-cyrus.c index 362cfa65354..7290949440c 100644 --- a/src/libmongoc/tests/test-mongoc-cyrus.c +++ b/src/libmongoc/tests/test-mongoc-cyrus.c @@ -75,7 +75,7 @@ test_sasl_canonicalize_hostname (void *ctx) client = test_framework_new_default_client (); ss = mongoc_cluster_stream_for_reads ( - &client->cluster, NULL, NULL, NULL, NULL, &error); + &client->cluster, NULL, NULL, NULL, NOT_AGGR_WITH_WRITE_STAGE, &error); ASSERT_OR_PRINT (ss, error); BSON_ASSERT (_mongoc_sasl_get_canonicalized_name ( From d3e4aa8cc941cacccc957af7f2c82c221624a626 Mon Sep 17 00:00:00 2001 From: vector-of-bool Date: Mon, 13 Dec 2021 19:47:55 +0000 Subject: [PATCH 21/52] 'default' case for optype handling --- src/libmongoc/src/mongoc/mongoc-topology-description.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/libmongoc/src/mongoc/mongoc-topology-description.c b/src/libmongoc/src/mongoc/mongoc-topology-description.c index 04a06ec5d92..c87c1ce6990 100644 --- a/src/libmongoc/src/mongoc/mongoc-topology-description.c +++ b/src/libmongoc/src/mongoc/mongoc-topology-description.c @@ -700,9 +700,10 @@ _calc_effective_read_mode (const mongoc_topology_description_t *td, } return requested_read_mode; } + default: + BSON_UNREACHABLE ( + "Invalid mongoc_ss_optype_t for _calc_effective_read_mode()"); } - BSON_UNREACHABLE ( - "Invalid mongoc_ss_optype_t for _calc_effective_read_mode()"); } /* @@ -841,6 +842,8 @@ mongoc_topology_description_suitable_servers ( } } } break; + default: + BSON_UNREACHABLE ("Invalid optype"); } } From e53fa76e8ab842c222292fb89fd224efb78236e1 Mon Sep 17 00:00:00 2001 From: vector-of-bool Date: Tue, 14 Dec 2021 23:58:44 +0000 Subject: [PATCH 22/52] Add "meta" to all test cases, for use with test setup --- src/libbson/tests/test-atomic.c | 8 +- src/libbson/tests/test-b64.c | 4 +- src/libbson/tests/test-bcon-basic.c | 58 ++--- src/libbson/tests/test-bcon-extract.c | 62 ++--- src/libbson/tests/test-bson-corpus.c | 2 +- src/libbson/tests/test-bson-error.c | 2 +- src/libbson/tests/test-bson-version.c | 2 +- src/libbson/tests/test-bson.c | 148 ++++++------ src/libbson/tests/test-clock.c | 2 +- src/libbson/tests/test-decimal128.c | 19 +- src/libbson/tests/test-endian.c | 6 +- src/libbson/tests/test-iso8601.c | 9 +- src/libbson/tests/test-iter.c | 73 +++--- src/libbson/tests/test-json.c | 221 +++++++++++------- src/libbson/tests/test-oid.c | 24 +- src/libbson/tests/test-reader.c | 16 +- src/libbson/tests/test-string.c | 31 +-- src/libbson/tests/test-utf8.c | 14 +- src/libbson/tests/test-value.c | 4 +- src/libbson/tests/test-writer.c | 22 +- src/libmongoc/tests/TestSuite.c | 34 ++- src/libmongoc/tests/TestSuite.h | 51 ++-- src/libmongoc/tests/bsonutil/bson-match.c | 2 +- src/libmongoc/tests/json-test-monitoring.c | 2 +- src/libmongoc/tests/json-test.c | 1 + src/libmongoc/tests/test-happy-eyeballs.c | 2 + src/libmongoc/tests/test-libmongoc.c | 2 +- src/libmongoc/tests/test-mongoc-aggregate.c | 2 +- src/libmongoc/tests/test-mongoc-array.c | 2 +- src/libmongoc/tests/test-mongoc-async.c | 6 +- src/libmongoc/tests/test-mongoc-aws.c | 3 + .../tests/test-mongoc-background-monitoring.c | 58 +++-- src/libmongoc/tests/test-mongoc-buffer.c | 2 +- src/libmongoc/tests/test-mongoc-bulk.c | 173 ++++++++++---- .../tests/test-mongoc-change-stream.c | 34 ++- src/libmongoc/tests/test-mongoc-client-pool.c | 35 ++- .../tests/test-mongoc-client-session.c | 146 ++++++++---- .../test-mongoc-client-side-encryption.c | 16 ++ src/libmongoc/tests/test-mongoc-client.c | 170 ++++++++++---- src/libmongoc/tests/test-mongoc-cluster.c | 55 ++++- src/libmongoc/tests/test-mongoc-cmd.c | 2 +- .../test-mongoc-collection-find-with-opts.c | 46 ++-- .../tests/test-mongoc-collection-find.c | 65 +++--- src/libmongoc/tests/test-mongoc-collection.c | 180 ++++++++------ .../tests/test-mongoc-command-monitoring.c | 41 +++- src/libmongoc/tests/test-mongoc-counters.c | 14 +- src/libmongoc/tests/test-mongoc-crud.c | 2 + src/libmongoc/tests/test-mongoc-cursor.c | 129 +++++----- src/libmongoc/tests/test-mongoc-database.c | 36 ++- src/libmongoc/tests/test-mongoc-dns.c | 13 ++ src/libmongoc/tests/test-mongoc-error.c | 14 +- src/libmongoc/tests/test-mongoc-exhaust.c | 18 +- .../tests/test-mongoc-find-and-modify.c | 14 +- .../tests/test-mongoc-generation-map.c | 7 +- .../tests/test-mongoc-gridfs-bucket.c | 9 +- .../tests/test-mongoc-gridfs-file-page.c | 16 +- src/libmongoc/tests/test-mongoc-gridfs.c | 50 ++-- src/libmongoc/tests/test-mongoc-handshake.c | 19 +- .../tests/test-mongoc-hedged-reads.c | 6 +- src/libmongoc/tests/test-mongoc-http.c | 1 + src/libmongoc/tests/test-mongoc-interrupt.c | 2 +- .../tests/test-mongoc-linux-distro-scanner.c | 3 + src/libmongoc/tests/test-mongoc-list.c | 2 +- .../tests/test-mongoc-loadbalanced.c | 11 + src/libmongoc/tests/test-mongoc-log.c | 6 +- .../tests/test-mongoc-long-namespace.c | 15 +- src/libmongoc/tests/test-mongoc-matcher.c | 20 +- .../tests/test-mongoc-max-staleness.c | 7 +- src/libmongoc/tests/test-mongoc-mongohouse.c | 3 + .../tests/test-mongoc-mongos-pinning.c | 2 + src/libmongoc/tests/test-mongoc-ocsp-cache.c | 5 +- src/libmongoc/tests/test-mongoc-opts.c | 1 + .../tests/test-mongoc-primary-stepdown.c | 5 + src/libmongoc/tests/test-mongoc-queue.c | 4 +- .../tests/test-mongoc-read-concern.c | 15 +- src/libmongoc/tests/test-mongoc-read-prefs.c | 34 ++- .../tests/test-mongoc-retryable-reads.c | 2 + .../tests/test-mongoc-retryable-writes.c | 10 + src/libmongoc/tests/test-mongoc-rpc.c | 45 ++-- .../tests/test-mongoc-sample-commands.c | 3 +- src/libmongoc/tests/test-mongoc-scram.c | 8 +- .../tests/test-mongoc-sdam-monitoring.c | 10 + src/libmongoc/tests/test-mongoc-sdam.c | 4 + .../tests/test-mongoc-server-description.c | 9 +- .../test-mongoc-server-selection-errors.c | 10 + .../tests/test-mongoc-server-stream.c | 2 + src/libmongoc/tests/test-mongoc-set.c | 2 +- src/libmongoc/tests/test-mongoc-shared.c | 4 +- src/libmongoc/tests/test-mongoc-socket.c | 5 +- .../tests/test-mongoc-speculative-auth.c | 6 + src/libmongoc/tests/test-mongoc-ssl.c | 6 +- .../tests/test-mongoc-stream-tls-error.c | 6 +- src/libmongoc/tests/test-mongoc-stream-tls.c | 35 +-- src/libmongoc/tests/test-mongoc-stream.c | 7 +- .../tests/test-mongoc-streamable-hello.c | 2 + src/libmongoc/tests/test-mongoc-thread.c | 1 + src/libmongoc/tests/test-mongoc-timeout.c | 10 +- .../tests/test-mongoc-topology-description.c | 10 +- .../tests/test-mongoc-topology-reconcile.c | 7 + .../tests/test-mongoc-topology-scanner.c | 23 +- src/libmongoc/tests/test-mongoc-topology.c | 47 +++- .../tests/test-mongoc-transactions.c | 12 + src/libmongoc/tests/test-mongoc-ts-pool.c | 6 +- src/libmongoc/tests/test-mongoc-uri.c | 64 ++--- src/libmongoc/tests/test-mongoc-usleep.c | 1 + src/libmongoc/tests/test-mongoc-util.c | 6 +- src/libmongoc/tests/test-mongoc-version.c | 2 +- .../tests/test-mongoc-versioned-api.c | 14 +- .../tests/test-mongoc-with-transaction.c | 1 + .../tests/test-mongoc-write-commands.c | 26 ++- .../tests/test-mongoc-write-concern.c | 34 ++- src/libmongoc/tests/test-mongoc-x509.c | 5 +- src/libmongoc/tests/unified/result.c | 6 +- src/libmongoc/tests/unified/util.c | 2 +- 114 files changed, 1882 insertions(+), 911 deletions(-) diff --git a/src/libbson/tests/test-atomic.c b/src/libbson/tests/test-atomic.c index 3f5d80332b2..91324cf340c 100644 --- a/src/libbson/tests/test-atomic.c +++ b/src/libbson/tests/test-atomic.c @@ -129,8 +129,8 @@ test_thrd_yield (void) void test_atomic_install (TestSuite *suite) { - TestSuite_Add (suite, "/atomic/integers", test_integers); - TestSuite_Add (suite, "/atomic/pointers", test_pointers); - TestSuite_Add (suite, "/atomic/thread_fence", test_thread_fence); - TestSuite_Add (suite, "/atomic/thread_yield", test_thrd_yield); + TestSuite_Add (suite, "/atomic/integers", "", test_integers); + TestSuite_Add (suite, "/atomic/pointers", "", test_pointers); + TestSuite_Add (suite, "/atomic/thread_fence", "", test_thread_fence); + TestSuite_Add (suite, "/atomic/thread_yield", "", test_thrd_yield); } diff --git a/src/libbson/tests/test-b64.c b/src/libbson/tests/test-b64.c index 5e5d77aef7e..a1184c48901 100644 --- a/src/libbson/tests/test-b64.c +++ b/src/libbson/tests/test-b64.c @@ -143,6 +143,6 @@ test_bson_b64_decode (void) void test_b64_install (TestSuite *suite) { - TestSuite_Add (suite, "/bson/b64/encode", test_bson_b64_encode); - TestSuite_Add (suite, "/bson/b64/decode", test_bson_b64_decode); + TestSuite_Add (suite, "/bson/b64/encode", "", test_bson_b64_encode); + TestSuite_Add (suite, "/bson/b64/decode", "", test_bson_b64_decode); } diff --git a/src/libbson/tests/test-bcon-basic.c b/src/libbson/tests/test-bcon-basic.c index 7e9f3d135a6..1d2a93e5c9d 100644 --- a/src/libbson/tests/test-bcon-basic.c +++ b/src/libbson/tests/test-bcon-basic.c @@ -632,32 +632,34 @@ test_append_ctx (void) void test_bcon_basic_install (TestSuite *suite) { - TestSuite_Add (suite, "/bson/bcon/test_utf8", test_utf8); - TestSuite_Add (suite, "/bson/bcon/test_double", test_double); - TestSuite_Add (suite, "/bson/bcon/test_binary", test_binary); - TestSuite_Add (suite, "/bson/bcon/test_undefined", test_undefined); - TestSuite_Add (suite, "/bson/bcon/test_oid", test_oid); - TestSuite_Add (suite, "/bson/bcon/test_bool", test_bool); - TestSuite_Add (suite, "/bson/bcon/test_date_time", test_date_time); - TestSuite_Add (suite, "/bson/bcon/test_null", test_null); - TestSuite_Add (suite, "/bson/bcon/test_regex", test_regex); - TestSuite_Add (suite, "/bson/bcon/test_dbpointer", test_dbpointer); - TestSuite_Add (suite, "/bson/bcon/test_code", test_code); - TestSuite_Add (suite, "/bson/bcon/test_symbol", test_symbol); - TestSuite_Add (suite, "/bson/bcon/test_codewscope", test_codewscope); - TestSuite_Add (suite, "/bson/bcon/test_int32", test_int32); - TestSuite_Add (suite, "/bson/bcon/test_timestamp", test_timestamp); - TestSuite_Add (suite, "/bson/bcon/test_int64", test_int64); - TestSuite_Add (suite, "/bson/bcon/test_decimal128", test_decimal128); - TestSuite_Add (suite, "/bson/bcon/test_maxkey", test_maxkey); - TestSuite_Add (suite, "/bson/bcon/test_minkey", test_minkey); - TestSuite_Add (suite, "/bson/bcon/test_bson_document", test_bson_document); - TestSuite_Add (suite, "/bson/bcon/test_bson_array", test_bson_array); - TestSuite_Add (suite, "/bson/bcon/test_inline_array", test_inline_array); - TestSuite_Add (suite, "/bson/bcon/test_inline_doc", test_inline_doc); - TestSuite_Add (suite, "/bson/bcon/test_inline_nested", test_inline_nested); - TestSuite_Add (suite, "/bson/bcon/test_concat", test_concat); - TestSuite_Add (suite, "/bson/bcon/test_iter", test_iter); - TestSuite_Add (suite, "/bson/bcon/test_bcon_new", test_bcon_new); - TestSuite_Add (suite, "/bson/bcon/test_append_ctx", test_append_ctx); + TestSuite_Add (suite, "/bson/bcon/test_utf8", "", test_utf8); + TestSuite_Add (suite, "/bson/bcon/test_double", "", test_double); + TestSuite_Add (suite, "/bson/bcon/test_binary", "", test_binary); + TestSuite_Add (suite, "/bson/bcon/test_undefined", "", test_undefined); + TestSuite_Add (suite, "/bson/bcon/test_oid", "", test_oid); + TestSuite_Add (suite, "/bson/bcon/test_bool", "", test_bool); + TestSuite_Add (suite, "/bson/bcon/test_date_time", "", test_date_time); + TestSuite_Add (suite, "/bson/bcon/test_null", "", test_null); + TestSuite_Add (suite, "/bson/bcon/test_regex", "", test_regex); + TestSuite_Add (suite, "/bson/bcon/test_dbpointer", "", test_dbpointer); + TestSuite_Add (suite, "/bson/bcon/test_code", "", test_code); + TestSuite_Add (suite, "/bson/bcon/test_symbol", "", test_symbol); + TestSuite_Add (suite, "/bson/bcon/test_codewscope", "", test_codewscope); + TestSuite_Add (suite, "/bson/bcon/test_int32", "", test_int32); + TestSuite_Add (suite, "/bson/bcon/test_timestamp", "", test_timestamp); + TestSuite_Add (suite, "/bson/bcon/test_int64", "", test_int64); + TestSuite_Add (suite, "/bson/bcon/test_decimal128", "", test_decimal128); + TestSuite_Add (suite, "/bson/bcon/test_maxkey", "", test_maxkey); + TestSuite_Add (suite, "/bson/bcon/test_minkey", "", test_minkey); + TestSuite_Add ( + suite, "/bson/bcon/test_bson_document", "", test_bson_document); + TestSuite_Add (suite, "/bson/bcon/test_bson_array", "", test_bson_array); + TestSuite_Add (suite, "/bson/bcon/test_inline_array", "", test_inline_array); + TestSuite_Add (suite, "/bson/bcon/test_inline_doc", "", test_inline_doc); + TestSuite_Add ( + suite, "/bson/bcon/test_inline_nested", "", test_inline_nested); + TestSuite_Add (suite, "/bson/bcon/test_concat", "", test_concat); + TestSuite_Add (suite, "/bson/bcon/test_iter", "", test_iter); + TestSuite_Add (suite, "/bson/bcon/test_bcon_new", "", test_bcon_new); + TestSuite_Add (suite, "/bson/bcon/test_append_ctx", "", test_append_ctx); } diff --git a/src/libbson/tests/test-bcon-extract.c b/src/libbson/tests/test-bcon-extract.c index 1370e7459b8..4825a0ac49b 100644 --- a/src/libbson/tests/test-bcon-extract.c +++ b/src/libbson/tests/test-bcon-extract.c @@ -489,34 +489,42 @@ test_iter (void) void test_bcon_extract_install (TestSuite *suite) { - TestSuite_Add (suite, "/bson/bcon/extract/test_utf8", test_utf8); - TestSuite_Add (suite, "/bson/bcon/extract/test_double", test_double); - TestSuite_Add (suite, "/bson/bcon/extract/test_decimal128", test_decimal128); - TestSuite_Add (suite, "/bson/bcon/extract/test_binary", test_binary); - TestSuite_Add (suite, "/bson/bcon/extract/test_undefined", test_undefined); - TestSuite_Add (suite, "/bson/bcon/extract/test_oid", test_oid); - TestSuite_Add (suite, "/bson/bcon/extract/test_bool", test_bool); - TestSuite_Add (suite, "/bson/bcon/extract/test_date_time", test_date_time); - TestSuite_Add (suite, "/bson/bcon/extract/test_null", test_null); - TestSuite_Add (suite, "/bson/bcon/extract/test_regex", test_regex); - TestSuite_Add (suite, "/bson/bcon/extract/test_dbpointer", test_dbpointer); - TestSuite_Add (suite, "/bson/bcon/extract/test_code", test_code); - TestSuite_Add (suite, "/bson/bcon/extract/test_symbol", test_symbol); - TestSuite_Add (suite, "/bson/bcon/extract/test_codewscope", test_codewscope); - TestSuite_Add (suite, "/bson/bcon/extract/test_int32", test_int32); - TestSuite_Add (suite, "/bson/bcon/extract/test_timestamp", test_timestamp); - TestSuite_Add (suite, "/bson/bcon/extract/test_int64", test_int64); - TestSuite_Add (suite, "/bson/bcon/extract/test_maxkey", test_maxkey); - TestSuite_Add (suite, "/bson/bcon/extract/test_minkey", test_minkey); + TestSuite_Add (suite, "/bson/bcon/extract/test_utf8", "", test_utf8); + TestSuite_Add (suite, "/bson/bcon/extract/test_double", "", test_double); TestSuite_Add ( - suite, "/bson/bcon/extract/test_bson_document", test_bson_document); - TestSuite_Add (suite, "/bson/bcon/extract/test_bson_array", test_bson_array); + suite, "/bson/bcon/extract/test_decimal128", "", test_decimal128); + TestSuite_Add (suite, "/bson/bcon/extract/test_binary", "", test_binary); TestSuite_Add ( - suite, "/bson/bcon/extract/test_inline_array", test_inline_array); - TestSuite_Add (suite, "/bson/bcon/extract/test_inline_doc", test_inline_doc); + suite, "/bson/bcon/extract/test_undefined", "", test_undefined); + TestSuite_Add (suite, "/bson/bcon/extract/test_oid", "", test_oid); + TestSuite_Add (suite, "/bson/bcon/extract/test_bool", "", test_bool); TestSuite_Add ( - suite, "/bson/bcon/extract/test_extract_ctx", test_extract_ctx); - TestSuite_Add (suite, "/bson/bcon/extract/test_nested", test_nested); - TestSuite_Add (suite, "/bson/bcon/extract/test_skip", test_skip); - TestSuite_Add (suite, "/bson/bcon/extract/test_iter", test_iter); + suite, "/bson/bcon/extract/test_date_time", "", test_date_time); + TestSuite_Add (suite, "/bson/bcon/extract/test_null", "", test_null); + TestSuite_Add (suite, "/bson/bcon/extract/test_regex", "", test_regex); + TestSuite_Add ( + suite, "/bson/bcon/extract/test_dbpointer", "", test_dbpointer); + TestSuite_Add (suite, "/bson/bcon/extract/test_code", "", test_code); + TestSuite_Add (suite, "/bson/bcon/extract/test_symbol", "", test_symbol); + TestSuite_Add ( + suite, "/bson/bcon/extract/test_codewscope", "", test_codewscope); + TestSuite_Add (suite, "/bson/bcon/extract/test_int32", "", test_int32); + TestSuite_Add ( + suite, "/bson/bcon/extract/test_timestamp", "", test_timestamp); + TestSuite_Add (suite, "/bson/bcon/extract/test_int64", "", test_int64); + TestSuite_Add (suite, "/bson/bcon/extract/test_maxkey", "", test_maxkey); + TestSuite_Add (suite, "/bson/bcon/extract/test_minkey", "", test_minkey); + TestSuite_Add ( + suite, "/bson/bcon/extract/test_bson_document", "", test_bson_document); + TestSuite_Add ( + suite, "/bson/bcon/extract/test_bson_array", "", test_bson_array); + TestSuite_Add ( + suite, "/bson/bcon/extract/test_inline_array", "", test_inline_array); + TestSuite_Add ( + suite, "/bson/bcon/extract/test_inline_doc", "", test_inline_doc); + TestSuite_Add ( + suite, "/bson/bcon/extract/test_extract_ctx", "", test_extract_ctx); + TestSuite_Add (suite, "/bson/bcon/extract/test_nested", "", test_nested); + TestSuite_Add (suite, "/bson/bcon/extract/test_skip", "", test_skip); + TestSuite_Add (suite, "/bson/bcon/extract/test_iter", "", test_iter); } diff --git a/src/libbson/tests/test-bson-corpus.c b/src/libbson/tests/test-bson-corpus.c index 7fbd4e28972..5204b286fab 100644 --- a/src/libbson/tests/test-bson-corpus.c +++ b/src/libbson/tests/test-bson-corpus.c @@ -326,5 +326,5 @@ test_bson_corpus_install (TestSuite *suite) { install_json_test_suite_with_check ( suite, BSON_JSON_DIR "/bson_corpus", test_bson_corpus_cb); - TestSuite_Add (suite, "/bson_corpus/prose_1", test_bson_corpus_prose_1); + TestSuite_Add (suite, "/bson_corpus/prose_1", "", test_bson_corpus_prose_1); } diff --git a/src/libbson/tests/test-bson-error.c b/src/libbson/tests/test-bson-error.c index c58ff519920..df7cfeedf4c 100644 --- a/src/libbson/tests/test-bson-error.c +++ b/src/libbson/tests/test-bson-error.c @@ -34,5 +34,5 @@ test_bson_error_basic (void) void test_bson_error_install (TestSuite *suite) { - TestSuite_Add (suite, "/bson/error/basic", test_bson_error_basic); + TestSuite_Add (suite, "/bson/error/basic", "", test_bson_error_basic); } diff --git a/src/libbson/tests/test-bson-version.c b/src/libbson/tests/test-bson-version.c index 9ea90d82053..5e5c30cda3c 100644 --- a/src/libbson/tests/test-bson-version.c +++ b/src/libbson/tests/test-bson-version.c @@ -20,5 +20,5 @@ test_bson_version (void) void test_bson_version_install (TestSuite *suite) { - TestSuite_Add (suite, "/bson/version", test_bson_version); + TestSuite_Add (suite, "/bson/version", "", test_bson_version); } diff --git a/src/libbson/tests/test-bson.c b/src/libbson/tests/test-bson.c index 85592af0955..258214a5953 100644 --- a/src/libbson/tests/test-bson.c +++ b/src/libbson/tests/test-bson.c @@ -2505,99 +2505,117 @@ test_bson_as_json_string (void) void test_bson_install (TestSuite *suite) { - TestSuite_Add (suite, "/bson/new", test_bson_new); - TestSuite_Add (suite, "/bson/new_from_buffer", test_bson_new_from_buffer); - TestSuite_Add (suite, "/bson/init", test_bson_init); - TestSuite_Add (suite, "/bson/init_static", test_bson_init_static); - TestSuite_Add (suite, "/bson/basic", test_bson_alloc); - TestSuite_Add (suite, "/bson/append_overflow", test_bson_append_overflow); - TestSuite_Add (suite, "/bson/append_array", test_bson_append_array); - TestSuite_Add (suite, "/bson/append_binary", test_bson_append_binary); + TestSuite_Add (suite, "/bson/new", "", test_bson_new); + TestSuite_Add ( + suite, "/bson/new_from_buffer", "", test_bson_new_from_buffer); + TestSuite_Add (suite, "/bson/init", "", test_bson_init); + TestSuite_Add (suite, "/bson/init_static", "", test_bson_init_static); + TestSuite_Add (suite, "/bson/basic", "", test_bson_alloc); + TestSuite_Add ( + suite, "/bson/append_overflow", "", test_bson_append_overflow); + TestSuite_Add (suite, "/bson/append_array", "", test_bson_append_array); + TestSuite_Add (suite, "/bson/append_binary", "", test_bson_append_binary); TestSuite_Add (suite, "/bson/append_binary_deprecated", + "", test_bson_append_binary_deprecated); - TestSuite_Add (suite, "/bson/append_bool", test_bson_append_bool); - TestSuite_Add (suite, "/bson/append_code", test_bson_append_code); + TestSuite_Add (suite, "/bson/append_bool", "", test_bson_append_bool); + TestSuite_Add (suite, "/bson/append_code", "", test_bson_append_code); + TestSuite_Add (suite, + "/bson/append_code_with_scope", + "", + test_bson_append_code_with_scope); + TestSuite_Add ( + suite, "/bson/append_dbpointer", "", test_bson_append_dbpointer); + TestSuite_Add ( + suite, "/bson/append_document", "", test_bson_append_document); + TestSuite_Add (suite, "/bson/append_double", "", test_bson_append_double); + TestSuite_Add (suite, "/bson/append_int32", "", test_bson_append_int32); + TestSuite_Add (suite, "/bson/append_int64", "", test_bson_append_int64); TestSuite_Add ( - suite, "/bson/append_code_with_scope", test_bson_append_code_with_scope); - TestSuite_Add (suite, "/bson/append_dbpointer", test_bson_append_dbpointer); - TestSuite_Add (suite, "/bson/append_document", test_bson_append_document); - TestSuite_Add (suite, "/bson/append_double", test_bson_append_double); - TestSuite_Add (suite, "/bson/append_int32", test_bson_append_int32); - TestSuite_Add (suite, "/bson/append_int64", test_bson_append_int64); + suite, "/bson/append_decimal128", "", test_bson_append_decimal128); + TestSuite_Add (suite, "/bson/append_iter", "", test_bson_append_iter); + TestSuite_Add (suite, "/bson/append_maxkey", "", test_bson_append_maxkey); + TestSuite_Add (suite, "/bson/append_minkey", "", test_bson_append_minkey); + TestSuite_Add (suite, "/bson/append_null", "", test_bson_append_null); + TestSuite_Add (suite, "/bson/append_oid", "", test_bson_append_oid); + TestSuite_Add (suite, "/bson/append_regex", "", test_bson_append_regex); TestSuite_Add ( - suite, "/bson/append_decimal128", test_bson_append_decimal128); - TestSuite_Add (suite, "/bson/append_iter", test_bson_append_iter); - TestSuite_Add (suite, "/bson/append_maxkey", test_bson_append_maxkey); - TestSuite_Add (suite, "/bson/append_minkey", test_bson_append_minkey); - TestSuite_Add (suite, "/bson/append_null", test_bson_append_null); - TestSuite_Add (suite, "/bson/append_oid", test_bson_append_oid); - TestSuite_Add (suite, "/bson/append_regex", test_bson_append_regex); + suite, "/bson/append_regex_w_len", "", test_bson_append_regex_w_len); + TestSuite_Add (suite, "/bson/append_utf8", "", test_bson_append_utf8); + TestSuite_Add (suite, "/bson/append_symbol", "", test_bson_append_symbol); + TestSuite_Add (suite, "/bson/append_time_t", "", test_bson_append_time_t); TestSuite_Add ( - suite, "/bson/append_regex_w_len", test_bson_append_regex_w_len); - TestSuite_Add (suite, "/bson/append_utf8", test_bson_append_utf8); - TestSuite_Add (suite, "/bson/append_symbol", test_bson_append_symbol); - TestSuite_Add (suite, "/bson/append_time_t", test_bson_append_time_t); - TestSuite_Add (suite, "/bson/append_timestamp", test_bson_append_timestamp); - TestSuite_Add (suite, "/bson/append_timeval", test_bson_append_timeval); - TestSuite_Add (suite, "/bson/append_undefined", test_bson_append_undefined); - TestSuite_Add (suite, "/bson/append_general", test_bson_append_general); - TestSuite_Add (suite, "/bson/append_deep", test_bson_append_deep); - TestSuite_Add (suite, "/bson/utf8_key", test_bson_utf8_key); - TestSuite_Add (suite, "/bson/validate", test_bson_validate); - TestSuite_Add (suite, "/bson/validate/dbref", test_bson_validate_dbref); - TestSuite_Add (suite, "/bson/validate/bool", test_bson_validate_bool); + suite, "/bson/append_timestamp", "", test_bson_append_timestamp); + TestSuite_Add (suite, "/bson/append_timeval", "", test_bson_append_timeval); TestSuite_Add ( - suite, "/bson/validate/dbpointer", test_bson_validate_dbpointer); - TestSuite_Add (suite, "/bson/new_1mm", test_bson_new_1mm); - TestSuite_Add (suite, "/bson/init_1mm", test_bson_init_1mm); - TestSuite_Add (suite, "/bson/build_child", test_bson_build_child); - TestSuite_Add (suite, "/bson/build_child_deep", test_bson_build_child_deep); + suite, "/bson/append_undefined", "", test_bson_append_undefined); + TestSuite_Add (suite, "/bson/append_general", "", test_bson_append_general); + TestSuite_Add (suite, "/bson/append_deep", "", test_bson_append_deep); + TestSuite_Add (suite, "/bson/utf8_key", "", test_bson_utf8_key); + TestSuite_Add (suite, "/bson/validate", "", test_bson_validate); + TestSuite_Add (suite, "/bson/validate/dbref", "", test_bson_validate_dbref); + TestSuite_Add (suite, "/bson/validate/bool", "", test_bson_validate_bool); + TestSuite_Add ( + suite, "/bson/validate/dbpointer", "", test_bson_validate_dbpointer); + TestSuite_Add (suite, "/bson/new_1mm", "", test_bson_new_1mm); + TestSuite_Add (suite, "/bson/init_1mm", "", test_bson_init_1mm); + TestSuite_Add (suite, "/bson/build_child", "", test_bson_build_child); + TestSuite_Add ( + suite, "/bson/build_child_deep", "", test_bson_build_child_deep); TestSuite_Add (suite, "/bson/build_child_deep_no_begin_end", + "", test_bson_build_child_deep_no_begin_end); TestSuite_Add ( - suite, "/bson/build_child_array", test_bson_build_child_array); - TestSuite_Add (suite, "/bson/count", test_bson_count_keys); - TestSuite_Add (suite, "/bson/copy", test_bson_copy); - TestSuite_Add (suite, "/bson/copy_to", test_bson_copy_to); + suite, "/bson/build_child_array", "", test_bson_build_child_array); + TestSuite_Add (suite, "/bson/count", "", test_bson_count_keys); + TestSuite_Add (suite, "/bson/copy", "", test_bson_copy); + TestSuite_Add (suite, "/bson/copy_to", "", test_bson_copy_to); TestSuite_Add (suite, "/bson/copy_to_excluding_noinit", + "", test_bson_copy_to_excluding_noinit); - TestSuite_Add (suite, "/bson/initializer", test_bson_initializer); - TestSuite_Add (suite, "/bson/concat", test_bson_concat); - TestSuite_Add (suite, "/bson/reinit", test_bson_reinit); - TestSuite_Add (suite, "/bson/macros", test_bson_macros); - TestSuite_Add (suite, "/bson/clear", test_bson_clear); - TestSuite_Add (suite, "/bson/steal", test_bson_steal); - TestSuite_Add (suite, "/bson/reserve_buffer", test_bson_reserve_buffer); - TestSuite_Add ( - suite, "/bson/reserve_buffer/errors", test_bson_reserve_buffer_errors); + TestSuite_Add (suite, "/bson/initializer", "", test_bson_initializer); + TestSuite_Add (suite, "/bson/concat", "", test_bson_concat); + TestSuite_Add (suite, "/bson/reinit", "", test_bson_reinit); + TestSuite_Add (suite, "/bson/macros", "", test_bson_macros); + TestSuite_Add (suite, "/bson/clear", "", test_bson_clear); + TestSuite_Add (suite, "/bson/steal", "", test_bson_steal); + TestSuite_Add (suite, "/bson/reserve_buffer", "", test_bson_reserve_buffer); + TestSuite_Add (suite, + "/bson/reserve_buffer/errors", + "", + test_bson_reserve_buffer_errors); TestSuite_Add ( - suite, "/bson/destroy_with_steal", test_bson_destroy_with_steal); - TestSuite_Add (suite, "/bson/has_field", test_bson_has_field); + suite, "/bson/destroy_with_steal", "", test_bson_destroy_with_steal); + TestSuite_Add (suite, "/bson/has_field", "", test_bson_has_field); TestSuite_Add ( - suite, "/bson/visit_invalid_field", test_bson_visit_invalid_field); + suite, "/bson/visit_invalid_field", "", test_bson_visit_invalid_field); TestSuite_Add ( - suite, "/bson/unsupported_type", test_bson_visit_unsupported_type); + suite, "/bson/unsupported_type", "", test_bson_visit_unsupported_type); TestSuite_Add (suite, "/bson/unsupported_type/bad_key", + "", test_bson_visit_unsupported_type_bad_key); TestSuite_Add (suite, "/bson/unsupported_type/empty_key", + "", test_bson_visit_unsupported_type_empty_key); - TestSuite_Add (suite, "/bson/binary_subtype_2", test_bson_subtype_2); - TestSuite_Add (suite, "/bson/regex_length", test_bson_regex_lengths); - TestSuite_Add (suite, "/util/next_power_of_two", test_next_power_of_two); - TestSuite_Add (suite, "/bson/empty_binary", test_bson_empty_binary); - TestSuite_Add (suite, "/bson/iter/key_len", test_bson_iter_key_len); + TestSuite_Add (suite, "/bson/binary_subtype_2", "", test_bson_subtype_2); + TestSuite_Add (suite, "/bson/regex_length", "", test_bson_regex_lengths); + TestSuite_Add (suite, "/util/next_power_of_two", "", test_next_power_of_two); + TestSuite_Add (suite, "/bson/empty_binary", "", test_bson_empty_binary); + TestSuite_Add (suite, "/bson/iter/key_len", "", test_bson_iter_key_len); TestSuite_Add (suite, "/bson/iter/init_from_data_at_offset", + "", test_bson_iter_init_from_data_at_offset); TestSuite_Add ( - suite, "/bson/value/null_handling", test_bson_binary_null_handling); + suite, "/bson/value/null_handling", "", test_bson_binary_null_handling); TestSuite_Add (suite, "/bson/append_null_from_utf8_or_symbol", + "", test_bson_append_null_from_utf8_or_symbol); - TestSuite_Add (suite, "/bson/as_json_string", test_bson_as_json_string); + TestSuite_Add (suite, "/bson/as_json_string", "", test_bson_as_json_string); } diff --git a/src/libbson/tests/test-clock.c b/src/libbson/tests/test-clock.c index 830d70c1df1..710ea1b0a73 100644 --- a/src/libbson/tests/test-clock.c +++ b/src/libbson/tests/test-clock.c @@ -21,5 +21,5 @@ void test_clock_install (TestSuite *suite) { TestSuite_Add ( - suite, "/bson/clock/get_monotonic_time", test_get_monotonic_time); + suite, "/bson/clock/get_monotonic_time", "", test_get_monotonic_time); } diff --git a/src/libbson/tests/test-decimal128.c b/src/libbson/tests/test-decimal128.c index f80c4e6c79f..b1ca765b8be 100644 --- a/src/libbson/tests/test-decimal128.c +++ b/src/libbson/tests/test-decimal128.c @@ -773,43 +773,58 @@ test_decimal128_install (TestSuite *suite) { TestSuite_Add (suite, "/bson/decimal128/to_string/infinity", + "", test_decimal128_to_string__infinity); - TestSuite_Add ( - suite, "/bson/decimal128/to_string/nan", test_decimal128_to_string__nan); + TestSuite_Add (suite, + "/bson/decimal128/to_string/nan", + "", + test_decimal128_to_string__nan); TestSuite_Add (suite, "/bson/decimal128/to_string/regular", + "", test_decimal128_to_string__regular); TestSuite_Add (suite, "/bson/decimal128/to_string/scientific", + "", test_decimal128_to_string__scientific); TestSuite_Add (suite, "/bson/decimal128/to_string/zero", + "", test_decimal128_to_string__zeros); TestSuite_Add (suite, "/bson/decimal128/from_string/invalid", + "", test_decimal128_from_string__invalid_inputs); TestSuite_Add (suite, "/bson/decimal128/from_string/nan", + "", test_decimal128_from_string__nan); TestSuite_Add (suite, "/bson/decimal128/from_string/infinity", + "", test_decimal128_from_string__infinity); TestSuite_Add (suite, "/bson/decimal128/from_string/basic", + "", test_decimal128_from_string__simple); TestSuite_Add (suite, "/bson/decimal128/from_string/scientific", + "", test_decimal128_from_string__scientific); TestSuite_Add (suite, "/bson/decimal128/from_string/large", + "", test_decimal128_from_string__large); TestSuite_Add (suite, "/bson/decimal128/from_string/exponent_normalization", + "", test_decimal128_from_string__exponent_normalization); TestSuite_Add (suite, "/bson/decimal128/from_string/zero", + "", test_decimal128_from_string__zeros); TestSuite_Add (suite, "/bson/decimal128/from_string/with_length", + "", test_decimal128_from_string_w_len__special); } diff --git a/src/libbson/tests/test-endian.c b/src/libbson/tests/test-endian.c index 0f4f247932b..f369f3496c9 100644 --- a/src/libbson/tests/test-endian.c +++ b/src/libbson/tests/test-endian.c @@ -53,7 +53,7 @@ test_swap64 (void) void test_endian_install (TestSuite *suite) { - TestSuite_Add (suite, "/endian/swap16", test_swap16); - TestSuite_Add (suite, "/endian/swap32", test_swap32); - TestSuite_Add (suite, "/endian/swap64", test_swap64); + TestSuite_Add (suite, "/endian/swap16", "", test_swap16); + TestSuite_Add (suite, "/endian/swap32", "", test_swap32); + TestSuite_Add (suite, "/endian/swap64", "", test_swap64); } diff --git a/src/libbson/tests/test-iso8601.c b/src/libbson/tests/test-iso8601.c index 91bb67f792d..4f81dac2467 100644 --- a/src/libbson/tests/test-iso8601.c +++ b/src/libbson/tests/test-iso8601.c @@ -378,9 +378,10 @@ test_bson_iso8601_leap_year (void) void test_iso8601_install (TestSuite *suite) { - TestSuite_Add (suite, "/bson/iso8601/utc", test_bson_iso8601_utc); - TestSuite_Add (suite, "/bson/iso8601/local", test_bson_iso8601_local); - TestSuite_Add (suite, "/bson/iso8601/invalid", test_bson_iso8601_invalid); + TestSuite_Add (suite, "/bson/iso8601/utc", "", test_bson_iso8601_utc); + TestSuite_Add (suite, "/bson/iso8601/local", "", test_bson_iso8601_local); TestSuite_Add ( - suite, "/bson/iso8601/leap_year", test_bson_iso8601_leap_year); + suite, "/bson/iso8601/invalid", "", test_bson_iso8601_invalid); + TestSuite_Add ( + suite, "/bson/iso8601/leap_year", "", test_bson_iso8601_leap_year); } diff --git a/src/libbson/tests/test-iter.c b/src/libbson/tests/test-iter.c index 6f2c0908af5..30a5182ac27 100644 --- a/src/libbson/tests/test-iter.c +++ b/src/libbson/tests/test-iter.c @@ -726,52 +726,71 @@ test_bson_iter_from_data (void) void test_iter_install (TestSuite *suite) { - TestSuite_Add (suite, "/bson/iter/test_string", test_bson_iter_utf8); - TestSuite_Add (suite, "/bson/iter/test_mixed", test_bson_iter_mixed); - TestSuite_Add (suite, "/bson/iter/test_overflow", test_bson_iter_overflow); - TestSuite_Add (suite, "/bson/iter/test_timeval", test_bson_iter_timeval); + TestSuite_Add (suite, "/bson/iter/test_string", "", test_bson_iter_utf8); + TestSuite_Add (suite, "/bson/iter/test_mixed", "", test_bson_iter_mixed); TestSuite_Add ( - suite, "/bson/iter/test_trailing_null", test_bson_iter_trailing_null); - TestSuite_Add (suite, "/bson/iter/test_fuzz", test_bson_iter_fuzz); - TestSuite_Add (suite, "/bson/iter/test_regex", test_bson_iter_regex); + suite, "/bson/iter/test_overflow", "", test_bson_iter_overflow); + TestSuite_Add (suite, "/bson/iter/test_timeval", "", test_bson_iter_timeval); + TestSuite_Add ( + suite, "/bson/iter/test_trailing_null", "", test_bson_iter_trailing_null); + TestSuite_Add (suite, "/bson/iter/test_fuzz", "", test_bson_iter_fuzz); + TestSuite_Add (suite, "/bson/iter/test_regex", "", test_bson_iter_regex); TestSuite_Add (suite, "/bson/iter/test_next_after_finish", + "", test_bson_iter_next_after_finish); - TestSuite_Add (suite, "/bson/iter/test_find_case", test_bson_iter_find_case); - TestSuite_Add ( - suite, "/bson/iter/test_find_w_len", test_bson_iter_find_w_len); - TestSuite_Add ( - suite, "/bson/iter/test_init_find_w_len", test_bson_iter_init_find_w_len); TestSuite_Add ( - suite, "/bson/iter/test_bson_iter_as_double", test_bson_iter_as_double); + suite, "/bson/iter/test_find_case", "", test_bson_iter_find_case); TestSuite_Add ( - suite, "/bson/iter/test_overwrite_int32", test_bson_iter_overwrite_int32); - TestSuite_Add ( - suite, "/bson/iter/test_overwrite_int64", test_bson_iter_overwrite_int64); + suite, "/bson/iter/test_find_w_len", "", test_bson_iter_find_w_len); + TestSuite_Add (suite, + "/bson/iter/test_init_find_w_len", + "", + test_bson_iter_init_find_w_len); + TestSuite_Add (suite, + "/bson/iter/test_bson_iter_as_double", + "", + test_bson_iter_as_double); + TestSuite_Add (suite, + "/bson/iter/test_overwrite_int32", + "", + test_bson_iter_overwrite_int32); + TestSuite_Add (suite, + "/bson/iter/test_overwrite_int64", + "", + test_bson_iter_overwrite_int64); TestSuite_Add (suite, "/bson/iter/test_overwrite_double", + "", test_bson_iter_overwrite_double); + TestSuite_Add (suite, + "/bson/iter/test_overwrite_bool", + "", + test_bson_iter_overwrite_bool); TestSuite_Add ( - suite, "/bson/iter/test_overwrite_bool", test_bson_iter_overwrite_bool); - TestSuite_Add ( - suite, "/bson/iter/test_overwrite_oid", test_bson_iter_overwrite_oid); + suite, "/bson/iter/test_overwrite_oid", "", test_bson_iter_overwrite_oid); TestSuite_Add (suite, "/bson/iter/test_overwrite_timestamp", + "", test_bson_iter_overwrite_timestamp); TestSuite_Add (suite, "/bson/iter/test_overwrite_date_time", + "", test_bson_iter_overwrite_date_time); TestSuite_Add (suite, "/bson/iter/test_bson_iter_overwrite_decimal128", + "", test_bson_iter_overwrite_decimal128); - TestSuite_Add (suite, "/bson/iter/recurse", test_bson_iter_recurse); - TestSuite_Add ( - suite, "/bson/iter/init_find_case", test_bson_iter_init_find_case); + TestSuite_Add (suite, "/bson/iter/recurse", "", test_bson_iter_recurse); TestSuite_Add ( - suite, "/bson/iter/find_descendant", test_bson_iter_find_descendant); - TestSuite_Add (suite, "/bson/iter/as_bool", test_bson_iter_as_bool); + suite, "/bson/iter/init_find_case", "", test_bson_iter_init_find_case); TestSuite_Add ( - suite, "/bson/iter/binary_deprecated", test_bson_iter_binary_deprecated); - TestSuite_Add (suite, "/bson/iter/from_data", test_bson_iter_from_data); - TestSuite_Add (suite, "/bson/iter/empty_key", test_bson_iter_empty_key); + suite, "/bson/iter/find_descendant", "", test_bson_iter_find_descendant); + TestSuite_Add (suite, "/bson/iter/as_bool", "", test_bson_iter_as_bool); + TestSuite_Add (suite, + "/bson/iter/binary_deprecated", + "", + test_bson_iter_binary_deprecated); + TestSuite_Add (suite, "/bson/iter/from_data", "", test_bson_iter_from_data); + TestSuite_Add (suite, "/bson/iter/empty_key", "", test_bson_iter_empty_key); } diff --git a/src/libbson/tests/test-json.c b/src/libbson/tests/test-json.c index de3581fba74..d0508edcd3a 100644 --- a/src/libbson/tests/test-json.c +++ b/src/libbson/tests/test-json.c @@ -3427,186 +3427,245 @@ test_bson_as_json_with_opts_all_types (void) void test_json_install (TestSuite *suite) { - TestSuite_Add (suite, "/bson/as_json/x1000", test_bson_as_json_x1000); - TestSuite_Add (suite, "/bson/as_json/multi", test_bson_as_json_multi); - TestSuite_Add (suite, "/bson/as_json/string", test_bson_as_json_string); - TestSuite_Add (suite, "/bson/as_json/int32", test_bson_as_json_int32); - TestSuite_Add (suite, "/bson/as_json/int64", test_bson_as_json_int64); - TestSuite_Add (suite, "/bson/as_json/double", test_bson_as_json_double); + TestSuite_Add (suite, "/bson/as_json/x1000", "", test_bson_as_json_x1000); + TestSuite_Add (suite, "/bson/as_json/multi", "", test_bson_as_json_multi); + TestSuite_Add (suite, "/bson/as_json/string", "", test_bson_as_json_string); + TestSuite_Add (suite, "/bson/as_json/int32", "", test_bson_as_json_int32); + TestSuite_Add (suite, "/bson/as_json/int64", "", test_bson_as_json_int64); + TestSuite_Add (suite, "/bson/as_json/double", "", test_bson_as_json_double); #if defined(NAN) && defined(INFINITY) TestSuite_Add (suite, "/bson/as_json/double/nonfinite", + "", test_bson_as_json_double_nonfinite); #endif - TestSuite_Add (suite, "/bson/as_json/code", test_bson_as_json_code); + TestSuite_Add (suite, "/bson/as_json/code", "", test_bson_as_json_code); TestSuite_Add ( - suite, "/bson/as_json/date_time", test_bson_as_json_date_time); - TestSuite_Add (suite, "/bson/as_json/regex", test_bson_as_json_regex); - TestSuite_Add (suite, "/bson/as_json/symbol", test_bson_as_json_symbol); - TestSuite_Add (suite, "/bson/as_json/utf8", test_bson_as_json_utf8); + suite, "/bson/as_json/date_time", "", test_bson_as_json_date_time); + TestSuite_Add (suite, "/bson/as_json/regex", "", test_bson_as_json_regex); + TestSuite_Add (suite, "/bson/as_json/symbol", "", test_bson_as_json_symbol); + TestSuite_Add (suite, "/bson/as_json/utf8", "", test_bson_as_json_utf8); TestSuite_Add ( - suite, "/bson/as_json/dbpointer", test_bson_as_json_dbpointer); + suite, "/bson/as_json/dbpointer", "", test_bson_as_json_dbpointer); TestSuite_Add (suite, "/bson/as_canonical_extended_json/dbpointer", + "", test_bson_as_canonical_extended_json_dbpointer); + TestSuite_Add (suite, + "/bson/as_json/stack_overflow", + "", + test_bson_as_json_stack_overflow); + TestSuite_Add (suite, "/bson/as_json/corrupt", "", test_bson_corrupt); + TestSuite_Add ( + suite, "/bson/as_json/corrupt_utf8", "", test_bson_corrupt_utf8); + TestSuite_Add ( + suite, "/bson/as_json/corrupt_binary", "", test_bson_corrupt_binary); + TestSuite_Add ( + suite, "/bson/as_json_spacing", "", test_bson_as_json_spacing); + TestSuite_Add (suite, "/bson/array_as_json", "", test_bson_array_as_json); TestSuite_Add ( - suite, "/bson/as_json/stack_overflow", test_bson_as_json_stack_overflow); - TestSuite_Add (suite, "/bson/as_json/corrupt", test_bson_corrupt); - TestSuite_Add (suite, "/bson/as_json/corrupt_utf8", test_bson_corrupt_utf8); + suite, "/bson/json/allow_multiple", "", test_bson_json_allow_multiple); TestSuite_Add ( - suite, "/bson/as_json/corrupt_binary", test_bson_corrupt_binary); - TestSuite_Add (suite, "/bson/as_json_spacing", test_bson_as_json_spacing); - TestSuite_Add (suite, "/bson/array_as_json", test_bson_array_as_json); + suite, "/bson/json/read/buffering", "", test_bson_json_read_buffering); + TestSuite_Add (suite, "/bson/json/read", "", test_bson_json_read); + TestSuite_Add (suite, "/bson/json/inc", "", test_bson_json_inc); + TestSuite_Add (suite, "/bson/json/array", "", test_bson_json_array); TestSuite_Add ( - suite, "/bson/json/allow_multiple", test_bson_json_allow_multiple); + suite, "/bson/json/array/single", "", test_bson_json_array_single); TestSuite_Add ( - suite, "/bson/json/read/buffering", test_bson_json_read_buffering); - TestSuite_Add (suite, "/bson/json/read", test_bson_json_read); - TestSuite_Add (suite, "/bson/json/inc", test_bson_json_inc); - TestSuite_Add (suite, "/bson/json/array", test_bson_json_array); + suite, "/bson/json/array/int64", "", test_bson_json_array_int64); TestSuite_Add ( - suite, "/bson/json/array/single", test_bson_json_array_single); - TestSuite_Add (suite, "/bson/json/array/int64", test_bson_json_array_int64); + suite, "/bson/json/array/subdoc", "", test_bson_json_array_subdoc); + TestSuite_Add (suite, "/bson/json/date", "", test_bson_json_date); TestSuite_Add ( - suite, "/bson/json/array/subdoc", test_bson_json_array_subdoc); - TestSuite_Add (suite, "/bson/json/date", test_bson_json_date); - TestSuite_Add (suite, "/bson/json/date/legacy", test_bson_json_date_legacy); + suite, "/bson/json/date/legacy", "", test_bson_json_date_legacy); TestSuite_Add ( - suite, "/bson/json/date/long", test_bson_json_date_numberlong); - TestSuite_Add (suite, "/bson/json/timestamp", test_bson_json_timestamp); - TestSuite_Add (suite, "/bson/json/read/empty", test_bson_json_read_empty); + suite, "/bson/json/date/long", "", test_bson_json_date_numberlong); + TestSuite_Add (suite, "/bson/json/timestamp", "", test_bson_json_timestamp); + TestSuite_Add ( + suite, "/bson/json/read/empty", "", test_bson_json_read_empty); TestSuite_Add (suite, "/bson/json/read/missing_complex", + "", test_bson_json_read_missing_complex); TestSuite_Add (suite, "/bson/json/read/invalid_binary", + "", test_bson_json_read_invalid_binary); + TestSuite_Add (suite, + "/bson/json/read/invalid_json", + "", + test_bson_json_read_invalid_json); TestSuite_Add ( - suite, "/bson/json/read/invalid_json", test_bson_json_read_invalid_json); - TestSuite_Add (suite, "/bson/json/read/bad_cb", test_bson_json_read_bad_cb); + suite, "/bson/json/read/bad_cb", "", test_bson_json_read_bad_cb); TestSuite_Add ( - suite, "/bson/json/read/invalid", test_bson_json_read_invalid); + suite, "/bson/json/read/invalid", "", test_bson_json_read_invalid); TestSuite_Add (suite, "/bson/json/read/invalid_base64", + "", test_bson_json_read_invalid_base64); TestSuite_Add ( - suite, "/bson/json/read/raw_utf8", test_bson_json_read_raw_utf8); - TestSuite_Add ( - suite, "/bson/json/read/corrupt_utf8", test_bson_json_read_corrupt_utf8); + suite, "/bson/json/read/raw_utf8", "", test_bson_json_read_raw_utf8); + TestSuite_Add (suite, + "/bson/json/read/corrupt_utf8", + "", + test_bson_json_read_corrupt_utf8); TestSuite_Add (suite, "/bson/json/read/corrupt_document", + "", test_bson_json_read_corrupt_document); TestSuite_Add ( - suite, "/bson/json/read/decimal128", test_bson_json_read_decimal128); + suite, "/bson/json/read/decimal128", "", test_bson_json_read_decimal128); TestSuite_Add ( - suite, "/bson/json/read/dbpointer", test_bson_json_read_dbpointer); - TestSuite_Add ( - suite, "/bson/json/read/legacy_regex", test_bson_json_read_legacy_regex); + suite, "/bson/json/read/dbpointer", "", test_bson_json_read_dbpointer); + TestSuite_Add (suite, + "/bson/json/read/legacy_regex", + "", + test_bson_json_read_legacy_regex); TestSuite_Add (suite, "/bson/json/read/regex_options_order", + "", test_bson_json_read_regex_options_order); - TestSuite_Add (suite, "/bson/json/read/binary", test_bson_json_read_binary); + TestSuite_Add ( + suite, "/bson/json/read/binary", "", test_bson_json_read_binary); TestSuite_Add (suite, "/bson/json/read/legacy_binary", + "", test_bson_json_read_legacy_binary); TestSuite_Add ( - suite, "/bson/json/read/file", test_json_reader_new_from_file); - TestSuite_Add ( - suite, "/bson/json/read/bad_path", test_json_reader_new_from_bad_path); + suite, "/bson/json/read/file", "", test_json_reader_new_from_file); + TestSuite_Add (suite, + "/bson/json/read/bad_path", + "", + test_json_reader_new_from_bad_path); TestSuite_Add ( - suite, "/bson/json/read/$numberLong", test_bson_json_number_long); + suite, "/bson/json/read/$numberLong", "", test_bson_json_number_long); TestSuite_Add (suite, "/bson/json/read/$numberLong/zero", + "", test_bson_json_number_long_zero); - TestSuite_Add (suite, "/bson/json/read/code", test_bson_json_code); - TestSuite_Add ( - suite, "/bson/json/read/code/errors", test_bson_json_code_errors); - TestSuite_Add (suite, "/bson/json/read/dbref", test_bson_json_dbref); - TestSuite_Add (suite, "/bson/json/read/uescape", test_bson_json_uescape); - TestSuite_Add ( - suite, "/bson/json/read/uescape/key", test_bson_json_uescape_key); + TestSuite_Add (suite, "/bson/json/read/code", "", test_bson_json_code); TestSuite_Add ( - suite, "/bson/json/read/uescape/bad", test_bson_json_uescape_bad); - TestSuite_Add (suite, "/bson/json/read/int32", test_bson_json_int32); - TestSuite_Add (suite, "/bson/json/read/int64", test_bson_json_int64); - TestSuite_Add (suite, "/bson/json/read/double", test_bson_json_double); + suite, "/bson/json/read/code/errors", "", test_bson_json_code_errors); + TestSuite_Add (suite, "/bson/json/read/dbref", "", test_bson_json_dbref); + TestSuite_Add (suite, "/bson/json/read/uescape", "", test_bson_json_uescape); TestSuite_Add ( - suite, "/bson/json/read/double/overflow", test_bson_json_double_overflow); - TestSuite_Add (suite, "/bson/json/read/double/nan", test_bson_json_nan); + suite, "/bson/json/read/uescape/key", "", test_bson_json_uescape_key); TestSuite_Add ( - suite, "/bson/json/read/double/infinity", test_bson_json_infinity); - TestSuite_Add (suite, "/bson/json/read/null", test_bson_json_null); - TestSuite_Add ( - suite, "/bson/json/read/empty_final", test_bson_json_empty_final_object); + suite, "/bson/json/read/uescape/bad", "", test_bson_json_uescape_bad); + TestSuite_Add (suite, "/bson/json/read/int32", "", test_bson_json_int32); + TestSuite_Add (suite, "/bson/json/read/int64", "", test_bson_json_int64); + TestSuite_Add (suite, "/bson/json/read/double", "", test_bson_json_double); + TestSuite_Add (suite, + "/bson/json/read/double/overflow", + "", + test_bson_json_double_overflow); + TestSuite_Add (suite, "/bson/json/read/double/nan", "", test_bson_json_nan); TestSuite_Add ( - suite, "/bson/as_json/decimal128", test_bson_as_json_decimal128); + suite, "/bson/json/read/double/infinity", "", test_bson_json_infinity); + TestSuite_Add (suite, "/bson/json/read/null", "", test_bson_json_null); + TestSuite_Add (suite, + "/bson/json/read/empty_final", + "", + test_bson_json_empty_final_object); TestSuite_Add ( - suite, "/bson/json/read/$numberDecimal", test_bson_json_number_decimal); - TestSuite_Add (suite, "/bson/json/errors", test_bson_json_errors); - TestSuite_Add (suite, "/bson/integer/width", test_bson_integer_width); + suite, "/bson/as_json/decimal128", "", test_bson_as_json_decimal128); + TestSuite_Add (suite, + "/bson/json/read/$numberDecimal", + "", + test_bson_json_number_decimal); + TestSuite_Add (suite, "/bson/json/errors", "", test_bson_json_errors); + TestSuite_Add (suite, "/bson/integer/width", "", test_bson_integer_width); TestSuite_Add ( - suite, "/bson/json/read/null_in_str", test_bson_json_null_in_str); + suite, "/bson/json/read/null_in_str", "", test_bson_json_null_in_str); TestSuite_Add ( - suite, "/bson/as_json/multi_object", test_bson_as_json_multi_object); + suite, "/bson/as_json/multi_object", "", test_bson_as_json_multi_object); TestSuite_Add (suite, "/bson/as_json_with_opts/double", + "", test_bson_as_json_with_opts_double); - TestSuite_Add ( - suite, "/bson/as_json_with_opts/utf8", test_bson_as_json_with_opts_utf8); + TestSuite_Add (suite, + "/bson/as_json_with_opts/utf8", + "", + test_bson_as_json_with_opts_utf8); TestSuite_Add (suite, "/bson/as_json_with_opts/document", + "", test_bson_as_json_with_opts_document); TestSuite_Add (suite, "/bson/as_json_with_opts/array", + "", test_bson_as_json_with_opts_array); TestSuite_Add (suite, "/bson/as_json_with_opts/binary", + "", test_bson_as_json_with_opts_binary); TestSuite_Add (suite, "/bson/as_json_with_opts/undefined", + "", test_bson_as_json_with_opts_undefined); - TestSuite_Add ( - suite, "/bson/as_json_with_opts/oid", test_bson_as_json_with_opts_oid); - TestSuite_Add ( - suite, "/bson/as_json_with_opts/bool", test_bson_as_json_with_opts_bool); + TestSuite_Add (suite, + "/bson/as_json_with_opts/oid", + "", + test_bson_as_json_with_opts_oid); + TestSuite_Add (suite, + "/bson/as_json_with_opts/bool", + "", + test_bson_as_json_with_opts_bool); TestSuite_Add (suite, "/bson/as_json_with_opts/date_time", + "", test_bson_as_json_with_opts_date_time); - TestSuite_Add ( - suite, "/bson/as_json_with_opts/null", test_bson_as_json_with_opts_null); + TestSuite_Add (suite, + "/bson/as_json_with_opts/null", + "", + test_bson_as_json_with_opts_null); TestSuite_Add (suite, "/bson/as_json_with_opts/regex", + "", test_bson_as_json_with_opts_regex); TestSuite_Add (suite, "/bson/as_json_with_opts/dbpointer", + "", test_bson_as_json_with_opts_dbpointer); - TestSuite_Add ( - suite, "/bson/as_json_with_opts/code", test_bson_as_json_with_opts_code); + TestSuite_Add (suite, + "/bson/as_json_with_opts/code", + "", + test_bson_as_json_with_opts_code); TestSuite_Add (suite, "/bson/as_json_with_opts/symbol", + "", test_bson_as_json_with_opts_symbol); TestSuite_Add (suite, "/bson/as_json_with_opts/codewscope", + "", test_bson_as_json_with_opts_codewscope); TestSuite_Add (suite, "/bson/as_json_with_opts/int32", + "", test_bson_as_json_with_opts_int32); TestSuite_Add (suite, "/bson/as_json_with_opts/int64", + "", test_bson_as_json_with_opts_int64); TestSuite_Add (suite, "/bson/as_json_with_opts/timestamp", + "", test_bson_as_json_with_opts_timestamp); TestSuite_Add (suite, "/bson/as_json_with_opts/minkey", + "", test_bson_as_json_with_opts_minkey); TestSuite_Add (suite, "/bson/as_json_with_opts/maxkey", + "", test_bson_as_json_with_opts_maxkey); TestSuite_Add (suite, "/bson/as_json_with_opts/decimal128", + "", test_bson_as_json_with_opts_decimal128); TestSuite_Add (suite, - "/bson/as_json_with_opts/all_types", - test_bson_as_json_with_opts_all_types); + "/bson/as_json_with_opts/all_types", + "", + test_bson_as_json_with_opts_all_types); } diff --git a/src/libbson/tests/test-oid.c b/src/libbson/tests/test-oid.c index 7a6cc96defa..fa36cf032e4 100644 --- a/src/libbson/tests/test-oid.c +++ b/src/libbson/tests/test-oid.c @@ -564,31 +564,33 @@ test_bson_hostnames (void) void test_oid_install (TestSuite *suite) { - TestSuite_Add (suite, "/bson/oid/init", test_bson_oid_init); + TestSuite_Add (suite, "/bson/oid/init", "", test_bson_oid_init); TestSuite_Add ( - suite, "/bson/oid/init_from_string", test_bson_oid_init_from_string); + suite, "/bson/oid/init_from_string", "", test_bson_oid_init_from_string); TestSuite_Add ( - suite, "/bson/oid/init_sequence", test_bson_oid_init_sequence); + suite, "/bson/oid/init_sequence", "", test_bson_oid_init_sequence); TestSuite_Add (suite, "/bson/oid/init_sequence_thread_safe", + "", test_bson_oid_init_sequence_thread_safe); #ifdef BSON_HAVE_SYSCALL_TID TestSuite_Add (suite, "/bson/oid/init_sequence_with_tid", + "", test_bson_oid_init_sequence_with_tid); #endif TestSuite_Add ( - suite, "/bson/oid/init_with_threads", test_bson_oid_init_with_threads); - TestSuite_Add (suite, "/bson/oid/hash", test_bson_oid_hash); - TestSuite_Add (suite, "/bson/oid/compare", test_bson_oid_compare); - TestSuite_Add (suite, "/bson/oid/copy", test_bson_oid_copy); - TestSuite_Add (suite, "/bson/oid/get_time_t", test_bson_oid_get_time_t); + suite, "/bson/oid/init_with_threads", "", test_bson_oid_init_with_threads); + TestSuite_Add (suite, "/bson/oid/hash", "", test_bson_oid_hash); + TestSuite_Add (suite, "/bson/oid/compare", "", test_bson_oid_compare); + TestSuite_Add (suite, "/bson/oid/copy", "", test_bson_oid_copy); + TestSuite_Add (suite, "/bson/oid/get_time_t", "", test_bson_oid_get_time_t); TestSuite_Add ( - suite, "/bson/oid/counter_overflow", test_bson_oid_counter_overflow); + suite, "/bson/oid/counter_overflow", "", test_bson_oid_counter_overflow); #ifndef _WIN32 if (!TestSuite_NoFork (suite)) { - TestSuite_Add (suite, "/bson/oid/after_fork", test_bson_oid_after_fork); + TestSuite_Add (suite, "/bson/oid/after_fork", "", test_bson_oid_after_fork); } #endif - TestSuite_Add (suite, "/bson/oid/hostnames", test_bson_hostnames); + TestSuite_Add (suite, "/bson/oid/hostnames", "", test_bson_hostnames); } diff --git a/src/libbson/tests/test-reader.c b/src/libbson/tests/test-reader.c index 9c6b6e3b2ae..c7974c26246 100644 --- a/src/libbson/tests/test-reader.c +++ b/src/libbson/tests/test-reader.c @@ -310,22 +310,28 @@ test_reader_reset (void) void test_reader_install (TestSuite *suite) { - TestSuite_Add (suite, "/bson/reader/new_from_data", test_reader_from_data); + TestSuite_Add ( + suite, "/bson/reader/new_from_data", "", test_reader_from_data); TestSuite_Add (suite, "/bson/reader/new_from_data_overflow", + "", test_reader_from_data_overflow); TestSuite_Add (suite, "/bson/reader/new_from_data_document_length_too_large", + "", test_reader_from_data_document_length_too_large); TestSuite_Add (suite, "/bson/reader/new_from_data_document_length_too_small", + "", test_reader_from_data_document_length_too_small); TestSuite_Add ( - suite, "/bson/reader/new_from_handle", test_reader_from_handle); - TestSuite_Add (suite, "/bson/reader/tell", test_reader_tell); + suite, "/bson/reader/new_from_handle", "", test_reader_from_handle); + TestSuite_Add (suite, "/bson/reader/tell", "", test_reader_tell); TestSuite_Add (suite, "/bson/reader/new_from_handle_corrupt", + "", test_reader_from_handle_corrupt); - TestSuite_Add (suite, "/bson/reader/grow_buffer", test_reader_grow_buffer); - TestSuite_Add (suite, "/bson/reader/reset", test_reader_reset); + TestSuite_Add ( + suite, "/bson/reader/grow_buffer", "", test_reader_grow_buffer); + TestSuite_Add (suite, "/bson/reader/reset", "", test_reader_reset); } diff --git a/src/libbson/tests/test-string.c b/src/libbson/tests/test-string.c index 8efd004b352..f321bc3f9ec 100644 --- a/src/libbson/tests/test-string.c +++ b/src/libbson/tests/test-string.c @@ -308,19 +308,24 @@ test_bson_strcasecmp (void) void test_string_install (TestSuite *suite) { - TestSuite_Add (suite, "/bson/string/new", test_bson_string_new); - TestSuite_Add (suite, "/bson/string/append", test_bson_string_append); - TestSuite_Add (suite, "/bson/string/append_c", test_bson_string_append_c); + TestSuite_Add (suite, "/bson/string/new", "", test_bson_string_new); + TestSuite_Add (suite, "/bson/string/append", "", test_bson_string_append); TestSuite_Add ( - suite, "/bson/string/append_printf", test_bson_string_append_printf); + suite, "/bson/string/append_c", "", test_bson_string_append_c); TestSuite_Add ( - suite, "/bson/string/append_unichar", test_bson_string_append_unichar); - TestSuite_Add (suite, "/bson/string/strdup", test_bson_strdup); - TestSuite_Add (suite, "/bson/string/strdup_printf", test_bson_strdup_printf); - TestSuite_Add (suite, "/bson/string/strndup", test_bson_strndup); - TestSuite_Add (suite, "/bson/string/ascii_strtoll", test_bson_ascii_strtoll); - TestSuite_Add (suite, "/bson/string/strncpy", test_bson_strncpy); - TestSuite_Add (suite, "/bson/string/snprintf", test_bson_snprintf); - TestSuite_Add (suite, "/bson/string/strnlen", test_bson_strnlen); - TestSuite_Add (suite, "/bson/string/strcasecmp", test_bson_strcasecmp); + suite, "/bson/string/append_printf", "", test_bson_string_append_printf); + TestSuite_Add (suite, + "/bson/string/append_unichar", + "", + test_bson_string_append_unichar); + TestSuite_Add (suite, "/bson/string/strdup", "", test_bson_strdup); + TestSuite_Add ( + suite, "/bson/string/strdup_printf", "", test_bson_strdup_printf); + TestSuite_Add (suite, "/bson/string/strndup", "", test_bson_strndup); + TestSuite_Add ( + suite, "/bson/string/ascii_strtoll", "", test_bson_ascii_strtoll); + TestSuite_Add (suite, "/bson/string/strncpy", "", test_bson_strncpy); + TestSuite_Add (suite, "/bson/string/snprintf", "", test_bson_snprintf); + TestSuite_Add (suite, "/bson/string/strnlen", "", test_bson_strnlen); + TestSuite_Add (suite, "/bson/string/strcasecmp", "", test_bson_strcasecmp); } diff --git a/src/libbson/tests/test-utf8.c b/src/libbson/tests/test-utf8.c index 14fe08d1888..5a9ef6b98a6 100644 --- a/src/libbson/tests/test-utf8.c +++ b/src/libbson/tests/test-utf8.c @@ -254,15 +254,15 @@ test_bson_utf8_non_shortest (void) void test_utf8_install (TestSuite *suite) { - TestSuite_Add (suite, "/bson/utf8/validate", test_bson_utf8_validate); - TestSuite_Add (suite, "/bson/utf8/invalid", test_bson_utf8_invalid); - TestSuite_Add (suite, "/bson/utf8/nil", test_bson_utf8_nil); + TestSuite_Add (suite, "/bson/utf8/validate", "", test_bson_utf8_validate); + TestSuite_Add (suite, "/bson/utf8/invalid", "", test_bson_utf8_invalid); + TestSuite_Add (suite, "/bson/utf8/nil", "", test_bson_utf8_nil); TestSuite_Add ( - suite, "/bson/utf8/escape_for_json", test_bson_utf8_escape_for_json); + suite, "/bson/utf8/escape_for_json", "", test_bson_utf8_escape_for_json); TestSuite_Add ( - suite, "/bson/utf8/get_char_next_char", test_bson_utf8_get_char); + suite, "/bson/utf8/get_char_next_char", "", test_bson_utf8_get_char); TestSuite_Add ( - suite, "/bson/utf8/from_unichar", test_bson_utf8_from_unichar); + suite, "/bson/utf8/from_unichar", "", test_bson_utf8_from_unichar); TestSuite_Add ( - suite, "/bson/utf8/non_shortest", test_bson_utf8_non_shortest); + suite, "/bson/utf8/non_shortest", "", test_bson_utf8_non_shortest); } diff --git a/src/libbson/tests/test-value.c b/src/libbson/tests/test-value.c index cd826588844..b09fc67d661 100644 --- a/src/libbson/tests/test-value.c +++ b/src/libbson/tests/test-value.c @@ -132,6 +132,6 @@ test_value_decimal128 (void) void test_value_install (TestSuite *suite) { - TestSuite_Add (suite, "/bson/value/basic", test_value_basic); - TestSuite_Add (suite, "/bson/value/decimal128", test_value_decimal128); + TestSuite_Add (suite, "/bson/value/basic", "", test_value_basic); + TestSuite_Add (suite, "/bson/value/decimal128", "", test_value_decimal128); } diff --git a/src/libbson/tests/test-writer.c b/src/libbson/tests/test-writer.c index f786049e82c..292a1a920e8 100644 --- a/src/libbson/tests/test-writer.c +++ b/src/libbson/tests/test-writer.c @@ -183,14 +183,20 @@ test_bson_writer_null_realloc_2 (void) void test_writer_install (TestSuite *suite) { + TestSuite_Add (suite, + "/bson/writer/custom_realloc", + "", + test_bson_writer_custom_realloc); TestSuite_Add ( - suite, "/bson/writer/custom_realloc", test_bson_writer_custom_realloc); + suite, "/bson/writer/shared_buffer", "", test_bson_writer_shared_buffer); + TestSuite_Add (suite, + "/bson/writer/empty_sequence", + "", + test_bson_writer_empty_sequence); TestSuite_Add ( - suite, "/bson/writer/shared_buffer", test_bson_writer_shared_buffer); - TestSuite_Add ( - suite, "/bson/writer/empty_sequence", test_bson_writer_empty_sequence); - TestSuite_Add ( - suite, "/bson/writer/null_realloc", test_bson_writer_null_realloc); - TestSuite_Add ( - suite, "/bson/writer/null_realloc_2", test_bson_writer_null_realloc_2); + suite, "/bson/writer/null_realloc", "", test_bson_writer_null_realloc); + TestSuite_Add (suite, + "/bson/writer/null_realloc_2", + "", + test_bson_writer_null_realloc_2); } diff --git a/src/libmongoc/tests/TestSuite.c b/src/libmongoc/tests/TestSuite.c index 05887056a4d..4ec65f98742 100644 --- a/src/libmongoc/tests/TestSuite.c +++ b/src/libmongoc/tests/TestSuite.c @@ -309,20 +309,24 @@ TestSuite_AddHelper (void *ctx) void TestSuite_Add (TestSuite *suite, /* IN */ const char *name, /* IN */ + const char *meta, /* IN */ TestFunc func) /* IN */ { TestSuite_AddFullWithTestFn ( - suite, name, TestSuite_AddHelper, NULL, func, TestSuite_CheckDummy); + suite, name, meta, TestSuite_AddHelper, NULL, func, TestSuite_CheckDummy); } void TestSuite_AddLive (TestSuite *suite, /* IN */ - const char *name, /* IN */ + const char *name, + const char *meta, /* IN */ TestFunc func) /* IN */ { + char *meta1 = bson_strdup_printf ("%s%s", meta, " uses-live-server"); TestSuite_AddFullWithTestFn ( - suite, name, TestSuite_AddHelper, NULL, func, TestSuite_CheckLive); + suite, name, meta1, TestSuite_AddHelper, NULL, func, TestSuite_CheckLive); + bson_free (meta1); } @@ -344,6 +348,7 @@ _TestSuite_AddCheck (Test *test, CheckFunc check, const char *name) Test * _V_TestSuite_AddFull (TestSuite *suite, const char *name, + const char *meta, TestFuncWC func, TestFuncDtor dtor, void *ctx, @@ -356,6 +361,7 @@ _V_TestSuite_AddFull (TestSuite *suite, test = (Test *) calloc (1, sizeof *test); test->name = bson_strdup (name); test->func = func; + test->meta = bson_strdup (meta); test->num_checks = 0; while ((check = va_arg (ap, CheckFunc))) { @@ -381,36 +387,40 @@ _V_TestSuite_AddFull (TestSuite *suite, void -_TestSuite_AddMockServerTest (TestSuite *suite, - const char *name, - TestFunc func, - ...) +_TestSuite_AddMockServerTest ( + TestSuite *suite, const char *name, const char *meta, TestFunc func, ...) { Test *test; va_list ap; + char *meta1 = bson_strdup_printf ("%s%s", meta, " uses-mock-server"); + va_start (ap, func); - test = _V_TestSuite_AddFull (suite, name, (TestFuncWC) func, NULL, NULL, ap); + test = _V_TestSuite_AddFull ( + suite, name, meta1, (TestFuncWC) func, NULL, NULL, ap); va_end (ap); _TestSuite_AddCheck (test, TestSuite_CheckMockServerAllowed, name); + bson_free (meta1); } void TestSuite_AddWC (TestSuite *suite, /* IN */ const char *name, /* IN */ + const char *meta, /* IN */ TestFuncWC func, /* IN */ TestFuncDtor dtor, /* IN */ void *ctx) /* IN */ { - TestSuite_AddFull (suite, name, func, dtor, ctx, TestSuite_CheckDummy); + TestSuite_AddFull (suite, name, meta, func, dtor, ctx, TestSuite_CheckDummy); } void _TestSuite_AddFull (TestSuite *suite, /* IN */ const char *name, /* IN */ + const char *meta, /* IN */ TestFuncWC func, /* IN */ TestFuncDtor dtor, /* IN */ void *ctx, @@ -419,7 +429,7 @@ _TestSuite_AddFull (TestSuite *suite, /* IN */ va_list ap; va_start (ap, ctx); - _V_TestSuite_AddFull (suite, name, func, dtor, ctx, ap); + _V_TestSuite_AddFull (suite, name, meta, func, dtor, ctx, ap); va_end (ap); } @@ -750,7 +760,8 @@ TestSuite_PrintTests (TestSuite *suite) /* IN */ printf ("\nTests:\n"); for (iter = suite->tests; iter; iter = iter->next) { - printf ("%s%s\n", suite->name, iter->name); + printf ( + "%s%s %s\n", suite->name, iter->name, iter->meta ? iter->meta : ""); } printf ("\n"); @@ -1075,6 +1086,7 @@ TestSuite_Destroy (TestSuite *suite) test->dtor (test->ctx); } free (test->name); + free (test->meta); free (test); } diff --git a/src/libmongoc/tests/TestSuite.h b/src/libmongoc/tests/TestSuite.h index 10fdd8b6a65..695b41795f0 100644 --- a/src/libmongoc/tests/TestSuite.h +++ b/src/libmongoc/tests/TestSuite.h @@ -653,6 +653,7 @@ typedef struct _TestFnCtx TestFnCtx; struct _Test { Test *next; char *name; + char *meta; TestFuncWC func; TestFuncDtor dtor; void *ctx; @@ -691,29 +692,35 @@ struct _TestFnCtx { void TestSuite_Init (TestSuite *suite, const char *name, int argc, char **argv); void -TestSuite_Add (TestSuite *suite, const char *name, TestFunc func); +TestSuite_Add (TestSuite *suite, + const char *name, + const char *meta, + TestFunc func); int TestSuite_CheckLive (void); void -TestSuite_AddLive (TestSuite *suite, const char *name, TestFunc func); +TestSuite_AddLive (TestSuite *suite, + const char *name, + const char *meta, + TestFunc func); int TestSuite_CheckMockServerAllowed (void); void -_TestSuite_AddMockServerTest (TestSuite *suite, - const char *name, - TestFunc func, - ...); -#define TestSuite_AddMockServerTest(_suite, _name, ...) \ - _TestSuite_AddMockServerTest (_suite, _name, __VA_ARGS__, NULL) +_TestSuite_AddMockServerTest ( + TestSuite *suite, const char *name, const char *meta, TestFunc func, ...); +#define TestSuite_AddMockServerTest(_suite, _name, _meta, ...) \ + _TestSuite_AddMockServerTest (_suite, _name, _meta, __VA_ARGS__, NULL) void TestSuite_AddWC (TestSuite *suite, const char *name, + const char *meta, TestFuncWC func, TestFuncDtor dtor, void *ctx); Test * _V_TestSuite_AddFull (TestSuite *suite, const char *name, + const char *meta, TestFuncWC func, TestFuncDtor dtor, void *ctx, @@ -721,6 +728,7 @@ _V_TestSuite_AddFull (TestSuite *suite, void _TestSuite_AddFull (TestSuite *suite, const char *name, + const char *meta, TestFuncWC func, TestFuncDtor dtor, void *ctx, @@ -729,19 +737,20 @@ void _TestSuite_TestFnCtxDtor (void *ctx); #define TestSuite_AddFull(_suite, _name, _func, _dtor, _ctx, ...) \ _TestSuite_AddFull (_suite, _name, _func, _dtor, _ctx, __VA_ARGS__, NULL) -#define TestSuite_AddFullWithTestFn( \ - _suite, _name, _func, _dtor, _test_fn, ...) \ - do { \ - TestFnCtx *ctx = malloc (sizeof (TestFnCtx)); \ - ctx->test_fn = (TestFunc) (_test_fn); \ - ctx->dtor = _dtor; \ - _TestSuite_AddFull (_suite, \ - _name, \ - _func, \ - _TestSuite_TestFnCtxDtor, \ - ctx, \ - __VA_ARGS__, \ - NULL); \ +#define TestSuite_AddFullWithTestFn( \ + _suite, _name, _meta, _func, _dtor, _test_fn, ...) \ + do { \ + TestFnCtx *ctx = malloc (sizeof (TestFnCtx)); \ + ctx->test_fn = (TestFunc) (_test_fn); \ + ctx->dtor = _dtor; \ + _TestSuite_AddFull (_suite, \ + _name, \ + _meta, \ + _func, \ + _TestSuite_TestFnCtxDtor, \ + ctx, \ + __VA_ARGS__, \ + NULL); \ } while (0) int TestSuite_Run (TestSuite *suite); diff --git a/src/libmongoc/tests/bsonutil/bson-match.c b/src/libmongoc/tests/bsonutil/bson-match.c index 0c3bb555227..d51017e3d00 100644 --- a/src/libmongoc/tests/bsonutil/bson-match.c +++ b/src/libmongoc/tests/bsonutil/bson-match.c @@ -618,5 +618,5 @@ test_match (void) void test_bson_match_install (TestSuite *suite) { - TestSuite_Add (suite, "/unified/selftest/bson/match", test_match); + TestSuite_Add (suite, "/unified/selftest/bson/match", "", test_match); } diff --git a/src/libmongoc/tests/json-test-monitoring.c b/src/libmongoc/tests/json-test-monitoring.c index 1a22bcda0dc..b9c6aedfdde 100644 --- a/src/libmongoc/tests/json-test-monitoring.c +++ b/src/libmongoc/tests/json-test-monitoring.c @@ -622,5 +622,5 @@ test_apm_matching (void) void test_apm_install (TestSuite *suite) { - TestSuite_Add (suite, "/apm_test_matching", test_apm_matching); + TestSuite_Add (suite, "/apm_test_matching", "", test_apm_matching); } diff --git a/src/libmongoc/tests/json-test.c b/src/libmongoc/tests/json-test.c index 26d5cb20aa5..2c6c8a49f3f 100644 --- a/src/libmongoc/tests/json-test.c +++ b/src/libmongoc/tests/json-test.c @@ -1945,6 +1945,7 @@ _install_json_test_suite_with_check (TestSuite *suite, va_start (ap, callback); _V_TestSuite_AddFull (suite, skip_json, + "json-test uses-live-server", (void (*) (void *)) callback, (void (*) (void *)) bson_destroy, test, diff --git a/src/libmongoc/tests/test-happy-eyeballs.c b/src/libmongoc/tests/test-happy-eyeballs.c index 86f9937ab5b..f8851821879 100644 --- a/src/libmongoc/tests/test-happy-eyeballs.c +++ b/src/libmongoc/tests/test-happy-eyeballs.c @@ -580,6 +580,7 @@ test_happy_eyeballs_install (TestSuite *suite) char *name = bson_strdup_printf ("/TOPOLOGY/happy_eyeballs/%d", i); TestSuite_AddFull (suite, name, + "", _run_testcase, NULL, he_testcases + i, @@ -589,6 +590,7 @@ test_happy_eyeballs_install (TestSuite *suite) } TestSuite_AddMockServerTest (suite, "/TOPOLOGY/happy_eyeballs/dns_cache/", + "", test_happy_eyeballs_dns_cache, test_framework_skip_if_no_dual_ip_hostname); } diff --git a/src/libmongoc/tests/test-libmongoc.c b/src/libmongoc/tests/test-libmongoc.c index e4b977b569e..4eacc30d930 100644 --- a/src/libmongoc/tests/test-libmongoc.c +++ b/src/libmongoc/tests/test-libmongoc.c @@ -2857,7 +2857,7 @@ main (int argc, char *argv[]) #endif TestSuite_Init (&suite, "", argc, argv); - TestSuite_Add (&suite, "/TestSuite/version_cmp", test_version_cmp); + TestSuite_Add (&suite, "/TestSuite/version_cmp", "", test_version_cmp); /* libbson */ diff --git a/src/libmongoc/tests/test-mongoc-aggregate.c b/src/libmongoc/tests/test-mongoc-aggregate.c index 028404c5832..cfbd85dd83c 100644 --- a/src/libmongoc/tests/test-mongoc-aggregate.c +++ b/src/libmongoc/tests/test-mongoc-aggregate.c @@ -101,5 +101,5 @@ void test_aggregate_install (TestSuite *suite) { TestSuite_AddMockServerTest ( - suite, "/Aggregate/query_flags", test_query_flags); + suite, "/Aggregate/query_flags", "", test_query_flags); } diff --git a/src/libmongoc/tests/test-mongoc-array.c b/src/libmongoc/tests/test-mongoc-array.c index cd4ff71eb68..a97a73809af 100644 --- a/src/libmongoc/tests/test-mongoc-array.c +++ b/src/libmongoc/tests/test-mongoc-array.c @@ -40,5 +40,5 @@ test_array (void) void test_array_install (TestSuite *suite) { - TestSuite_Add (suite, "/Array/Basic", test_array); + TestSuite_Add (suite, "/Array/Basic", "", test_array); } diff --git a/src/libmongoc/tests/test-mongoc-async.c b/src/libmongoc/tests/test-mongoc-async.c index 4289328544a..7965e3eea01 100644 --- a/src/libmongoc/tests/test-mongoc-async.c +++ b/src/libmongoc/tests/test-mongoc-async.c @@ -372,9 +372,9 @@ test_hello_delay () void test_async_install (TestSuite *suite) { - TestSuite_AddMockServerTest (suite, "/Async/hello", test_hello); + TestSuite_AddMockServerTest (suite, "/Async/hello", "", test_hello); #if defined(MONGOC_ENABLE_SSL_OPENSSL) - TestSuite_AddMockServerTest (suite, "/Async/hello_ssl", test_hello_ssl); + TestSuite_AddMockServerTest (suite, "/Async/hello_ssl", "", test_hello_ssl); #else /* Skip this test on OpenSSL since was having issues connecting. */ /* Skip on Windows until CDRIVER-3519 is resolved. */ @@ -386,5 +386,5 @@ test_async_install (TestSuite *suite) test_framework_skip_if_not_single, test_framework_skip_if_windows); #endif - TestSuite_AddMockServerTest (suite, "/Async/delay", test_hello_delay); + TestSuite_AddMockServerTest (suite, "/Async/delay", "", test_hello_delay); } diff --git a/src/libmongoc/tests/test-mongoc-aws.c b/src/libmongoc/tests/test-mongoc-aws.c index 3ccc6592205..a3991f96918 100644 --- a/src/libmongoc/tests/test-mongoc-aws.c +++ b/src/libmongoc/tests/test-mongoc-aws.c @@ -271,12 +271,14 @@ test_aws_install (TestSuite *suite) { TestSuite_AddFull (suite, "/aws/obtain_credentials", + "", test_obtain_credentials, NULL /* dtor */, NULL /* ctx */, test_framework_skip_if_no_aws); TestSuite_AddFull (suite, "/aws/obtain_credentials_from_env", + "", test_obtain_credentials_from_env, NULL /* dtor */, NULL /* ctx */, @@ -284,6 +286,7 @@ test_aws_install (TestSuite *suite) test_framework_skip_if_no_setenv); TestSuite_AddFull (suite, "/aws/derive_region", + "", test_derive_region, NULL /* dtor */, NULL /* ctx */, diff --git a/src/libmongoc/tests/test-mongoc-background-monitoring.c b/src/libmongoc/tests/test-mongoc-background-monitoring.c index 763039c3161..2584b35b9b9 100644 --- a/src/libmongoc/tests/test-mongoc-background-monitoring.c +++ b/src/libmongoc/tests/test-mongoc-background-monitoring.c @@ -1130,69 +1130,91 @@ void test_monitoring_install (TestSuite *suite) { /* Tests for initial connection. */ + TestSuite_AddMockServerTest (suite, + "/server_monitor_thread/connect/succeeds", + "", + test_connect_succeeds); TestSuite_AddMockServerTest ( - suite, "/server_monitor_thread/connect/succeeds", test_connect_succeeds); - TestSuite_AddMockServerTest ( - suite, "/server_monitor_thread/connect/hangup", test_connect_hangup); - TestSuite_AddMockServerTest ( - suite, "/server_monitor_thread/connect/badreply", test_connect_badreply); - TestSuite_AddMockServerTest ( - suite, "/server_monitor_thread/connect/shutdown", test_connect_shutdown); + suite, "/server_monitor_thread/connect/hangup", "", test_connect_hangup); + TestSuite_AddMockServerTest (suite, + "/server_monitor_thread/connect/badreply", + "", + test_connect_badreply); + TestSuite_AddMockServerTest (suite, + "/server_monitor_thread/connect/shutdown", + "", + test_connect_shutdown); TestSuite_AddMockServerTest (suite, "/server_monitor_thread/connect/requestscan", + "", test_connect_requestscan); /* Tests for retry. */ TestSuite_AddMockServerTest ( - suite, "/server_monitor_thread/retry/succeeds", test_retry_succeeds); + suite, "/server_monitor_thread/retry/succeeds", "", test_retry_succeeds); TestSuite_AddMockServerTest ( - suite, "/server_monitor_thread/retry/hangup", test_retry_hangup); + suite, "/server_monitor_thread/retry/hangup", "", test_retry_hangup); TestSuite_AddMockServerTest ( - suite, "/server_monitor_thread/retry/badreply", test_retry_badreply); + suite, "/server_monitor_thread/retry/badreply", "", test_retry_badreply); TestSuite_AddMockServerTest ( - suite, "/server_monitor_thread/retry/shutdown", test_retry_shutdown); + suite, "/server_monitor_thread/retry/shutdown", "", test_retry_shutdown); /* Tests for streaming. */ TestSuite_AddMockServerTest (suite, "/server_monitor_thread/streaming/succeeds", + "", test_streaming_succeeds); - TestSuite_AddMockServerTest ( - suite, "/server_monitor_thread/streaming/hangup", test_streaming_hangup); + TestSuite_AddMockServerTest (suite, + "/server_monitor_thread/streaming/hangup", + "", + test_streaming_hangup); TestSuite_AddMockServerTest (suite, "/server_monitor_thread/streaming/badreply", + "", test_streaming_badreply); TestSuite_AddMockServerTest (suite, "/server_monitor_thread/streaming/shutdown", + "", test_streaming_shutdown); - TestSuite_AddMockServerTest ( - suite, "/server_monitor_thread/streaming/cancel", test_streaming_cancel); + TestSuite_AddMockServerTest (suite, + "/server_monitor_thread/streaming/cancel", + "", + test_streaming_cancel); /* Tests for moretocome. */ TestSuite_AddMockServerTest (suite, "/server_monitor_thread/moretocome/succeeds", + "", test_moretocome_succeeds); TestSuite_AddMockServerTest (suite, "/server_monitor_thread/moretocome/hangup", + "", test_moretocome_hangup); TestSuite_AddMockServerTest (suite, "/server_monitor_thread/moretocome/badreply", + "", test_moretocome_badreply); TestSuite_AddMockServerTest (suite, "/server_monitor_thread/moretocome/shutdown", + "", test_moretocome_shutdown); TestSuite_AddMockServerTest (suite, "/server_monitor_thread/moretocome/cancel", + "", test_moretocome_cancel); /* Test flip flopping. */ TestSuite_AddMockServerTest ( - suite, "/server_monitor_thread/flip_flop", test_flip_flop); + suite, "/server_monitor_thread/flip_flop", "", test_flip_flop); /* Test repeated scan requests. */ TestSuite_AddMockServerTest (suite, "/server_monitor_thread/repeated_requestscan", + "", test_repeated_requestscan); - TestSuite_AddMockServerTest ( - suite, "/server_monitor_thread/sleep_after_scan", test_sleep_after_scan); + TestSuite_AddMockServerTest (suite, + "/server_monitor_thread/sleep_after_scan", + "", + test_sleep_after_scan); } diff --git a/src/libmongoc/tests/test-mongoc-buffer.c b/src/libmongoc/tests/test-mongoc-buffer.c index 3874b76997a..8afddc93dad 100644 --- a/src/libmongoc/tests/test-mongoc-buffer.c +++ b/src/libmongoc/tests/test-mongoc-buffer.c @@ -38,5 +38,5 @@ test_mongoc_buffer_basic (void) void test_buffer_install (TestSuite *suite) { - TestSuite_Add (suite, "/Buffer/Basic", test_mongoc_buffer_basic); + TestSuite_Add (suite, "/Buffer/Basic", "", test_mongoc_buffer_basic); } diff --git a/src/libmongoc/tests/test-mongoc-bulk.c b/src/libmongoc/tests/test-mongoc-bulk.c index 1d567a2d43d..7eac589a504 100644 --- a/src/libmongoc/tests/test-mongoc-bulk.c +++ b/src/libmongoc/tests/test-mongoc-bulk.c @@ -4756,188 +4756,249 @@ test_bulk_bypass_document_validation (void) void test_bulk_install (TestSuite *suite) { - TestSuite_AddLive (suite, "/BulkOperation/basic", test_bulk); - TestSuite_AddLive (suite, "/BulkOperation/opts", test_opts); - TestSuite_AddMockServerTest (suite, "/BulkOperation/error", test_bulk_error); + TestSuite_AddLive (suite, "/BulkOperation/basic", "", test_bulk); + TestSuite_AddLive (suite, "/BulkOperation/opts", "", test_opts); TestSuite_AddMockServerTest ( - suite, "/BulkOperation/error/unordered", test_bulk_error_unordered); + suite, "/BulkOperation/error", "", test_bulk_error); + TestSuite_AddMockServerTest ( + suite, "/BulkOperation/error/unordered", "", test_bulk_error_unordered); TestSuite_AddLive ( - suite, "/BulkOperation/insert_ordered", test_insert_ordered); + suite, "/BulkOperation/insert_ordered", "", test_insert_ordered); TestSuite_AddLive ( - suite, "/BulkOperation/insert_unordered", test_insert_unordered); + suite, "/BulkOperation/insert_unordered", "", test_insert_unordered); TestSuite_AddLive ( - suite, "/BulkOperation/insert_check_keys", test_insert_check_keys); + suite, "/BulkOperation/insert_check_keys", "", test_insert_check_keys); TestSuite_AddLive ( - suite, "/BulkOperation/update_ordered", test_update_ordered); + suite, "/BulkOperation/update_ordered", "", test_update_ordered); TestSuite_AddLive ( - suite, "/BulkOperation/update_unordered", test_update_unordered); + suite, "/BulkOperation/update_unordered", "", test_update_unordered); TestSuite_AddLive (suite, "/BulkOperation/update_one_check_keys", + "", test_update_one_check_keys); TestSuite_AddLive ( - suite, "/BulkOperation/update_check_keys", test_update_check_keys); + suite, "/BulkOperation/update_check_keys", "", test_update_check_keys); TestSuite_AddLive (suite, "/BulkOperation/update_one_with_opts_check_keys", + "", test_update_one_with_opts_check_keys); TestSuite_AddLive (suite, "/BulkOperation/update_many_with_opts_check_keys", + "", test_update_many_with_opts_check_keys); TestSuite_AddLive (suite, "/BulkOperation/update_one_invalid_first", + "", test_update_one_invalid_first); - TestSuite_AddLive ( - suite, "/BulkOperation/update_invalid_first", test_update_invalid_first); + TestSuite_AddLive (suite, + "/BulkOperation/update_invalid_first", + "", + test_update_invalid_first); TestSuite_AddLive (suite, "/BulkOperation/update_one_with_opts_invalid_first", + "", test_update_one_with_opts_invalid_first); TestSuite_AddLive (suite, "/BulkOperation/update_many_with_opts_invalid_first", + "", test_update_many_with_opts_invalid_first); TestSuite_AddLive (suite, "/BulkOperation/replace_one_invalid_first", + "", test_replace_one_invalid_first); TestSuite_AddLive (suite, "/BulkOperation/replace_one_with_opts_invalid_first", + "", test_replace_one_with_opts_invalid_first); TestSuite_AddLive (suite, "/BulkOperation/update_one_invalid_second", + "", test_update_one_invalid_second); TestSuite_AddLive (suite, "/BulkOperation/update_invalid_second", + "", test_update_invalid_second); TestSuite_AddLive (suite, "/BulkOperation/update_one_with_opts_invalid_second", + "", test_update_one_with_opts_invalid_second); TestSuite_AddLive (suite, "/BulkOperation/update_many_with_opts_invalid_second", + "", test_update_many_with_opts_invalid_second); TestSuite_AddLive (suite, "/BulkOperation/replace_one_invalid_second", + "", test_replace_one_invalid_second); TestSuite_AddLive (suite, "/BulkOperation/replace_one_with_opts_invalid_second", + "", test_replace_one_with_opts_invalid_second); - TestSuite_AddLive ( - suite, "/BulkOperation/insert_invalid_first", test_insert_invalid_first); + TestSuite_AddLive (suite, + "/BulkOperation/insert_invalid_first", + "", + test_insert_invalid_first); TestSuite_AddLive (suite, "/BulkOperation/insert_invalid_second", + "", test_insert_invalid_second); TestSuite_AddLive (suite, "/BulkOperation/insert_with_opts_invalid_first", + "", test_insert_with_opts_invalid_first); TestSuite_AddLive (suite, "/BulkOperation/insert_with_opts_invalid_second", + "", test_insert_with_opts_invalid_second); TestSuite_AddLive (suite, "/BulkOperation/insert_with_opts_validate", + "", test_insert_with_opts_validate); TestSuite_AddLive (suite, "/BulkOperation/remove_one_after_invalid", + "", test_remove_one_after_invalid); - TestSuite_AddLive ( - suite, "/BulkOperation/remove_after_invalid", test_remove_after_invalid); + TestSuite_AddLive (suite, + "/BulkOperation/remove_after_invalid", + "", + test_remove_after_invalid); TestSuite_AddLive (suite, "/BulkOperation/remove_one_with_opts_after_invalid", + "", test_remove_one_with_opts_after_invalid); TestSuite_AddLive (suite, "/BulkOperation/remove_many_with_opts_after_invalid", + "", test_remove_many_with_opts_after_invalid); TestSuite_AddLive ( - suite, "/BulkOperation/upsert_ordered", test_upsert_ordered); + suite, "/BulkOperation/upsert_ordered", "", test_upsert_ordered); TestSuite_AddLive ( - suite, "/BulkOperation/upsert_unordered", test_upsert_unordered); + suite, "/BulkOperation/upsert_unordered", "", test_upsert_unordered); TestSuite_AddFull (suite, "/BulkOperation/upsert_unordered_oversized", + "", test_upsert_unordered_oversized, NULL, NULL, test_framework_skip_if_slow_or_live); TestSuite_AddFull (suite, "/BulkOperation/upsert_large", + "", test_upsert_large, NULL, NULL, test_framework_skip_if_slow_or_live); TestSuite_AddFull (suite, "/BulkOperation/upsert_huge", + "", test_upsert_huge, NULL, NULL, test_framework_skip_if_slow_or_live); TestSuite_AddLive (suite, "/BulkOperation/upserted_index_ordered", + "", test_upserted_index_ordered); TestSuite_AddLive (suite, "/BulkOperation/upserted_index_unordered", + "", test_upserted_index_unordered); TestSuite_AddLive ( - suite, "/BulkOperation/update_one_ordered", test_update_one_ordered); - TestSuite_AddLive ( - suite, "/BulkOperation/update_one_unordered", test_update_one_unordered); + suite, "/BulkOperation/update_one_ordered", "", test_update_one_ordered); + TestSuite_AddLive (suite, + "/BulkOperation/update_one_unordered", + "", + test_update_one_unordered); TestSuite_AddLive (suite, "/BulkOperation/update_with_opts_validate", + "", test_update_with_opts_validate); TestSuite_AddFull (suite, "/BulkOperation/update_arrayfilters", + "", test_update_arrayfilters, NULL, NULL, test_framework_skip_if_max_wire_version_less_than_6); TestSuite_AddFull (suite, "/BulkOperation/update_arrayfilters/unsupported", + "", test_update_arrayfilters_unsupported, NULL, NULL, test_framework_skip_if_max_wire_version_more_than_5); - TestSuite_AddLive ( - suite, "/BulkOperation/update/hint/validate", test_update_hint_validate); - TestSuite_AddLive ( - suite, "/BulkOperation/delete/hint/validate", test_delete_hint_validate); - TestSuite_AddLive ( - suite, "/BulkOperation/replace_one_ordered", test_replace_one_ordered); + TestSuite_AddLive (suite, + "/BulkOperation/update/hint/validate", + "", + test_update_hint_validate); + TestSuite_AddLive (suite, + "/BulkOperation/delete/hint/validate", + "", + test_delete_hint_validate); + TestSuite_AddLive (suite, + "/BulkOperation/replace_one_ordered", + "", + test_replace_one_ordered); TestSuite_AddLive (suite, "/BulkOperation/replace_one_unordered", + "", test_replace_one_unordered); - TestSuite_AddLive ( - suite, "/BulkOperation/replace_one/keys", test_replace_one_check_keys); + TestSuite_AddLive (suite, + "/BulkOperation/replace_one/keys", + "", + test_replace_one_check_keys); TestSuite_AddLive (suite, "/BulkOperation/replace_one_with_opts/keys", + "", test_replace_one_with_opts_check_keys); TestSuite_AddLive (suite, "/BulkOperation/replace_one_with_opts_validate", + "", test_replace_one_with_opts_validate); - TestSuite_AddLive (suite, "/BulkOperation/index_offset", test_index_offset); TestSuite_AddLive ( - suite, "/BulkOperation/single_ordered_bulk", test_single_ordered_bulk); + suite, "/BulkOperation/index_offset", "", test_index_offset); + TestSuite_AddLive (suite, + "/BulkOperation/single_ordered_bulk", + "", + test_single_ordered_bulk); TestSuite_AddLive (suite, "/BulkOperation/insert_continue_on_error", + "", test_insert_continue_on_error); TestSuite_AddLive (suite, "/BulkOperation/update_continue_on_error", + "", test_update_continue_on_error); TestSuite_AddLive (suite, "/BulkOperation/remove_continue_on_error", + "", test_remove_continue_on_error); TestSuite_AddLive (suite, "/BulkOperation/single_error_ordered_bulk", + "", test_single_error_ordered_bulk); TestSuite_AddLive (suite, "/BulkOperation/multiple_error_ordered_bulk", + "", test_multiple_error_ordered_bulk); TestSuite_AddLive (suite, "/BulkOperation/single_unordered_bulk", + "", test_single_unordered_bulk); TestSuite_AddLive (suite, "/BulkOperation/single_error_unordered_bulk", + "", test_single_error_unordered_bulk); TestSuite_AddFull (suite, "/BulkOperation/oversized/ordered", + "", test_oversized_bulk_op_ordered, NULL, NULL, test_framework_skip_if_slow_or_live); TestSuite_AddFull (suite, "/BulkOperation/oversized/unordered", + "", test_oversized_bulk_op_unordered, NULL, NULL, @@ -4945,124 +5006,156 @@ test_bulk_install (TestSuite *suite) TestSuite_AddMockServerTest ( suite, "/BulkOperation/write_concern/write_command/ordered", + "", test_write_concern_write_command_ordered); TestSuite_AddMockServerTest ( suite, "/BulkOperation/write_concern/write_command/ordered/multi_err", + "", test_write_concern_write_command_ordered_multi_err); TestSuite_AddMockServerTest ( suite, "/BulkOperation/write_concern/write_command/unordered", + "", test_write_concern_write_command_unordered); TestSuite_AddMockServerTest ( suite, "/BulkOperation/write_concern/write_command/unordered/multi_err", + "", test_write_concern_write_command_unordered_multi_err); TestSuite_AddMockServerTest (suite, "/BulkOperation/writes/unordered/error", + "", test_unordered_bulk_writes_with_error); TestSuite_AddMockServerTest ( suite, "/BulkOperation/write_concern/error/write_command/v1", + "", test_write_concern_error_write_command_v1); TestSuite_AddMockServerTest ( suite, "/BulkOperation/write_concern/error/write_command/v2", + "", test_write_concern_error_write_command_v2); TestSuite_AddLive (suite, "/BulkOperation/multiple_error_unordered_bulk", + "", test_multiple_error_unordered_bulk); TestSuite_AddMockServerTest ( suite, "/BulkOperation/wtimeout_duplicate_key/write_commands", + "", test_wtimeout_plus_duplicate_key_err_write_commands); TestSuite_AddFull (suite, "/BulkOperation/large_inserts_ordered", + "", test_large_inserts_ordered, NULL, NULL, test_framework_skip_if_slow_or_live); TestSuite_AddFull (suite, "/BulkOperation/large_inserts_unordered", + "", test_large_inserts_unordered, NULL, NULL, test_framework_skip_if_slow_or_live); TestSuite_AddFull (suite, "/BulkOperation/numerous_ordered", + "", test_numerous_ordered, NULL, NULL, test_framework_skip_if_slow_or_live); TestSuite_AddFull (suite, "/BulkOperation/numerous_unordered", + "", test_numerous_unordered, NULL, NULL, test_framework_skip_if_slow_or_live); TestSuite_AddLive (suite, "/BulkOperation/CDRIVER-372_ordered", + "", test_bulk_edge_case_372_ordered); TestSuite_AddLive (suite, "/BulkOperation/CDRIVER-372_unordered", + "", test_bulk_edge_case_372_unordered); - TestSuite_AddLive (suite, "/BulkOperation/new", test_bulk_new); - TestSuite_AddLive ( - suite, "/BulkOperation/OP_MSG/max_batch_size", test_bulk_max_batch_size); + TestSuite_AddLive (suite, "/BulkOperation/new", "", test_bulk_new); + TestSuite_AddLive (suite, + "/BulkOperation/OP_MSG/max_batch_size", + "", + test_bulk_max_batch_size); TestSuite_AddLive ( - suite, "/BulkOperation/OP_MSG/max_msg_size", test_bulk_max_msg_size); - TestSuite_AddLive (suite, "/BulkOperation/split", test_bulk_split); + suite, "/BulkOperation/OP_MSG/max_msg_size", "", test_bulk_max_msg_size); + TestSuite_AddLive (suite, "/BulkOperation/split", "", test_bulk_split); TestSuite_AddFull (suite, "/BulkOperation/write_concern/split", + "", test_bulk_write_concern_split, NULL /* dtor */, NULL /* ctx */, test_framework_skip_if_no_getlasterror); TestSuite_AddMockServerTest (suite, "/BulkOperation/hint/single/command/secondary", + "", test_hint_single_command_secondary); TestSuite_AddMockServerTest (suite, "/BulkOperation/hint/single/command/primary", + "", test_hint_single_command_primary); TestSuite_AddMockServerTest (suite, "/BulkOperation/hint/pooled/command/secondary", + "", test_hint_pooled_command_secondary); TestSuite_AddMockServerTest (suite, "/BulkOperation/hint/pooled/command/primary", + "", test_hint_pooled_command_primary); - TestSuite_AddLive (suite, "/BulkOperation/reply_w0", test_bulk_reply_w0); + TestSuite_AddLive (suite, "/BulkOperation/reply_w0", "", test_bulk_reply_w0); TestSuite_AddLive (suite, "/BulkOperation/invalid_write_concern", + "", test_bulk_invalid_write_concern); TestSuite_AddMockServerTest (suite, "/BulkOperation/opts/collation/w0/wire5", + "", test_bulk_collation_w0_wire5); TestSuite_AddMockServerTest (suite, "/BulkOperation/opts/collation/w0/wire4", + "", test_bulk_collation_w0_wire4); TestSuite_AddMockServerTest (suite, "/BulkOperation/opts/collation/w1/wire5", + "", test_bulk_collation_w1_wire5); TestSuite_AddMockServerTest (suite, "/BulkOperation/opts/collation/w1/wire4", + "", test_bulk_collation_w1_wire4); TestSuite_AddMockServerTest (suite, "/BulkOperation/opts/collation/multi/w0/wire5", + "", test_bulk_collation_multi_w0_wire5); TestSuite_AddMockServerTest (suite, "/BulkOperation/opts/collation/multi/w0/wire4", + "", test_bulk_collation_multi_w0_wire4); TestSuite_AddMockServerTest (suite, "/BulkOperation/opts/collation/multi/w1/wire5", + "", test_bulk_collation_multi_w1_wire5); TestSuite_AddMockServerTest (suite, "/BulkOperation/opts/collation/multi/w1/wire4", + "", test_bulk_collation_multi_w1_wire4); TestSuite_Add (suite, "/BulkOperation/update_one/error_message", + "", test_bulk_update_one_error_message); - TestSuite_Add (suite, "/BulkOperation/opts/parse", test_bulk_opts_parse); - TestSuite_Add (suite, "/BulkOperation/no_client", test_bulk_no_client); + TestSuite_Add (suite, "/BulkOperation/opts/parse", "", test_bulk_opts_parse); + TestSuite_Add (suite, "/BulkOperation/no_client", "", test_bulk_no_client); TestSuite_AddLive ( - suite, "/BulkOperation/bypass", test_bulk_bypass_document_validation); + suite, "/BulkOperation/bypass", "", test_bulk_bypass_document_validation); } diff --git a/src/libmongoc/tests/test-mongoc-change-stream.c b/src/libmongoc/tests/test-mongoc-change-stream.c index 58db4c04a36..01a55876709 100644 --- a/src/libmongoc/tests/test-mongoc-change-stream.c +++ b/src/libmongoc/tests/test-mongoc-change-stream.c @@ -2612,10 +2612,11 @@ test_change_stream_install (TestSuite *suite) { char resolved[PATH_MAX]; TestSuite_AddMockServerTest ( - suite, "/change_stream/pipeline", test_change_stream_pipeline); + suite, "/change_stream/pipeline", "", test_change_stream_pipeline); TestSuite_AddFull (suite, "/change_stream/live/single_server", + "", test_change_stream_live_single_server, NULL, NULL, @@ -2623,6 +2624,7 @@ test_change_stream_install (TestSuite *suite) TestSuite_AddFull (suite, "/change_stream/live/track_resume_token", + "", test_change_stream_live_track_resume_token, NULL, NULL, @@ -2631,6 +2633,7 @@ test_change_stream_install (TestSuite *suite) TestSuite_AddFull (suite, "/change_stream/live/batch_size", + "", test_change_stream_live_batch_size, NULL, NULL, @@ -2638,6 +2641,7 @@ test_change_stream_install (TestSuite *suite) TestSuite_AddFull (suite, "/change_stream/live/missing_resume_token", + "", test_change_stream_live_missing_resume_token, NULL, NULL, @@ -2645,6 +2649,7 @@ test_change_stream_install (TestSuite *suite) TestSuite_AddFull (suite, "/change_stream/live/invalid_resume_token", + "", test_change_stream_live_invalid_resume_token, NULL, NULL, @@ -2652,13 +2657,15 @@ test_change_stream_install (TestSuite *suite) TestSuite_AddMockServerTest (suite, "/change_stream/resumable_error", + "", test_change_stream_resumable_error); TestSuite_AddMockServerTest ( - suite, "/change_stream/options", test_change_stream_options); + suite, "/change_stream/options", "", test_change_stream_options); TestSuite_AddFull (suite, "/change_stream/live/watch", + "", test_change_stream_live_watch, NULL, NULL, @@ -2666,6 +2673,7 @@ test_change_stream_install (TestSuite *suite) TestSuite_AddFull (suite, "/change_stream/live/read_prefs", + "", test_change_stream_live_read_prefs, NULL, NULL, @@ -2674,10 +2682,12 @@ test_change_stream_install (TestSuite *suite) TestSuite_Add (suite, "/change_stream/server_selection_fails", + "", test_change_stream_server_selection_fails); TestSuite_AddFull (suite, "/change_stream/next_after_error", + "", test_change_stream_next_after_error, NULL, NULL, @@ -2685,14 +2695,16 @@ test_change_stream_install (TestSuite *suite) TestSuite_AddFull (suite, "/change_stream/accepts_array", + "", test_change_stream_accepts_array, NULL, NULL, test_framework_skip_if_not_rs_version_6); TestSuite_AddMockServerTest ( - suite, "/change_stream/getmore_errors", test_getmore_errors); + suite, "/change_stream/getmore_errors", "", test_getmore_errors); TestSuite_AddFull (suite, "/change_stream/start_at_operation_time", + "", test_change_stream_start_at_operation_time, NULL, NULL, @@ -2701,6 +2713,7 @@ test_change_stream_install (TestSuite *suite) _skip_if_no_start_at_optime); TestSuite_AddFull (suite, "/change_stream/resume_at_optime", + "", test_change_stream_resume_at_optime, NULL, NULL, @@ -2710,6 +2723,7 @@ test_change_stream_install (TestSuite *suite) test_framework_skip_if_no_failpoint); TestSuite_AddFull (suite, "/change_stream/resume_with_post_batch_resume_token", + "", test_change_stream_resume_with_post_batch_resume_token, NULL, NULL, @@ -2719,30 +2733,35 @@ test_change_stream_install (TestSuite *suite) test_framework_skip_if_no_failpoint); TestSuite_AddFull (suite, "/change_stream/database", + "", test_change_stream_database_watch, NULL, NULL, _skip_if_no_db_watch); TestSuite_AddFull (suite, "/change_stream/client", + "", test_change_stream_client_watch, NULL, NULL, _skip_if_no_client_watch); TestSuite_AddMockServerTest ( - suite, "/change_stream/resume_with_first_doc", test_resume_cases); + suite, "/change_stream/resume_with_first_doc", "", test_resume_cases); TestSuite_AddMockServerTest ( suite, "/change_stream/resume_with_first_doc/post_batch_resume_token", + "", test_resume_cases_with_post_batch_resume_token); TestSuite_AddFull (suite, "/change_stream/error_null_doc", + "", test_error_null_doc, NULL, NULL, _skip_if_no_client_watch); TestSuite_AddFull (suite, "/change_stream/live/prose_test_11", + "", prose_test_11, NULL, NULL, @@ -2750,6 +2769,7 @@ test_change_stream_install (TestSuite *suite) test_framework_skip_if_max_wire_version_less_than_8); TestSuite_AddFull (suite, "/change_stream/live/prose_test_12", + "", prose_test_12, NULL, NULL, @@ -2757,6 +2777,7 @@ test_change_stream_install (TestSuite *suite) test_framework_skip_if_max_wire_version_more_than_7); TestSuite_AddFull (suite, "/change_stream/live/prose_test_13", + "", prose_test_13, NULL, NULL, @@ -2764,15 +2785,16 @@ test_change_stream_install (TestSuite *suite) _skip_if_no_start_at_optime); TestSuite_AddFull (suite, "/change_stream/live/prose_test_14", + "", prose_test_14, NULL, NULL, test_framework_skip_if_mongos, test_framework_skip_if_not_rs_version_7); TestSuite_AddMockServerTest ( - suite, "/change_streams/prose_test_17", prose_test_17); + suite, "/change_streams/prose_test_17", "", prose_test_17); TestSuite_AddMockServerTest ( - suite, "/change_streams/prose_test_18", prose_test_18); + suite, "/change_streams/prose_test_18", "", prose_test_18); test_framework_resolve_path (JSON_DIR "/change_streams/legacy", resolved); install_json_test_suite (suite, resolved, &test_change_stream_spec_cb); diff --git a/src/libmongoc/tests/test-mongoc-client-pool.c b/src/libmongoc/tests/test-mongoc-client-pool.c index 8082bcb08b2..9f377fc13d6 100644 --- a/src/libmongoc/tests/test-mongoc-client-pool.c +++ b/src/libmongoc/tests/test-mongoc-client-pool.c @@ -470,39 +470,54 @@ test_client_pool_max_pool_size_exceeded (void) void test_client_pool_install (TestSuite *suite) { - TestSuite_Add (suite, "/ClientPool/basic", test_mongoc_client_pool_basic); TestSuite_Add ( - suite, "/ClientPool/try_pop", test_mongoc_client_pool_try_pop); + suite, "/ClientPool/basic", "", test_mongoc_client_pool_basic); TestSuite_Add ( - suite, "/ClientPool/pop_timeout", test_mongoc_client_pool_pop_timeout); + suite, "/ClientPool/try_pop", "", test_mongoc_client_pool_try_pop); + TestSuite_Add (suite, + "/ClientPool/pop_timeout", + "", + test_mongoc_client_pool_pop_timeout); TestSuite_Add (suite, "/ClientPool/min_size_zero", + "", test_mongoc_client_pool_min_size_zero); TestSuite_Add (suite, "/ClientPool/min_size_dispose", + "", test_mongoc_client_pool_min_size_dispose); - TestSuite_Add ( - suite, "/ClientPool/set_max_size", test_mongoc_client_pool_set_max_size); - TestSuite_Add ( - suite, "/ClientPool/set_min_size", test_mongoc_client_pool_set_min_size); + TestSuite_Add (suite, + "/ClientPool/set_max_size", + "", + test_mongoc_client_pool_set_max_size); + TestSuite_Add (suite, + "/ClientPool/set_min_size", + "", + test_mongoc_client_pool_set_min_size); TestSuite_Add ( - suite, "/ClientPool/handshake", test_mongoc_client_pool_handshake); + suite, "/ClientPool/handshake", "", test_mongoc_client_pool_handshake); TestSuite_AddFull (suite, "/ClientPool/create_client_pool_unused_session", + "", test_client_pool_create_unused_session, NULL /* dtor */, NULL /* ctx */, test_framework_skip_if_no_sessions); #ifndef MONGOC_ENABLE_SSL - TestSuite_Add ( - suite, "/ClientPool/ssl_disabled", test_mongoc_client_pool_ssl_disabled); + TestSuite_Add (suite, + "/ClientPool/ssl_disabled", + "", + "", + test_mongoc_client_pool_ssl_disabled); #endif TestSuite_AddLive (suite, "/ClientPool/destroy_without_push", + "", test_client_pool_destroy_without_pushing); TestSuite_AddLive (suite, "/ClientPool/max_pool_size_exceeded", + "", test_client_pool_max_pool_size_exceeded); } diff --git a/src/libmongoc/tests/test-mongoc-client-session.c b/src/libmongoc/tests/test-mongoc-client-session.c index 9763f957677..a16294fbbc1 100644 --- a/src/libmongoc/tests/test-mongoc-client-session.c +++ b/src/libmongoc/tests/test-mongoc-client-session.c @@ -2585,32 +2585,36 @@ test_unacknowledged_explicit_cs_explicit_wc (void *ctx) } -#define add_session_test(_suite, _name, _test_fn, _allow_read_concern) \ +#define add_session_test(_suite, _name, _meta, _test_fn, _allow_read_concern) \ + TestSuite_AddFullWithTestFn ( \ + _suite, \ + _name, \ + _meta, \ + (_allow_read_concern) ? run_session_test : run_session_test_no_rc, \ + NULL, \ + _test_fn, \ + test_framework_skip_if_no_cluster_time, \ + test_framework_skip_if_no_crypto) + +#define add_session_test_wc( \ + _suite, _name, _meta, _test_fn, _allow_read_concern, ...) \ TestSuite_AddFullWithTestFn ( \ _suite, \ _name, \ + _meta, \ (_allow_read_concern) ? run_session_test : run_session_test_no_rc, \ NULL, \ _test_fn, \ test_framework_skip_if_no_cluster_time, \ - test_framework_skip_if_no_crypto) - -#define add_session_test_wc(_suite, _name, _test_fn, _allow_read_concern, ...) \ - TestSuite_AddFullWithTestFn ( \ - _suite, \ - _name, \ - (_allow_read_concern) ? run_session_test : run_session_test_no_rc, \ - NULL, \ - _test_fn, \ - test_framework_skip_if_no_cluster_time, \ - test_framework_skip_if_no_crypto, \ + test_framework_skip_if_no_crypto, \ __VA_ARGS__) #define add_unacknowledged_test( \ - _suite, _name, _test_fn, _explicit_cs, _inherit_wc) \ + _suite, _name, _meta, _test_fn, _explicit_cs, _inherit_wc) \ TestSuite_AddFullWithTestFn ( \ _suite, \ _name, \ + _meta, \ (_explicit_cs) \ ? (_inherit_wc ? test_unacknowledged_explicit_cs_inherit_wc \ : test_unacknowledged_implicit_cs_explicit_wc) \ @@ -2797,12 +2801,14 @@ test_session_install (TestSuite *suite) { char resolved[PATH_MAX]; - TestSuite_Add (suite, "/Session/opts/clone", test_session_opts_clone); + TestSuite_Add (suite, "/Session/opts/clone", "", test_session_opts_clone); TestSuite_Add (suite, "/Session/opts/causal_consistency_and_snapshot", + "", test_session_opts_causal_consistency_and_snapshot); TestSuite_AddFull (suite, "/Session/no_crypto", + "", test_session_no_crypto, NULL, NULL, @@ -2811,6 +2817,7 @@ test_session_install (TestSuite *suite) test_framework_skip_if_crypto); TestSuite_AddFull (suite, "/Session/lifo/single", + "", test_session_pool_lifo_single, NULL, NULL, @@ -2818,6 +2825,7 @@ test_session_install (TestSuite *suite) test_framework_skip_if_no_crypto); TestSuite_AddFull (suite, "/Session/lifo/pooled", + "", test_session_pool_lifo_pooled, NULL, NULL, @@ -2825,6 +2833,7 @@ test_session_install (TestSuite *suite) test_framework_skip_if_no_crypto); TestSuite_AddFull (suite, "/Session/timeout/single", + "", test_session_pool_timeout_single, NULL, NULL, @@ -2833,6 +2842,7 @@ test_session_install (TestSuite *suite) test_framework_skip_if_slow); TestSuite_AddFull (suite, "/Session/timeout/pooled", + "", test_session_pool_timeout_pooled, NULL, NULL, @@ -2841,6 +2851,7 @@ test_session_install (TestSuite *suite) test_framework_skip_if_slow); TestSuite_AddFull (suite, "/Session/reap/single", + "", test_session_pool_reap_single, NULL, NULL, @@ -2849,6 +2860,7 @@ test_session_install (TestSuite *suite) test_framework_skip_if_slow); TestSuite_AddFull (suite, "/Session/reap/pooled", + "", test_session_pool_reap_pooled, NULL, NULL, @@ -2857,6 +2869,7 @@ test_session_install (TestSuite *suite) test_framework_skip_if_slow); TestSuite_AddFull (suite, "/Session/id_bad", + "", test_session_id_bad, NULL, NULL, @@ -2864,6 +2877,7 @@ test_session_install (TestSuite *suite) test_framework_skip_if_no_crypto); TestSuite_AddFull (suite, "/Session/supported/single", + "", test_session_supported_single, NULL, NULL, @@ -2871,6 +2885,7 @@ test_session_install (TestSuite *suite) test_framework_skip_if_no_crypto); TestSuite_AddFull (suite, "/Session/supported/pooled", + "", test_session_supported_pooled, NULL, NULL, @@ -2878,18 +2893,22 @@ test_session_install (TestSuite *suite) test_framework_skip_if_no_crypto); TestSuite_AddMockServerTest (suite, "/Session/end/mock/single", + "", test_mock_end_sessions_single, test_framework_skip_if_no_crypto); TestSuite_AddMockServerTest (suite, "/Session/end/mock/pooled", + "", test_mock_end_sessions_pooled, test_framework_skip_if_no_crypto); TestSuite_AddMockServerTest (suite, "/Session/end/mock/disconnected", + "", test_mock_end_sessions_server_disconnect, test_framework_skip_if_no_crypto); TestSuite_AddFull (suite, "/Session/end/single", + "", test_end_sessions_single, NULL, NULL, @@ -2897,6 +2916,7 @@ test_session_install (TestSuite *suite) test_framework_skip_if_max_wire_version_less_than_6); TestSuite_AddFull (suite, "/Session/end/pooled", + "", test_end_sessions_pooled, NULL, NULL, @@ -2904,6 +2924,7 @@ test_session_install (TestSuite *suite) test_framework_skip_if_max_wire_version_less_than_6); TestSuite_AddFull (suite, "/Session/end/many/single", + "", test_end_sessions_many_single, NULL, NULL, @@ -2912,6 +2933,7 @@ test_session_install (TestSuite *suite) test_framework_skip_if_slow); TestSuite_AddFull (suite, "/Session/end/many/pooled", + "", test_end_sessions_many_pooled, NULL, NULL, @@ -2920,6 +2942,7 @@ test_session_install (TestSuite *suite) test_framework_skip_if_slow); TestSuite_AddFull (suite, "/Session/advance_cluster_time", + "", test_session_advance_cluster_time, NULL, NULL, @@ -2927,6 +2950,7 @@ test_session_install (TestSuite *suite) test_framework_skip_if_no_sessions); TestSuite_AddFull (suite, "/Session/advance_operation_time", + "", test_session_advance_operation_time, NULL, NULL, @@ -2935,55 +2959,64 @@ test_session_install (TestSuite *suite) /* "true" is for tests that expect readConcern: afterClusterTime for causally * consistent sessions, "false" is for tests that prohibit readConcern */ - add_session_test (suite, "/Session/cmd", test_cmd, false); - add_session_test (suite, "/Session/read_cmd", test_read_cmd, true); - add_session_test (suite, "/Session/write_cmd", test_write_cmd, false); + add_session_test (suite, "/Session/cmd", "", test_cmd, false); + add_session_test (suite, "/Session/read_cmd", "", test_read_cmd, true); + add_session_test (suite, "/Session/write_cmd", "", test_write_cmd, false); add_session_test ( - suite, "/Session/read_write_cmd", test_read_write_cmd, true); - add_session_test (suite, "/Session/db_cmd", test_db_cmd, false); + suite, "/Session/read_write_cmd", "", test_read_write_cmd, true); + add_session_test (suite, "/Session/db_cmd", "", test_db_cmd, false); TestSuite_AddFullWithTestFn (suite, "/Session/count", + "", (TestFuncWC) run_count_test, NULL, test_count, test_framework_skip_if_no_cluster_time, test_framework_skip_if_no_crypto); - add_session_test (suite, "/Session/cursor", test_cursor, true); - add_session_test (suite, "/Session/drop", test_drop, false); - add_session_test (suite, "/Session/drop_index", test_drop_index, false); - add_session_test (suite, "/Session/create_index", test_create_index, false); - add_session_test (suite, "/Session/replace_one", test_replace_one, false); - add_session_test (suite, "/Session/update_one", test_update_one, false); - add_session_test (suite, "/Session/update_many", test_update_many, false); - add_session_test (suite, "/Session/insert_one", test_insert_one, false); - add_session_test (suite, "/Session/insert_many", test_insert_many, false); - add_session_test (suite, "/Session/delete_one", test_delete_one, false); - add_session_test (suite, "/Session/delete_many", test_delete_many, false); - add_session_test (suite, "/Session/rename", test_rename, false); - add_session_test (suite, "/Session/fam", test_fam, true); - add_session_test (suite, "/Session/db_drop", test_db_drop, false); - add_session_test (suite, "/Session/gridfs_find", test_gridfs_find, true); + add_session_test (suite, "/Session/cursor", "", test_cursor, true); + add_session_test (suite, "/Session/drop", "", test_drop, false); + add_session_test (suite, "/Session/drop_index", "", test_drop_index, false); + add_session_test ( + suite, "/Session/create_index", "", test_create_index, false); add_session_test ( - suite, "/Session/gridfs_find_one", test_gridfs_find_one, true); + suite, "/Session/replace_one", "", test_replace_one, false); + add_session_test (suite, "/Session/update_one", "", test_update_one, false); + add_session_test ( + suite, "/Session/update_many", "", test_update_many, false); + add_session_test (suite, "/Session/insert_one", "", test_insert_one, false); + add_session_test ( + suite, "/Session/insert_many", "", test_insert_many, false); + add_session_test (suite, "/Session/delete_one", "", test_delete_one, false); + add_session_test ( + suite, "/Session/delete_many", "", test_delete_many, false); + add_session_test (suite, "/Session/rename", "", test_rename, false); + add_session_test (suite, "/Session/fam", "", test_fam, true); + add_session_test (suite, "/Session/db_drop", "", test_db_drop, false); + add_session_test (suite, "/Session/gridfs_find", "", test_gridfs_find, true); + add_session_test ( + suite, "/Session/gridfs_find_one", "", test_gridfs_find_one, true); add_session_test_wc (suite, "/Session/watch", + "", test_watch, true, test_framework_skip_if_not_rs_version_6); - add_session_test (suite, "/Session/aggregate", test_aggregate, true); - add_session_test (suite, "/Session/create", test_create, false); + add_session_test (suite, "/Session/aggregate", "", test_aggregate, true); + add_session_test (suite, "/Session/create", "", test_create, false); + add_session_test ( + suite, "/Session/database_names", "", test_database_names, true); add_session_test ( - suite, "/Session/database_names", test_database_names, true); + suite, "/Session/find_databases", "", test_find_databases, true); add_session_test ( - suite, "/Session/find_databases", test_find_databases, true); + suite, "/Session/find_collections", "", test_find_collections, true); add_session_test ( - suite, "/Session/find_collections", test_find_collections, true); + suite, "/Session/collection_names", "", test_collection_names, true); + add_session_test (suite, "/Session/bulk", "", test_bulk, false); add_session_test ( - suite, "/Session/collection_names", test_collection_names, true); - add_session_test (suite, "/Session/bulk", test_bulk, false); - add_session_test (suite, "/Session/find_indexes", test_find_indexes, true); + suite, "/Session/find_indexes", "", test_find_indexes, true); TestSuite_AddFullWithTestFn (suite, "/Session/bulk_set_session", + "", run_session_test_bulk_operation, NULL, test_bulk_set_session, @@ -2991,6 +3024,7 @@ test_session_install (TestSuite *suite) test_framework_skip_if_no_crypto); TestSuite_AddFullWithTestFn (suite, "/Session/bulk_set_client", + "", run_session_test_bulk_operation, NULL, test_bulk_set_client, @@ -2998,6 +3032,7 @@ test_session_install (TestSuite *suite) test_framework_skip_if_no_crypto); TestSuite_AddFull (suite, "/Session/cursor_implicit_session", + "", test_cursor_implicit_session, NULL, NULL, @@ -3005,6 +3040,7 @@ test_session_install (TestSuite *suite) test_framework_skip_if_no_crypto); TestSuite_AddFull (suite, "/Session/change_stream_implicit_session", + "", test_change_stream_implicit_session, NULL, NULL, @@ -3012,6 +3048,7 @@ test_session_install (TestSuite *suite) test_framework_skip_if_no_crypto); TestSuite_AddFull (suite, "/Session/cmd_error", + "", test_cmd_error, NULL, NULL, @@ -3019,6 +3056,7 @@ test_session_install (TestSuite *suite) test_framework_skip_if_no_crypto); TestSuite_AddFull (suite, "/Session/read_concern", + "", test_read_concern, NULL, NULL, @@ -3027,48 +3065,56 @@ test_session_install (TestSuite *suite) add_unacknowledged_test ( suite, "/Session/unacknowledged/insert_one/explicit_cs/inherit_wc", + "", test_insert_one, true, true); add_unacknowledged_test ( suite, "/Session/unacknowledged/insert_one/explicit_cs/explicit_wc", + "", test_insert_one, true, false); add_unacknowledged_test ( suite, "/Session/unacknowledged/insert_one/implicit_cs/inherit_wc", + "", test_insert_one, false, true); add_unacknowledged_test ( suite, "/Session/unacknowledged/insert_one/implicit_cs/explicit_wc", + "", test_insert_one, false, false); add_unacknowledged_test ( suite, "/Session/unacknowledged/bulk/explicit_cs/inherit_wc", + "", test_bulk, true, true); add_unacknowledged_test ( suite, "/Session/unacknowledged/bulk/explicit_cs/explicit_wc", + "", test_bulk, true, false); add_unacknowledged_test ( suite, "/Session/unacknowledged/bulk/implicit_cs/inherit_wc", + "", test_bulk, false, true); add_unacknowledged_test ( suite, "/Session/unacknowledged/bulk/implicit_cs/explicit_wc", + "", test_bulk, false, false); @@ -3079,12 +3125,14 @@ test_session_install (TestSuite *suite) add_unacknowledged_test ( suite, "/Session/unacknowledged/find_and_modify/explicit_cs/explicit_wc", + "", test_fam, true, false); add_unacknowledged_test ( suite, "/Session/unacknowledged/find_and_modify/implicit_cs/explicit_wc", + "", test_fam, false, false); @@ -3093,60 +3141,70 @@ test_session_install (TestSuite *suite) add_unacknowledged_test ( suite, "/Session/unacknowledged/db_cmd/explicit_cs/explicit_wc", + "", test_db_cmd, true, false); add_unacknowledged_test ( suite, "/Session/unacknowledged/db_cmd/implicit_cs/explicit_wc", + "", test_db_cmd, false, false); add_unacknowledged_test ( suite, "/Session/unacknowledged/read_write_cmd/explicit_cs/inherit_wc", + "", test_read_write_cmd, true, true); add_unacknowledged_test ( suite, "/Session/unacknowledged/read_write_cmd/explicit_cs/explicit_wc", + "", test_read_write_cmd, true, false); add_unacknowledged_test ( suite, "/Session/unacknowledged/read_write_cmd/implicit_cs/inherit_wc", + "", test_read_write_cmd, false, true); add_unacknowledged_test ( suite, "/Session/unacknowledged/read_write_cmd/implicit_cs/explicit_wc", + "", test_read_write_cmd, false, false); add_unacknowledged_test ( suite, "/Session/unacknowledged/write_cmd/explicit_cs/inherit_wc", + "", test_write_cmd, true, true); add_unacknowledged_test ( suite, "/Session/unacknowledged/write_cmd/explicit_cs/explicit_wc", + "", test_write_cmd, true, false); add_unacknowledged_test ( suite, "/Session/unacknowledged/write_cmd/implicit_cs/inherit_wc", + "", test_write_cmd, false, true); add_unacknowledged_test ( suite, "/Session/unacknowledged/write_cmd/implicit_cs/explicit_wc", + "", test_write_cmd, false, false); @@ -3160,6 +3218,7 @@ test_session_install (TestSuite *suite) TestSuite_AddFull ( suite, "/Session/dirty", + "", test_session_dirty, NULL /* dtor */, NULL /* ctx */, @@ -3170,6 +3229,7 @@ test_session_install (TestSuite *suite) TestSuite_AddFull (suite, "/Session/snapshot/prose_test_1", + "", test_sessions_snapshot_prose_test_1, NULL, NULL, diff --git a/src/libmongoc/tests/test-mongoc-client-side-encryption.c b/src/libmongoc/tests/test-mongoc-client-side-encryption.c index 60e452e666d..35476957ca1 100644 --- a/src/libmongoc/tests/test-mongoc-client-side-encryption.c +++ b/src/libmongoc/tests/test-mongoc-client-side-encryption.c @@ -3157,6 +3157,7 @@ test_client_side_encryption_install (TestSuite *suite) /* Prose tests from the spec. */ TestSuite_AddFull (suite, "/client_side_encryption/datakey_and_double_encryption", + "", test_datakey_and_double_encryption, NULL, NULL, @@ -3166,6 +3167,7 @@ test_client_side_encryption_install (TestSuite *suite) TestSuite_AddFull ( suite, "/client_side_encryption/external_key_vault", + "", test_external_key_vault, NULL, NULL, @@ -3175,6 +3177,7 @@ test_client_side_encryption_install (TestSuite *suite) TestSuite_AddFull ( suite, "/client_side_encryption/bson_size_limits_and_batch_splitting", + "", test_bson_size_limits_and_batch_splitting, NULL, NULL, @@ -3182,6 +3185,7 @@ test_client_side_encryption_install (TestSuite *suite) test_framework_skip_if_max_wire_version_less_than_8); TestSuite_AddFull (suite, "/client_side_encryption/views_are_prohibited", + "", test_views_are_prohibited, NULL, NULL, @@ -3189,6 +3193,7 @@ test_client_side_encryption_install (TestSuite *suite) test_framework_skip_if_max_wire_version_less_than_8); TestSuite_AddFull (suite, "/client_side_encryption/corpus", + "", test_corpus, NULL, NULL, @@ -3198,6 +3203,7 @@ test_client_side_encryption_install (TestSuite *suite) TestSuite_AddFull ( suite, "/client_side_encryption/custom_endpoint", + "", test_custom_endpoint, NULL, NULL, @@ -3207,6 +3213,7 @@ test_client_side_encryption_install (TestSuite *suite) TestSuite_AddFull (suite, "/client_side_encryption/bypass_spawning_mongocryptd/" "mongocryptdBypassSpawn", + "", test_bypass_spawning_via_mongocryptdBypassSpawn, NULL, NULL, @@ -3215,6 +3222,7 @@ test_client_side_encryption_install (TestSuite *suite) TestSuite_AddFull (suite, "/client_side_encryption/bypass_spawning_mongocryptd/" "bypassAutoEncryption", + "", test_bypass_spawning_via_bypassAutoEncryption, NULL, NULL, @@ -3222,6 +3230,7 @@ test_client_side_encryption_install (TestSuite *suite) test_framework_skip_if_max_wire_version_less_than_8); TestSuite_AddFull (suite, "/client_side_encryption/kms_tls/valid", + "", test_kms_tls_cert_valid, NULL, NULL, @@ -3229,6 +3238,7 @@ test_client_side_encryption_install (TestSuite *suite) test_framework_skip_if_max_wire_version_less_than_8); TestSuite_AddFull (suite, "/client_side_encryption/kms_tls/expired", + "", test_kms_tls_cert_expired, NULL, NULL, @@ -3236,6 +3246,7 @@ test_client_side_encryption_install (TestSuite *suite) test_framework_skip_if_max_wire_version_less_than_8); TestSuite_AddFull (suite, "/client_side_encryption/kms_tls/wrong_host", + "", test_kms_tls_cert_wrong_host, NULL, NULL, @@ -3245,6 +3256,7 @@ test_client_side_encryption_install (TestSuite *suite) /* Other, C driver specific, tests. */ TestSuite_AddFull (suite, "/client_side_encryption/single_and_pool_mismatches", + "", test_invalid_single_and_pool_mismatches, NULL, NULL, @@ -3252,6 +3264,7 @@ test_client_side_encryption_install (TestSuite *suite) test_framework_skip_if_max_wire_version_less_than_8); TestSuite_AddFull (suite, "/client_side_encryption/multi_threaded", + "", test_multi_threaded, NULL, NULL, @@ -3259,6 +3272,7 @@ test_client_side_encryption_install (TestSuite *suite) test_framework_skip_if_max_wire_version_less_than_8); TestSuite_AddFull (suite, "/client_side_encryption/malformed_explicit", + "", test_malformed_explicit, NULL, NULL, @@ -3267,6 +3281,7 @@ test_client_side_encryption_install (TestSuite *suite) TestSuite_AddFull ( suite, "/client_side_encryption/kms_tls_options", + "", test_kms_tls_options, NULL, NULL, @@ -3279,6 +3294,7 @@ test_client_side_encryption_install (TestSuite *suite) TestSuite_AddFull (suite, "/client_side_encryption/kms_tls_options/extra_rejected", + "", test_kms_tls_options_extra_rejected, NULL, NULL, diff --git a/src/libmongoc/tests/test-mongoc-client.c b/src/libmongoc/tests/test-mongoc-client.c index 5eb749df1b6..1710e6d9c04 100644 --- a/src/libmongoc/tests/test-mongoc-client.c +++ b/src/libmongoc/tests/test-mongoc-client.c @@ -4151,21 +4151,23 @@ test_client_install (TestSuite *suite) if (test_framework_getenv_bool ("MONGOC_CHECK_IPV6")) { /* try to validate ipv6 too */ TestSuite_AddLive ( - suite, "/Client/ipv6/single", test_mongoc_client_ipv6_single); + suite, "/Client/ipv6/single", "", test_mongoc_client_ipv6_single); /* try to validate ipv6 too */ TestSuite_AddLive ( - suite, "/Client/ipv6/single", test_mongoc_client_ipv6_pooled); + suite, "/Client/ipv6/single", "", test_mongoc_client_ipv6_pooled); } TestSuite_AddFull (suite, "/Client/authenticate", + "", test_mongoc_client_authenticate, NULL, NULL, test_framework_skip_if_no_auth); TestSuite_AddFull (suite, "/Client/speculative_auth_failure/single", + "", test_mongoc_client_single_speculative_auth_failure, NULL, NULL, @@ -4173,6 +4175,7 @@ test_client_install (TestSuite *suite) test_framework_skip_if_no_failpoint); TestSuite_AddFull (suite, "/Client/speculative_auth_failure/pooled", + "", test_mongoc_client_pooled_speculative_auth_failure, NULL, NULL, @@ -4180,276 +4183,351 @@ test_client_install (TestSuite *suite) test_framework_skip_if_no_failpoint); TestSuite_AddFull (suite, "/Client/authenticate_cached/pool", + "", test_mongoc_client_authenticate_cached_pooled, NULL, NULL, test_framework_skip_if_no_auth); TestSuite_AddFull (suite, "/Client/authenticate_cached/client", + "", test_mongoc_client_authenticate_cached_single, NULL, NULL, test_framework_skip_if_no_auth); TestSuite_AddFull (suite, "/Client/authenticate_failure", + "", test_mongoc_client_authenticate_failure, NULL, NULL, test_framework_skip_if_no_auth); TestSuite_AddFull (suite, "/Client/authenticate_timeout", + "", test_mongoc_client_authenticate_timeout, NULL, NULL, test_framework_skip_if_no_auth); - TestSuite_AddLive (suite, "/Client/command", test_mongoc_client_command); - TestSuite_AddLive ( - suite, "/Client/command_defaults", test_mongoc_client_command_defaults); - TestSuite_AddLive ( - suite, "/Client/command_secondary", test_mongoc_client_command_secondary); + TestSuite_AddLive (suite, "/Client/command", "", test_mongoc_client_command); + TestSuite_AddLive (suite, + "/Client/command_defaults", + "", + test_mongoc_client_command_defaults); + TestSuite_AddLive (suite, + "/Client/command_secondary", + "", + test_mongoc_client_command_secondary); TestSuite_AddMockServerTest ( - suite, "/Client/command_w_server_id", test_client_cmd_w_server_id); + suite, "/Client/command_w_server_id", "", test_client_cmd_w_server_id); TestSuite_AddMockServerTest (suite, "/Client/command_w_server_id/sharded", + "", test_client_cmd_w_server_id_sharded); TestSuite_AddFull (suite, "/Client/command_w_server_id/option", + "", test_server_id_option, NULL, NULL, test_framework_skip_if_auth); TestSuite_AddFull (suite, "/Client/command_w_write_concern", + "", test_client_cmd_w_write_concern, NULL, NULL, test_framework_skip_if_max_wire_version_less_than_5); - TestSuite_AddMockServerTest ( - suite, "/Client/command/write_concern", test_client_cmd_write_concern); + TestSuite_AddMockServerTest (suite, + "/Client/command/write_concern", + "", + test_client_cmd_write_concern); TestSuite_AddMockServerTest (suite, "/Client/command/write_concern_fam", + "", test_client_cmd_write_concern_fam); TestSuite_AddMockServerTest (suite, "/Client/command/read_prefs/simple/single", + "", test_command_simple_read_prefs_single); TestSuite_AddMockServerTest (suite, "/Client/command/read_prefs/simple/pooled", + "", test_command_simple_read_prefs_pooled); TestSuite_AddMockServerTest (suite, "/Client/command/read_prefs/single", + "", test_command_read_prefs_single); TestSuite_AddMockServerTest (suite, "/Client/command/read_prefs/pooled", + "", test_command_read_prefs_pooled); TestSuite_AddLive ( - suite, "/Client/command_not_found/cursor", test_command_not_found); - TestSuite_AddLive ( - suite, "/Client/command_not_found/simple", test_command_not_found_simple); + suite, "/Client/command_not_found/cursor", "", test_command_not_found); + TestSuite_AddLive (suite, + "/Client/command_not_found/simple", + "", + test_command_not_found_simple); TestSuite_AddMockServerTest (suite, "/Client/command_with_opts/read_prefs", + "", test_command_with_opts_read_prefs); TestSuite_AddMockServerTest (suite, "/Client/command_with_opts/read_write", + "", test_read_write_cmd_with_opts); + TestSuite_AddMockServerTest (suite, + "/Client/command_with_opts/legacy", + "", + test_command_with_opts_legacy); TestSuite_AddMockServerTest ( - suite, "/Client/command_with_opts/legacy", test_command_with_opts_legacy); - TestSuite_AddMockServerTest ( - suite, "/Client/command_with_opts", test_command_with_opts); - TestSuite_AddMockServerTest ( - suite, "/Client/command_with_opts/op_msg", test_command_with_opts_op_msg); + suite, "/Client/command_with_opts", "", test_command_with_opts); + TestSuite_AddMockServerTest (suite, + "/Client/command_with_opts/op_msg", + "", + test_command_with_opts_op_msg); TestSuite_AddMockServerTest ( - suite, "/Client/command_with_opts/read", test_read_command_with_opts); - TestSuite_AddLive (suite, "/Client/command/empty", test_command_empty); + suite, "/Client/command_with_opts/read", "", test_read_command_with_opts); + TestSuite_AddLive (suite, "/Client/command/empty", "", test_command_empty); TestSuite_AddMockServerTest ( - suite, "/Client/command/no_errmsg", test_command_no_errmsg); + suite, "/Client/command/no_errmsg", "", test_command_no_errmsg); TestSuite_AddMockServerTest ( - suite, "/Client/unavailable_seeds", test_unavailable_seeds); + suite, "/Client/unavailable_seeds", "", test_unavailable_seeds); TestSuite_AddMockServerTest (suite, "/Client/rs_seeds_no_connect/single", + "", test_rs_seeds_no_connect_single); TestSuite_AddMockServerTest (suite, "/Client/rs_seeds_no_connect/pooled", + "", test_rs_seeds_no_connect_pooled); - TestSuite_AddMockServerTest ( - suite, "/Client/rs_seeds_connect/single", test_rs_seeds_connect_single); - TestSuite_AddMockServerTest ( - suite, "/Client/rs_seeds_connect/pooled", test_rs_seeds_connect_pooled); + TestSuite_AddMockServerTest (suite, + "/Client/rs_seeds_connect/single", + "", + test_rs_seeds_connect_single); + TestSuite_AddMockServerTest (suite, + "/Client/rs_seeds_connect/pooled", + "", + test_rs_seeds_connect_pooled); TestSuite_AddMockServerTest (suite, "/Client/rs_seeds_reconnect/single", + "", test_rs_seeds_reconnect_single); TestSuite_AddMockServerTest (suite, "/Client/rs_seeds_reconnect/pooled", + "", test_rs_seeds_reconnect_pooled); TestSuite_AddMockServerTest (suite, "/Client/mongos_seeds_no_connect/single", + "", test_mongos_seeds_no_connect_single); TestSuite_AddMockServerTest (suite, "/Client/mongos_seeds_no_connect/pooled", + "", test_mongos_seeds_no_connect_pooled); TestSuite_AddMockServerTest (suite, "/Client/mongos_seeds_connect/single", + "", test_mongos_seeds_connect_single); TestSuite_AddMockServerTest (suite, "/Client/mongos_seeds_connect/pooled", + "", test_mongos_seeds_connect_pooled); TestSuite_AddMockServerTest (suite, "/Client/mongos_seeds_reconnect/single", + "", test_mongos_seeds_reconnect_single); TestSuite_AddMockServerTest (suite, "/Client/mongos_seeds_reconnect/pooled", + "", test_mongos_seeds_reconnect_pooled); TestSuite_AddFull (suite, "/Client/recovering", + "", test_recovering, NULL, NULL, test_framework_skip_if_slow); - TestSuite_AddLive (suite, "/Client/server_status", test_server_status); + TestSuite_AddLive (suite, "/Client/server_status", "", test_server_status); TestSuite_AddMockServerTest ( - suite, "/Client/database_names", test_get_database_names); + suite, "/Client/database_names", "", test_get_database_names); TestSuite_AddFull (suite, "/Client/connect/uds", + "", test_mongoc_client_unix_domain_socket, NULL, NULL, test_framework_skip_if_no_uds); TestSuite_AddMockServerTest ( - suite, "/Client/mismatched_me", test_mongoc_client_mismatched_me); + suite, "/Client/mismatched_me", "", test_mongoc_client_mismatched_me); TestSuite_AddMockServerTest ( - suite, "/Client/handshake/pool", test_mongoc_handshake_pool); + suite, "/Client/handshake/pool", "", test_mongoc_handshake_pool); TestSuite_Add (suite, "/Client/application_handshake", + "", test_mongoc_client_application_handshake); TestSuite_AddFull (suite, "/Client/sends_handshake_single", + "", test_client_sends_handshake_single, NULL, NULL, test_framework_skip_if_slow); TestSuite_Add (suite, "/Client/sends_handshake_pooled", + "", test_client_sends_handshake_pooled); TestSuite_AddMockServerTest ( - suite, "/Client/appname_single_uri", test_client_appname_single_uri); + suite, "/Client/appname_single_uri", "", test_client_appname_single_uri); TestSuite_AddMockServerTest (suite, "/Client/appname_single_no_uri", + "", test_client_appname_single_no_uri); TestSuite_AddMockServerTest ( - suite, "/Client/appname_pooled_uri", test_client_appname_pooled_uri); + suite, "/Client/appname_pooled_uri", "", test_client_appname_pooled_uri); TestSuite_AddMockServerTest (suite, "/Client/appname_pooled_no_uri", + "", test_client_appname_pooled_no_uri); TestSuite_AddMockServerTest ( - suite, "/Client/wire_version", test_wire_version); + suite, "/Client/wire_version", "", test_wire_version); #ifdef MONGOC_ENABLE_SSL - TestSuite_AddLive (suite, "/Client/ssl_opts/single", test_ssl_single); - TestSuite_AddLive (suite, "/Client/ssl_opts/pooled", test_ssl_pooled); - TestSuite_Add (suite, "/Client/set_ssl_opts", test_set_ssl_opts); - TestSuite_Add (suite, "/Client/ssl_opts_override", test_ssl_opts_override); + TestSuite_AddLive (suite, "/Client/ssl_opts/single", "", test_ssl_single); + TestSuite_AddLive (suite, "/Client/ssl_opts/pooled", "", test_ssl_pooled); + TestSuite_Add (suite, "/Client/set_ssl_opts", "", test_set_ssl_opts); + TestSuite_Add ( + suite, "/Client/ssl_opts_override", "", test_ssl_opts_override); TestSuite_Add (suite, "/Client/ssl_opts_padding_not_null/single", + "", test_ssl_opts_padding_not_null); - TestSuite_AddLive (suite, "/Client/ssl_hang", test_client_buildinfo_hang); + TestSuite_AddLive ( + suite, "/Client/ssl_hang", "", test_client_buildinfo_hang); #if defined(MONGOC_ENABLE_SSL_OPENSSL) || \ defined(MONGOC_ENABLE_SSL_SECURE_TRANSPORT) TestSuite_AddMockServerTest (suite, "/Client/ssl_opts/copies_single", + "", test_ssl_client_single_copies_args); TestSuite_AddMockServerTest (suite, "/Client/ssl_opts/copies_pooled", + "", test_ssl_client_pooled_copies_args); TestSuite_AddMockServerTest ( - suite, "/Client/ssl/reconnect/single", test_ssl_reconnect_single); + suite, "/Client/ssl/reconnect/single", "", test_ssl_reconnect_single); TestSuite_AddMockServerTest ( - suite, "/Client/ssl/reconnect/pooled", test_ssl_reconnect_pooled); + suite, "/Client/ssl/reconnect/pooled", "", test_ssl_reconnect_pooled); #endif #else /* No SSL support at all */ TestSuite_Add ( - suite, "/Client/ssl_disabled", test_mongoc_client_ssl_disabled); + suite, "/Client/ssl_disabled", "", test_mongoc_client_ssl_disabled); #endif TestSuite_AddMockServerTest (suite, "/Client/client_reset/sessions", + "", test_client_reset_sessions, test_framework_skip_if_no_crypto); TestSuite_AddMockServerTest ( - suite, "/Client/client_reset/cursors", test_client_reset_cursors); - TestSuite_AddMockServerTest ( - suite, "/Client/client_reset/connections", test_client_reset_connections); + suite, "/Client/client_reset/cursors", "", test_client_reset_cursors); + TestSuite_AddMockServerTest (suite, + "/Client/client_reset/connections", + "", + test_client_reset_connections); TestSuite_AddLive (suite, "/Client/get_description/single", + "", test_mongoc_client_get_description_single); TestSuite_AddLive (suite, "/Client/get_description/pooled", + "", test_mongoc_client_get_description_pooled); TestSuite_AddLive (suite, "/Client/descriptions/single", + "", test_mongoc_client_descriptions_single); TestSuite_AddFull (suite, "/Client/descriptions/pooled", + "", test_mongoc_client_descriptions_pooled, NULL, NULL, TestSuite_CheckLive); TestSuite_AddLive (suite, "/Client/select_server/single", + "", test_mongoc_client_select_server_single); TestSuite_AddLive (suite, "/Client/select_server/pooled", + "", test_mongoc_client_select_server_pooled); TestSuite_AddLive (suite, "/Client/select_server/err/single", + "", test_mongoc_client_select_server_error_single); TestSuite_AddLive (suite, "/Client/select_server/err/pooled", + "", test_mongoc_client_select_server_error_pooled); TestSuite_AddMockServerTest (suite, "/Client/select_server/retry/succeed", + "", test_mongoc_client_select_server_retry_succeed); TestSuite_AddMockServerTest (suite, "/Client/select_server/retry/fail", + "", test_mongoc_client_select_server_retry_fail); TestSuite_AddMockServerTest (suite, "/Client/fetch_stream/retry/succeed", + "", test_mongoc_client_fetch_stream_retry_succeed); TestSuite_AddMockServerTest (suite, "/Client/fetch_stream/retry/fail", + "", test_mongoc_client_fetch_stream_retry_fail); TestSuite_AddFull (suite, "/Client/null_error_pointer/single", + "", test_null_error_pointer_single, NULL, NULL, test_framework_skip_if_slow); TestSuite_AddFull (suite, "/Client/null_error_pointer/pooled", + "", test_null_error_pointer_pooled, NULL, NULL, test_framework_skip_if_slow); - TestSuite_Add (suite, "/Client/get_database", test_get_database); - TestSuite_Add (suite, "/Client/invalid_server_id", test_invalid_server_id); + TestSuite_Add (suite, "/Client/get_database", "", test_get_database); + TestSuite_Add ( + suite, "/Client/invalid_server_id", "", test_invalid_server_id); TestSuite_AddMockServerTest (suite, "/Client/recv_network_error", + "", test_mongoc_client_recv_network_error); TestSuite_AddLive (suite, "/Client/get_handshake_hello_response/single", + "", test_mongoc_client_get_handshake_hello_response_single); TestSuite_AddLive (suite, "/Client/get_handshake_hello_response/pooled", + "", test_mongoc_client_get_handshake_hello_response_pooled); TestSuite_AddLive ( suite, "/Client/get_handshake_establishes_connection/single", + "", test_mongoc_client_get_handshake_establishes_connection_single); TestSuite_AddLive ( suite, "/Client/get_handshake_establishes_connection/pooled", + "", test_mongoc_client_get_handshake_establishes_connection_pooled); } diff --git a/src/libmongoc/tests/test-mongoc-cluster.c b/src/libmongoc/tests/test-mongoc-cluster.c index db73ae3ff98..3703c6a3182 100644 --- a/src/libmongoc/tests/test-mongoc-cluster.c +++ b/src/libmongoc/tests/test-mongoc-cluster.c @@ -1945,6 +1945,7 @@ test_cluster_install (TestSuite *suite) while (p->name) { TestSuite_AddFull (suite, p->name, + "", _test_dollar_query, NULL, p, @@ -1953,139 +1954,177 @@ test_cluster_install (TestSuite *suite) p++; } + TestSuite_AddLive (suite, + "/Cluster/test_get_max_bson_obj_size", + "", + test_get_max_bson_obj_size); TestSuite_AddLive ( - suite, "/Cluster/test_get_max_bson_obj_size", test_get_max_bson_obj_size); - TestSuite_AddLive ( - suite, "/Cluster/test_get_max_msg_size", test_get_max_msg_size); + suite, "/Cluster/test_get_max_msg_size", "", test_get_max_msg_size); TestSuite_AddFull (suite, "/Cluster/disconnect/single", + "", test_cluster_node_disconnect_single, NULL, NULL, test_framework_skip_if_slow); TestSuite_AddFull (suite, "/Cluster/disconnect/pooled", + "", test_cluster_node_disconnect_pooled, NULL, NULL, test_framework_skip_if_slow); TestSuite_AddMockServerTest (suite, "/Cluster/command/timeout/single", + "", test_cluster_command_timeout_single); TestSuite_AddMockServerTest (suite, "/Cluster/command/timeout/pooled", + "", test_cluster_command_timeout_pooled); - TestSuite_AddMockServerTest ( - suite, "/Cluster/command/notprimary", test_cluster_command_not_primary); + TestSuite_AddMockServerTest (suite, + "/Cluster/command/notprimary", + "", + test_cluster_command_not_primary); TestSuite_AddFull (suite, "/Cluster/write_command/disconnect", + "", test_write_command_disconnect, NULL, NULL, test_framework_skip_if_slow); TestSuite_AddLive (suite, "/Cluster/cluster_time/command_simple/single", + "", test_cluster_time_command_simple_single); TestSuite_AddLive (suite, "/Cluster/cluster_time/command_simple/pooled", + "", test_cluster_time_command_simple_pooled); TestSuite_AddLive (suite, "/Cluster/cluster_time/command/single", + "", test_cluster_time_command_single); TestSuite_AddLive (suite, "/Cluster/cluster_time/command/pooled", + "", test_cluster_time_command_pooled); TestSuite_AddLive (suite, "/Cluster/cluster_time/command_with_opts/single", + "", test_cluster_time_command_with_opts_single); TestSuite_AddLive (suite, "/Cluster/cluster_time/command_with_opts/pooled", + "", test_cluster_time_command_with_opts_pooled); TestSuite_AddLive (suite, "/Cluster/cluster_time/aggregate/single", + "", test_cluster_time_aggregate_single); TestSuite_AddLive (suite, "/Cluster/cluster_time/aggregate/pooled", + "", test_cluster_time_aggregate_pooled); TestSuite_AddLive (suite, "/Cluster/cluster_time/cursor/single", + "", test_cluster_time_cursor_single); TestSuite_AddLive (suite, "/Cluster/cluster_time/cursor/pooled", + "", test_cluster_time_cursor_pooled); TestSuite_AddLive (suite, "/Cluster/cluster_time/insert/single", + "", test_cluster_time_insert_single); TestSuite_AddLive (suite, "/Cluster/cluster_time/insert/pooled", + "", test_cluster_time_insert_pooled); TestSuite_AddMockServerTest (suite, "/Cluster/cluster_time/comparison/single", + "", test_cluster_time_comparison_single, test_framework_skip_if_slow); TestSuite_AddMockServerTest (suite, "/Cluster/cluster_time/comparison/pooled", + "", test_cluster_time_comparison_pooled, test_framework_skip_if_slow); TestSuite_AddMockServerTest ( suite, "/Cluster/cluster_time/advanced_not_sent_to_standalone", + "", test_advanced_cluster_time_not_sent_to_standalone, test_framework_skip_if_no_crypto); TestSuite_AddMockServerTest (suite, "/Cluster/not_primary/single/op_query", + "", test_not_primary_single_op_query, test_framework_skip_if_slow); TestSuite_AddMockServerTest (suite, "/Cluster/not_primary/pooled/op_query", + "", test_not_primary_pooled_op_query, test_framework_skip_if_slow); TestSuite_AddMockServerTest (suite, "/Cluster/not_primary/single/op_msg", + "", test_not_primary_single_op_msg, test_framework_skip_if_slow); TestSuite_AddMockServerTest (suite, "/Cluster/not_primary/pooled/op_msg", + "", test_not_primary_pooled_op_msg, test_framework_skip_if_slow); TestSuite_AddMockServerTest (suite, "/Cluster/not_primary_auth/single/op_query", + "", test_not_primary_auth_single_op_query, test_framework_skip_if_slow); TestSuite_AddMockServerTest (suite, "/Cluster/not_primary_auth/pooled/op_query", + "", test_not_primary_auth_pooled_op_query, test_framework_skip_if_slow); TestSuite_AddMockServerTest (suite, "/Cluster/not_primary_auth/single/op_msg", + "", test_not_primary_auth_single_op_msg, test_framework_skip_if_slow); TestSuite_AddMockServerTest (suite, "/Cluster/not_primary_auth/pooled/op_msg", + "", test_not_primary_auth_pooled_op_msg, test_framework_skip_if_slow); TestSuite_AddMockServerTest ( - suite, "/Cluster/hello_fails", test_cluster_hello_fails); + suite, "/Cluster/hello_fails", "", test_cluster_hello_fails); TestSuite_AddMockServerTest ( - suite, "/Cluster/hello_hangup", test_cluster_hello_hangup); + suite, "/Cluster/hello_hangup", "", test_cluster_hello_hangup); TestSuite_AddMockServerTest (suite, "/Cluster/command_error/op_msg", + "", test_cluster_command_error_op_msg); TestSuite_AddMockServerTest (suite, "/Cluster/command_error/op_query", + "", test_cluster_command_error_op_query); TestSuite_AddMockServerTest ( - suite, "/Cluster/hello_on_unknown/mock", test_hello_on_unknown); + suite, "/Cluster/hello_on_unknown/mock", "", test_hello_on_unknown); TestSuite_AddLive (suite, "/Cluster/cmd_on_unknown_serverid/pooled", + "", test_cmd_on_unknown_serverid_pooled); TestSuite_AddLive (suite, "/Cluster/cmd_on_unknown_serverid/single", + "", test_cmd_on_unknown_serverid_single); TestSuite_AddLive (suite, "/Cluster/stream_invalidation/single", + "", test_cluster_stream_invalidation_single); TestSuite_AddLive (suite, "/Cluster/stream_invalidation/pooled", + "", test_cluster_stream_invalidation_pooled); } diff --git a/src/libmongoc/tests/test-mongoc-cmd.c b/src/libmongoc/tests/test-mongoc-cmd.c index e02c8d102ed..d33f36bfe97 100644 --- a/src/libmongoc/tests/test-mongoc-cmd.c +++ b/src/libmongoc/tests/test-mongoc-cmd.c @@ -83,5 +83,5 @@ void test_client_cmd_install (TestSuite *suite) { TestSuite_AddMockServerTest ( - suite, "/Client/cmd/options", test_client_cmd_options); + suite, "/Client/cmd/options", "", test_client_cmd_options); } diff --git a/src/libmongoc/tests/test-mongoc-collection-find-with-opts.c b/src/libmongoc/tests/test-mongoc-collection-find-with-opts.c index c2dafa007dd..1cbd0c4cdf8 100644 --- a/src/libmongoc/tests/test-mongoc-collection-find-with-opts.c +++ b/src/libmongoc/tests/test-mongoc-collection-find-with-opts.c @@ -962,84 +962,98 @@ void test_collection_find_with_opts_install (TestSuite *suite) { TestSuite_AddMockServerTest ( - suite, "/Collection/find_with_opts/dollar_or", test_dollar_or); + suite, "/Collection/find_with_opts/dollar_or", "", test_dollar_or); TestSuite_AddMockServerTest (suite, "/Collection/find_with_opts/snapshot_dollar_or", + "", test_snapshot_dollar_or); TestSuite_AddMockServerTest (suite, "/Collection/find_with_opts/key_named_filter", + "", test_key_named_filter); TestSuite_AddMockServerTest ( suite, "/Collection/find_with_opts/query/subdoc_named_filter", + "", test_op_query_subdoc_named_filter); TestSuite_AddMockServerTest ( - suite, "/Collection/find_with_opts/newoption", test_newoption); + suite, "/Collection/find_with_opts/newoption", "", test_newoption); TestSuite_AddMockServerTest ( suite, "/Collection/find_with_opts/cmd/subdoc_named_filter", + "", test_find_cmd_subdoc_named_filter_with_option); TestSuite_AddMockServerTest ( - suite, "/Collection/find_with_opts/orderby", test_sort); + suite, "/Collection/find_with_opts/orderby", "", test_sort); TestSuite_AddMockServerTest ( - suite, "/Collection/find_with_opts/fields", test_fields); + suite, "/Collection/find_with_opts/fields", "", test_fields); TestSuite_AddMockServerTest ( - suite, "/Collection/find_with_opts/slice", test_slice); + suite, "/Collection/find_with_opts/slice", "", test_slice); TestSuite_AddMockServerTest (suite, "/Collection/find_with_opts/modifiers/integer", + "", test_int_modifiers); TestSuite_AddMockServerTest ( suite, "/Collection/find_with_opts/modifiers/index_spec", + "", test_index_spec_modifiers); TestSuite_AddMockServerTest ( - suite, "/Collection/find_with_opts/comment", test_comment); + suite, "/Collection/find_with_opts/comment", "", test_comment); TestSuite_AddMockServerTest ( - suite, "/Collection/find_with_opts/modifiers/bool", test_snapshot); + suite, "/Collection/find_with_opts/modifiers/bool", "", test_snapshot); TestSuite_AddMockServerTest ( - suite, "/Collection/find_with_opts/showdiskloc", test_diskloc); + suite, "/Collection/find_with_opts/showdiskloc", "", test_diskloc); TestSuite_AddMockServerTest ( - suite, "/Collection/find_with_opts/returnkey", test_returnkey); + suite, "/Collection/find_with_opts/returnkey", "", test_returnkey); TestSuite_AddMockServerTest ( - suite, "/Collection/find_with_opts/skip", test_skip); + suite, "/Collection/find_with_opts/skip", "", test_skip); TestSuite_AddMockServerTest ( - suite, "/Collection/find_with_opts/batch_size", test_batch_size); + suite, "/Collection/find_with_opts/batch_size", "", test_batch_size); TestSuite_AddMockServerTest ( - suite, "/Collection/find_with_opts/limit", test_limit); + suite, "/Collection/find_with_opts/limit", "", test_limit); TestSuite_AddMockServerTest ( - suite, "/Collection/find_with_opts/singlebatch", test_singlebatch); + suite, "/Collection/find_with_opts/singlebatch", "", test_singlebatch); TestSuite_AddMockServerTest ( suite, "/Collection/find_with_opts/singlebatch/no_limit", + "", test_singlebatch_no_limit); TestSuite_AddMockServerTest ( suite, "/Collection/find_with_opts/unrecognized_dollar", + "", test_unrecognized_dollar_option); TestSuite_AddMockServerTest ( - suite, "/Collection/find_with_opts/flags", test_query_flags); + suite, "/Collection/find_with_opts/flags", "", test_query_flags); TestSuite_AddMockServerTest ( - suite, "/Collection/find_with_opts/exhaust", test_exhaust); + suite, "/Collection/find_with_opts/exhaust", "", test_exhaust); TestSuite_AddMockServerTest (suite, "/Collection/find_with_opts/await/getmore_cmd", + "", test_getmore_cmd_await); TestSuite_AddMockServerTest ( - suite, "/Collection/find_with_opts/server_id", test_find_w_server_id); + suite, "/Collection/find_with_opts/server_id", "", test_find_w_server_id); TestSuite_AddMockServerTest (suite, "/Collection/find_cmd_with_opts/server_id", + "", test_find_cmd_w_server_id); TestSuite_AddMockServerTest (suite, "/Collection/find_with_opts/server_id/sharded", + "", test_find_w_server_id_sharded); TestSuite_AddMockServerTest ( suite, "/Collection/find_cmd_with_opts/server_id/sharded", + "", test_find_cmd_w_server_id_sharded); TestSuite_AddLive (suite, "/Collection/find_with_opts/server_id/option", + "", test_server_id_option); TestSuite_AddFull (suite, "/Collection/find_with_opts/collation/error", + "", test_find_with_opts_collation_error, NULL, NULL, diff --git a/src/libmongoc/tests/test-mongoc-collection-find.c b/src/libmongoc/tests/test-mongoc-collection-find.c index 14f0c405c44..14a0d67aa7d 100644 --- a/src/libmongoc/tests/test-mongoc-collection-find.c +++ b/src/libmongoc/tests/test-mongoc-collection-find.c @@ -1200,66 +1200,79 @@ void test_collection_find_install (TestSuite *suite) { TestSuite_AddLive ( - suite, "/Collection/find/dollar_query", test_dollar_query); - TestSuite_AddLive (suite, "/Collection/find/dollar_or", test_dollar_or); + suite, "/Collection/find/dollar_query", "", test_dollar_query); + TestSuite_AddLive (suite, "/Collection/find/dollar_or", "", test_dollar_or); TestSuite_AddLive (suite, "/Collection/find/mixed_dollar_nondollar", + "", test_mixed_dollar_nondollar); TestSuite_AddLive ( - suite, "/Collection/find/key_named_filter", test_key_named_filter); + suite, "/Collection/find/key_named_filter", "", test_key_named_filter); TestSuite_AddLive (suite, "/Collection/find/key_named_filter/$query", + "", test_key_named_filter_with_dollar_query); - TestSuite_AddLive ( - suite, "/Collection/find/subdoc_named_filter", test_subdoc_named_filter); + TestSuite_AddLive (suite, + "/Collection/find/subdoc_named_filter", + "", + test_subdoc_named_filter); TestSuite_AddLive (suite, "/Collection/find/subdoc_named_filter/$query", + "", test_subdoc_named_filter_with_dollar_query); - TestSuite_AddLive (suite, "/Collection/find/newoption", test_newoption); - TestSuite_AddLive (suite, "/Collection/find/orderby", test_orderby); - TestSuite_AddLive (suite, "/Collection/find/fields", test_fields); + TestSuite_AddLive (suite, "/Collection/find/newoption", "", test_newoption); + TestSuite_AddLive (suite, "/Collection/find/orderby", "", test_orderby); + TestSuite_AddLive (suite, "/Collection/find/fields", "", test_fields); TestSuite_AddFull (suite, "/Collection/find/modifiers/maxscan", + "", test_maxscan, NULL, NULL, test_framework_skip_if_max_wire_version_more_than_6); TestSuite_AddLive ( - suite, "/Collection/find/modifiers/maxtimems", test_maxtimems); - TestSuite_AddLive (suite, "/Collection/find/comment", test_comment); - TestSuite_AddLive (suite, "/Collection/find/hint", test_hint); - TestSuite_AddLive (suite, "/Collection/find/max", test_max); - TestSuite_AddLive (suite, "/Collection/find/min", test_min); - TestSuite_AddLive (suite, "/Collection/find/modifiers/bool", test_snapshot); - TestSuite_AddLive (suite, "/Collection/find/showdiskloc", test_diskloc); - TestSuite_AddLive (suite, "/Collection/find/returnkey", test_returnkey); - TestSuite_AddLive (suite, "/Collection/find/skip", test_skip); - TestSuite_AddLive (suite, "/Collection/find/batch_size", test_batch_size); - TestSuite_AddLive (suite, "/Collection/find/limit", test_limit); + suite, "/Collection/find/modifiers/maxtimems", "", test_maxtimems); + TestSuite_AddLive (suite, "/Collection/find/comment", "", test_comment); + TestSuite_AddLive (suite, "/Collection/find/hint", "", test_hint); + TestSuite_AddLive (suite, "/Collection/find/max", "", test_max); + TestSuite_AddLive (suite, "/Collection/find/min", "", test_min); + TestSuite_AddLive ( + suite, "/Collection/find/modifiers/bool", "", test_snapshot); + TestSuite_AddLive (suite, "/Collection/find/showdiskloc", "", test_diskloc); + TestSuite_AddLive (suite, "/Collection/find/returnkey", "", test_returnkey); + TestSuite_AddLive (suite, "/Collection/find/skip", "", test_skip); + TestSuite_AddLive ( + suite, "/Collection/find/batch_size", "", test_batch_size); + TestSuite_AddLive (suite, "/Collection/find/limit", "", test_limit); TestSuite_AddLive ( - suite, "/Collection/find/negative_limit", test_negative_limit); - TestSuite_Add ( - suite, "/Collection/find/unrecognized", test_unrecognized_dollar_option); - TestSuite_AddLive (suite, "/Collection/find/flags", test_query_flags); + suite, "/Collection/find/negative_limit", "", test_negative_limit); + TestSuite_Add (suite, + "/Collection/find/unrecognized", + "", + test_unrecognized_dollar_option); + TestSuite_AddLive (suite, "/Collection/find/flags", "", test_query_flags); TestSuite_AddMockServerTest ( - suite, "/Collection/find/exhaust", test_exhaust); + suite, "/Collection/find/exhaust", "", test_exhaust); TestSuite_AddMockServerTest ( - suite, "/Collection/getmore/batch_size", test_getmore_batch_size); + suite, "/Collection/getmore/batch_size", "", test_getmore_batch_size); TestSuite_AddFull (suite, "/Collection/getmore/invalid_reply", + "", test_getmore_invalid_reply, NULL, NULL, test_framework_skip_if_slow); TestSuite_AddMockServerTest ( - suite, "/Collection/getmore/await", test_getmore_await); + suite, "/Collection/getmore/await", "", test_getmore_await); TestSuite_AddLive (suite, "/Collection/tailable/timeout/single", + "", test_tailable_timeout_single); #ifndef MONGOC_ENABLE_SSL_SECURE_TRANSPORT #ifndef MONGOC_ENABLE_SSL_SECURE_CHANNEL TestSuite_AddLive (suite, "/Collection/tailable/timeout/pooled", + "", test_tailable_timeout_pooled); #endif #endif diff --git a/src/libmongoc/tests/test-mongoc-collection.c b/src/libmongoc/tests/test-mongoc-collection.c index d820ded90f8..548920a6c95 100644 --- a/src/libmongoc/tests/test-mongoc-collection.c +++ b/src/libmongoc/tests/test-mongoc-collection.c @@ -4471,7 +4471,7 @@ test_aggregate_install (TestSuite *suite) context->with_options ? "with_options" : "no_options"); TestSuite_AddWC ( - suite, name, test_aggregate_modern, NULL, (void *) context); + suite, name, "", test_aggregate_modern, NULL, (void *) context); bson_free (name); } } @@ -6419,244 +6419,292 @@ test_collection_install (TestSuite *suite) TestSuite_AddFull (suite, "/Collection/aggregate/write_concern", + "", test_aggregate_w_write_concern, NULL, NULL, test_framework_skip_if_max_wire_version_less_than_5); TestSuite_AddFull (suite, "/Collection/read_prefs_is_valid", + "", test_read_prefs_is_valid, NULL, NULL, test_framework_skip_if_mongos); - TestSuite_AddLive (suite, "/Collection/insert_many", test_insert_many); + TestSuite_AddLive (suite, "/Collection/insert_many", "", test_insert_many); TestSuite_AddLive ( - suite, "/Collection/insert_bulk_empty", test_insert_bulk_empty); - TestSuite_AddLive (suite, "/Collection/copy", test_copy); - TestSuite_AddLive (suite, "/Collection/insert", test_insert); + suite, "/Collection/insert_bulk_empty", "", test_insert_bulk_empty); + TestSuite_AddLive (suite, "/Collection/copy", "", test_copy); + TestSuite_AddLive (suite, "/Collection/insert", "", test_insert); TestSuite_AddLive ( - suite, "/Collection/insert/null_string", test_insert_null); + suite, "/Collection/insert/null_string", "", test_insert_null); TestSuite_AddFull (suite, "/Collection/insert/oversize", + "", test_insert_oversize, NULL, NULL, test_framework_skip_if_slow_or_live); TestSuite_AddMockServerTest ( - suite, "/Collection/insert/keys", test_insert_command_keys); - TestSuite_AddLive (suite, "/Collection/save", test_save); - TestSuite_AddLive (suite, "/Collection/insert/w0", test_insert_w0); - TestSuite_AddLive (suite, "/Collection/update/w0", test_update_w0); - TestSuite_AddLive (suite, "/Collection/remove/w0", test_remove_w0); + suite, "/Collection/insert/keys", "", test_insert_command_keys); + TestSuite_AddLive (suite, "/Collection/save", "", test_save); + TestSuite_AddLive (suite, "/Collection/insert/w0", "", test_insert_w0); + TestSuite_AddLive (suite, "/Collection/update/w0", "", test_update_w0); + TestSuite_AddLive (suite, "/Collection/remove/w0", "", test_remove_w0); TestSuite_AddLive ( - suite, "/Collection/insert_twice/w0", test_insert_twice_w0); - TestSuite_AddLive (suite, "/Collection/index", test_index); - TestSuite_AddLive ( - suite, "/Collection/index_w_write_concern", test_index_w_write_concern); + suite, "/Collection/insert_twice/w0", "", test_insert_twice_w0); + TestSuite_AddLive (suite, "/Collection/index", "", test_index); + TestSuite_AddLive (suite, + "/Collection/index_w_write_concern", + "", + test_index_w_write_concern); TestSuite_AddMockServerTest (suite, "/Collection/index/collation/wire4", + "", test_index_with_collation_fail); - TestSuite_AddMockServerTest ( - suite, "/Collection/index/collation/wire5", test_index_with_collation_ok); - TestSuite_AddLive (suite, "/Collection/index_compound", test_index_compound); + TestSuite_AddMockServerTest (suite, + "/Collection/index/collation/wire5", + "", + test_index_with_collation_ok); + TestSuite_AddLive ( + suite, "/Collection/index_compound", "", test_index_compound); TestSuite_AddFull (suite, "/Collection/index_geo", + "", test_index_geo, NULL, NULL, test_framework_skip_if_max_wire_version_more_than_9); - TestSuite_AddLive (suite, "/Collection/index_storage", test_index_storage); - TestSuite_AddLive (suite, "/Collection/regex", test_regex); + TestSuite_AddLive ( + suite, "/Collection/index_storage", "", test_index_storage); + TestSuite_AddLive (suite, "/Collection/regex", "", test_regex); TestSuite_AddFull (suite, "/Collection/decimal128", + "", test_decimal128, NULL, NULL, skip_unless_server_has_decimal128); - TestSuite_AddLive (suite, "/Collection/update", test_update); + TestSuite_AddLive (suite, "/Collection/update", "", test_update); TestSuite_AddFull (suite, "/Collection/update_pipeline", + "", test_update_pipeline, NULL, NULL, test_framework_skip_if_max_wire_version_less_than_8); - TestSuite_AddLive (suite, "/Collection/update/multi", test_update_multi); - TestSuite_AddLive (suite, "/Collection/update/upsert", test_update_upsert); + TestSuite_AddLive (suite, "/Collection/update/multi", "", test_update_multi); + TestSuite_AddLive ( + suite, "/Collection/update/upsert", "", test_update_upsert); TestSuite_AddFull (suite, "/Collection/update/oversize", + "", test_update_oversize, NULL, NULL, test_framework_skip_if_slow_or_live); - TestSuite_AddLive (suite, "/Collection/remove", test_remove); - TestSuite_AddLive (suite, "/Collection/remove/multi", test_remove_multi); + TestSuite_AddLive (suite, "/Collection/remove", "", test_remove); + TestSuite_AddLive (suite, "/Collection/remove/multi", "", test_remove_multi); TestSuite_AddFull (suite, "/Collection/remove/oversize", + "", test_remove_oversize, NULL, NULL, test_framework_skip_if_slow_or_live); - TestSuite_AddLive (suite, "/Collection/count", test_count); + TestSuite_AddLive (suite, "/Collection/count", "", test_count); TestSuite_AddMockServerTest ( - suite, "/Collection/count_with_opts", test_count_with_opts); + suite, "/Collection/count_with_opts", "", test_count_with_opts); TestSuite_AddMockServerTest ( - suite, "/Collection/count/read_pref", test_count_read_pref); + suite, "/Collection/count/read_pref", "", test_count_read_pref); TestSuite_AddMockServerTest ( - suite, "/Collection/count/read_concern", test_count_read_concern); + suite, "/Collection/count/read_concern", "", test_count_read_concern); TestSuite_AddMockServerTest (suite, "/Collection/count/collation/wire4", + "", test_count_with_collation_fail); - TestSuite_AddMockServerTest ( - suite, "/Collection/count/collation/wire5", test_count_with_collation_ok); + TestSuite_AddMockServerTest (suite, + "/Collection/count/collation/wire5", + "", + test_count_with_collation_ok); TestSuite_AddFull (suite, "/Collection/count/read_concern_live", + "", test_count_read_concern_live, NULL, NULL, mongod_supports_majority_read_concern); - TestSuite_AddLive (suite, "/Collection/drop", test_drop); - TestSuite_AddLive (suite, "/Collection/aggregate", test_aggregate); + TestSuite_AddLive (suite, "/Collection/drop", "", test_drop); + TestSuite_AddLive (suite, "/Collection/aggregate", "", test_aggregate); TestSuite_AddMockServerTest (suite, "/Collection/aggregate/inherit/collection", + "", test_aggregate_inherit_collection); TestSuite_AddLive ( - suite, "/Collection/aggregate/large", test_aggregate_large); + suite, "/Collection/aggregate/large", "", test_aggregate_large); TestSuite_AddFull (suite, "/Collection/aggregate/secondary", + "", test_aggregate_secondary, NULL, NULL, test_framework_skip_if_mongos); TestSuite_AddMockServerTest (suite, "/Collection/aggregate/secondary/sharded", + "", test_aggregate_secondary_sharded); - TestSuite_AddMockServerTest ( - suite, "/Collection/aggregate/read_concern", test_aggregate_read_concern); + TestSuite_AddMockServerTest (suite, + "/Collection/aggregate/read_concern", + "", + test_aggregate_read_concern); TestSuite_AddFull (suite, "/Collection/aggregate/bypass_document_validation", + "", test_aggregate_bypass, NULL, NULL, test_framework_skip_if_max_wire_version_less_than_4); TestSuite_AddMockServerTest (suite, "/Collection/aggregate/collation/wire4", + "", test_aggregate_with_collation_fail); TestSuite_AddMockServerTest (suite, "/Collection/aggregate/collation/wire5", + "", test_aggregate_with_collation_ok); - TestSuite_AddMockServerTest ( - suite, "/Collection/aggregate_w_server_id", test_aggregate_w_server_id); + TestSuite_AddMockServerTest (suite, + "/Collection/aggregate_w_server_id", + "", + test_aggregate_w_server_id); TestSuite_AddMockServerTest (suite, "/Collection/aggregate_w_server_id/sharded", + "", test_aggregate_w_server_id_sharded); TestSuite_AddFull (suite, "/Collection/aggregate_w_server_id/option", + "", test_aggregate_server_id_option, NULL, NULL, test_framework_skip_if_auth); TestSuite_AddFull (suite, "/Collection/validate", + "", test_validate, NULL, NULL, test_framework_skip_if_slow_or_live); - TestSuite_AddLive (suite, "/Collection/rename", test_rename); - TestSuite_AddLive (suite, "/Collection/stats", test_stats); + TestSuite_AddLive (suite, "/Collection/rename", "", test_rename); + TestSuite_AddLive (suite, "/Collection/stats", "", test_stats); TestSuite_AddMockServerTest ( - suite, "/Collection/stats/read_pref", test_stats_read_pref); + suite, "/Collection/stats/read_pref", "", test_stats_read_pref); TestSuite_AddMockServerTest ( - suite, "/Collection/find_read_concern", test_find_read_concern); + suite, "/Collection/find_read_concern", "", test_find_read_concern); TestSuite_AddFull (suite, "/Collection/getmore_read_concern_live", + "", test_getmore_read_concern_live, NULL, NULL, test_framework_skip_if_max_wire_version_less_than_4); TestSuite_AddLive ( - suite, "/Collection/find_and_modify", test_find_and_modify); + suite, "/Collection/find_and_modify", "", test_find_and_modify); TestSuite_AddMockServerTest (suite, "/Collection/find_and_modify/write_concern", + "", test_find_and_modify_write_concern_wire_32); TestSuite_AddMockServerTest ( suite, "/Collection/find_and_modify/write_concern_pre_32", + "", test_find_and_modify_write_concern_wire_pre_32); TestSuite_AddFull (suite, "/Collection/large_return", + "", test_large_return, NULL, NULL, test_framework_skip_if_slow_or_live); - TestSuite_AddLive (suite, "/Collection/many_return", test_many_return); + TestSuite_AddLive (suite, "/Collection/many_return", "", test_many_return); TestSuite_AddLive ( - suite, "/Collection/insert_one_validate", test_insert_one_validate); + suite, "/Collection/insert_one_validate", "", test_insert_one_validate); TestSuite_AddLive ( - suite, "/Collection/insert_many_validate", test_insert_many_validate); - TestSuite_AddMockServerTest (suite, "/Collection/limit", test_find_limit); + suite, "/Collection/insert_many_validate", "", test_insert_many_validate); TestSuite_AddMockServerTest ( - suite, "/Collection/batch_size", test_find_batch_size); + suite, "/Collection/limit", "", test_find_limit); + TestSuite_AddMockServerTest ( + suite, "/Collection/batch_size", "", test_find_batch_size); TestSuite_AddFull (suite, "/Collection/command_fully_qualified", + "", test_command_fq, NULL, NULL, test_framework_skip_if_mongos); - TestSuite_AddLive (suite, "/Collection/get_index_info", test_get_index_info); + TestSuite_AddLive ( + suite, "/Collection/get_index_info", "", test_get_index_info); TestSuite_AddMockServerTest ( - suite, "/Collection/find_indexes/error", test_find_indexes_err); + suite, "/Collection/find_indexes/error", "", test_find_indexes_err); TestSuite_AddLive ( - suite, "/Collection/insert/duplicate_key", test_insert_duplicate_key); + suite, "/Collection/insert/duplicate_key", "", test_insert_duplicate_key); TestSuite_AddFull (suite, "/Collection/create_index/fail", + "", test_create_index_fail, NULL, NULL, test_framework_skip_if_offline); - TestSuite_AddLive (suite, "/Collection/insert_one", test_insert_one); + TestSuite_AddLive (suite, "/Collection/insert_one", "", test_insert_one); TestSuite_AddLive ( - suite, "/Collection/update_and_replace", test_update_and_replace); - TestSuite_AddLive ( - suite, "/Collection/array_filters_validate", test_array_filters_validate); + suite, "/Collection/update_and_replace", "", test_update_and_replace); + TestSuite_AddLive (suite, + "/Collection/array_filters_validate", + "", + test_array_filters_validate); TestSuite_AddLive ( - suite, "/Collection/replace_one_validate", test_replace_one_validate); + suite, "/Collection/replace_one_validate", "", test_replace_one_validate); TestSuite_AddLive ( - suite, "/Collection/update_one_validate", test_update_one_validate); + suite, "/Collection/update_one_validate", "", test_update_one_validate); TestSuite_AddLive ( - suite, "/Collection/update_many_validate", test_update_many_validate); + suite, "/Collection/update_many_validate", "", test_update_many_validate); TestSuite_AddLive ( - suite, "/Collection/delete_one_or_many", test_delete_one_or_many); + suite, "/Collection/delete_one_or_many", "", test_delete_one_or_many); TestSuite_AddMockServerTest ( - suite, "/Collection/delete/collation", test_delete_collation); + suite, "/Collection/delete/collation", "", test_delete_collation); TestSuite_AddMockServerTest ( - suite, "/Collection/update/collation", test_update_collation); + suite, "/Collection/update/collation", "", test_update_collation); TestSuite_AddMockServerTest ( - suite, "/Collection/update/hint", test_update_hint); + suite, "/Collection/update/hint", "", test_update_hint); TestSuite_AddLive ( - suite, "/Collection/update/hint/validate", test_update_hint_validate); + suite, "/Collection/update/hint/validate", "", test_update_hint_validate); TestSuite_AddMockServerTest ( - suite, "/Collection/count_documents", test_count_documents); + suite, "/Collection/count_documents", "", test_count_documents); TestSuite_AddLive ( - suite, "/Collection/count_documents_live", test_count_documents_live); + suite, "/Collection/count_documents_live", "", test_count_documents_live); TestSuite_AddMockServerTest (suite, "/Collection/estimated_document_count", + "", test_estimated_document_count); TestSuite_AddLive (suite, "/Collection/estimated_document_count_live", + "", test_estimated_document_count_live); TestSuite_AddLive ( - suite, "/Collection/insert_bulk_validate", test_insert_bulk_validate); + suite, "/Collection/insert_bulk_validate", "", test_insert_bulk_validate); TestSuite_AddMockServerTest (suite, "/Collection/aggregate_with_batch_size", + "", test_aggregate_with_batch_size); TestSuite_AddFull (suite, "/Collection/aggregate_is_sent_to_primary_w_dollar_out", + "", test_aggregate_is_sent_to_primary_w_dollar_out, NULL, NULL, test_framework_skip_if_not_replset); TestSuite_AddFull (suite, "/Collection/fam/no_error_on_retry", + "", test_fam_no_error_on_retry, NULL, NULL, diff --git a/src/libmongoc/tests/test-mongoc-command-monitoring.c b/src/libmongoc/tests/test-mongoc-command-monitoring.c index 6b48b9b6ce3..5571cce95fc 100644 --- a/src/libmongoc/tests/test-mongoc-command-monitoring.c +++ b/src/libmongoc/tests/test-mongoc-command-monitoring.c @@ -1356,63 +1356,86 @@ test_command_monitoring_install (TestSuite *suite) { test_all_spec_tests (suite); TestSuite_AddMockServerTest ( - suite, "/command_monitoring/get_error", test_get_error); + suite, "/command_monitoring/get_error", "", test_get_error); TestSuite_AddLive (suite, "/command_monitoring/set_callbacks/single", + "", test_set_callbacks_single); TestSuite_AddLive (suite, "/command_monitoring/set_callbacks/pooled", + "", test_set_callbacks_pooled); TestSuite_AddLive (suite, "/command_monitoring/set_callbacks/pooled_try_pop", + "", test_set_callbacks_pooled_try_pop); /* require aggregation cursor */ - TestSuite_AddLive ( - suite, "/command_monitoring/set_callbacks/change", test_change_callbacks); - TestSuite_AddLive ( - suite, "/command_monitoring/set_callbacks/reset", test_reset_callbacks); + TestSuite_AddLive (suite, + "/command_monitoring/set_callbacks/change", + "", + test_change_callbacks); + TestSuite_AddLive (suite, + "/command_monitoring/set_callbacks/reset", + "", + test_reset_callbacks); TestSuite_AddLive (suite, "/command_monitoring/operation_id/bulk/collection/single", + "", test_collection_bulk_op_single); TestSuite_AddLive (suite, "/command_monitoring/operation_id/bulk/collection/pooled", + "", test_collection_bulk_op_pooled); TestSuite_AddLive (suite, "/command_monitoring/operation_id/bulk/new/single", + "", test_bulk_op_single); TestSuite_AddLive (suite, "/command_monitoring/operation_id/bulk/new/pooled", + "", test_bulk_op_pooled); TestSuite_AddMockServerTest ( suite, "/command_monitoring/operation_id/query/single/cmd", + "", test_query_operation_id_single_cmd); TestSuite_AddMockServerTest ( suite, "/command_monitoring/operation_id/query/pooled/cmd", + "", test_query_operation_id_pooled_cmd); - TestSuite_AddLive (suite, "/command_monitoring/client_cmd", test_client_cmd); TestSuite_AddLive ( - suite, "/command_monitoring/client_cmd_simple", test_client_cmd_simple); - TestSuite_AddLive ( - suite, "/command_monitoring/client_cmd/op_ids", test_client_cmd_op_ids); + suite, "/command_monitoring/client_cmd", "", test_client_cmd); + TestSuite_AddLive (suite, + "/command_monitoring/client_cmd_simple", + "", + test_client_cmd_simple); + TestSuite_AddLive (suite, + "/command_monitoring/client_cmd/op_ids", + "", + test_client_cmd_op_ids); TestSuite_AddFull (suite, "/command_monitoring/killcursors_deprecated", + "", test_killcursors_deprecated, NULL /* dtor */, NULL /* ctx */, test_framework_skip_if_no_legacy_opcodes); TestSuite_AddMockServerTest (suite, "/command_monitoring/failed_reply_mock", + "", test_command_failed_reply_mock); TestSuite_AddMockServerTest (suite, "/command_monitoring/failed_reply_hangup", + "", test_command_failed_reply_hangup); TestSuite_AddMockServerTest (suite, "/command_monitoring/service_id/loadbalanced", + "", test_service_id_loadbalanced); TestSuite_AddMockServerTest ( suite, "/command_monitoring/service_id/not_loadbalanced", + "", test_service_id_not_loadbalanced); } diff --git a/src/libmongoc/tests/test-mongoc-counters.c b/src/libmongoc/tests/test-mongoc-counters.c index e11d47ebbc4..a7488b0a442 100644 --- a/src/libmongoc/tests/test-mongoc-counters.c +++ b/src/libmongoc/tests/test-mongoc-counters.c @@ -565,6 +565,7 @@ test_counters_install (TestSuite *suite) #ifdef MONGOC_ENABLE_SHM_COUNTERS TestSuite_AddFull (suite, "/counters/op_msg", + "", test_counters_op_msg, NULL, NULL, @@ -573,6 +574,7 @@ test_counters_install (TestSuite *suite) test_framework_skip_if_compressors); TestSuite_AddFull (suite, "/counters/op_compressed", + "", test_counters_op_compressed, NULL, NULL, @@ -582,6 +584,7 @@ test_counters_install (TestSuite *suite) /* test before OP_MSG. */ TestSuite_AddFull (suite, "/counters/op_query", + "", test_counters_op_query, NULL, NULL, @@ -592,29 +595,32 @@ test_counters_install (TestSuite *suite) /* test before the getMore and killCursors commands were introduced. */ TestSuite_AddFull (suite, "/counters/op_getmore_killcursors", + "", test_counters_op_getmore_killcursors, NULL, NULL, test_framework_skip_if_max_wire_version_more_than_3, test_framework_skip_if_compressors, test_framework_skip_if_auth); - TestSuite_AddLive (suite, "/counters/cursors", test_counters_cursors); - TestSuite_AddLive (suite, "/counters/clients", test_counters_clients); + TestSuite_AddLive (suite, "/counters/cursors", "", test_counters_cursors); + TestSuite_AddLive (suite, "/counters/clients", "", test_counters_clients); TestSuite_AddFull (suite, "/counters/streams", + "", test_counters_streams, NULL, NULL, TestSuite_CheckLive); TestSuite_AddFull (suite, "/counters/auth", + "", test_counters_auth, NULL, NULL, test_framework_skip_if_no_auth, test_framework_skip_if_not_single); - TestSuite_AddLive (suite, "/counters/dns", test_counters_dns); + TestSuite_AddLive (suite, "/counters/dns", "", test_counters_dns); TestSuite_AddMockServerTest ( - suite, "/counters/streams_timeout", test_counters_streams_timeout); + suite, "/counters/streams_timeout", "", test_counters_streams_timeout); #endif } diff --git a/src/libmongoc/tests/test-mongoc-crud.c b/src/libmongoc/tests/test-mongoc-crud.c index 53b8d536062..58da72be6f2 100644 --- a/src/libmongoc/tests/test-mongoc-crud.c +++ b/src/libmongoc/tests/test-mongoc-crud.c @@ -172,6 +172,7 @@ test_crud_install (TestSuite *suite) TestSuite_AddFull (suite, "/crud/prose_test_1", + "", prose_test_1, NULL, /* dtor */ NULL, /* ctx */ @@ -180,6 +181,7 @@ test_crud_install (TestSuite *suite) TestSuite_AddFull (suite, "/crud/prose_test_2", + "", prose_test_2, NULL, /* dtor */ NULL, /* ctx */ diff --git a/src/libmongoc/tests/test-mongoc-cursor.c b/src/libmongoc/tests/test-mongoc-cursor.c index e3d8f8c243d..f977c8104be 100644 --- a/src/libmongoc/tests/test-mongoc-cursor.c +++ b/src/libmongoc/tests/test-mongoc-cursor.c @@ -445,18 +445,25 @@ _make_array_cursor (mongoc_collection_t *coll) #define TEST_CURSOR_FIND(prefix, fn) \ TestSuite_AddFullWithTestFn (suite, \ prefix "/find", \ + "", \ fn, \ NULL, \ _make_find_cursor, \ TestSuite_CheckLive); -#define TEST_CURSOR_CMD(prefix, fn) \ - TestSuite_AddFullWithTestFn ( \ - suite, prefix "/cmd", fn, NULL, _make_cmd_cursor, TestSuite_CheckLive); +#define TEST_CURSOR_CMD(prefix, fn) \ + TestSuite_AddFullWithTestFn (suite, \ + prefix "/cmd", \ + "", \ + fn, \ + NULL, \ + _make_cmd_cursor, \ + TestSuite_CheckLive); #define TEST_CURSOR_CMD_DEPRECATED(prefix, fn) \ TestSuite_AddFullWithTestFn (suite, \ prefix "/cmd_deprecated", \ + "", \ fn, \ NULL, \ _make_cmd_deprecated_cursor, \ @@ -465,6 +472,7 @@ _make_array_cursor (mongoc_collection_t *coll) #define TEST_CURSOR_ARRAY(prefix, fn) \ TestSuite_AddFullWithTestFn (suite, \ prefix "/array", \ + "", \ fn, \ NULL, \ _make_array_cursor, \ @@ -473,6 +481,7 @@ _make_array_cursor (mongoc_collection_t *coll) #define TEST_CURSOR_AGG(prefix, fn) \ TestSuite_AddFullWithTestFn (suite, \ prefix "/agg", \ + "", \ fn, \ NULL, \ _make_cmd_cursor_from_agg, \ @@ -699,16 +708,18 @@ test_kill_cursor_live (void) cursor = _mongoc_cursor_find_new ( client, collection->ns, b, NULL, NULL, NULL, NULL); /* override the typical priming, and immediately transition to an OPQUERY - * find cursor. */ + * find cursor. */ cursor->impl.destroy (&cursor->impl); _mongoc_cursor_impl_find_opquery_init (cursor, b); cursor->cursor_id = ctx.cursor_id; - cursor->state = END_OF_BATCH; /* meaning, "finished reading first batch" */ + cursor->state = + END_OF_BATCH; /* meaning, "finished reading first batch" */ r = mongoc_cursor_next (cursor, &doc); ASSERT (!r); ASSERT (mongoc_cursor_error (cursor, &error)); - ASSERT_ERROR_CONTAINS (error, MONGOC_ERROR_CURSOR, 16, "cursor is invalid"); + ASSERT_ERROR_CONTAINS ( + error, MONGOC_ERROR_CURSOR, 16, "cursor is invalid"); mongoc_cursor_destroy (cursor); } else { @@ -1575,8 +1586,8 @@ mongoc_query_flags_t expected_flag[] = { MONGOC_QUERY_SECONDARY_OK, }; -/* test that mongoc_cursor_set_hint sets secondaryOk for mongos only if read pref - * is secondaryPreferred. */ +/* test that mongoc_cursor_set_hint sets secondaryOk for mongos only if read + * pref is secondaryPreferred. */ static void test_cursor_hint_mongos (void) { @@ -1881,8 +1892,8 @@ _test_cursor_n_return_find_cmd (mongoc_cursor_t *cursor, } future = future_cursor_next (cursor, &doc); - request = - mock_server_receives_command (server, "db", MONGOC_QUERY_SECONDARY_OK, NULL); + request = mock_server_receives_command ( + server, "db", MONGOC_QUERY_SECONDARY_OK, NULL); ASSERT (match_bson (request_get_doc (request, 0), &find_cmd, true)); @@ -2139,8 +2150,8 @@ test_empty_final_batch (void) * one document in first batch */ future = future_cursor_next (cursor, &doc); - request = - mock_server_receives_command (server, "db", MONGOC_QUERY_SECONDARY_OK, NULL); + request = mock_server_receives_command ( + server, "db", MONGOC_QUERY_SECONDARY_OK, NULL); mock_server_replies_to_find ( request, MONGOC_QUERY_SECONDARY_OK, 1234, 0, "db.coll", "{}", true); @@ -2153,11 +2164,16 @@ test_empty_final_batch (void) * empty batch with nonzero cursor id */ future = future_cursor_next (cursor, &doc); - request = - mock_server_receives_command (server, "db", MONGOC_QUERY_SECONDARY_OK, NULL); + request = mock_server_receives_command ( + server, "db", MONGOC_QUERY_SECONDARY_OK, NULL); - mock_server_replies_to_find ( - request, MONGOC_QUERY_SECONDARY_OK, 1234, 0, "db.coll", "" /* empty */, true); + mock_server_replies_to_find (request, + MONGOC_QUERY_SECONDARY_OK, + 1234, + 0, + "db.coll", + "" /* empty */, + true); ASSERT (!future_get_bool (future)); ASSERT_OR_PRINT (!mongoc_cursor_error (cursor, &error), error); @@ -2168,8 +2184,8 @@ test_empty_final_batch (void) * final batch, empty with zero cursor id */ future = future_cursor_next (cursor, &doc); - request = - mock_server_receives_command (server, "db", MONGOC_QUERY_SECONDARY_OK, NULL); + request = mock_server_receives_command ( + server, "db", MONGOC_QUERY_SECONDARY_OK, NULL); ASSERT_CMPINT64 ( bson_lookup_int64 (request_get_doc (request, 0), "batchSize"), @@ -2353,97 +2369,104 @@ void test_cursor_install (TestSuite *suite) { test_common_cursor_functions_install (suite); - TestSuite_AddLive (suite, "/Cursor/limit", test_limit); - TestSuite_AddLive (suite, - "" - "/Cursor/kill/live", - test_kill_cursor_live); + TestSuite_AddLive (suite, "/Cursor/limit", "", test_limit); + TestSuite_AddLive (suite, "/Cursor/kill/live", "", test_kill_cursor_live); TestSuite_AddMockServerTest ( - suite, "/Cursor/kill/single", test_kill_cursors_single); + suite, "/Cursor/kill/single", "", test_kill_cursors_single); TestSuite_AddMockServerTest ( - suite, "/Cursor/kill/pooled", test_kill_cursors_pooled); + suite, "/Cursor/kill/pooled", "", test_kill_cursors_pooled); TestSuite_AddMockServerTest ( - suite, "/Cursor/kill/single/cmd", test_kill_cursors_single_cmd); + suite, "/Cursor/kill/single/cmd", "", test_kill_cursors_single_cmd); TestSuite_AddMockServerTest ( - suite, "/Cursor/kill/pooled/cmd", test_kill_cursors_pooled_cmd); + suite, "/Cursor/kill/pooled/cmd", "", test_kill_cursors_pooled_cmd); TestSuite_AddMockServerTest (suite, "/Cursor/client_kill_cursor/with_primary", + "", test_client_kill_cursor_with_primary); TestSuite_AddMockServerTest (suite, "/Cursor/client_kill_cursor/without_primary", + "", test_client_kill_cursor_without_primary); TestSuite_AddMockServerTest ( suite, "/Cursor/client_kill_cursor/with_primary/wv4", + "", test_client_kill_cursor_with_primary_wire_version_4); TestSuite_AddMockServerTest ( suite, "/Cursor/client_kill_cursor/without_primary/wv4", + "", test_client_kill_cursor_without_primary_wire_version_4); TestSuite_AddLive ( - suite, "/Cursor/empty_collection", test_cursor_empty_collection); + suite, "/Cursor/empty_collection", "", test_cursor_empty_collection); TestSuite_AddLive ( - suite, "/Cursor/new_from_agg", test_cursor_new_from_aggregate); + suite, "/Cursor/new_from_agg", "", test_cursor_new_from_aggregate); TestSuite_AddLive (suite, "/Cursor/new_from_agg_no_initial", + "", test_cursor_new_from_aggregate_no_initial); TestSuite_AddFull (suite, "/Cursor/new_from_find", + "", test_cursor_new_from_find, NULL, NULL, test_framework_skip_if_max_wire_version_less_than_4); TestSuite_AddFull (suite, "/Cursor/new_from_find_batches", + "", test_cursor_new_from_find_batches, NULL, NULL, test_framework_skip_if_max_wire_version_less_than_4); - TestSuite_AddLive (suite, "/Cursor/new_invalid", test_cursor_new_invalid); + TestSuite_AddLive ( + suite, "/Cursor/new_invalid", "", test_cursor_new_invalid); TestSuite_AddMockServerTest ( - suite, "/Cursor/new_tailable_await", test_cursor_new_tailable_await); + suite, "/Cursor/new_tailable_await", "", test_cursor_new_tailable_await); TestSuite_AddMockServerTest ( - suite, "/Cursor/int64_t_maxtimems", test_cursor_int64_t_maxtimems); + suite, "/Cursor/int64_t_maxtimems", "", test_cursor_int64_t_maxtimems); TestSuite_AddMockServerTest ( - suite, "/Cursor/new_ignores_fields", test_cursor_new_ignores_fields); + suite, "/Cursor/new_ignores_fields", "", test_cursor_new_ignores_fields); + TestSuite_AddLive ( + suite, "/Cursor/new_invalid_filter", "", test_cursor_new_invalid_filter); TestSuite_AddLive ( - suite, "/Cursor/new_invalid_filter", test_cursor_new_invalid_filter); + suite, "/Cursor/new_invalid_opts", "", test_cursor_new_invalid_opts); + TestSuite_AddLive (suite, "/Cursor/new_static", "", test_cursor_new_static); TestSuite_AddLive ( - suite, "/Cursor/new_invalid_opts", test_cursor_new_invalid_opts); - TestSuite_AddLive (suite, "/Cursor/new_static", test_cursor_new_static); - TestSuite_AddLive (suite, "/Cursor/hint/errors", test_cursor_hint_errors); + suite, "/Cursor/hint/errors", "", test_cursor_hint_errors); TestSuite_AddMockServerTest ( - suite, "/Cursor/hint/single/secondary", test_hint_single_secondary); + suite, "/Cursor/hint/single/secondary", "", test_hint_single_secondary); TestSuite_AddMockServerTest ( - suite, "/Cursor/hint/single/primary", test_hint_single_primary); + suite, "/Cursor/hint/single/primary", "", test_hint_single_primary); TestSuite_AddMockServerTest ( - suite, "/Cursor/hint/pooled/secondary", test_hint_pooled_secondary); + suite, "/Cursor/hint/pooled/secondary", "", test_hint_pooled_secondary); TestSuite_AddMockServerTest ( - suite, "/Cursor/hint/pooled/primary", test_hint_pooled_primary); + suite, "/Cursor/hint/pooled/primary", "", test_hint_pooled_primary); TestSuite_AddMockServerTest ( - suite, "/Cursor/hint/mongos", test_cursor_hint_mongos); + suite, "/Cursor/hint/mongos", "", test_cursor_hint_mongos); TestSuite_AddMockServerTest ( - suite, "/Cursor/hint/mongos/cmd", test_cursor_hint_mongos_cmd); + suite, "/Cursor/hint/mongos/cmd", "", test_cursor_hint_mongos_cmd); TestSuite_AddLive ( - suite, "/Cursor/hint/no_warmup/single", test_hint_no_warmup_single); + suite, "/Cursor/hint/no_warmup/single", "", test_hint_no_warmup_single); TestSuite_AddLive ( - suite, "/Cursor/hint/no_warmup/pooled", test_hint_no_warmup_pooled); - TestSuite_AddLive (suite, "/Cursor/tailable/alive", test_tailable_alive); + suite, "/Cursor/hint/no_warmup/pooled", "", test_hint_no_warmup_pooled); + TestSuite_AddLive (suite, "/Cursor/tailable/alive", "", test_tailable_alive); TestSuite_AddMockServerTest ( - suite, "/Cursor/n_return/find_cmd", test_n_return_find_cmd); + suite, "/Cursor/n_return/find_cmd", "", test_n_return_find_cmd); TestSuite_AddMockServerTest (suite, "/Cursor/n_return/find_cmd/with_opts", + "", test_n_return_find_cmd_with_opts); TestSuite_AddLive ( - suite, "/Cursor/empty_final_batch_live", test_empty_final_batch_live); + suite, "/Cursor/empty_final_batch_live", "", test_empty_final_batch_live); TestSuite_AddMockServerTest ( - suite, "/Cursor/empty_final_batch", test_empty_final_batch); + suite, "/Cursor/empty_final_batch", "", test_empty_final_batch); TestSuite_AddLive ( - suite, "/Cursor/error_document/query", test_error_document_query); + suite, "/Cursor/error_document/query", "", test_error_document_query); TestSuite_AddLive ( - suite, "/Cursor/error_document/getmore", test_error_document_getmore); + suite, "/Cursor/error_document/getmore", "", test_error_document_getmore); TestSuite_AddLive ( - suite, "/Cursor/error_document/command", test_error_document_command); + suite, "/Cursor/error_document/command", "", test_error_document_command); TestSuite_AddLive ( - suite, "/Cursor/find_error/is_alive", test_find_error_is_alive); + suite, "/Cursor/find_error/is_alive", "", test_find_error_is_alive); } diff --git a/src/libmongoc/tests/test-mongoc-database.c b/src/libmongoc/tests/test-mongoc-database.c index e72a918f2c3..ec2c42d99cb 100644 --- a/src/libmongoc/tests/test-mongoc-database.c +++ b/src/libmongoc/tests/test-mongoc-database.c @@ -1213,53 +1213,67 @@ test_get_default_database (void) void test_database_install (TestSuite *suite) { - TestSuite_AddMockServerTest ( - suite, "/Database/aggregate/writeConcern", test_aggregate_write_concern); + TestSuite_AddMockServerTest (suite, + "/Database/aggregate/writeConcern", + "", + test_aggregate_write_concern); TestSuite_AddMockServerTest (suite, "/Database/aggregate/inherit/database", + "", test_aggregate_inherit_database); TestSuite_AddFull (suite, "/Database/create_with_write_concern", + "", test_create_with_write_concern, NULL, NULL, test_framework_skip_if_max_wire_version_less_than_5); - TestSuite_AddLive (suite, "/Database/copy", test_copy); - TestSuite_AddLive (suite, "/Database/has_collection", test_has_collection); - TestSuite_AddLive (suite, "/Database/command", test_command); + TestSuite_AddLive (suite, "/Database/copy", "", test_copy); + TestSuite_AddLive ( + suite, "/Database/has_collection", "", test_has_collection); + TestSuite_AddLive (suite, "/Database/command", "", test_command); TestSuite_AddMockServerTest (suite, "/Database/command/read_prefs/simple/single", + "", test_db_command_simple_read_prefs_single); TestSuite_AddMockServerTest (suite, "/Database/command/read_prefs/simple/pooled", + "", test_db_command_simple_read_prefs_pooled); TestSuite_AddMockServerTest (suite, "/Database/command/read_prefs/single", + "", test_db_command_read_prefs_single); TestSuite_AddMockServerTest (suite, "/Database/command/read_prefs/pooled", + "", test_db_command_read_prefs_pooled); - TestSuite_AddLive (suite, "/Database/drop", test_drop); + TestSuite_AddLive (suite, "/Database/drop", "", test_drop); TestSuite_AddLive ( - suite, "/Database/create_collection", test_create_collection); + suite, "/Database/create_collection", "", test_create_collection); TestSuite_AddLive ( - suite, "/Database/get_collection_info", test_get_collection_info); + suite, "/Database/get_collection_info", "", test_get_collection_info); TestSuite_AddLive (suite, "/Database/get_collection_info_regex", + "", test_get_collection_info_regex); TestSuite_AddLive (suite, "/Database/get_collection_info_with_opts_regex", + "", test_get_collection_info_with_opts_regex); TestSuite_AddMockServerTest (suite, "/Database/get_collection/getmore_cmd", + "", test_get_collection_info_getmore_cmd); - TestSuite_AddLive (suite, "/Database/get_collection", test_get_collection); TestSuite_AddLive ( - suite, "/Database/get_collection_names", test_get_collection_names); + suite, "/Database/get_collection", "", test_get_collection); + TestSuite_AddLive ( + suite, "/Database/get_collection_names", "", test_get_collection_names); TestSuite_AddMockServerTest (suite, "/Database/get_collection_names_error", + "", test_get_collection_names_error); TestSuite_Add ( - suite, "/Database/get_default_database", test_get_default_database); + suite, "/Database/get_default_database", "", test_get_default_database); } diff --git a/src/libmongoc/tests/test-mongoc-dns.c b/src/libmongoc/tests/test-mongoc-dns.c index e17f354ae9b..48083335298 100644 --- a/src/libmongoc/tests/test-mongoc-dns.c +++ b/src/libmongoc/tests/test-mongoc-dns.c @@ -1366,18 +1366,21 @@ test_dns_install (TestSuite *suite) test_all_spec_tests (suite); TestSuite_AddFull (suite, "/initial_dns_seedlist_discovery/null_error_pointer", + "", test_null_error_pointer, NULL, NULL, test_framework_skip_if_no_crypto); TestSuite_AddFull (suite, "/initial_dns_seedlist_discovery/srv_polling/mocked", + "", test_srv_polling_mocked, NULL, NULL, NULL); TestSuite_AddFull (suite, "/initial_dns_seedlist_discovery/small_initial_buffer", + "", test_small_initial_buffer, NULL, NULL, @@ -1390,6 +1393,7 @@ test_dns_install (TestSuite *suite) TestSuite_AddFull ( suite, "/initial_dns_seedlist_discovery/srv_polling/prose_test_9/single", + "", prose_test_9_single, NULL, NULL, @@ -1398,6 +1402,7 @@ test_dns_install (TestSuite *suite) TestSuite_AddFull ( suite, "/initial_dns_seedlist_discovery/srv_polling/prose_test_9/pooled", + "", prose_test_9_pooled, NULL, NULL, @@ -1406,6 +1411,7 @@ test_dns_install (TestSuite *suite) TestSuite_AddFull ( suite, "/initial_dns_seedlist_discovery/srv_polling/prose_test_10/single", + "", prose_test_10_single, NULL, NULL, @@ -1414,6 +1420,7 @@ test_dns_install (TestSuite *suite) TestSuite_AddFull ( suite, "/initial_dns_seedlist_discovery/srv_polling/prose_test_10/pooled", + "", prose_test_10_pooled, NULL, NULL, @@ -1422,6 +1429,7 @@ test_dns_install (TestSuite *suite) TestSuite_AddFull ( suite, "/initial_dns_seedlist_discovery/srv_polling/prose_test_11/single", + "", prose_test_11_single, NULL, NULL, @@ -1430,6 +1438,7 @@ test_dns_install (TestSuite *suite) TestSuite_AddFull ( suite, "/initial_dns_seedlist_discovery/srv_polling/prose_test_11/pooled", + "", prose_test_11_pooled, NULL, NULL, @@ -1438,6 +1447,7 @@ test_dns_install (TestSuite *suite) TestSuite_AddFull ( suite, "/initial_dns_seedlist_discovery/srv_polling/prose_test_12/single", + "", prose_test_12_single, NULL, NULL, @@ -1446,6 +1456,7 @@ test_dns_install (TestSuite *suite) TestSuite_AddFull ( suite, "/initial_dns_seedlist_discovery/srv_polling/prose_test_12/pooled", + "", prose_test_12_pooled, NULL, NULL, @@ -1454,6 +1465,7 @@ test_dns_install (TestSuite *suite) TestSuite_AddFull ( suite, "/initial_dns_seedlist_discovery/load-balanced/invalid_topology/pooled", + "", test_invalid_topology_pooled, NULL, NULL, @@ -1462,6 +1474,7 @@ test_dns_install (TestSuite *suite) TestSuite_AddFull ( suite, "/initial_dns_seedlist_discovery/load-balanced/invalid_topology/single", + "", test_invalid_topology_single, NULL, NULL, diff --git a/src/libmongoc/tests/test-mongoc-error.c b/src/libmongoc/tests/test-mongoc-error.c index 6db73fc7186..07aa34a2998 100644 --- a/src/libmongoc/tests/test-mongoc-error.c +++ b/src/libmongoc/tests/test-mongoc-error.c @@ -241,15 +241,15 @@ void test_error_install (TestSuite *suite) { TestSuite_AddLive ( - suite, "/Error/set_api/single", test_set_error_api_single); + suite, "/Error/set_api/single", "", test_set_error_api_single); TestSuite_AddLive ( - suite, "/Error/set_api/pooled", test_set_error_api_pooled); + suite, "/Error/set_api/pooled", "", test_set_error_api_pooled); TestSuite_AddMockServerTest ( - suite, "/Error/command/default", test_command_error_default); + suite, "/Error/command/default", "", test_command_error_default); TestSuite_AddMockServerTest ( - suite, "/Error/command/v1", test_command_error_v1); + suite, "/Error/command/v1", "", test_command_error_v1); TestSuite_AddMockServerTest ( - suite, "/Error/command/v2", test_command_error_v2); - TestSuite_Add (suite, "/Error/has_label", test_has_label); - TestSuite_Add (suite, "/Error/state_change", test_state_change); + suite, "/Error/command/v2", "", test_command_error_v2); + TestSuite_Add (suite, "/Error/has_label", "", test_has_label); + TestSuite_Add (suite, "/Error/state_change", "", test_state_change); } diff --git a/src/libmongoc/tests/test-mongoc-exhaust.c b/src/libmongoc/tests/test-mongoc-exhaust.c index f6f83f751ea..861c9bce0a6 100644 --- a/src/libmongoc/tests/test-mongoc-exhaust.c +++ b/src/libmongoc/tests/test-mongoc-exhaust.c @@ -663,6 +663,7 @@ test_exhaust_install (TestSuite *suite) { TestSuite_AddFull (suite, "/Client/exhaust_cursor/single", + "", test_exhaust_cursor_single, NULL, NULL, @@ -670,6 +671,7 @@ test_exhaust_install (TestSuite *suite) test_framework_skip_if_no_legacy_opcodes); TestSuite_AddFull (suite, "/Client/exhaust_cursor/pool", + "", test_exhaust_cursor_pool, NULL, NULL, @@ -677,6 +679,7 @@ test_exhaust_install (TestSuite *suite) test_framework_skip_if_no_legacy_opcodes); TestSuite_AddFull (suite, "/Client/exhaust_cursor/batches", + "", test_exhaust_cursor_multi_batch, NULL, NULL, @@ -684,45 +687,56 @@ test_exhaust_install (TestSuite *suite) test_framework_skip_if_no_legacy_opcodes); TestSuite_AddLive (suite, "/Client/set_max_await_time_ms", + "", test_cursor_set_max_await_time_ms); TestSuite_AddMockServerTest ( suite, "/Client/exhaust_cursor/err/network/1st_batch/single", + "", test_exhaust_network_err_1st_batch_single); TestSuite_AddMockServerTest ( suite, "/Client/exhaust_cursor/err/network/1st_batch/pooled", + "", test_exhaust_network_err_1st_batch_pooled); TestSuite_AddMockServerTest ( suite, "/Client/exhaust_cursor/err/server/1st_batch/single", + "", test_exhaust_server_err_1st_batch_single); TestSuite_AddMockServerTest ( suite, "/Client/exhaust_cursor/err/server/1st_batch/pooled", + "", test_exhaust_server_err_1st_batch_pooled); TestSuite_AddMockServerTest ( suite, "/Client/exhaust_cursor/err/network/2nd_batch/single", + "", test_exhaust_network_err_2nd_batch_single); TestSuite_AddMockServerTest ( suite, "/Client/exhaust_cursor/err/network/2nd_batch/pooled", + "", test_exhaust_network_err_2nd_batch_pooled); TestSuite_AddMockServerTest ( suite, "/Client/exhaust_cursor/err/server/2nd_batch/single", + "", test_exhaust_server_err_2nd_batch_single); TestSuite_AddMockServerTest ( suite, "/Client/exhaust_cursor/err/server/2nd_batch/pooled", + "", test_exhaust_server_err_2nd_batch_pooled); #ifndef _WIN32 /* Skip on Windows, since "fork" is not available and this test is not * particularly platform dependent. */ if (!TestSuite_NoFork (suite)) { - TestSuite_AddLive ( - suite, "/Client/exhaust_cursor/after_reset", test_exhaust_in_child); + TestSuite_AddLive (suite, + "/Client/exhaust_cursor/after_reset", + "", + test_exhaust_in_child); } #endif /* _WIN32 */ } diff --git a/src/libmongoc/tests/test-mongoc-find-and-modify.c b/src/libmongoc/tests/test-mongoc-find-and-modify.c index 6211eff601a..c6953555042 100644 --- a/src/libmongoc/tests/test-mongoc-find-and-modify.c +++ b/src/libmongoc/tests/test-mongoc-find-and-modify.c @@ -608,38 +608,46 @@ void test_find_and_modify_install (TestSuite *suite) { TestSuite_AddLive ( - suite, "/find_and_modify/find_and_modify", test_find_and_modify); + suite, "/find_and_modify/find_and_modify", "", test_find_and_modify); TestSuite_AddMockServerTest (suite, "/find_and_modify/find_and_modify/bypass/true", + "", test_find_and_modify_bypass_true); TestSuite_AddMockServerTest (suite, "/find_and_modify/find_and_modify/bypass/false", + "", test_find_and_modify_bypass_false); TestSuite_AddMockServerTest ( suite, "/find_and_modify/find_and_modify/write_concern", + "", test_find_and_modify_write_concern_wire_32); TestSuite_AddMockServerTest ( suite, "/find_and_modify/find_and_modify/write_concern_pre_32", + "", test_find_and_modify_write_concern_wire_pre_32); TestSuite_AddFull (suite, "/find_and_modify/find_and_modify/write_concern_failure", + "", test_find_and_modify_write_concern_wire_32_failure, NULL, NULL, should_run_fam_wc); TestSuite_AddMockServerTest ( - suite, "/find_and_modify/opts", test_find_and_modify_opts); + suite, "/find_and_modify/opts", "", test_find_and_modify_opts); TestSuite_AddMockServerTest (suite, "/find_and_modify/opts/write_concern", + "", test_find_and_modify_opts_write_concern); TestSuite_AddMockServerTest (suite, "/find_and_modify/collation/ok", + "", test_find_and_modify_collation_ok); TestSuite_AddMockServerTest (suite, "/find_and_modify/collation/fail", + "", test_find_and_modify_collation_fail); TestSuite_AddLive ( - suite, "/find_and_modify/hint", test_find_and_modify_hint); + suite, "/find_and_modify/hint", "", test_find_and_modify_hint); } diff --git a/src/libmongoc/tests/test-mongoc-generation-map.c b/src/libmongoc/tests/test-mongoc-generation-map.c index f8c4153cb84..2155e1e5b6c 100644 --- a/src/libmongoc/tests/test-mongoc-generation-map.c +++ b/src/libmongoc/tests/test-mongoc-generation-map.c @@ -49,6 +49,9 @@ test_generation_map_basic (void) { mongoc_generation_map_destroy (gm); } -void test_generation_map_install (TestSuite *suite) { - TestSuite_Add (suite, "/generation_map/basic", test_generation_map_basic); +void +test_generation_map_install (TestSuite *suite) +{ + TestSuite_Add ( + suite, "/generation_map/basic", "", test_generation_map_basic); } diff --git a/src/libmongoc/tests/test-mongoc-gridfs-bucket.c b/src/libmongoc/tests/test-mongoc-gridfs-bucket.c index 1de57e78657..0f817df37cc 100644 --- a/src/libmongoc/tests/test-mongoc-gridfs-bucket.c +++ b/src/libmongoc/tests/test-mongoc-gridfs-bucket.c @@ -1151,17 +1151,19 @@ void test_gridfs_bucket_install (TestSuite *suite) { test_all_spec_tests (suite); - TestSuite_AddLive (suite, "/gridfs/create_bucket", test_create_bucket); + TestSuite_AddLive (suite, "/gridfs/create_bucket", "", test_create_bucket); TestSuite_AddLive ( - suite, "/gridfs/upload_and_download", test_upload_and_download); + suite, "/gridfs/upload_and_download", "", test_upload_and_download); TestSuite_AddFull (suite, "/gridfs/upload_error", + "", test_upload_error, NULL, NULL, test_framework_skip_if_no_auth); TestSuite_AddFull (suite, "/gridfs/find_w_session", + "", test_find_w_session, NULL, NULL, @@ -1169,10 +1171,11 @@ test_gridfs_bucket_install (TestSuite *suite) test_framework_skip_if_no_crypto); TestSuite_AddFull (suite, "/gridfs/find", + "", test_find, NULL, NULL, test_framework_skip_if_no_sessions, test_framework_skip_if_no_crypto); - TestSuite_AddLive (suite, "/gridfs/options", test_gridfs_bucket_opts); + TestSuite_AddLive (suite, "/gridfs/options", "", test_gridfs_bucket_opts); } diff --git a/src/libmongoc/tests/test-mongoc-gridfs-file-page.c b/src/libmongoc/tests/test-mongoc-gridfs-file-page.c index fbc3ba4ef92..916bb3d5a5a 100644 --- a/src/libmongoc/tests/test-mongoc-gridfs-file-page.c +++ b/src/libmongoc/tests/test-mongoc-gridfs-file-page.c @@ -214,12 +214,12 @@ test_memset0 (void) void test_gridfs_file_page_install (TestSuite *suite) { - TestSuite_Add (suite, "/gridfs_old/File/Page/create", test_create); - TestSuite_Add (suite, "/gridfs_old/File/Page/get_data", test_get_data); - TestSuite_Add (suite, "/gridfs_old/File/Page/get_len", test_get_len); - TestSuite_Add (suite, "/gridfs_old/File/Page/is_dirty", test_is_dirty); - TestSuite_Add (suite, "/gridfs_old/File/Page/read", test_read); - TestSuite_Add (suite, "/gridfs_old/File/Page/seek", test_seek); - TestSuite_Add (suite, "/gridfs_old/File/Page/write", test_write); - TestSuite_Add (suite, "/gridfs_old/File/Page/memset0", test_memset0); + TestSuite_Add (suite, "/gridfs_old/File/Page/create", "", test_create); + TestSuite_Add (suite, "/gridfs_old/File/Page/get_data", "", test_get_data); + TestSuite_Add (suite, "/gridfs_old/File/Page/get_len", "", test_get_len); + TestSuite_Add (suite, "/gridfs_old/File/Page/is_dirty", "", test_is_dirty); + TestSuite_Add (suite, "/gridfs_old/File/Page/read", "", test_read); + TestSuite_Add (suite, "/gridfs_old/File/Page/seek", "", test_seek); + TestSuite_Add (suite, "/gridfs_old/File/Page/write", "", test_write); + TestSuite_Add (suite, "/gridfs_old/File/Page/memset0", "", test_memset0); } diff --git a/src/libmongoc/tests/test-mongoc-gridfs.c b/src/libmongoc/tests/test-mongoc-gridfs.c index a0c32c1cd0a..476ab6f7f7e 100644 --- a/src/libmongoc/tests/test-mongoc-gridfs.c +++ b/src/libmongoc/tests/test-mongoc-gridfs.c @@ -1557,44 +1557,52 @@ test_write_failure (void) void test_gridfs_install (TestSuite *suite) { - TestSuite_AddLive (suite, "/gridfs_old/create", test_create); + TestSuite_AddLive (suite, "/gridfs_old/create", "", test_create); TestSuite_AddLive ( - suite, "/gridfs_old/create_from_stream", test_create_from_stream); - TestSuite_AddLive (suite, "/gridfs_old/list", test_list); - TestSuite_AddLive (suite, "/gridfs_old/find_one_empty", test_find_one_empty); - TestSuite_AddLive (suite, "/gridfs_old/find_with_opts", test_find_with_opts); + suite, "/gridfs_old/create_from_stream", "", test_create_from_stream); + TestSuite_AddLive (suite, "/gridfs_old/list", "", test_list); + TestSuite_AddLive ( + suite, "/gridfs_old/find_one_empty", "", test_find_one_empty); + TestSuite_AddLive ( + suite, "/gridfs_old/find_with_opts", "", test_find_with_opts); TestSuite_AddMockServerTest (suite, "/gridfs_old/find_one_with_opts/limit", + "", test_find_one_with_opts_limit); - TestSuite_AddLive (suite, "/gridfs_old/properties", test_properties); - TestSuite_AddLive (suite, "/gridfs_old/empty", test_empty); - TestSuite_AddLive (suite, "/gridfs_old/read", test_read); - TestSuite_AddLive (suite, "/gridfs_old/seek", test_seek); - TestSuite_AddLive (suite, "/gridfs_old/stream", test_stream); - TestSuite_AddLive (suite, "/gridfs_old/remove", test_remove); - TestSuite_AddLive (suite, "/gridfs_old/write", test_write); + TestSuite_AddLive (suite, "/gridfs_old/properties", "", test_properties); + TestSuite_AddLive (suite, "/gridfs_old/empty", "", test_empty); + TestSuite_AddLive (suite, "/gridfs_old/read", "", test_read); + TestSuite_AddLive (suite, "/gridfs_old/seek", "", test_seek); + TestSuite_AddLive (suite, "/gridfs_old/stream", "", test_stream); + TestSuite_AddLive (suite, "/gridfs_old/remove", "", test_remove); + TestSuite_AddLive (suite, "/gridfs_old/write", "", test_write); + TestSuite_AddLive ( + suite, "/gridfs_old/write_at_boundary", "", test_write_at_boundary); TestSuite_AddLive ( - suite, "/gridfs_old/write_at_boundary", test_write_at_boundary); - TestSuite_AddLive (suite, "/gridfs_old/write_past_end", test_write_past_end); + suite, "/gridfs_old/write_past_end", "", test_write_past_end); TestSuite_AddFull (suite, "/gridfs_old/test_long_seek", + "", test_long_seek, NULL, NULL, test_framework_skip_if_slow_or_live); TestSuite_AddLive ( - suite, "/gridfs_old/remove_by_filename", test_remove_by_filename); + suite, "/gridfs_old/remove_by_filename", "", test_remove_by_filename); TestSuite_AddFull (suite, "/gridfs_old/missing_chunk", + "", test_missing_chunk, NULL, NULL, test_framework_skip_if_slow_or_live); - TestSuite_AddLive (suite, "/gridfs_old/oversize_chunk", test_oversize); - TestSuite_AddLive (suite, "/gridfs_old/missing_file", test_missing_file); - TestSuite_AddLive (suite, "/gridfs_old/file_set_id", test_set_id); - TestSuite_AddMockServerTest ( - suite, "/gridfs_old/inherit_client_config", test_inherit_client_config); + TestSuite_AddLive (suite, "/gridfs_old/oversize_chunk", "", test_oversize); + TestSuite_AddLive (suite, "/gridfs_old/missing_file", "", test_missing_file); + TestSuite_AddLive (suite, "/gridfs_old/file_set_id", "", test_set_id); + TestSuite_AddMockServerTest (suite, + "/gridfs_old/inherit_client_config", + "", + test_inherit_client_config); TestSuite_AddMockServerTest ( - suite, "/gridfs_old/write_failure", test_write_failure); + suite, "/gridfs_old/write_failure", "", test_write_failure); } diff --git a/src/libmongoc/tests/test-mongoc-handshake.c b/src/libmongoc/tests/test-mongoc-handshake.c index bdeae2d8e36..c9bacb76cc1 100644 --- a/src/libmongoc/tests/test-mongoc-handshake.c +++ b/src/libmongoc/tests/test-mongoc-handshake.c @@ -935,40 +935,53 @@ test_handshake_install (TestSuite *suite) { TestSuite_Add (suite, "/MongoDB/handshake/appname_in_uri", + "", test_mongoc_handshake_appname_in_uri); TestSuite_Add (suite, "/MongoDB/handshake/appname_frozen_single", + "", test_mongoc_handshake_appname_frozen_single); TestSuite_Add (suite, "/MongoDB/handshake/appname_frozen_pooled", + "", test_mongoc_handshake_appname_frozen_pooled); TestSuite_AddMockServerTest (suite, "/MongoDB/handshake/success", + "", test_mongoc_handshake_data_append_success); TestSuite_AddMockServerTest (suite, "/MongoDB/handshake/null_args", + "", test_mongoc_handshake_data_append_null_args); TestSuite_Add (suite, "/MongoDB/handshake/big_platform", + "", test_mongoc_handshake_big_platform); TestSuite_Add (suite, "/MongoDB/handshake/oversized_platform", + "", test_mongoc_handshake_oversized_platform); TestSuite_Add (suite, "/MongoDB/handshake/failure", + "", test_mongoc_handshake_data_append_after_cmd); TestSuite_AddMockServerTest ( - suite, "/MongoDB/handshake/too_big", test_mongoc_handshake_too_big); - TestSuite_Add ( - suite, "/MongoDB/handshake/oversized_flags", test_mongoc_oversized_flags); + suite, "/MongoDB/handshake/too_big", "", test_mongoc_handshake_too_big); + TestSuite_Add (suite, + "/MongoDB/handshake/oversized_flags", + "", + test_mongoc_oversized_flags); TestSuite_AddMockServerTest (suite, "/MongoDB/handshake/cannot_send", + "", test_mongoc_handshake_cannot_send); TestSuite_Add (suite, "/MongoDB/handshake/platform_config", + "", test_handshake_platform_config); TestSuite_Add (suite, "/MongoDB/handshake/race_condition", + "", test_mongoc_handshake_race_condition); } diff --git a/src/libmongoc/tests/test-mongoc-hedged-reads.c b/src/libmongoc/tests/test-mongoc-hedged-reads.c index aee62a8f96e..25d1274dc8e 100644 --- a/src/libmongoc/tests/test-mongoc-hedged-reads.c +++ b/src/libmongoc/tests/test-mongoc-hedged-reads.c @@ -100,6 +100,8 @@ test_mongos_hedged_reads_read_pref (void) void test_client_hedged_reads_install (TestSuite *suite) { - TestSuite_AddMockServerTest ( - suite, "/Client/hedged_reads/mongos", test_mongos_hedged_reads_read_pref); + TestSuite_AddMockServerTest (suite, + "/Client/hedged_reads/mongos", + "", + test_mongos_hedged_reads_read_pref); } diff --git a/src/libmongoc/tests/test-mongoc-http.c b/src/libmongoc/tests/test-mongoc-http.c index ce473ab18ae..a00a9d15d80 100644 --- a/src/libmongoc/tests/test-mongoc-http.c +++ b/src/libmongoc/tests/test-mongoc-http.c @@ -53,6 +53,7 @@ test_http_install (TestSuite *suite) { TestSuite_AddFull (suite, "/http", + "", test_mongoc_http, NULL /* dtor */, NULL /* ctx */, diff --git a/src/libmongoc/tests/test-mongoc-interrupt.c b/src/libmongoc/tests/test-mongoc-interrupt.c index 4af8db9be70..b3d41fe6d5e 100644 --- a/src/libmongoc/tests/test-mongoc-interrupt.c +++ b/src/libmongoc/tests/test-mongoc-interrupt.c @@ -147,5 +147,5 @@ test_interrupt (void) void test_interrupt_install (TestSuite *suite) { - TestSuite_AddMockServerTest (suite, "/interrupt", test_interrupt); + TestSuite_AddMockServerTest (suite, "/interrupt", "", test_interrupt); } diff --git a/src/libmongoc/tests/test-mongoc-linux-distro-scanner.c b/src/libmongoc/tests/test-mongoc-linux-distro-scanner.c index b3c725a47b9..6e5e3d6ab51 100644 --- a/src/libmongoc/tests/test-mongoc-linux-distro-scanner.c +++ b/src/libmongoc/tests/test-mongoc-linux-distro-scanner.c @@ -289,12 +289,15 @@ test_linux_distro_scanner_install (TestSuite *suite) #ifdef MONGOC_OS_IS_LINUX TestSuite_Add (suite, "/LinuxDistroScanner/test_read_generic_release_file", + "", test_read_generic_release_file); TestSuite_Add (suite, "/LinuxDistroScanner/test_read_key_value_file", + "", test_read_key_value_file); TestSuite_Add (suite, "/LinuxDistroScanner/test_distro_scanner_reads", + "", test_distro_scanner_reads); #endif } diff --git a/src/libmongoc/tests/test-mongoc-list.c b/src/libmongoc/tests/test-mongoc-list.c index 9ac2116bc83..e42a67ec539 100644 --- a/src/libmongoc/tests/test-mongoc-list.c +++ b/src/libmongoc/tests/test-mongoc-list.c @@ -49,5 +49,5 @@ test_mongoc_list_basic (void) void test_list_install (TestSuite *suite) { - TestSuite_Add (suite, "/List/Basic", test_mongoc_list_basic); + TestSuite_Add (suite, "/List/Basic", "", test_mongoc_list_basic); } diff --git a/src/libmongoc/tests/test-mongoc-loadbalanced.c b/src/libmongoc/tests/test-mongoc-loadbalanced.c index 4219d58b283..cf306194e4b 100644 --- a/src/libmongoc/tests/test-mongoc-loadbalanced.c +++ b/src/libmongoc/tests/test-mongoc-loadbalanced.c @@ -789,18 +789,21 @@ test_loadbalanced_install (TestSuite *suite) { TestSuite_AddFull (suite, "/loadbalanced/sessions/supported", + "", test_loadbalanced_sessions_supported, NULL /* ctx */, NULL /* dtor */, skip_if_not_loadbalanced); TestSuite_AddFull (suite, "/loadbalanced/sessions/do_not_expire", + "", test_loadbalanced_sessions_do_not_expire, NULL /* ctx */, NULL /* dtor */, skip_if_not_loadbalanced); TestSuite_AddFull (suite, "/loadbalanced/client_uri_validation", + "", test_loadbalanced_client_uri_validation, NULL /* ctx */, NULL /* dtor */, @@ -808,6 +811,7 @@ test_loadbalanced_install (TestSuite *suite) TestSuite_AddFull (suite, "/loadbalanced/connect/single", + "", test_loadbalanced_connect_single, NULL /* ctx */, NULL /* dtor */, @@ -815,6 +819,7 @@ test_loadbalanced_install (TestSuite *suite) TestSuite_AddFull (suite, "/loadbalanced/connect/pooled", + "", test_loadbalanced_connect_pooled, NULL /* ctx */, NULL /* dtor */, @@ -823,6 +828,7 @@ test_loadbalanced_install (TestSuite *suite) TestSuite_AddFull ( suite, "/loadbalanced/server_selection_establishes_connection/single", + "", test_loadbalanced_server_selection_establishes_connection_single, NULL /* ctx */, NULL /* dtor */, @@ -830,6 +836,7 @@ test_loadbalanced_install (TestSuite *suite) TestSuite_AddFull (suite, "/loadbalanced/cooldown_is_bypassed/single", + "", test_loadbalanced_cooldown_is_bypassed_single, NULL /* dtor */, NULL /* ctx */, @@ -838,20 +845,24 @@ test_loadbalanced_install (TestSuite *suite) TestSuite_AddMockServerTest (suite, "/loadbalanced/handshake_sends_loadbalanced", + "", test_loadbalanced_handshake_sends_loadbalanced); TestSuite_AddMockServerTest ( suite, "/loadbalanced/handshake_rejects_non_loadbalanced", + "", test_loadbalanced_handshake_rejects_non_loadbalanced); TestSuite_AddMockServerTest ( suite, "/loadbalanced/pre_handshake_error_does_not_clear_pool", + "", test_pre_handshake_error_does_not_clear_pool); TestSuite_AddMockServerTest ( suite, "/loadbalanced/post_handshake_error_clears_pool", + "", test_post_handshake_error_clears_pool); } diff --git a/src/libmongoc/tests/test-mongoc-log.c b/src/libmongoc/tests/test-mongoc-log.c index 00904ed1e4d..db0224d3c37 100644 --- a/src/libmongoc/tests/test-mongoc-log.c +++ b/src/libmongoc/tests/test-mongoc-log.c @@ -185,18 +185,20 @@ test_mongoc_log_trace_disabled (void *context) void test_log_install (TestSuite *suite) { - TestSuite_Add (suite, "/Log/basic", test_mongoc_log_handler); + TestSuite_Add (suite, "/Log/basic", "", test_mongoc_log_handler); TestSuite_AddFull (suite, "/Log/trace/enabled", + "", test_mongoc_log_trace_enabled, NULL, NULL, should_run_trace_tests); TestSuite_AddFull (suite, "/Log/trace/disabled", + "", test_mongoc_log_trace_disabled, NULL, NULL, should_not_run_trace_tests); - TestSuite_Add (suite, "/Log/null", test_mongoc_log_null); + TestSuite_Add (suite, "/Log/null", "", test_mongoc_log_null); } diff --git a/src/libmongoc/tests/test-mongoc-long-namespace.c b/src/libmongoc/tests/test-mongoc-long-namespace.c index bb9f0ae687b..4035abbd127 100644 --- a/src/libmongoc/tests/test-mongoc-long-namespace.c +++ b/src/libmongoc/tests/test-mongoc-long-namespace.c @@ -574,11 +574,13 @@ unsupported_long_db (void) void test_long_namespace_install (TestSuite *suite) { + const char *common_meta = "uses-live-server"; /* MongoDB 4.4 (wire version 9) introduced support for long namespaces in * SERVER-32959 */ TestSuite_AddFullWithTestFn ( suite, "/long_namespace/client_command", + common_meta, run_test, NULL /* dtor */, client_command, @@ -587,6 +589,7 @@ test_long_namespace_install (TestSuite *suite) TestSuite_AddFullWithTestFn ( suite, "/long_namespace/database_command", + common_meta, run_test, NULL /* dtor */, database_command, @@ -595,6 +598,7 @@ test_long_namespace_install (TestSuite *suite) TestSuite_AddFullWithTestFn ( suite, "/long_namespace/collection_command", + common_meta, run_test, NULL /* dtor */, collection_command, @@ -603,6 +607,7 @@ test_long_namespace_install (TestSuite *suite) TestSuite_AddFullWithTestFn ( suite, "/long_namespace/crud", + common_meta, run_test, NULL /* dtor */, crud, @@ -611,6 +616,7 @@ test_long_namespace_install (TestSuite *suite) TestSuite_AddFullWithTestFn ( suite, "/long_namespace/getmore", + common_meta, run_test, NULL /* dtor */, getmore, @@ -618,6 +624,7 @@ test_long_namespace_install (TestSuite *suite) TestSuite_AddFullWithTestFn (suite, "/long_namespace/change_stream", + common_meta, run_test, NULL /* dtor */, change_stream, @@ -627,6 +634,7 @@ test_long_namespace_install (TestSuite *suite) TestSuite_AddFullWithTestFn ( suite, "/long_namespace/collection_rename", + common_meta, run_test, NULL /* dtor */, collection_rename, @@ -635,11 +643,14 @@ test_long_namespace_install (TestSuite *suite) TestSuite_AddFull (suite, "/long_namespace/unsupported_long_coll", + common_meta, unsupported_long_coll, NULL /* dtor */, NULL /* ctx */, test_framework_skip_if_max_wire_version_more_than_8); - TestSuite_AddLive ( - suite, "/long_namespace/unsupported_long_db", unsupported_long_db); + TestSuite_AddLive (suite, + "/long_namespace/unsupported_long_db", + common_meta, + unsupported_long_db); } diff --git a/src/libmongoc/tests/test-mongoc-matcher.c b/src/libmongoc/tests/test-mongoc-matcher.c index 7b07e5dd77f..3de7dfe2ade 100644 --- a/src/libmongoc/tests/test-mongoc-matcher.c +++ b/src/libmongoc/tests/test-mongoc-matcher.c @@ -553,14 +553,14 @@ END_IGNORE_DEPRECATIONS void test_matcher_install (TestSuite *suite) { - TestSuite_Add (suite, "/Matcher/basic", test_mongoc_matcher_basic); - TestSuite_Add (suite, "/Matcher/array", test_mongoc_matcher_array); - TestSuite_Add (suite, "/Matcher/compare", test_mongoc_matcher_compare); - TestSuite_Add (suite, "/Matcher/logic", test_mongoc_matcher_logic_ops); - TestSuite_Add (suite, "/Matcher/bad_spec", test_mongoc_matcher_bad_spec); - TestSuite_Add (suite, "/Matcher/eq/utf8", test_mongoc_matcher_eq_utf8); - TestSuite_Add (suite, "/Matcher/eq/int32", test_mongoc_matcher_eq_int32); - TestSuite_Add (suite, "/Matcher/eq/int64", test_mongoc_matcher_eq_int64); - TestSuite_Add (suite, "/Matcher/eq/doc", test_mongoc_matcher_eq_doc); - TestSuite_Add (suite, "/Matcher/in/basic", test_mongoc_matcher_in_basic); + TestSuite_Add (suite, "/Matcher/basic", "", test_mongoc_matcher_basic); + TestSuite_Add (suite, "/Matcher/array", "", test_mongoc_matcher_array); + TestSuite_Add (suite, "/Matcher/compare", "", test_mongoc_matcher_compare); + TestSuite_Add (suite, "/Matcher/logic", "", test_mongoc_matcher_logic_ops); + TestSuite_Add (suite, "/Matcher/bad_spec", "", test_mongoc_matcher_bad_spec); + TestSuite_Add (suite, "/Matcher/eq/utf8", "", test_mongoc_matcher_eq_utf8); + TestSuite_Add (suite, "/Matcher/eq/int32", "", test_mongoc_matcher_eq_int32); + TestSuite_Add (suite, "/Matcher/eq/int64", "", test_mongoc_matcher_eq_int64); + TestSuite_Add (suite, "/Matcher/eq/doc", "", test_mongoc_matcher_eq_doc); + TestSuite_Add (suite, "/Matcher/in/basic", "", test_mongoc_matcher_in_basic); } diff --git a/src/libmongoc/tests/test-mongoc-max-staleness.c b/src/libmongoc/tests/test-mongoc-max-staleness.c index 68470e0253b..f422a2d772b 100644 --- a/src/libmongoc/tests/test-mongoc-max-staleness.c +++ b/src/libmongoc/tests/test-mongoc-max-staleness.c @@ -357,12 +357,14 @@ test_client_max_staleness_install (TestSuite *suite) { test_all_spec_tests (suite); TestSuite_Add ( - suite, "/Client/max_staleness", test_mongoc_client_max_staleness); + suite, "/Client/max_staleness", "", test_mongoc_client_max_staleness); TestSuite_AddMockServerTest (suite, "/Client/max_staleness/mongos", + "", test_mongos_max_staleness_read_pref); TestSuite_AddFull (suite, "/Client/last_write_date", + "", test_last_write_date, NULL, NULL, @@ -370,6 +372,7 @@ test_client_max_staleness_install (TestSuite *suite) test_framework_skip_if_slow); TestSuite_AddFull (suite, "/Client/last_write_date/pooled", + "", test_last_write_date_pooled, NULL, NULL, @@ -377,12 +380,14 @@ test_client_max_staleness_install (TestSuite *suite) test_framework_skip_if_slow); TestSuite_AddFull (suite, "/Client/last_write_date_absent", + "", test_last_write_date_absent, NULL, NULL, test_framework_skip_if_rs_version_5); TestSuite_AddFull (suite, "/Client/last_write_date_absent/pooled", + "", test_last_write_date_absent_pooled, NULL, NULL, diff --git a/src/libmongoc/tests/test-mongoc-mongohouse.c b/src/libmongoc/tests/test-mongoc-mongohouse.c index adb15f85b6b..d473e6868e7 100644 --- a/src/libmongoc/tests/test-mongoc-mongohouse.c +++ b/src/libmongoc/tests/test-mongoc-mongohouse.c @@ -306,6 +306,7 @@ test_mongohouse_install (TestSuite *suite) TestSuite_AddFull (suite, "/mongohouse/kill_cursors", + "", test_mongohouse_kill_cursors, NULL, NULL, @@ -313,6 +314,7 @@ test_mongohouse_install (TestSuite *suite) TestSuite_AddFull (suite, "/mongohouse/no_auth", + "", test_mongohouse_no_auth, NULL, NULL, @@ -320,6 +322,7 @@ test_mongohouse_install (TestSuite *suite) TestSuite_AddFull (suite, "/mongohouse/auth", + "", test_mongohouse_auth, NULL, NULL, diff --git a/src/libmongoc/tests/test-mongoc-mongos-pinning.c b/src/libmongoc/tests/test-mongoc-mongos-pinning.c index 463c9120adb..31d8d8f4a42 100644 --- a/src/libmongoc/tests/test-mongoc-mongos-pinning.c +++ b/src/libmongoc/tests/test-mongoc-mongos-pinning.c @@ -187,6 +187,7 @@ test_mongos_pinning_install (TestSuite *suite) { TestSuite_AddFull (suite, "/mongos_pinning/new_transaction_unpins", + "", test_new_transaction_unpins, NULL, NULL, @@ -197,6 +198,7 @@ test_mongos_pinning_install (TestSuite *suite) TestSuite_AddFull (suite, "/mongos_pinning/non_transaction_unpins", + "", test_non_transaction_unpins, NULL, NULL, diff --git a/src/libmongoc/tests/test-mongoc-ocsp-cache.c b/src/libmongoc/tests/test-mongoc-ocsp-cache.c index 65737132ca6..8c4f23ea85c 100644 --- a/src/libmongoc/tests/test-mongoc-ocsp-cache.c +++ b/src/libmongoc/tests/test-mongoc-ocsp-cache.c @@ -182,10 +182,11 @@ test_mongoc_cache_remove_expired_cert (void) void test_ocsp_cache_install (TestSuite *suite) { - TestSuite_Add (suite, "/OCSPCache/insert", test_mongoc_cache_insert); - TestSuite_Add (suite, "/OCSPCache/update", test_mongoc_cache_update); + TestSuite_Add (suite, "/OCSPCache/insert", "", test_mongoc_cache_insert); + TestSuite_Add (suite, "/OCSPCache/update", "", test_mongoc_cache_update); TestSuite_Add (suite, "/OCSPCache/remove_expired_cert", + "", test_mongoc_cache_remove_expired_cert); } #else diff --git a/src/libmongoc/tests/test-mongoc-opts.c b/src/libmongoc/tests/test-mongoc-opts.c index 45939377041..a255d4c5c6e 100644 --- a/src/libmongoc/tests/test-mongoc-opts.c +++ b/src/libmongoc/tests/test-mongoc-opts.c @@ -1002,6 +1002,7 @@ install_inheritance_tests (TestSuite *suite, TestSuite_AddFull (suite, name, + "", test_func_inherits_opts, NULL, test, diff --git a/src/libmongoc/tests/test-mongoc-primary-stepdown.c b/src/libmongoc/tests/test-mongoc-primary-stepdown.c index c6371df75ed..25aec7d2e4a 100644 --- a/src/libmongoc/tests/test-mongoc-primary-stepdown.c +++ b/src/libmongoc/tests/test-mongoc-primary-stepdown.c @@ -475,6 +475,7 @@ test_primary_stepdown_install (TestSuite *suite) { TestSuite_AddFull (suite, "/Stepdown/getmore", + "", test_getmore_iteration_runner, NULL, NULL, @@ -483,6 +484,7 @@ test_primary_stepdown_install (TestSuite *suite) TestSuite_AddFull (suite, "/Stepdown/not_primary_keep", + "", test_not_primary_keep_pool_runner, NULL, NULL, @@ -491,6 +493,7 @@ test_primary_stepdown_install (TestSuite *suite) TestSuite_AddFull (suite, "/Stepdown/not_primary_reset", + "", test_not_primary_reset_pool_runner, NULL, NULL, @@ -499,6 +502,7 @@ test_primary_stepdown_install (TestSuite *suite) TestSuite_AddFull (suite, "/Stepdown/shutdown_reset_pool", + "", test_shutdown_reset_pool_runner, NULL, NULL, @@ -507,6 +511,7 @@ test_primary_stepdown_install (TestSuite *suite) TestSuite_AddFull (suite, "/Stepdown/interrupt_shutdown", + "", test_interrupted_shutdown_reset_pool_runner, NULL, NULL, diff --git a/src/libmongoc/tests/test-mongoc-queue.c b/src/libmongoc/tests/test-mongoc-queue.c index 02ee288cb4d..8dec903a424 100644 --- a/src/libmongoc/tests/test-mongoc-queue.c +++ b/src/libmongoc/tests/test-mongoc-queue.c @@ -52,6 +52,6 @@ test_mongoc_queue_pop_tail (void) void test_queue_install (TestSuite *suite) { - TestSuite_Add (suite, "/Queue/basic", test_mongoc_queue_basic); - TestSuite_Add (suite, "/Queue/pop_tail", test_mongoc_queue_pop_tail); + TestSuite_Add (suite, "/Queue/basic", "", test_mongoc_queue_basic); + TestSuite_Add (suite, "/Queue/pop_tail", "", test_mongoc_queue_pop_tail); } diff --git a/src/libmongoc/tests/test-mongoc-read-concern.c b/src/libmongoc/tests/test-mongoc-read-concern.c index a00e8dc7f9a..b5d2a15d674 100644 --- a/src/libmongoc/tests/test-mongoc-read-concern.c +++ b/src/libmongoc/tests/test-mongoc-read-concern.c @@ -269,23 +269,30 @@ test_explicit_read_concern_prohibited (void) void test_read_concern_install (TestSuite *suite) { - TestSuite_Add (suite, "/ReadConcern/append", test_read_concern_append); - TestSuite_Add (suite, "/ReadConcern/basic", test_read_concern_basic); + TestSuite_Add (suite, "/ReadConcern/append", "", test_read_concern_append); + TestSuite_Add (suite, "/ReadConcern/basic", "", test_read_concern_basic); TestSuite_Add (suite, "/ReadConcern/bson_omits_defaults", + "", test_read_concern_bson_omits_defaults); - TestSuite_Add ( - suite, "/ReadConcern/always_mutable", test_read_concern_always_mutable); + TestSuite_Add (suite, + "/ReadConcern/always_mutable", + "", + test_read_concern_always_mutable); TestSuite_AddMockServerTest (suite, "/ReadConcern/allowed/inherited", + "", test_inherited_read_concern_allowed); TestSuite_AddMockServerTest (suite, "/ReadConcern/allowed/explicit", + "", test_explicit_read_concern_allowed); TestSuite_AddMockServerTest (suite, "/ReadConcern/prohibited/inherited", + "", test_inherited_read_concern_prohibited); TestSuite_AddMockServerTest (suite, "/ReadConcern/prohibited/explicit", + "", test_explicit_read_concern_prohibited); } diff --git a/src/libmongoc/tests/test-mongoc-read-prefs.c b/src/libmongoc/tests/test-mongoc-read-prefs.c index 5aff346881a..4e94473da4e 100644 --- a/src/libmongoc/tests/test-mongoc-read-prefs.c +++ b/src/libmongoc/tests/test-mongoc-read-prefs.c @@ -1097,41 +1097,51 @@ void test_read_prefs_install (TestSuite *suite) { TestSuite_AddMockServerTest ( - suite, "/ReadPrefs/standalone/null", test_read_prefs_standalone_null); + suite, "/ReadPrefs/standalone/null", "", test_read_prefs_standalone_null); TestSuite_AddMockServerTest (suite, "/ReadPrefs/standalone/primary", + "", test_read_prefs_standalone_primary); TestSuite_AddMockServerTest (suite, "/ReadPrefs/standalone/secondary", + "", test_read_prefs_standalone_secondary); TestSuite_AddMockServerTest ( - suite, "/ReadPrefs/standalone/tags", test_read_prefs_standalone_tags); - TestSuite_AddMockServerTest ( - suite, "/ReadPrefs/rsprimary/primary", test_read_prefs_primary_rsprimary); + suite, "/ReadPrefs/standalone/tags", "", test_read_prefs_standalone_tags); + TestSuite_AddMockServerTest (suite, + "/ReadPrefs/rsprimary/primary", + "", + test_read_prefs_primary_rsprimary); TestSuite_AddMockServerTest (suite, "/ReadPrefs/rssecondary/secondary", + "", test_read_prefs_secondary_rssecondary); TestSuite_AddMockServerTest ( - suite, "/ReadPrefs/mongos/null", test_read_prefs_mongos_null); + suite, "/ReadPrefs/mongos/null", "", test_read_prefs_mongos_null); TestSuite_AddMockServerTest ( - suite, "/ReadPrefs/mongos/primary", test_read_prefs_mongos_primary); - TestSuite_AddMockServerTest ( - suite, "/ReadPrefs/mongos/secondary", test_read_prefs_mongos_secondary); + suite, "/ReadPrefs/mongos/primary", "", test_read_prefs_mongos_primary); + TestSuite_AddMockServerTest (suite, + "/ReadPrefs/mongos/secondary", + "", + test_read_prefs_mongos_secondary); TestSuite_AddMockServerTest (suite, "/ReadPrefs/mongos/secondaryPreferred", + "", test_read_prefs_mongos_secondary_preferred); TestSuite_AddMockServerTest ( - suite, "/ReadPrefs/mongos/tags", test_read_prefs_mongos_tags); + suite, "/ReadPrefs/mongos/tags", "", test_read_prefs_mongos_tags); TestSuite_AddMockServerTest (suite, "/ReadPrefs/mongos/maxStaleness", + "", test_read_prefs_mongos_max_staleness); TestSuite_AddMockServerTest (suite, "/ReadPrefs/mongos/hedgedReads", + "", test_read_prefs_mongos_hedged_reads); TestSuite_AddMockServerTest ( - suite, "/ReadPrefs/mongos/readConcern", test_mongos_read_concern); + suite, "/ReadPrefs/mongos/readConcern", "", test_mongos_read_concern); TestSuite_AddMockServerTest ( - suite, "/ReadPrefs/OP_MSG/secondary", test_op_msg_direct_secondary); + suite, "/ReadPrefs/OP_MSG/secondary", "", test_op_msg_direct_secondary); TestSuite_AddMockServerTest ( - suite, "/ReadPrefs/OP_MSG/mongos", test_op_msg_direct_mongos); + suite, "/ReadPrefs/OP_MSG/mongos", "", test_op_msg_direct_mongos); } diff --git a/src/libmongoc/tests/test-mongoc-retryable-reads.c b/src/libmongoc/tests/test-mongoc-retryable-reads.c index c37d4c2cd09..bc34b875e09 100644 --- a/src/libmongoc/tests/test-mongoc-retryable-reads.c +++ b/src/libmongoc/tests/test-mongoc-retryable-reads.c @@ -300,6 +300,7 @@ test_retryable_reads_install (TestSuite *suite) /* Since we need failpoints, require wire version 7 */ TestSuite_AddFull (suite, "/retryable_reads/cmd_helpers", + "", test_cmd_helpers, NULL, NULL, @@ -308,6 +309,7 @@ test_retryable_reads_install (TestSuite *suite) test_framework_skip_if_no_failpoint); TestSuite_AddFull (suite, "/retryable_reads/retry_off", + "", test_retry_reads_off, NULL, NULL, diff --git a/src/libmongoc/tests/test-mongoc-retryable-writes.c b/src/libmongoc/tests/test-mongoc-retryable-writes.c index e1e4f5fbfcc..056de8b44e2 100644 --- a/src/libmongoc/tests/test-mongoc-retryable-writes.c +++ b/src/libmongoc/tests/test-mongoc-retryable-writes.c @@ -678,37 +678,45 @@ test_retryable_writes_install (TestSuite *suite) test_all_spec_tests (suite); TestSuite_AddMockServerTest (suite, "/retryable_writes/failover", + "", test_rs_failover, test_framework_skip_if_no_crypto); TestSuite_AddFull (suite, "/retryable_writes/command_with_opts", + "", test_command_with_opts, NULL, NULL, test_framework_skip_if_not_rs_version_6); TestSuite_AddMockServerTest (suite, "/retryable_writes/insert_one_unacknowledged", + "", test_insert_one_unacknowledged, test_framework_skip_if_no_crypto); TestSuite_AddMockServerTest (suite, "/retryable_writes/update_one_unacknowledged", + "", test_update_one_unacknowledged, test_framework_skip_if_no_crypto); TestSuite_AddMockServerTest (suite, "/retryable_writes/delete_one_unacknowledged", + "", test_delete_one_unacknowledged, test_framework_skip_if_no_crypto); TestSuite_AddMockServerTest (suite, "/retryable_writes/remove_unacknowledged", + "", test_remove_unacknowledged, test_framework_skip_if_no_crypto); TestSuite_AddMockServerTest ( suite, "/retryable_writes/bulk_operation_execute_unacknowledged", + "", test_bulk_operation_execute_unacknowledged, test_framework_skip_if_no_crypto); TestSuite_AddFull (suite, "/retryable_writes/no_crypto", + "", test_retry_no_crypto, NULL, NULL, @@ -716,10 +724,12 @@ test_retryable_writes_install (TestSuite *suite) TestSuite_AddMockServerTest ( suite, "/retryable_writes/unsupported_storage_engine_error", + "", test_unsupported_storage_engine_error, test_framework_skip_if_no_crypto); TestSuite_AddFull (suite, "/retryable_writes/bulk_tracks_new_server", + "", test_bulk_retry_tracks_new_server, NULL /* dtor */, NULL /* ctx */, diff --git a/src/libmongoc/tests/test-mongoc-rpc.c b/src/libmongoc/tests/test-mongoc-rpc.c index d75b867fc9c..ffb3488c8a7 100644 --- a/src/libmongoc/tests/test-mongoc-rpc.c +++ b/src/libmongoc/tests/test-mongoc-rpc.c @@ -662,24 +662,37 @@ test_mongoc_rpc_buffer_iov (void) void test_rpc_install (TestSuite *suite) { - TestSuite_Add (suite, "/Rpc/delete/gather", test_mongoc_rpc_delete_gather); - TestSuite_Add (suite, "/Rpc/delete/scatter", test_mongoc_rpc_delete_scatter); TestSuite_Add ( - suite, "/Rpc/get_more/gather", test_mongoc_rpc_get_more_gather); + suite, "/Rpc/delete/gather", "", test_mongoc_rpc_delete_gather); TestSuite_Add ( - suite, "/Rpc/get_more/scatter", test_mongoc_rpc_get_more_scatter); - TestSuite_Add (suite, "/Rpc/insert/gather", test_mongoc_rpc_insert_gather); - TestSuite_Add (suite, "/Rpc/insert/scatter", test_mongoc_rpc_insert_scatter); + suite, "/Rpc/delete/scatter", "", test_mongoc_rpc_delete_scatter); TestSuite_Add ( - suite, "/Rpc/kill_cursors/gather", test_mongoc_rpc_kill_cursors_gather); + suite, "/Rpc/get_more/gather", "", test_mongoc_rpc_get_more_gather); TestSuite_Add ( - suite, "/Rpc/kill_cursors/scatter", test_mongoc_rpc_kill_cursors_scatter); - TestSuite_Add (suite, "/Rpc/query/gather", test_mongoc_rpc_query_gather); - TestSuite_Add (suite, "/Rpc/query/scatter", test_mongoc_rpc_query_scatter); - TestSuite_Add (suite, "/Rpc/reply/gather", test_mongoc_rpc_reply_gather); - TestSuite_Add (suite, "/Rpc/reply/scatter", test_mongoc_rpc_reply_scatter); - TestSuite_Add (suite, "/Rpc/reply/scatter2", test_mongoc_rpc_reply_scatter2); - TestSuite_Add (suite, "/Rpc/update/gather", test_mongoc_rpc_update_gather); - TestSuite_Add (suite, "/Rpc/update/scatter", test_mongoc_rpc_update_scatter); - TestSuite_Add (suite, "/Rpc/buffer/iov", test_mongoc_rpc_buffer_iov); + suite, "/Rpc/get_more/scatter", "", test_mongoc_rpc_get_more_scatter); + TestSuite_Add ( + suite, "/Rpc/insert/gather", "", test_mongoc_rpc_insert_gather); + TestSuite_Add ( + suite, "/Rpc/insert/scatter", "", test_mongoc_rpc_insert_scatter); + TestSuite_Add (suite, + "/Rpc/kill_cursors/gather", + "", + test_mongoc_rpc_kill_cursors_gather); + TestSuite_Add (suite, + "/Rpc/kill_cursors/scatter", + "", + test_mongoc_rpc_kill_cursors_scatter); + TestSuite_Add (suite, "/Rpc/query/gather", "", test_mongoc_rpc_query_gather); + TestSuite_Add ( + suite, "/Rpc/query/scatter", "", test_mongoc_rpc_query_scatter); + TestSuite_Add (suite, "/Rpc/reply/gather", "", test_mongoc_rpc_reply_gather); + TestSuite_Add ( + suite, "/Rpc/reply/scatter", "", test_mongoc_rpc_reply_scatter); + TestSuite_Add ( + suite, "/Rpc/reply/scatter2", "", test_mongoc_rpc_reply_scatter2); + TestSuite_Add ( + suite, "/Rpc/update/gather", "", test_mongoc_rpc_update_gather); + TestSuite_Add ( + suite, "/Rpc/update/scatter", "", test_mongoc_rpc_update_scatter); + TestSuite_Add (suite, "/Rpc/buffer/iov", "", test_mongoc_rpc_buffer_iov); } diff --git a/src/libmongoc/tests/test-mongoc-sample-commands.c b/src/libmongoc/tests/test-mongoc-sample-commands.c index f31efae5dff..5cdf474ac49 100644 --- a/src/libmongoc/tests/test-mongoc-sample-commands.c +++ b/src/libmongoc/tests/test-mongoc-sample-commands.c @@ -3964,9 +3964,10 @@ test_with_txn_example (void *unused) void test_samples_install (TestSuite *suite) { - TestSuite_AddLive (suite, "/Samples", test_sample_commands); + TestSuite_AddLive (suite, "/Samples", "", test_sample_commands); TestSuite_AddFull (suite, "/Samples/with_txn", + "", test_with_txn_example, NULL, NULL, diff --git a/src/libmongoc/tests/test-mongoc-scram.c b/src/libmongoc/tests/test-mongoc-scram.c index 5bc022d3744..14dd3ddbb0f 100644 --- a/src/libmongoc/tests/test-mongoc-scram.c +++ b/src/libmongoc/tests/test-mongoc-scram.c @@ -627,13 +627,15 @@ test_scram_install (TestSuite *suite) #ifdef MONGOC_ENABLE_SSL TestSuite_Add (suite, "/scram/username_not_set", + "", test_mongoc_scram_step_username_not_set); - TestSuite_Add (suite, "/scram/sasl_prep", test_mongoc_scram_sasl_prep); + TestSuite_Add (suite, "/scram/sasl_prep", "", test_mongoc_scram_sasl_prep); TestSuite_Add ( - suite, "/scram/iteration_count", test_mongoc_scram_iteration_count); + suite, "/scram/iteration_count", "", test_mongoc_scram_iteration_count); #endif TestSuite_AddFull (suite, "/scram/auth_tests", + "", test_mongoc_scram_auth, NULL /* dtor */, NULL /* ctx */, @@ -643,6 +645,7 @@ test_scram_install (TestSuite *suite) TestSuite_CheckLive); TestSuite_AddFull (suite, "/scram/saslprep_auth", + "", test_mongoc_saslprep_auth, NULL /* dtor */, NULL /* ctx */, @@ -653,6 +656,7 @@ test_scram_install (TestSuite *suite) TestSuite_CheckLive); TestSuite_AddFull (suite, "/scram/saslprep_auth_no_icu", + "", test_mongoc_saslprep_auth_no_icu, NULL /* dtor */, NULL /* ctx */, diff --git a/src/libmongoc/tests/test-mongoc-sdam-monitoring.c b/src/libmongoc/tests/test-mongoc-sdam-monitoring.c index 1e9b42c900d..cc9624a885b 100644 --- a/src/libmongoc/tests/test-mongoc-sdam-monitoring.c +++ b/src/libmongoc/tests/test-mongoc-sdam-monitoring.c @@ -1003,36 +1003,44 @@ test_sdam_monitoring_install (TestSuite *suite) TestSuite_AddLive ( suite, "/server_discovery_and_monitoring/monitoring/topology/single", + "", test_topology_events_single); TestSuite_AddLive ( suite, "/server_discovery_and_monitoring/monitoring/topology/pooled", + "", test_topology_events_pooled); TestSuite_AddLive ( suite, "/server_discovery_and_monitoring/monitoring/topology/disabled", + "", test_topology_events_disabled); TestSuite_AddMockServerTest ( suite, "/server_discovery_and_monitoring/monitoring/heartbeat/single/succeeded", + "", test_heartbeat_events_single_succeeded); TestSuite_AddMockServerTest ( suite, "/server_discovery_and_monitoring/monitoring/heartbeat/single/failed", + "", test_heartbeat_events_single_failed); TestSuite_AddMockServerTest ( suite, "/server_discovery_and_monitoring/monitoring/heartbeat/pooled/succeeded", + "", test_heartbeat_events_pooled_succeeded); _TestSuite_AddMockServerTest ( suite, "/server_discovery_and_monitoring/monitoring/heartbeat/pooled/failed", + "", test_heartbeat_events_pooled_failed, test_framework_skip_if_time_sensitive, NULL); TestSuite_AddFull ( suite, "/server_discovery_and_monitoring/monitoring/heartbeat/single/dns", + "", test_heartbeat_fails_dns_single, NULL, NULL, @@ -1040,6 +1048,7 @@ test_sdam_monitoring_install (TestSuite *suite) TestSuite_AddFull ( suite, "/server_discovery_and_monitoring/monitoring/heartbeat/pooled/dns", + "", test_heartbeat_fails_dns_pooled, NULL, NULL, @@ -1047,6 +1056,7 @@ test_sdam_monitoring_install (TestSuite *suite) TestSuite_AddMockServerTest ( suite, "/server_discovery_and_monitoring/monitoring/no_duplicates", + "", test_no_duplicates, NULL, NULL); diff --git a/src/libmongoc/tests/test-mongoc-sdam.c b/src/libmongoc/tests/test-mongoc-sdam.c index c69360a2fbc..7e806c1faba 100644 --- a/src/libmongoc/tests/test-mongoc-sdam.c +++ b/src/libmongoc/tests/test-mongoc-sdam.c @@ -917,24 +917,28 @@ test_sdam_install (TestSuite *suite) test_all_spec_tests (suite); TestSuite_AddFull (suite, "/server_discovery_and_monitoring/topology/discovery", + "", test_topology_discovery, NULL /* dtor */, NULL /* ctx */, test_framework_skip_if_not_replset); TestSuite_AddFull (suite, "/server_discovery_and_monitoring/directconnection", + "", test_direct_connection, NULL /* dtor */, NULL /* ctx */, test_framework_skip_if_not_replset); TestSuite_AddFull (suite, "/server_discovery_and_monitoring/existing/behavior", + "", test_existing_behavior, NULL /* dtor */, NULL /* ctx */, test_framework_skip_if_not_replset); TestSuite_AddFull (suite, "/server_discovery_and_monitoring/prose/rtt", + "", test_prose_rtt, NULL /* dtor */, NULL /* ctx */, diff --git a/src/libmongoc/tests/test-mongoc-server-description.c b/src/libmongoc/tests/test-mongoc-server-description.c index c2440afcb77..6dde85c5c5e 100644 --- a/src/libmongoc/tests/test-mongoc-server-description.c +++ b/src/libmongoc/tests/test-mongoc-server-description.c @@ -385,22 +385,27 @@ void test_server_description_install (TestSuite *suite) { TestSuite_Add ( - suite, "/server_description/equal", test_server_description_equal); + suite, "/server_description/equal", "", test_server_description_equal); TestSuite_Add (suite, "/server_description/msg_without_isdbgrid", + "", test_server_description_msg_without_isdbgrid); TestSuite_Add (suite, "/server_description/ignores_unset_rtt", + "", test_server_description_ignores_rtt); TestSuite_Add ( - suite, "/server_description/hello", test_server_description_hello); + suite, "/server_description/hello", "", test_server_description_hello); TestSuite_Add (suite, "/server_description/hello_cmd_not_found", + "", test_server_description_hello_cmd_not_found); TestSuite_Add (suite, "/server_description/legacy_hello", + "", test_server_description_legacy_hello); TestSuite_Add (suite, "/server_description/legacy_hello_ok", + "", test_server_description_legacy_hello_ok); } diff --git a/src/libmongoc/tests/test-mongoc-server-selection-errors.c b/src/libmongoc/tests/test-mongoc-server-selection-errors.c index 5f1639ac10f..98b85e786c6 100644 --- a/src/libmongoc/tests/test-mongoc-server-selection-errors.c +++ b/src/libmongoc/tests/test-mongoc-server-selection-errors.c @@ -286,54 +286,64 @@ test_server_selection_errors_install (TestSuite *suite) { TestSuite_Add (suite, "/server_selection/errors/dns/direct/single", + "", test_server_selection_error_dns_direct_single); TestSuite_AddFull (suite, "/server_selection/errors/dns/direct/pooled", + "", test_server_selection_error_dns_direct_pooled, NULL, NULL, test_framework_skip_if_slow); TestSuite_Add (suite, "/server_selection/errors/dns/multi/fail/single", + "", test_server_selection_error_dns_multi_fail_single); TestSuite_AddFull (suite, "/server_selection/errors/dns/multi/fail/pooled", + "", test_server_selection_error_dns_multi_fail_pooled, NULL, NULL, test_framework_skip_if_slow); TestSuite_AddFull (suite, "/server_selection/errors/dns/multi/success/single", + "", test_server_selection_error_dns_multi_success_single, NULL, NULL, test_framework_skip_if_single); TestSuite_AddFull (suite, "/server_selection/errors/dns/multi/success/pooled", + "", test_server_selection_error_dns_multi_success_pooled, NULL, NULL, test_framework_skip_if_single); TestSuite_AddFull (suite, "/server_selection/errors/uds/auth_failure/single", + "", test_server_selection_uds_auth_failure_single, NULL, NULL, test_framework_skip_if_no_uds); TestSuite_AddFull (suite, "/server_selection/errors/uds/auth_failure/pooled", + "", test_server_selection_uds_auth_failure_pooled, NULL, NULL, test_framework_skip_if_no_uds); TestSuite_AddFull (suite, "/server_selection/errors/uds/not_found/single", + "", test_server_selection_uds_not_found_single, NULL, NULL, test_framework_skip_if_windows); TestSuite_AddFull (suite, "/server_selection/errors/uds/not_found/pooled", + "", test_server_selection_uds_not_found_pooled, NULL, NULL, diff --git a/src/libmongoc/tests/test-mongoc-server-stream.c b/src/libmongoc/tests/test-mongoc-server-stream.c index f851616425b..382d65546bc 100644 --- a/src/libmongoc/tests/test-mongoc-server-stream.c +++ b/src/libmongoc/tests/test-mongoc-server-stream.c @@ -217,12 +217,14 @@ test_server_stream_install (TestSuite *suite) { TestSuite_AddFull (suite, "/server_stream/ties_server_description/pooled", + "", test_server_stream_ties_server_description_pooled, NULL /* dtor */, NULL /* ctx */, NULL); TestSuite_AddFull (suite, "/server_stream/ties_server_description/single", + "", test_server_stream_ties_server_description_single, NULL /* dtor */, NULL /* ctx */, diff --git a/src/libmongoc/tests/test-mongoc-set.c b/src/libmongoc/tests/test-mongoc-set.c index 102bef7068f..e60872379ed 100644 --- a/src/libmongoc/tests/test-mongoc-set.c +++ b/src/libmongoc/tests/test-mongoc-set.c @@ -88,5 +88,5 @@ test_set_new (void) void test_set_install (TestSuite *suite) { - TestSuite_Add (suite, "/Set/new", test_set_new); + TestSuite_Add (suite, "/Set/new", "", test_set_new); } diff --git a/src/libmongoc/tests/test-mongoc-shared.c b/src/libmongoc/tests/test-mongoc-shared.c index 635490e9746..68041e8e271 100644 --- a/src/libmongoc/tests/test-mongoc-shared.c +++ b/src/libmongoc/tests/test-mongoc-shared.c @@ -121,6 +121,6 @@ test_aliased (void) void test_shared_install (TestSuite *suite) { - TestSuite_Add (suite, "/shared/simple", test_simple); - TestSuite_Add (suite, "/shared/aliased", test_aliased); + TestSuite_Add (suite, "/shared/simple", "", test_simple); + TestSuite_Add (suite, "/shared/aliased", "", test_aliased); } diff --git a/src/libmongoc/tests/test-mongoc-socket.c b/src/libmongoc/tests/test-mongoc-socket.c index e32430eb4e0..2514a71aacc 100644 --- a/src/libmongoc/tests/test-mongoc-socket.c +++ b/src/libmongoc/tests/test-mongoc-socket.c @@ -450,21 +450,24 @@ void test_socket_install (TestSuite *suite) { TestSuite_Add ( - suite, "/Socket/check_closed", test_mongoc_socket_check_closed); + suite, "/Socket/check_closed", "", test_mongoc_socket_check_closed); TestSuite_AddFull (suite, "/Socket/timed_out", + "", test_mongoc_socket_timed_out, NULL, NULL, test_framework_skip_if_slow); TestSuite_AddFull (suite, "/Socket/sendv", + "", test_mongoc_socket_sendv, NULL, NULL, test_framework_skip_if_slow); TestSuite_AddFull (suite, "/Socket/connect_refusal", + "", test_mongoc_socket_poll_refusal, NULL, NULL, diff --git a/src/libmongoc/tests/test-mongoc-speculative-auth.c b/src/libmongoc/tests/test-mongoc-speculative-auth.c index 188c702b23d..b564cacc28c 100644 --- a/src/libmongoc/tests/test-mongoc-speculative-auth.c +++ b/src/libmongoc/tests/test-mongoc-speculative-auth.c @@ -428,28 +428,34 @@ test_speculative_auth_install (TestSuite *suite) #ifdef MONGOC_ENABLE_CRYPTO TestSuite_AddMockServerTest (suite, "/speculative_auth/request_none", + "", test_mongoc_speculative_auth_request_none); #if defined(MONGOC_ENABLE_SSL_OPENSSL) || \ defined(MONGOC_ENABLE_SSL_SECURE_TRANSPORT) TestSuite_AddMockServerTest (suite, "/speculative_auth/request_x509", + "", test_mongoc_speculative_auth_request_x509); #endif /* MONGOC_ENABLE_SSL_* */ TestSuite_AddMockServerTest (suite, "/speculative_auth/request_scram", + "", test_mongoc_speculative_auth_request_scram); TestSuite_AddMockServerTest (suite, "/speculative_auth_pool/request_none", + "", test_mongoc_speculative_auth_request_none_pool); #if defined(MONGOC_ENABLE_SSL_OPENSSL) || \ defined(MONGOC_ENABLE_SSL_SECURE_TRANSPORT) TestSuite_AddMockServerTest (suite, "/speculative_auth_pool/request_x509", + "", test_mongoc_speculative_auth_request_x509_pool); #endif /* MONGOC_ENABLE_SSL_* */ TestSuite_AddMockServerTest ( suite, "/speculative_auth_pool/request_scram", + "", test_mongoc_speculative_auth_request_scram_pool); #endif /* MONGOC_ENABLE_CRYPTO */ } diff --git a/src/libmongoc/tests/test-mongoc-ssl.c b/src/libmongoc/tests/test-mongoc-ssl.c index 9a2e01e7ba4..3faaa16b736 100644 --- a/src/libmongoc/tests/test-mongoc-ssl.c +++ b/src/libmongoc/tests/test-mongoc-ssl.c @@ -210,7 +210,9 @@ void test_ssl_install (TestSuite *suite) { #ifdef MONGOC_ENABLE_SSL - TestSuite_Add (suite, "/ssl_opt/from_bson", test_mongoc_ssl_opts_from_bson); - TestSuite_Add (suite, "/ssl_opt/cleanup", test_mongoc_ssl_opts_cleanup_zero); + TestSuite_Add ( + suite, "/ssl_opt/from_bson", "", test_mongoc_ssl_opts_from_bson); + TestSuite_Add ( + suite, "/ssl_opt/cleanup", "", test_mongoc_ssl_opts_cleanup_zero); #endif /* MONGOC_ENABLE_SSL */ } diff --git a/src/libmongoc/tests/test-mongoc-stream-tls-error.c b/src/libmongoc/tests/test-mongoc-stream-tls-error.c index 37b0dd64a3d..9c59ef5e9b4 100644 --- a/src/libmongoc/tests/test-mongoc-stream-tls-error.c +++ b/src/libmongoc/tests/test-mongoc-stream-tls-error.c @@ -390,14 +390,14 @@ test_stream_tls_error_install (TestSuite *suite) #if !defined(MONGOC_ENABLE_SSL_SECURE_CHANNEL) && \ !defined(MONGOC_ENABLE_SSL_LIBRESSL) #if !defined(__APPLE__) - TestSuite_Add (suite, "/TLS/hangup", test_mongoc_tls_hangup); + TestSuite_Add (suite, "/TLS/hangup", "", test_mongoc_tls_hangup); #endif /* see CDRIVER-2222 this occasionally stalls for a few 100ms on Mac */ #if !defined(MONGOC_ENABLE_SSL_SECURE_TRANSPORT) TestSuite_Add ( - suite, "/TLS/handshake_stall", test_mongoc_tls_handshake_stall); + suite, "/TLS/handshake_stall", "", test_mongoc_tls_handshake_stall); #endif #endif /* !MONGOC_ENABLE_SSL_SECURE_CHANNEL && !MONGOC_ENABLE_SSL_LIBRESSL */ - TestSuite_Add (suite, "/TLS/load_files", test_mongoc_tls_load_files); + TestSuite_Add (suite, "/TLS/load_files", "", test_mongoc_tls_load_files); } diff --git a/src/libmongoc/tests/test-mongoc-stream-tls.c b/src/libmongoc/tests/test-mongoc-stream-tls.c index 37af3e0736f..bc65fbed37b 100644 --- a/src/libmongoc/tests/test-mongoc-stream-tls.c +++ b/src/libmongoc/tests/test-mongoc-stream-tls.c @@ -418,34 +418,37 @@ test_stream_tls_install (TestSuite *suite) { #if !defined(MONGOC_ENABLE_SSL_SECURE_CHANNEL) && \ !defined(MONGOC_ENABLE_SSL_LIBRESSL) - TestSuite_Add (suite, "/TLS/commonName", test_mongoc_tls_common_name); - TestSuite_Add (suite, "/TLS/altname", test_mongoc_tls_altname); - TestSuite_Add (suite, "/TLS/basic", test_mongoc_tls_basic); + TestSuite_Add (suite, "/TLS/commonName", "", test_mongoc_tls_common_name); + TestSuite_Add (suite, "/TLS/altname", "", test_mongoc_tls_altname); + TestSuite_Add (suite, "/TLS/basic", "", test_mongoc_tls_basic); TestSuite_Add (suite, "/TLS/allow_invalid_hostname", + "", test_mongoc_tls_allow_invalid_hostname); - TestSuite_Add (suite, "/TLS/wild", test_mongoc_tls_wild); - TestSuite_Add (suite, "/TLS/no_verify", test_mongoc_tls_no_verify); - TestSuite_Add (suite, "/TLS/bad_verify", test_mongoc_tls_bad_verify); - TestSuite_Add (suite, "/TLS/no_certs", test_mongoc_tls_no_certs); + TestSuite_Add (suite, "/TLS/wild", "", test_mongoc_tls_wild); + TestSuite_Add (suite, "/TLS/no_verify", "", test_mongoc_tls_no_verify); + TestSuite_Add (suite, "/TLS/bad_verify", "", test_mongoc_tls_bad_verify); + TestSuite_Add (suite, "/TLS/no_certs", "", test_mongoc_tls_no_certs); - TestSuite_Add (suite, "/TLS/expired", test_mongoc_tls_expired); + TestSuite_Add (suite, "/TLS/expired", "", test_mongoc_tls_expired); #ifdef MONGOC_ENABLE_SSL_OPENSSL - TestSuite_Add (suite, "/TLS/ip", test_mongoc_tls_ip); - TestSuite_Add (suite, "/TLS/password", test_mongoc_tls_password); - TestSuite_Add (suite, "/TLS/bad_password", test_mongoc_tls_bad_password); - TestSuite_Add ( - suite, "/TLS/weak_cert_validation", test_mongoc_tls_weak_cert_validation); - TestSuite_Add (suite, "/TLS/crl", test_mongoc_tls_crl); + TestSuite_Add (suite, "/TLS/ip", "", test_mongoc_tls_ip); + TestSuite_Add (suite, "/TLS/password", "", test_mongoc_tls_password); + TestSuite_Add (suite, "/TLS/bad_password", "", test_mongoc_tls_bad_password); + TestSuite_Add (suite, + "/TLS/weak_cert_validation", + "", + test_mongoc_tls_weak_cert_validation); + TestSuite_Add (suite, "/TLS/crl", "", test_mongoc_tls_crl); #endif #if !defined(__APPLE__) && !defined(_WIN32) && \ defined(MONGOC_ENABLE_SSL_OPENSSL) && OPENSSL_VERSION_NUMBER >= 0x10000000L - TestSuite_Add (suite, "/TLS/trust_dir", test_mongoc_tls_trust_dir); + TestSuite_Add (suite, "/TLS/trust_dir", "", test_mongoc_tls_trust_dir); #endif TestSuite_AddLive ( - suite, "/TLS/insecure_nowarning", test_mongoc_tls_insecure_nowarning); + suite, "/TLS/insecure_nowarning", "", test_mongoc_tls_insecure_nowarning); #endif } diff --git a/src/libmongoc/tests/test-mongoc-stream.c b/src/libmongoc/tests/test-mongoc-stream.c index cb89e60eca0..22a19cb95b1 100644 --- a/src/libmongoc/tests/test-mongoc-stream.c +++ b/src/libmongoc/tests/test-mongoc-stream.c @@ -164,7 +164,8 @@ test_stream_writev_full (void) void test_stream_install (TestSuite *suite) { - TestSuite_Add (suite, "/Stream/buffered/basic", test_buffered_basic); - TestSuite_Add (suite, "/Stream/buffered/oversized", test_buffered_oversized); - TestSuite_Add (suite, "/Stream/writev_full", test_stream_writev_full); + TestSuite_Add (suite, "/Stream/buffered/basic", "", test_buffered_basic); + TestSuite_Add ( + suite, "/Stream/buffered/oversized", "", test_buffered_oversized); + TestSuite_Add (suite, "/Stream/writev_full", "", test_stream_writev_full); } diff --git a/src/libmongoc/tests/test-mongoc-streamable-hello.c b/src/libmongoc/tests/test-mongoc-streamable-hello.c index 0d16f5e4e06..b56a0549ac3 100644 --- a/src/libmongoc/tests/test-mongoc-streamable-hello.c +++ b/src/libmongoc/tests/test-mongoc-streamable-hello.c @@ -175,8 +175,10 @@ test_streamable_hello_install (TestSuite *suite) { TestSuite_AddMockServerTest (suite, "/streamable/topology_version/update", + "", test_topology_version_update); TestSuite_Add (suite, "/streamable/topology_version/compare", + "", test_topology_version_compare); } diff --git a/src/libmongoc/tests/test-mongoc-thread.c b/src/libmongoc/tests/test-mongoc-thread.c index 8b0da5be1b4..8d72c949cc8 100644 --- a/src/libmongoc/tests/test-mongoc-thread.c +++ b/src/libmongoc/tests/test-mongoc-thread.c @@ -35,6 +35,7 @@ test_thread_install (TestSuite *suite) { TestSuite_AddFull (suite, "/Thread/cond_wait", + "", test_cond_wait, NULL /* dtor */, NULL /* ctx */, diff --git a/src/libmongoc/tests/test-mongoc-timeout.c b/src/libmongoc/tests/test-mongoc-timeout.c index 51f4b1cf8e1..2f81d6e5fa8 100644 --- a/src/libmongoc/tests/test-mongoc-timeout.c +++ b/src/libmongoc/tests/test-mongoc-timeout.c @@ -157,9 +157,9 @@ test_mongoc_timeout_destroy (void) void test_timeout_install (TestSuite *suite) { - TestSuite_Add (suite, "/Timeout/new", test_mongoc_timeout_new); - TestSuite_Add (suite, "/Timeout/set", test_mongoc_timeout_set); - TestSuite_Add (suite, "/Timeout/get", test_mongoc_timeout_get); - TestSuite_Add (suite, "/Timeout/copy", test_mongoc_timeout_copy); - TestSuite_Add (suite, "/Timeout/destroy", test_mongoc_timeout_destroy); + TestSuite_Add (suite, "/Timeout/new", "", test_mongoc_timeout_new); + TestSuite_Add (suite, "/Timeout/set", "", test_mongoc_timeout_set); + TestSuite_Add (suite, "/Timeout/get", "", test_mongoc_timeout_get); + TestSuite_Add (suite, "/Timeout/copy", "", test_mongoc_timeout_copy); + TestSuite_Add (suite, "/Timeout/destroy", "", test_mongoc_timeout_destroy); } diff --git a/src/libmongoc/tests/test-mongoc-topology-description.c b/src/libmongoc/tests/test-mongoc-topology-description.c index 38c438abffa..d00c27ae982 100644 --- a/src/libmongoc/tests/test-mongoc-topology-description.c +++ b/src/libmongoc/tests/test-mongoc-topology-description.c @@ -355,20 +355,26 @@ test_topology_description_install (TestSuite *suite) { TestSuite_AddLive (suite, "/TopologyDescription/readable_writable/single", + "", test_has_readable_writable_server_single); TestSuite_AddLive (suite, "/TopologyDescription/readable_writable/pooled", + "", test_has_readable_writable_server_pooled); - TestSuite_Add (suite, "/TopologyDescription/get_servers", test_get_servers); + TestSuite_Add ( + suite, "/TopologyDescription/get_servers", "", test_get_servers); TestSuite_Add (suite, "/TopologyDescription/topology_version_equal", + "", test_topology_version_equal); TestSuite_Add (suite, "/TopologyDescription/new_copy", + "", test_topology_description_new_copy); TestSuite_Add ( - suite, "/TopologyDescription/pool_clear", test_topology_pool_clear); + suite, "/TopologyDescription/pool_clear", "", test_topology_pool_clear); TestSuite_Add (suite, "/TopologyDescription/pool_clear_by_serviceid", + "", test_topology_pool_clear_by_serviceid); } diff --git a/src/libmongoc/tests/test-mongoc-topology-reconcile.c b/src/libmongoc/tests/test-mongoc-topology-reconcile.c index 950e8ed73e8..669ceeb747f 100644 --- a/src/libmongoc/tests/test-mongoc-topology-reconcile.c +++ b/src/libmongoc/tests/test-mongoc-topology-reconcile.c @@ -664,30 +664,37 @@ test_topology_reconcile_install (TestSuite *suite) { TestSuite_AddMockServerTest (suite, "/TOPOLOGY/reconcile/rs/pooled", + "", test_topology_reconcile_rs_pooled, test_framework_skip_if_slow); TestSuite_AddMockServerTest (suite, "/TOPOLOGY/reconcile/rs/single", + "", test_topology_reconcile_rs_single, test_framework_skip_if_slow); TestSuite_AddMockServerTest (suite, "/TOPOLOGY/reconcile/sharded/pooled", + "", test_topology_reconcile_sharded_pooled); TestSuite_AddMockServerTest (suite, "/TOPOLOGY/reconcile/sharded/single", + "", test_topology_reconcile_sharded_single); TestSuite_AddFull (suite, "/TOPOLOGY/reconcile/from_handshake", + "", test_topology_reconcile_from_handshake, NULL, NULL, test_framework_skip_if_not_replset); TestSuite_AddMockServerTest (suite, "/TOPOLOGY/reconcile/retire/single", + "", test_topology_reconcile_retire_single, test_framework_skip_if_slow); TestSuite_AddMockServerTest (suite, "/TOPOLOGY/reconcile/add/single", + "", test_topology_reconcile_add_single, test_framework_skip_if_slow); } diff --git a/src/libmongoc/tests/test-mongoc-topology-scanner.c b/src/libmongoc/tests/test-mongoc-topology-scanner.c index 6ec91491ea7..8b0498af1c8 100644 --- a/src/libmongoc/tests/test-mongoc-topology-scanner.c +++ b/src/libmongoc/tests/test-mongoc-topology-scanner.c @@ -711,33 +711,43 @@ void test_topology_scanner_install (TestSuite *suite) { TestSuite_AddMockServerTest ( - suite, "/TOPOLOGY/scanner", test_topology_scanner); + suite, "/TOPOLOGY/scanner", "", test_topology_scanner); #ifdef MONGOC_ENABLE_SSL_OPENSSL TestSuite_AddMockServerTest ( - suite, "/TOPOLOGY/scanner_ssl", test_topology_scanner_ssl); + suite, "/TOPOLOGY/scanner_ssl", "", test_topology_scanner_ssl); #endif - TestSuite_AddMockServerTest ( - suite, "/TOPOLOGY/scanner_discovery", test_topology_scanner_discovery); - TestSuite_AddMockServerTest ( - suite, "/TOPOLOGY/scanner_oscillate", test_topology_scanner_oscillate); + TestSuite_AddMockServerTest (suite, + "/TOPOLOGY/scanner_discovery", + "", + test_topology_scanner_discovery); + TestSuite_AddMockServerTest (suite, + "/TOPOLOGY/scanner_oscillate", + "", + test_topology_scanner_oscillate); TestSuite_Add (suite, "/TOPOLOGY/scanner_connection_error", + "", test_topology_scanner_connection_error); TestSuite_AddMockServerTest (suite, "/TOPOLOGY/scanner_socket_timeout", + "", test_topology_scanner_socket_timeout); TestSuite_AddMockServerTest (suite, "/TOPOLOGY/blocking_initiator", + "", test_topology_scanner_blocking_initiator); TestSuite_AddMockServerTest (suite, "/TOPOLOGY/dns", + "", test_topology_scanner_dns, test_framework_skip_if_no_dual_ip_hostname); TestSuite_AddMockServerTest (suite, "/TOPOLOGY/retired_fails_to_initiate", + "", test_topology_retired_fails_to_initiate); TestSuite_AddFull (suite, "/TOPOLOGY/scanner/renegotiate/single", + "", test_topology_scanner_does_not_renegotiate_single, NULL, NULL, @@ -745,6 +755,7 @@ test_topology_scanner_install (TestSuite *suite) test_framework_skip_if_valgrind); TestSuite_AddFull (suite, "/TOPOLOGY/scanner/renegotiate/pooled", + "", test_topology_scanner_does_not_renegotiate_pooled, NULL, NULL, diff --git a/src/libmongoc/tests/test-mongoc-topology.c b/src/libmongoc/tests/test-mongoc-topology.c index 1f93f2887ab..2d4451ab3c7 100644 --- a/src/libmongoc/tests/test-mongoc-topology.c +++ b/src/libmongoc/tests/test-mongoc-topology.c @@ -2445,32 +2445,37 @@ void test_topology_install (TestSuite *suite) { TestSuite_AddLive ( - suite, "/Topology/client_creation", test_topology_client_creation); + suite, "/Topology/client_creation", "", test_topology_client_creation); TestSuite_AddLive (suite, "/Topology/client_pool_creation", + "", test_topology_client_pool_creation); TestSuite_AddLive ( - suite, "/Topology/start_stop", test_topology_thread_start_stop); + suite, "/Topology/start_stop", "", test_topology_thread_start_stop); TestSuite_AddFull (suite, "/Topology/server_selection_try_once_option", + "", test_server_selection_try_once_option, NULL, NULL, test_framework_skip_if_slow); TestSuite_AddFull (suite, "/Topology/server_selection_try_once", + "", test_server_selection_try_once, NULL, NULL, test_framework_skip_if_slow); TestSuite_AddFull (suite, "/Topology/server_selection_try_once_false", + "", test_server_selection_try_once_false, NULL, NULL, test_framework_skip_if_slow); TestSuite_AddFull (suite, "/Topology/invalidate_server/single", + "", test_topology_invalidate_server_single, NULL, NULL, @@ -2478,6 +2483,7 @@ test_topology_install (TestSuite *suite) test_framework_skip_if_valgrind); TestSuite_AddFull (suite, "/Topology/invalidate_server/pooled", + "", test_topology_invalidate_server_pooled, NULL, NULL, @@ -2485,126 +2491,151 @@ test_topology_install (TestSuite *suite) test_framework_skip_if_valgrind); TestSuite_AddFull (suite, "/Topology/invalid_cluster_node", + "", test_invalid_cluster_node, NULL, NULL, test_framework_skip_if_slow_or_live); TestSuite_AddFull (suite, "/Topology/max_wire_version_race_condition", + "", test_max_wire_version_race_condition, NULL, NULL, test_framework_skip_if_no_auth); TestSuite_AddMockServerTest (suite, "/Topology/cooldown/standalone", + "", test_cooldown_standalone, NULL, NULL, test_framework_skip_if_slow); TestSuite_AddMockServerTest (suite, "/Topology/cooldown/rs", + "", test_cooldown_rs, NULL, NULL, test_framework_skip_if_slow); TestSuite_AddMockServerTest (suite, "/Topology/cooldown/retry", + "", test_cooldown_retry, NULL, NULL, test_framework_skip_if_slow); TestSuite_AddFull (suite, "/Topology/multiple_selection_errors", + "", test_multiple_selection_errors, NULL, NULL, test_framework_skip_if_offline); _TestSuite_AddMockServerTest (suite, "/Topology/connect_timeout/succeed", + "", test_select_after_timeout, test_framework_skip_if_time_sensitive, NULL); _TestSuite_AddMockServerTest (suite, "/Topology/try_once/succeed", + "", test_select_after_try_once, test_framework_skip_if_time_sensitive, NULL); TestSuite_AddLive ( - suite, "/Topology/invalid_server_id", test_invalid_server_id); + suite, "/Topology/invalid_server_id", "", test_invalid_server_id); TestSuite_AddMockServerTest (suite, "/Topology/server_removed/single", + "", test_server_removed_during_handshake_single); TestSuite_AddMockServerTest (suite, "/Topology/server_removed/pooled", + "", test_server_removed_during_handshake_pooled); TestSuite_AddFull (suite, "/Topology/rtt", + "", test_rtt, NULL, NULL, test_framework_skip_if_slow); TestSuite_AddMockServerTest ( - suite, "/Topology/add_and_scan_failure", test_add_and_scan_failure); + suite, "/Topology/add_and_scan_failure", "", test_add_and_scan_failure); TestSuite_AddMockServerTest (suite, "/Topology/hello_retry/single/hangup", + "", test_hello_retry_single_hangup, test_framework_skip_if_slow); TestSuite_AddMockServerTest (suite, "/Topology/hello_retry/single/timeout", + "", test_hello_retry_single_timeout, test_framework_skip_if_slow); TestSuite_AddMockServerTest (suite, "/Topology/hello_retry/single/hangup/fail", + "", test_hello_retry_single_hangup_fail, test_framework_skip_if_slow); TestSuite_AddMockServerTest (suite, "/Topology/hello_retry/single/timeout/fail", + "", test_hello_retry_single_timeout_fail, test_framework_skip_if_slow); TestSuite_AddMockServerTest (suite, "/Topology/hello_retry/pooled/hangup", + "", test_hello_retry_pooled_hangup, test_framework_skip_if_slow); TestSuite_AddMockServerTest (suite, "/Topology/hello_retry/pooled/timeout", + "", test_hello_retry_pooled_timeout, test_framework_skip_if_slow); TestSuite_AddMockServerTest (suite, "/Topology/hello_retry/pooled/hangup/fail", + "", test_hello_retry_pooled_hangup_fail, test_framework_skip_if_slow); TestSuite_AddMockServerTest (suite, "/Topology/hello_retry/pooled/timeout/fail", + "", test_hello_retry_pooled_timeout_fail, test_framework_skip_if_slow); TestSuite_AddMockServerTest (suite, "/Topology/incompatible_error", + "", test_incompatible_error, test_framework_skip_if_slow); TestSuite_AddMockServerTest (suite, "/Topology/compatible_null_error_pointer", + "", test_compatible_null_error_pointer, test_framework_skip_if_slow); TestSuite_AddMockServerTest (suite, "/Topology/handshake/updates_clustertime", + "", test_cluster_time_updated_during_handshake); TestSuite_AddMockServerTest ( - suite, "/Topology/request_scan_on_error", test_request_scan_on_error); + suite, "/Topology/request_scan_on_error", "", test_request_scan_on_error); TestSuite_AddMockServerTest (suite, "/Topology/last_server_removed_warning", + "", test_last_server_removed_warning); TestSuite_AddMockServerTest ( - suite, "/Topology/slow_server/pooled", test_slow_server_pooled); + suite, "/Topology/slow_server/pooled", "", test_slow_server_pooled); TestSuite_AddMockServerTest (suite, "/Topology/hello/versioned_api/single", + "", test_hello_versioned_api_single); TestSuite_AddMockServerTest (suite, "/Topology/hello/versioned_api/pooled", + "", test_hello_versioned_api_pooled); TestSuite_AddMockServerTest ( - suite, "/Topology/hello_ok/single", test_hello_ok_single); + suite, "/Topology/hello_ok/single", "", test_hello_ok_single); TestSuite_AddMockServerTest ( - suite, "/Topology/hello_ok/pooled", test_hello_ok_pooled); + suite, "/Topology/hello_ok/pooled", "", test_hello_ok_pooled); } diff --git a/src/libmongoc/tests/test-mongoc-transactions.c b/src/libmongoc/tests/test-mongoc-transactions.c index 7ae7662ee13..8ecd1643f96 100644 --- a/src/libmongoc/tests/test-mongoc-transactions.c +++ b/src/libmongoc/tests/test-mongoc-transactions.c @@ -1188,36 +1188,43 @@ test_transactions_install (TestSuite *suite) TestSuite_AddFull (suite, "/transactions/supported", + "", test_transactions_supported, NULL, NULL, test_framework_skip_if_no_txns); TestSuite_AddFull (suite, "/transactions/in_transaction", + "", test_in_transaction, NULL, NULL, test_framework_skip_if_no_txns); TestSuite_AddMockServerTest (suite, "/transactions/server_selection_err", + "", test_server_selection_error, test_framework_skip_if_no_crypto); TestSuite_AddMockServerTest (suite, "/transactions/network_err", + "", test_network_error, test_framework_skip_if_no_crypto); TestSuite_AddMockServerTest (suite, "/transactions/unknown_commit_result", + "", test_unknown_commit_result, test_framework_skip_if_no_crypto); TestSuite_AddFull (suite, "/transactions/cursor_primary_read_pref", + "", test_cursor_primary_read_pref, NULL, NULL, test_framework_skip_if_no_txns); TestSuite_AddFull (suite, "/transactions/inherit_from_client", + "", test_inherit_from_client, NULL, NULL, @@ -1226,6 +1233,7 @@ test_transactions_install (TestSuite *suite) suite, "/transactions/" "transaction_fails_on_unsupported_version_or_sharded_cluster", + "", test_transaction_fails_on_unsupported_version_or_sharded_cluster, NULL, NULL, @@ -1233,6 +1241,7 @@ test_transactions_install (TestSuite *suite) test_framework_skip_if_no_crypto); TestSuite_AddFull (suite, "/transactions/recovery_token_cleared", + "", test_transaction_recovery_token_cleared, NULL, NULL, @@ -1242,6 +1251,7 @@ test_transactions_install (TestSuite *suite) test_framework_skip_if_not_mongos); TestSuite_AddFull (suite, "/transactions/selected_server_pinned_to_mongos", + "", test_selected_server_is_pinned_to_mongos, NULL, NULL, @@ -1250,10 +1260,12 @@ test_transactions_install (TestSuite *suite) test_framework_skip_if_not_mongos); TestSuite_AddMockServerTest (suite, "/transactions/get_transaction_opts", + "", test_get_transaction_opts, test_framework_skip_if_no_crypto); TestSuite_AddFull (suite, "/transactions/max_commit_time_ms_is_reset", + "", test_max_commit_time_ms_is_reset, NULL, NULL, diff --git a/src/libmongoc/tests/test-mongoc-ts-pool.c b/src/libmongoc/tests/test-mongoc-ts-pool.c index b81467f98d1..0006e143344 100644 --- a/src/libmongoc/tests/test-mongoc-ts-pool.c +++ b/src/libmongoc/tests/test-mongoc-ts-pool.c @@ -91,7 +91,7 @@ test_ts_pool_special (void) void test_ts_pool_install (TestSuite *suite) { - TestSuite_Add (suite, "/Util/ts-pool-empty", test_ts_pool_empty); - TestSuite_Add (suite, "/Util/ts-pool", test_ts_pool_simple); - TestSuite_Add (suite, "/Util/ts-pool-special", test_ts_pool_special); + TestSuite_Add (suite, "/Util/ts-pool-empty", "", test_ts_pool_empty); + TestSuite_Add (suite, "/Util/ts-pool", "", test_ts_pool_simple); + TestSuite_Add (suite, "/Util/ts-pool-special", "", test_ts_pool_special); } diff --git a/src/libmongoc/tests/test-mongoc-uri.c b/src/libmongoc/tests/test-mongoc-uri.c index 2a40b0bab5a..ae4b82b97e7 100644 --- a/src/libmongoc/tests/test-mongoc-uri.c +++ b/src/libmongoc/tests/test-mongoc-uri.c @@ -905,11 +905,12 @@ test_mongoc_host_list_from_string (void) "Could not parse address"); capture_logs (true); - ASSERT (!_mongoc_host_list_from_string (&host_list, "[::1]extra_chars:27017")); + ASSERT ( + !_mongoc_host_list_from_string (&host_list, "[::1]extra_chars:27017")); ASSERT_CAPTURED_LOG ("_mongoc_host_list_from_string", MONGOC_LOG_LEVEL_ERROR, "If present, port should immediately follow the \"]\"" - "in an IPv6 address"); + "in an IPv6 address"); /* normal parsing, host and port are split, host is downcased */ ASSERT (_mongoc_host_list_from_string (&host_list, "localHOST:27019")); @@ -2686,50 +2687,57 @@ test_one_tls_option_enables_tls () static void test_casing_options () { - mongoc_uri_t* uri; + mongoc_uri_t *uri; bson_error_t error; - uri = mongoc_uri_new("mongodb://localhost:27017/"); + uri = mongoc_uri_new ("mongodb://localhost:27017/"); mongoc_uri_set_option_as_bool (uri, "TLS", true); - mongoc_uri_parse_options(uri, "ssl=false", false, &error); - ASSERT_ERROR_CONTAINS(error, MONGOC_ERROR_COMMAND, MONGOC_ERROR_COMMAND_INVALID_ARG, + mongoc_uri_parse_options (uri, "ssl=false", false, &error); + ASSERT_ERROR_CONTAINS (error, + MONGOC_ERROR_COMMAND, + MONGOC_ERROR_COMMAND_INVALID_ARG, "conflicts"); - mongoc_uri_destroy(uri); + mongoc_uri_destroy (uri); } void test_uri_install (TestSuite *suite) { - TestSuite_Add (suite, "/Uri/new", test_mongoc_uri_new); - TestSuite_Add (suite, "/Uri/new_with_error", test_mongoc_uri_new_with_error); + TestSuite_Add (suite, "/Uri/new", "", test_mongoc_uri_new); + TestSuite_Add ( + suite, "/Uri/new_with_error", "", test_mongoc_uri_new_with_error); TestSuite_Add ( - suite, "/Uri/new_for_host_port", test_mongoc_uri_new_for_host_port); - TestSuite_Add (suite, "/Uri/compressors", test_mongoc_uri_compressors); - TestSuite_Add (suite, "/Uri/unescape", test_mongoc_uri_unescape); - TestSuite_Add (suite, "/Uri/read_prefs", test_mongoc_uri_read_prefs); - TestSuite_Add (suite, "/Uri/read_concern", test_mongoc_uri_read_concern); - TestSuite_Add (suite, "/Uri/write_concern", test_mongoc_uri_write_concern); + suite, "/Uri/new_for_host_port", "", test_mongoc_uri_new_for_host_port); + TestSuite_Add (suite, "/Uri/compressors", "", test_mongoc_uri_compressors); + TestSuite_Add (suite, "/Uri/unescape", "", test_mongoc_uri_unescape); + TestSuite_Add (suite, "/Uri/read_prefs", "", test_mongoc_uri_read_prefs); + TestSuite_Add (suite, "/Uri/read_concern", "", test_mongoc_uri_read_concern); TestSuite_Add ( - suite, "/HostList/from_string", test_mongoc_host_list_from_string); + suite, "/Uri/write_concern", "", test_mongoc_uri_write_concern); + TestSuite_Add ( + suite, "/HostList/from_string", "", test_mongoc_host_list_from_string); TestSuite_Add (suite, "/Uri/auth_mechanism_properties", + "", test_mongoc_uri_authmechanismproperties); - TestSuite_Add (suite, "/Uri/functions", test_mongoc_uri_functions); - TestSuite_Add (suite, "/Uri/ssl", test_mongoc_uri_ssl); - TestSuite_Add (suite, "/Uri/tls", test_mongoc_uri_tls); + TestSuite_Add (suite, "/Uri/functions", "", test_mongoc_uri_functions); + TestSuite_Add (suite, "/Uri/ssl", "", test_mongoc_uri_ssl); + TestSuite_Add (suite, "/Uri/tls", "", test_mongoc_uri_tls); + TestSuite_Add ( + suite, "/Uri/compound_setters", "", test_mongoc_uri_compound_setters); TestSuite_Add ( - suite, "/Uri/compound_setters", test_mongoc_uri_compound_setters); - TestSuite_Add (suite, "/Uri/long_hostname", test_mongoc_uri_long_hostname); + suite, "/Uri/long_hostname", "", test_mongoc_uri_long_hostname); TestSuite_Add ( - suite, "/Uri/local_threshold_ms", test_mongoc_uri_local_threshold_ms); - TestSuite_Add (suite, "/Uri/srv", test_mongoc_uri_srv); - TestSuite_Add (suite, "/Uri/dns_options", test_mongoc_uri_dns_options); - TestSuite_Add (suite, "/Uri/utf8", test_mongoc_uri_utf8); - TestSuite_Add (suite, "/Uri/duplicates", test_mongoc_uri_duplicates); - TestSuite_Add (suite, "/Uri/int_options", test_mongoc_uri_int_options); + suite, "/Uri/local_threshold_ms", "", test_mongoc_uri_local_threshold_ms); + TestSuite_Add (suite, "/Uri/srv", "", test_mongoc_uri_srv); + TestSuite_Add (suite, "/Uri/dns_options", "", test_mongoc_uri_dns_options); + TestSuite_Add (suite, "/Uri/utf8", "", test_mongoc_uri_utf8); + TestSuite_Add (suite, "/Uri/duplicates", "", test_mongoc_uri_duplicates); + TestSuite_Add (suite, "/Uri/int_options", "", test_mongoc_uri_int_options); TestSuite_Add (suite, "/Uri/one_tls_option_enables_tls", + "", test_one_tls_option_enables_tls); - TestSuite_Add(suite, "/Uri/options_casing", test_casing_options); + TestSuite_Add (suite, "/Uri/options_casing", "", test_casing_options); } diff --git a/src/libmongoc/tests/test-mongoc-usleep.c b/src/libmongoc/tests/test-mongoc-usleep.c index 9bbdf342851..f3f6d703c83 100644 --- a/src/libmongoc/tests/test-mongoc-usleep.c +++ b/src/libmongoc/tests/test-mongoc-usleep.c @@ -21,6 +21,7 @@ test_usleep_install (TestSuite *suite) { TestSuite_AddFull (suite, "/Sleep/basic", + "", test_mongoc_usleep_basic, NULL /* dtor */, NULL /* dtor */, diff --git a/src/libmongoc/tests/test-mongoc-util.c b/src/libmongoc/tests/test-mongoc-util.c index 26a7369d64b..a377bbe1450 100644 --- a/src/libmongoc/tests/test-mongoc-util.c +++ b/src/libmongoc/tests/test-mongoc-util.c @@ -67,7 +67,7 @@ test_lowercase_utf8 (void) void test_util_install (TestSuite *suite) { - TestSuite_Add (suite, "/Util/command_name", test_command_name); - TestSuite_Add (suite, "/Util/rand_simple", test_rand_simple); - TestSuite_Add (suite, "/Util/lowercase_utf8", test_lowercase_utf8); + TestSuite_Add (suite, "/Util/command_name", "", test_command_name); + TestSuite_Add (suite, "/Util/rand_simple", "", test_rand_simple); + TestSuite_Add (suite, "/Util/lowercase_utf8", "", test_lowercase_utf8); } diff --git a/src/libmongoc/tests/test-mongoc-version.c b/src/libmongoc/tests/test-mongoc-version.c index 51d93daa965..147a1bb3032 100644 --- a/src/libmongoc/tests/test-mongoc-version.c +++ b/src/libmongoc/tests/test-mongoc-version.c @@ -20,5 +20,5 @@ test_mongoc_version (void) void test_version_install (TestSuite *suite) { - TestSuite_Add (suite, "/Version", test_mongoc_version); + TestSuite_Add (suite, "/Version", "", test_mongoc_version); } diff --git a/src/libmongoc/tests/test-mongoc-versioned-api.c b/src/libmongoc/tests/test-mongoc-versioned-api.c index 15baea13af8..6be4843f38f 100644 --- a/src/libmongoc/tests/test-mongoc-versioned-api.c +++ b/src/libmongoc/tests/test-mongoc-versioned-api.c @@ -179,13 +179,17 @@ test_client_versioned_api_install (TestSuite *suite) run_unified_tests (suite, JSON_DIR "/versioned_api"); TestSuite_Add ( - suite, "/VersionedApi/client", _test_mongoc_server_api_client); - TestSuite_Add ( - suite, "/VersionedApi/client_pool", _test_mongoc_server_api_client_pool); + suite, "/VersionedApi/client", "", _test_mongoc_server_api_client); + TestSuite_Add (suite, + "/VersionedApi/client_pool", + "", + _test_mongoc_server_api_client_pool); TestSuite_Add (suite, "/VersionedApi/client_pool_once", + "", _test_mongoc_server_api_client_pool_once); - TestSuite_Add (suite, "/VersionedApi/copy", _test_mongoc_server_api_copy); TestSuite_Add ( - suite, "/VersionedApi/setters", _test_mongoc_server_api_setters); + suite, "/VersionedApi/copy", "", _test_mongoc_server_api_copy); + TestSuite_Add ( + suite, "/VersionedApi/setters", "", _test_mongoc_server_api_setters); } diff --git a/src/libmongoc/tests/test-mongoc-with-transaction.c b/src/libmongoc/tests/test-mongoc-with-transaction.c index ec57bf09b7d..ebbf03b528a 100644 --- a/src/libmongoc/tests/test-mongoc-with-transaction.c +++ b/src/libmongoc/tests/test-mongoc-with-transaction.c @@ -81,6 +81,7 @@ test_with_transaction_install (TestSuite *suite) { TestSuite_AddFull (suite, "/with_transaction/timeout_tests", + "", test_with_transaction_timeout, NULL, NULL, diff --git a/src/libmongoc/tests/test-mongoc-write-commands.c b/src/libmongoc/tests/test-mongoc-write-commands.c index 77acaee3fcd..c64ffc500bb 100644 --- a/src/libmongoc/tests/test-mongoc-write-commands.c +++ b/src/libmongoc/tests/test-mongoc-write-commands.c @@ -752,33 +752,45 @@ _test_invalid_wc_server_error (void *unused) void test_write_command_install (TestSuite *suite) { - TestSuite_AddLive (suite, "/WriteCommand/split_insert", test_split_insert); TestSuite_AddLive ( - suite, "/WriteCommand/bypass_not_sent", test_bypass_not_sent); + suite, "/WriteCommand/split_insert", "", test_split_insert); TestSuite_AddLive ( - suite, "/WriteCommand/invalid_write_concern", test_invalid_write_concern); + suite, "/WriteCommand/bypass_not_sent", "", test_bypass_not_sent); + TestSuite_AddLive (suite, + "/WriteCommand/invalid_write_concern", + "", + test_invalid_write_concern); TestSuite_AddFull (suite, "/WriteCommand/bypass_validation", + "", test_bypass_validation, NULL, NULL, test_framework_skip_if_max_wire_version_less_than_4); TestSuite_AddMockServerTest (suite, "/WriteCommand/split_opquery_with_options", + "", test_split_opquery_with_options); TestSuite_AddMockServerTest (suite, "/WriteCommand/insert_disconnect_mid_batch", + "", test_opmsg_disconnect_mid_batch); - TestSuite_AddMockServerTest ( - suite, "/WriteCommand/w0_legacy_insert_many", test_w0_legacy_insert_many); - TestSuite_AddMockServerTest ( - suite, "/WriteCommand/w0_legacy_update_one", test_w0_legacy_update_one); + TestSuite_AddMockServerTest (suite, + "/WriteCommand/w0_legacy_insert_many", + "", + test_w0_legacy_insert_many); + TestSuite_AddMockServerTest (suite, + "/WriteCommand/w0_legacy_update_one", + "", + test_w0_legacy_update_one); TestSuite_AddMockServerTest ( suite, "/WriteCommand/w0_legacy_update_and_replace_validation", + "", test_w0_legacy_update_and_replace_validation); TestSuite_AddFull (suite, "/WriteCommand/invalid_wc_server_error", + "", _test_invalid_wc_server_error, NULL, NULL, diff --git a/src/libmongoc/tests/test-mongoc-write-concern.c b/src/libmongoc/tests/test-mongoc-write-concern.c index 2e667cd689c..19fc5f2ee17 100644 --- a/src/libmongoc/tests/test-mongoc-write-concern.c +++ b/src/libmongoc/tests/test-mongoc-write-concern.c @@ -746,41 +746,54 @@ test_fam_session_txn (void *unused) void test_write_concern_install (TestSuite *suite) { - TestSuite_Add (suite, "/WriteConcern/append", test_write_concern_append); - TestSuite_Add (suite, "/WriteConcern/basic", test_write_concern_basic); + TestSuite_Add (suite, "/WriteConcern/append", "", test_write_concern_append); + TestSuite_Add (suite, "/WriteConcern/basic", "", test_write_concern_basic); TestSuite_Add (suite, "/WriteConcern/bson_omits_defaults", + "", test_write_concern_bson_omits_defaults); TestSuite_Add (suite, "/WriteConcern/bson_includes_false_fsync_and_journal", + "", test_write_concern_bson_includes_false_fsync_and_journal); TestSuite_Add (suite, "/WriteConcern/fsync_and_journal_gle_and_validity", + "", test_write_concern_fsync_and_journal_w1_and_validity); TestSuite_Add (suite, "/WriteConcern/wtimeout_validity", + "", test_write_concern_wtimeout_validity); - TestSuite_Add ( - suite, "/WriteConcern/from_iterator", test_write_concern_from_iterator); - TestSuite_Add ( - suite, "/WriteConcern/always_mutable", test_write_concern_always_mutable); + TestSuite_Add (suite, + "/WriteConcern/from_iterator", + "", + test_write_concern_from_iterator); + TestSuite_Add (suite, + "/WriteConcern/always_mutable", + "", + test_write_concern_always_mutable); TestSuite_Add (suite, "/WriteConcern/wtimeout_preserved", + "", test_write_concern_wtimeout_preserved); TestSuite_AddMockServerTest ( - suite, "/WriteConcern/allowed", test_write_concern_allowed); + suite, "/WriteConcern/allowed", "", test_write_concern_allowed); TestSuite_AddMockServerTest ( - suite, "/WriteConcern/prohibited", test_write_concern_prohibited); - TestSuite_AddLive ( - suite, "/WriteConcern/unacknowledged", test_write_concern_unacknowledged); + suite, "/WriteConcern/prohibited", "", test_write_concern_prohibited); + TestSuite_AddLive (suite, + "/WriteConcern/unacknowledged", + "", + test_write_concern_unacknowledged); TestSuite_AddFull (suite, "/WriteConcern/inherited_fam", + "", test_fam_no_session_no_txn, NULL, NULL, test_framework_skip_if_max_wire_version_less_than_4); TestSuite_AddFull (suite, "/WriteConcern/inherited_fam_session_no_txn", + "", test_fam_session_no_txn, NULL, NULL, @@ -788,6 +801,7 @@ test_write_concern_install (TestSuite *suite) test_framework_skip_if_no_txns); TestSuite_AddFull (suite, "/WriteConcern/inherited_fam_txn", + "", test_fam_session_txn, NULL, NULL, diff --git a/src/libmongoc/tests/test-mongoc-x509.c b/src/libmongoc/tests/test-mongoc-x509.c index 0a1c6d36a0e..79757240ad4 100644 --- a/src/libmongoc/tests/test-mongoc-x509.c +++ b/src/libmongoc/tests/test-mongoc-x509.c @@ -90,10 +90,11 @@ void test_x509_install (TestSuite *suite) { #if defined(MONGOC_ENABLE_SSL) && !defined(MONGOC_ENABLE_SSL_LIBRESSL) - TestSuite_Add (suite, "/X509/extract_subject", test_extract_subject); + TestSuite_Add (suite, "/X509/extract_subject", "", test_extract_subject); #endif #ifdef MONGOC_ENABLE_OCSP_OPENSSL - TestSuite_Add (suite, "/X509/tlsfeature_parsing", test_tlsfeature_parsing); + TestSuite_Add ( + suite, "/X509/tlsfeature_parsing", "", test_tlsfeature_parsing); #endif } diff --git a/src/libmongoc/tests/unified/result.c b/src/libmongoc/tests/unified/result.c index 6b06209f5e3..303cdebafe6 100644 --- a/src/libmongoc/tests/unified/result.c +++ b/src/libmongoc/tests/unified/result.c @@ -568,6 +568,8 @@ test_resultfrombulkwrite (void) void test_result_install (TestSuite *suite) { - TestSuite_Add ( - suite, "/unified/result/resultfrombulkwrite", test_resultfrombulkwrite); + TestSuite_Add (suite, + "/unified/result/resultfrombulkwrite", + "", + test_resultfrombulkwrite); } diff --git a/src/libmongoc/tests/unified/util.c b/src/libmongoc/tests/unified/util.c index 51d4ec9db37..7cc99018e6e 100644 --- a/src/libmongoc/tests/unified/util.c +++ b/src/libmongoc/tests/unified/util.c @@ -161,7 +161,7 @@ void test_bson_util_install (TestSuite *suite) { TestSuite_Add ( - suite, "/unified/selftest/util/copy_and_sort", test_copy_and_sort); + suite, "/unified/selftest/util/copy_and_sort", "", test_copy_and_sort); } /* TODO (CDRIVER-3525) add test support for CMAP events once the C driver From a8c6fcd30e99227cbaf08df4ecfebc9d83ee32c4 Mon Sep 17 00:00:00 2001 From: vector-of-bool Date: Wed, 15 Dec 2021 22:52:18 +0000 Subject: [PATCH 23/52] Add a 'uses-live-server' meta tag to identify which tests need a live server test fixture --- build/cmake/LoadTests.cmake | 20 +- src/libmongoc/tests/test-mongoc-bulk.c | 24 +- .../tests/test-mongoc-change-stream.c | 50 +++-- src/libmongoc/tests/test-mongoc-client-pool.c | 2 +- .../tests/test-mongoc-client-session.c | 209 +++++++++++------- src/libmongoc/tests/test-mongoc-client.c | 6 +- .../test-mongoc-collection-find-with-opts.c | 2 +- .../tests/test-mongoc-collection-find.c | 2 +- src/libmongoc/tests/test-mongoc-collection.c | 38 ++-- .../tests/test-mongoc-command-monitoring.c | 2 +- src/libmongoc/tests/test-mongoc-counters.c | 12 +- src/libmongoc/tests/test-mongoc-crud.c | 4 +- src/libmongoc/tests/test-mongoc-cursor.c | 38 ++-- src/libmongoc/tests/test-mongoc-database.c | 2 +- src/libmongoc/tests/test-mongoc-exhaust.c | 6 +- .../tests/test-mongoc-find-and-modify.c | 2 +- .../tests/test-mongoc-gridfs-bucket.c | 4 +- src/libmongoc/tests/test-mongoc-gridfs.c | 4 +- .../tests/test-mongoc-max-staleness.c | 8 +- .../tests/test-mongoc-mongos-pinning.c | 4 +- .../tests/test-mongoc-primary-stepdown.c | 10 +- .../tests/test-mongoc-retryable-reads.c | 4 +- .../tests/test-mongoc-retryable-writes.c | 6 +- .../tests/test-mongoc-sample-commands.c | 2 +- src/libmongoc/tests/test-mongoc-sdam.c | 8 +- .../test-mongoc-server-selection-errors.c | 4 +- .../tests/test-mongoc-topology-reconcile.c | 2 +- .../tests/test-mongoc-topology-scanner.c | 4 +- src/libmongoc/tests/test-mongoc-topology.c | 18 +- .../tests/test-mongoc-transactions.c | 16 +- .../tests/test-mongoc-with-transaction.c | 2 +- .../tests/test-mongoc-write-commands.c | 4 +- .../tests/test-mongoc-write-concern.c | 6 +- 33 files changed, 297 insertions(+), 228 deletions(-) diff --git a/build/cmake/LoadTests.cmake b/build/cmake/LoadTests.cmake index cb5135a66cf..d3fd6a11f57 100644 --- a/build/cmake/LoadTests.cmake +++ b/build/cmake/LoadTests.cmake @@ -28,7 +28,7 @@ string (REPLACE "\n" ";" lines "${tests_out}") function (_register_test name ctest_run) # Define the test. Use `--ctest-run` to tell it that CTest is in control. - add_test ("${name}" "${TEST_LIBMONGOC_EXE}" --ctest-run "${line}" ${ARGN}) + add_test ("${name}" "${TEST_LIBMONGOC_EXE}" --ctest-run "${ctest_run}" ${ARGN}) set_tests_properties ("${name}" PROPERTIES # test-libmongoc expects to execute in the root of the source directory WORKING_DIRECTORY "${SRC_ROOT}" @@ -47,17 +47,27 @@ foreach (line IN LISTS lines) continue () endif () # The new test name is prefixed with 'mongoc' - set (test "mongoc${line}") - if (NOT _MDB_TEST_FIXTURES_AUTO_USE) - _register_test ("${test}" "${line}") + separate_arguments (listing UNIX_COMMAND "${line}") + list (GET listing 0 test_name) + set (meta "${listing}") + list (REMOVE_AT meta 0) + set (test "mongoc${test_name}") + if (NOT _MDB_TEST_FIXTURES_AUTO_USE OR NOT (meta MATCHES "uses-live-server")) + _register_test ("${test}" "${test_name}") + set_tests_properties ("${test}" PROPERTIES + TIMEOUT 15 + LABELS "${meta}" + ) else () foreach (fxt IN LISTS _MDB_TEST_FIXTURES_AUTO_USE) set (qualname "${fxt}/${test}") - _register_test ("${qualname}" "${line}") + _register_test ("${qualname}" "${test_name}") set_tests_properties ("${qualname}" PROPERTIES FIXTURES_REQUIRED "${fxt}" RESOURCE_LOCK "${fxt}" ENVIRONMENT "MONGOC_TEST_URI=mongodb://localhost:${_MDB_FIXTURE_${fxt}_PORT}" + TIMEOUT 15 + LABELS "${meta}" ) endforeach () endif () diff --git a/src/libmongoc/tests/test-mongoc-bulk.c b/src/libmongoc/tests/test-mongoc-bulk.c index 8106046aff3..864b0b9fc8a 100644 --- a/src/libmongoc/tests/test-mongoc-bulk.c +++ b/src/libmongoc/tests/test-mongoc-bulk.c @@ -4877,21 +4877,21 @@ test_bulk_install (TestSuite *suite) suite, "/BulkOperation/upsert_unordered", "", test_upsert_unordered); TestSuite_AddFull (suite, "/BulkOperation/upsert_unordered_oversized", - "", + "uses-live-server", test_upsert_unordered_oversized, NULL, NULL, test_framework_skip_if_slow_or_live); TestSuite_AddFull (suite, "/BulkOperation/upsert_large", - "", + "uses-live-server", test_upsert_large, NULL, NULL, test_framework_skip_if_slow_or_live); TestSuite_AddFull (suite, "/BulkOperation/upsert_huge", - "", + "uses-live-server", test_upsert_huge, NULL, NULL, @@ -4916,14 +4916,14 @@ test_bulk_install (TestSuite *suite) test_update_with_opts_validate); TestSuite_AddFull (suite, "/BulkOperation/update_arrayfilters", - "", + "uses-live-server", test_update_arrayfilters, NULL, NULL, test_framework_skip_if_max_wire_version_less_than_6); TestSuite_AddFull (suite, "/BulkOperation/update_arrayfilters/unsupported", - "", + "uses-live-server", test_update_arrayfilters_unsupported, NULL, NULL, @@ -4992,14 +4992,14 @@ test_bulk_install (TestSuite *suite) test_single_error_unordered_bulk); TestSuite_AddFull (suite, "/BulkOperation/oversized/ordered", - "", + "uses-live-server", test_oversized_bulk_op_ordered, NULL, NULL, test_framework_skip_if_slow_or_live); TestSuite_AddFull (suite, "/BulkOperation/oversized/unordered", - "", + "uses-live-server", test_oversized_bulk_op_unordered, NULL, NULL, @@ -5049,28 +5049,28 @@ test_bulk_install (TestSuite *suite) test_wtimeout_plus_duplicate_key_err_write_commands); TestSuite_AddFull (suite, "/BulkOperation/large_inserts_ordered", - "", + "uses-live-server", test_large_inserts_ordered, NULL, NULL, test_framework_skip_if_slow_or_live); TestSuite_AddFull (suite, "/BulkOperation/large_inserts_unordered", - "", + "uses-live-server", test_large_inserts_unordered, NULL, NULL, test_framework_skip_if_slow_or_live); TestSuite_AddFull (suite, "/BulkOperation/numerous_ordered", - "", + "uses-live-server", test_numerous_ordered, NULL, NULL, test_framework_skip_if_slow_or_live); TestSuite_AddFull (suite, "/BulkOperation/numerous_unordered", - "", + "uses-live-server", test_numerous_unordered, NULL, NULL, @@ -5093,7 +5093,7 @@ test_bulk_install (TestSuite *suite) TestSuite_AddLive (suite, "/BulkOperation/split", "", test_bulk_split); TestSuite_AddFull (suite, "/BulkOperation/write_concern/split", - "", + "uses-live-server", test_bulk_write_concern_split, NULL /* dtor */, NULL /* ctx */, diff --git a/src/libmongoc/tests/test-mongoc-change-stream.c b/src/libmongoc/tests/test-mongoc-change-stream.c index df0872b7db8..810af878cff 100644 --- a/src/libmongoc/tests/test-mongoc-change-stream.c +++ b/src/libmongoc/tests/test-mongoc-change-stream.c @@ -2615,7 +2615,7 @@ test_change_stream_install (TestSuite *suite) TestSuite_AddFull (suite, "/change_stream/live/single_server", - "", + "uses-live-server", test_change_stream_live_single_server, NULL, NULL, @@ -2623,7 +2623,7 @@ test_change_stream_install (TestSuite *suite) TestSuite_AddFull (suite, "/change_stream/live/track_resume_token", - "", + "uses-live-server", test_change_stream_live_track_resume_token, NULL, NULL, @@ -2632,7 +2632,7 @@ test_change_stream_install (TestSuite *suite) TestSuite_AddFull (suite, "/change_stream/live/batch_size", - "", + "uses-live-server", test_change_stream_live_batch_size, NULL, NULL, @@ -2640,7 +2640,7 @@ test_change_stream_install (TestSuite *suite) TestSuite_AddFull (suite, "/change_stream/live/missing_resume_token", - "", + "uses-live-server", test_change_stream_live_missing_resume_token, NULL, NULL, @@ -2648,7 +2648,7 @@ test_change_stream_install (TestSuite *suite) TestSuite_AddFull (suite, "/change_stream/live/invalid_resume_token", - "", + "uses-live-server", test_change_stream_live_invalid_resume_token, NULL, NULL, @@ -2664,7 +2664,7 @@ test_change_stream_install (TestSuite *suite) TestSuite_AddFull (suite, "/change_stream/live/watch", - "", + "uses-live-server", test_change_stream_live_watch, NULL, NULL, @@ -2672,7 +2672,7 @@ test_change_stream_install (TestSuite *suite) TestSuite_AddFull (suite, "/change_stream/live/read_prefs", - "", + "uses-live-server", test_change_stream_live_read_prefs, NULL, NULL, @@ -2686,7 +2686,7 @@ test_change_stream_install (TestSuite *suite) TestSuite_AddFull (suite, "/change_stream/next_after_error", - "", + "uses-live-server", test_change_stream_next_after_error, NULL, NULL, @@ -2694,7 +2694,7 @@ test_change_stream_install (TestSuite *suite) TestSuite_AddFull (suite, "/change_stream/accepts_array", - "", + "uses-live-server", test_change_stream_accepts_array, NULL, NULL, @@ -2703,7 +2703,7 @@ test_change_stream_install (TestSuite *suite) suite, "/change_stream/getmore_errors", "", test_getmore_errors); TestSuite_AddFull (suite, "/change_stream/start_at_operation_time", - "", + "uses-live-server", test_change_stream_start_at_operation_time, NULL, NULL, @@ -2712,7 +2712,7 @@ test_change_stream_install (TestSuite *suite) _skip_if_no_start_at_optime); TestSuite_AddFull (suite, "/change_stream/resume_at_optime", - "", + "uses-live-server", test_change_stream_resume_at_optime, NULL, NULL, @@ -2722,7 +2722,7 @@ test_change_stream_install (TestSuite *suite) test_framework_skip_if_no_failpoint); TestSuite_AddFull (suite, "/change_stream/resume_with_post_batch_resume_token", - "", + "uses-live-server", test_change_stream_resume_with_post_batch_resume_token, NULL, NULL, @@ -2732,14 +2732,14 @@ test_change_stream_install (TestSuite *suite) test_framework_skip_if_no_failpoint); TestSuite_AddFull (suite, "/change_stream/database", - "", + "uses-live-server", test_change_stream_database_watch, NULL, NULL, _skip_if_no_db_watch); TestSuite_AddFull (suite, "/change_stream/client", - "", + "uses-live-server", test_change_stream_client_watch, NULL, NULL, @@ -2753,14 +2753,14 @@ test_change_stream_install (TestSuite *suite) test_resume_cases_with_post_batch_resume_token); TestSuite_AddFull (suite, "/change_stream/error_null_doc", - "", + "uses-live-server", test_error_null_doc, NULL, NULL, _skip_if_no_client_watch); TestSuite_AddFull (suite, "/change_stream/live/prose_test_11", - "", + "uses-live-server", prose_test_11, NULL, NULL, @@ -2768,7 +2768,7 @@ test_change_stream_install (TestSuite *suite) test_framework_skip_if_max_wire_version_less_than_8); TestSuite_AddFull (suite, "/change_stream/live/prose_test_12", - "", + "uses-live-server", prose_test_12, NULL, NULL, @@ -2776,7 +2776,7 @@ test_change_stream_install (TestSuite *suite) test_framework_skip_if_max_wire_version_more_than_7); TestSuite_AddFull (suite, "/change_stream/live/prose_test_13", - "", + "uses-live-server", prose_test_13, NULL, NULL, @@ -2784,16 +2784,20 @@ test_change_stream_install (TestSuite *suite) _skip_if_no_start_at_optime); TestSuite_AddFull (suite, "/change_stream/live/prose_test_14", - "", + "uses-live-server", prose_test_14, NULL, NULL, test_framework_skip_if_mongos, test_framework_skip_if_not_rs_version_7); - TestSuite_AddMockServerTest ( - suite, "/change_streams/prose_test_17", "", prose_test_17); - TestSuite_AddMockServerTest ( - suite, "/change_streams/prose_test_18", "", prose_test_18); + TestSuite_AddMockServerTest (suite, + "/change_streams/prose_test_17", + "uses-live-server", + prose_test_17); + TestSuite_AddMockServerTest (suite, + "/change_streams/prose_test_18", + "uses-live-server", + prose_test_18); install_json_test_suite ( suite, JSON_DIR, "change_streams/legacy", &test_change_stream_spec_cb); diff --git a/src/libmongoc/tests/test-mongoc-client-pool.c b/src/libmongoc/tests/test-mongoc-client-pool.c index 9f377fc13d6..1b7937f7199 100644 --- a/src/libmongoc/tests/test-mongoc-client-pool.c +++ b/src/libmongoc/tests/test-mongoc-client-pool.c @@ -500,7 +500,7 @@ test_client_pool_install (TestSuite *suite) TestSuite_AddFull (suite, "/ClientPool/create_client_pool_unused_session", - "", + "uses-live-server", test_client_pool_create_unused_session, NULL /* dtor */, NULL /* ctx */, diff --git a/src/libmongoc/tests/test-mongoc-client-session.c b/src/libmongoc/tests/test-mongoc-client-session.c index d87b87d8878..15f40a43d0c 100644 --- a/src/libmongoc/tests/test-mongoc-client-session.c +++ b/src/libmongoc/tests/test-mongoc-client-session.c @@ -2806,7 +2806,7 @@ test_session_install (TestSuite *suite) test_session_opts_causal_consistency_and_snapshot); TestSuite_AddFull (suite, "/Session/no_crypto", - "", + "uses-live-server", test_session_no_crypto, NULL, NULL, @@ -2815,7 +2815,7 @@ test_session_install (TestSuite *suite) test_framework_skip_if_crypto); TestSuite_AddFull (suite, "/Session/lifo/single", - "", + "uses-live-server", test_session_pool_lifo_single, NULL, NULL, @@ -2823,7 +2823,7 @@ test_session_install (TestSuite *suite) test_framework_skip_if_no_crypto); TestSuite_AddFull (suite, "/Session/lifo/pooled", - "", + "uses-live-server", test_session_pool_lifo_pooled, NULL, NULL, @@ -2831,7 +2831,7 @@ test_session_install (TestSuite *suite) test_framework_skip_if_no_crypto); TestSuite_AddFull (suite, "/Session/timeout/single", - "", + "uses-live-server", test_session_pool_timeout_single, NULL, NULL, @@ -2840,7 +2840,7 @@ test_session_install (TestSuite *suite) test_framework_skip_if_slow); TestSuite_AddFull (suite, "/Session/timeout/pooled", - "", + "uses-live-server", test_session_pool_timeout_pooled, NULL, NULL, @@ -2849,7 +2849,7 @@ test_session_install (TestSuite *suite) test_framework_skip_if_slow); TestSuite_AddFull (suite, "/Session/reap/single", - "", + "uses-live-server", test_session_pool_reap_single, NULL, NULL, @@ -2858,7 +2858,7 @@ test_session_install (TestSuite *suite) test_framework_skip_if_slow); TestSuite_AddFull (suite, "/Session/reap/pooled", - "", + "uses-live-server", test_session_pool_reap_pooled, NULL, NULL, @@ -2867,7 +2867,7 @@ test_session_install (TestSuite *suite) test_framework_skip_if_slow); TestSuite_AddFull (suite, "/Session/id_bad", - "", + "uses-live-server", test_session_id_bad, NULL, NULL, @@ -2875,7 +2875,7 @@ test_session_install (TestSuite *suite) test_framework_skip_if_no_crypto); TestSuite_AddFull (suite, "/Session/supported/single", - "", + "uses-live-server", test_session_supported_single, NULL, NULL, @@ -2883,7 +2883,7 @@ test_session_install (TestSuite *suite) test_framework_skip_if_no_crypto); TestSuite_AddFull (suite, "/Session/supported/pooled", - "", + "uses-live-server", test_session_supported_pooled, NULL, NULL, @@ -2906,7 +2906,7 @@ test_session_install (TestSuite *suite) test_framework_skip_if_no_crypto); TestSuite_AddFull (suite, "/Session/end/single", - "", + "uses-live-server", test_end_sessions_single, NULL, NULL, @@ -2914,7 +2914,7 @@ test_session_install (TestSuite *suite) test_framework_skip_if_max_wire_version_less_than_6); TestSuite_AddFull (suite, "/Session/end/pooled", - "", + "uses-live-server", test_end_sessions_pooled, NULL, NULL, @@ -2922,7 +2922,7 @@ test_session_install (TestSuite *suite) test_framework_skip_if_max_wire_version_less_than_6); TestSuite_AddFull (suite, "/Session/end/many/single", - "", + "uses-live-server", test_end_sessions_many_single, NULL, NULL, @@ -2931,7 +2931,7 @@ test_session_install (TestSuite *suite) test_framework_skip_if_slow); TestSuite_AddFull (suite, "/Session/end/many/pooled", - "", + "uses-live-server", test_end_sessions_many_pooled, NULL, NULL, @@ -2940,7 +2940,7 @@ test_session_install (TestSuite *suite) test_framework_skip_if_slow); TestSuite_AddFull (suite, "/Session/advance_cluster_time", - "", + "uses-live-server", test_session_advance_cluster_time, NULL, NULL, @@ -2948,7 +2948,7 @@ test_session_install (TestSuite *suite) test_framework_skip_if_no_sessions); TestSuite_AddFull (suite, "/Session/advance_operation_time", - "", + "uses-live-server", test_session_advance_operation_time, NULL, NULL, @@ -2957,64 +2957,119 @@ test_session_install (TestSuite *suite) /* "true" is for tests that expect readConcern: afterClusterTime for causally * consistent sessions, "false" is for tests that prohibit readConcern */ - add_session_test (suite, "/Session/cmd", "", test_cmd, false); - add_session_test (suite, "/Session/read_cmd", "", test_read_cmd, true); - add_session_test (suite, "/Session/write_cmd", "", test_write_cmd, false); add_session_test ( - suite, "/Session/read_write_cmd", "", test_read_write_cmd, true); - add_session_test (suite, "/Session/db_cmd", "", test_db_cmd, false); + suite, "/Session/cmd", "uses-live-server", test_cmd, false); + add_session_test ( + suite, "/Session/read_cmd", "uses-live-server", test_read_cmd, true); + add_session_test ( + suite, "/Session/write_cmd", "uses-live-server", test_write_cmd, false); + add_session_test (suite, + "/Session/read_write_cmd", + "uses-live-server", + test_read_write_cmd, + true); + add_session_test ( + suite, "/Session/db_cmd", "uses-live-server", test_db_cmd, false); TestSuite_AddFullWithTestFn (suite, "/Session/count", - "", + "uses-live-server", (TestFuncWC) run_count_test, NULL, test_count, test_framework_skip_if_no_cluster_time, test_framework_skip_if_no_crypto); - add_session_test (suite, "/Session/cursor", "", test_cursor, true); - add_session_test (suite, "/Session/drop", "", test_drop, false); - add_session_test (suite, "/Session/drop_index", "", test_drop_index, false); add_session_test ( - suite, "/Session/create_index", "", test_create_index, false); + suite, "/Session/cursor", "uses-live-server", test_cursor, true); + add_session_test ( + suite, "/Session/drop", "uses-live-server", test_drop, false); add_session_test ( - suite, "/Session/replace_one", "", test_replace_one, false); - add_session_test (suite, "/Session/update_one", "", test_update_one, false); + suite, "/Session/drop_index", "uses-live-server", test_drop_index, false); + add_session_test (suite, + "/Session/create_index", + "uses-live-server", + test_create_index, + false); + add_session_test (suite, + "/Session/replace_one", + "uses-live-server", + test_replace_one, + false); add_session_test ( - suite, "/Session/update_many", "", test_update_many, false); - add_session_test (suite, "/Session/insert_one", "", test_insert_one, false); + suite, "/Session/update_one", "uses-live-server", test_update_one, false); + add_session_test (suite, + "/Session/update_many", + "uses-live-server", + test_update_many, + false); add_session_test ( - suite, "/Session/insert_many", "", test_insert_many, false); - add_session_test (suite, "/Session/delete_one", "", test_delete_one, false); + suite, "/Session/insert_one", "uses-live-server", test_insert_one, false); + add_session_test (suite, + "/Session/insert_many", + "uses-live-server", + test_insert_many, + false); add_session_test ( - suite, "/Session/delete_many", "", test_delete_many, false); - add_session_test (suite, "/Session/rename", "", test_rename, false); - add_session_test (suite, "/Session/fam", "", test_fam, true); - add_session_test (suite, "/Session/db_drop", "", test_db_drop, false); - add_session_test (suite, "/Session/gridfs_find", "", test_gridfs_find, true); + suite, "/Session/delete_one", "uses-live-server", test_delete_one, false); + add_session_test (suite, + "/Session/delete_many", + "uses-live-server", + test_delete_many, + false); add_session_test ( - suite, "/Session/gridfs_find_one", "", test_gridfs_find_one, true); + suite, "/Session/rename", "uses-live-server", test_rename, false); + add_session_test (suite, "/Session/fam", "uses-live-server", test_fam, true); + add_session_test ( + suite, "/Session/db_drop", "uses-live-server", test_db_drop, false); + add_session_test (suite, + "/Session/gridfs_find", + "uses-live-server", + test_gridfs_find, + true); + add_session_test (suite, + "/Session/gridfs_find_one", + "uses-live-server", + test_gridfs_find_one, + true); add_session_test_wc (suite, "/Session/watch", - "", + "uses-live-server", test_watch, true, test_framework_skip_if_not_rs_version_6); - add_session_test (suite, "/Session/aggregate", "", test_aggregate, true); - add_session_test (suite, "/Session/create", "", test_create, false); - add_session_test ( - suite, "/Session/database_names", "", test_database_names, true); - add_session_test ( - suite, "/Session/find_databases", "", test_find_databases, true); add_session_test ( - suite, "/Session/find_collections", "", test_find_collections, true); + suite, "/Session/aggregate", "uses-live-server", test_aggregate, true); add_session_test ( - suite, "/Session/collection_names", "", test_collection_names, true); - add_session_test (suite, "/Session/bulk", "", test_bulk, false); + suite, "/Session/create", "uses-live-server", test_create, false); + add_session_test (suite, + "/Session/database_names", + "uses-live-server", + test_database_names, + true); + add_session_test (suite, + "/Session/find_databases", + "uses-live-server", + test_find_databases, + true); + add_session_test (suite, + "/Session/find_collections", + "uses-live-server", + test_find_collections, + true); + add_session_test (suite, + "/Session/collection_names", + "uses-live-server", + test_collection_names, + true); add_session_test ( - suite, "/Session/find_indexes", "", test_find_indexes, true); + suite, "/Session/bulk", "uses-live-server", test_bulk, false); + add_session_test (suite, + "/Session/find_indexes", + "uses-live-server", + test_find_indexes, + true); TestSuite_AddFullWithTestFn (suite, "/Session/bulk_set_session", - "", + "uses-live-server", run_session_test_bulk_operation, NULL, test_bulk_set_session, @@ -3022,7 +3077,7 @@ test_session_install (TestSuite *suite) test_framework_skip_if_no_crypto); TestSuite_AddFullWithTestFn (suite, "/Session/bulk_set_client", - "", + "uses-live-server", run_session_test_bulk_operation, NULL, test_bulk_set_client, @@ -3030,7 +3085,7 @@ test_session_install (TestSuite *suite) test_framework_skip_if_no_crypto); TestSuite_AddFull (suite, "/Session/cursor_implicit_session", - "", + "uses-live-server", test_cursor_implicit_session, NULL, NULL, @@ -3038,7 +3093,7 @@ test_session_install (TestSuite *suite) test_framework_skip_if_no_crypto); TestSuite_AddFull (suite, "/Session/change_stream_implicit_session", - "", + "uses-live-server", test_change_stream_implicit_session, NULL, NULL, @@ -3046,7 +3101,7 @@ test_session_install (TestSuite *suite) test_framework_skip_if_no_crypto); TestSuite_AddFull (suite, "/Session/cmd_error", - "", + "uses-live-server", test_cmd_error, NULL, NULL, @@ -3054,7 +3109,7 @@ test_session_install (TestSuite *suite) test_framework_skip_if_no_crypto); TestSuite_AddFull (suite, "/Session/read_concern", - "", + "uses-live-server", test_read_concern, NULL, NULL, @@ -3063,56 +3118,56 @@ test_session_install (TestSuite *suite) add_unacknowledged_test ( suite, "/Session/unacknowledged/insert_one/explicit_cs/inherit_wc", - "", + "uses-live-server", test_insert_one, true, true); add_unacknowledged_test ( suite, "/Session/unacknowledged/insert_one/explicit_cs/explicit_wc", - "", + "uses-live-server", test_insert_one, true, false); add_unacknowledged_test ( suite, "/Session/unacknowledged/insert_one/implicit_cs/inherit_wc", - "", + "uses-live-server", test_insert_one, false, true); add_unacknowledged_test ( suite, "/Session/unacknowledged/insert_one/implicit_cs/explicit_wc", - "", + "uses-live-server", test_insert_one, false, false); add_unacknowledged_test ( suite, "/Session/unacknowledged/bulk/explicit_cs/inherit_wc", - "", + "uses-live-server", test_bulk, true, true); add_unacknowledged_test ( suite, "/Session/unacknowledged/bulk/explicit_cs/explicit_wc", - "", + "uses-live-server", test_bulk, true, false); add_unacknowledged_test ( suite, "/Session/unacknowledged/bulk/implicit_cs/inherit_wc", - "", + "uses-live-server", test_bulk, false, true); add_unacknowledged_test ( suite, "/Session/unacknowledged/bulk/implicit_cs/explicit_wc", - "", + "uses-live-server", test_bulk, false, false); @@ -3123,14 +3178,14 @@ test_session_install (TestSuite *suite) add_unacknowledged_test ( suite, "/Session/unacknowledged/find_and_modify/explicit_cs/explicit_wc", - "", + "uses-live-server", test_fam, true, false); add_unacknowledged_test ( suite, "/Session/unacknowledged/find_and_modify/implicit_cs/explicit_wc", - "", + "uses-live-server", test_fam, false, false); @@ -3139,70 +3194,70 @@ test_session_install (TestSuite *suite) add_unacknowledged_test ( suite, "/Session/unacknowledged/db_cmd/explicit_cs/explicit_wc", - "", + "uses-live-server", test_db_cmd, true, false); add_unacknowledged_test ( suite, "/Session/unacknowledged/db_cmd/implicit_cs/explicit_wc", - "", + "uses-live-server", test_db_cmd, false, false); add_unacknowledged_test ( suite, "/Session/unacknowledged/read_write_cmd/explicit_cs/inherit_wc", - "", + "uses-live-server", test_read_write_cmd, true, true); add_unacknowledged_test ( suite, "/Session/unacknowledged/read_write_cmd/explicit_cs/explicit_wc", - "", + "uses-live-server", test_read_write_cmd, true, false); add_unacknowledged_test ( suite, "/Session/unacknowledged/read_write_cmd/implicit_cs/inherit_wc", - "", + "uses-live-server", test_read_write_cmd, false, true); add_unacknowledged_test ( suite, "/Session/unacknowledged/read_write_cmd/implicit_cs/explicit_wc", - "", + "uses-live-server", test_read_write_cmd, false, false); add_unacknowledged_test ( suite, "/Session/unacknowledged/write_cmd/explicit_cs/inherit_wc", - "", + "uses-live-server", test_write_cmd, true, true); add_unacknowledged_test ( suite, "/Session/unacknowledged/write_cmd/explicit_cs/explicit_wc", - "", + "uses-live-server", test_write_cmd, true, false); add_unacknowledged_test ( suite, "/Session/unacknowledged/write_cmd/implicit_cs/inherit_wc", - "", + "uses-live-server", test_write_cmd, false, true); add_unacknowledged_test ( suite, "/Session/unacknowledged/write_cmd/implicit_cs/explicit_wc", - "", + "uses-live-server", test_write_cmd, false, false); @@ -3216,7 +3271,7 @@ test_session_install (TestSuite *suite) TestSuite_AddFull ( suite, "/Session/dirty", - "", + "uses-live-server", test_session_dirty, NULL /* dtor */, NULL /* ctx */, @@ -3227,7 +3282,7 @@ test_session_install (TestSuite *suite) TestSuite_AddFull (suite, "/Session/snapshot/prose_test_1", - "", + "uses-live-server", test_sessions_snapshot_prose_test_1, NULL, NULL, diff --git a/src/libmongoc/tests/test-mongoc-client.c b/src/libmongoc/tests/test-mongoc-client.c index 1710e6d9c04..8961eea1461 100644 --- a/src/libmongoc/tests/test-mongoc-client.c +++ b/src/libmongoc/tests/test-mongoc-client.c @@ -4226,14 +4226,14 @@ test_client_install (TestSuite *suite) test_client_cmd_w_server_id_sharded); TestSuite_AddFull (suite, "/Client/command_w_server_id/option", - "", + "uses-live-server", test_server_id_option, NULL, NULL, test_framework_skip_if_auth); TestSuite_AddFull (suite, "/Client/command_w_write_concern", - "", + "uses-live-server", test_client_cmd_w_write_concern, NULL, NULL, @@ -4454,7 +4454,7 @@ test_client_install (TestSuite *suite) test_mongoc_client_descriptions_single); TestSuite_AddFull (suite, "/Client/descriptions/pooled", - "", + "uses-live-server", test_mongoc_client_descriptions_pooled, NULL, NULL, diff --git a/src/libmongoc/tests/test-mongoc-collection-find-with-opts.c b/src/libmongoc/tests/test-mongoc-collection-find-with-opts.c index 1cbd0c4cdf8..f021a7343e0 100644 --- a/src/libmongoc/tests/test-mongoc-collection-find-with-opts.c +++ b/src/libmongoc/tests/test-mongoc-collection-find-with-opts.c @@ -1053,7 +1053,7 @@ test_collection_find_with_opts_install (TestSuite *suite) test_server_id_option); TestSuite_AddFull (suite, "/Collection/find_with_opts/collation/error", - "", + "uses-live-server", test_find_with_opts_collation_error, NULL, NULL, diff --git a/src/libmongoc/tests/test-mongoc-collection-find.c b/src/libmongoc/tests/test-mongoc-collection-find.c index 14a0d67aa7d..839a6f0c850 100644 --- a/src/libmongoc/tests/test-mongoc-collection-find.c +++ b/src/libmongoc/tests/test-mongoc-collection-find.c @@ -1225,7 +1225,7 @@ test_collection_find_install (TestSuite *suite) TestSuite_AddLive (suite, "/Collection/find/fields", "", test_fields); TestSuite_AddFull (suite, "/Collection/find/modifiers/maxscan", - "", + "uses-live-server", test_maxscan, NULL, NULL, diff --git a/src/libmongoc/tests/test-mongoc-collection.c b/src/libmongoc/tests/test-mongoc-collection.c index b3dde9b1c27..7cedd5d024a 100644 --- a/src/libmongoc/tests/test-mongoc-collection.c +++ b/src/libmongoc/tests/test-mongoc-collection.c @@ -6419,14 +6419,14 @@ test_collection_install (TestSuite *suite) TestSuite_AddFull (suite, "/Collection/aggregate/write_concern", - "", + "uses-live-server", test_aggregate_w_write_concern, NULL, NULL, test_framework_skip_if_max_wire_version_less_than_5); TestSuite_AddFull (suite, "/Collection/read_prefs_is_valid", - "", + "uses-live-server", test_read_prefs_is_valid, NULL, NULL, @@ -6440,7 +6440,7 @@ test_collection_install (TestSuite *suite) suite, "/Collection/insert/null_string", "", test_insert_null); TestSuite_AddFull (suite, "/Collection/insert/oversize", - "", + "uses-live-server", test_insert_oversize, NULL, NULL, @@ -6470,7 +6470,7 @@ test_collection_install (TestSuite *suite) suite, "/Collection/index_compound", "", test_index_compound); TestSuite_AddFull (suite, "/Collection/index_geo", - "", + "uses-live-server", test_index_geo, NULL, NULL, @@ -6480,7 +6480,7 @@ test_collection_install (TestSuite *suite) TestSuite_AddLive (suite, "/Collection/regex", "", test_regex); TestSuite_AddFull (suite, "/Collection/decimal128", - "", + "uses-live-server", test_decimal128, NULL, NULL, @@ -6488,7 +6488,7 @@ test_collection_install (TestSuite *suite) TestSuite_AddLive (suite, "/Collection/update", "", test_update); TestSuite_AddFull (suite, "/Collection/update_pipeline", - "", + "uses-live-server", test_update_pipeline, NULL, NULL, @@ -6498,7 +6498,7 @@ test_collection_install (TestSuite *suite) suite, "/Collection/update/upsert", "", test_update_upsert); TestSuite_AddFull (suite, "/Collection/update/oversize", - "", + "uses-live-server", test_update_oversize, NULL, NULL, @@ -6507,7 +6507,7 @@ test_collection_install (TestSuite *suite) TestSuite_AddLive (suite, "/Collection/remove/multi", "", test_remove_multi); TestSuite_AddFull (suite, "/Collection/remove/oversize", - "", + "uses-live-server", test_remove_oversize, NULL, NULL, @@ -6529,7 +6529,7 @@ test_collection_install (TestSuite *suite) test_count_with_collation_ok); TestSuite_AddFull (suite, "/Collection/count/read_concern_live", - "", + "uses-live-server", test_count_read_concern_live, NULL, NULL, @@ -6544,7 +6544,7 @@ test_collection_install (TestSuite *suite) suite, "/Collection/aggregate/large", "", test_aggregate_large); TestSuite_AddFull (suite, "/Collection/aggregate/secondary", - "", + "uses-live-server", test_aggregate_secondary, NULL, NULL, @@ -6559,7 +6559,7 @@ test_collection_install (TestSuite *suite) test_aggregate_read_concern); TestSuite_AddFull (suite, "/Collection/aggregate/bypass_document_validation", - "", + "uses-live-server", test_aggregate_bypass, NULL, NULL, @@ -6582,14 +6582,14 @@ test_collection_install (TestSuite *suite) test_aggregate_w_server_id_sharded); TestSuite_AddFull (suite, "/Collection/aggregate_w_server_id/option", - "", + "uses-live-server", test_aggregate_server_id_option, NULL, NULL, test_framework_skip_if_auth); TestSuite_AddFull (suite, "/Collection/validate", - "", + "uses-live-server", test_validate, NULL, NULL, @@ -6602,7 +6602,7 @@ test_collection_install (TestSuite *suite) suite, "/Collection/find_read_concern", "", test_find_read_concern); TestSuite_AddFull (suite, "/Collection/getmore_read_concern_live", - "", + "uses-live-server", test_getmore_read_concern_live, NULL, NULL, @@ -6620,7 +6620,7 @@ test_collection_install (TestSuite *suite) test_find_and_modify_write_concern_wire_pre_32); TestSuite_AddFull (suite, "/Collection/large_return", - "", + "uses-live-server", test_large_return, NULL, NULL, @@ -6636,7 +6636,7 @@ test_collection_install (TestSuite *suite) suite, "/Collection/batch_size", "", test_find_batch_size); TestSuite_AddFull (suite, "/Collection/command_fully_qualified", - "", + "uses-live-server", test_command_fq, NULL, NULL, @@ -6649,7 +6649,7 @@ test_collection_install (TestSuite *suite) suite, "/Collection/insert/duplicate_key", "", test_insert_duplicate_key); TestSuite_AddFull (suite, "/Collection/create_index/fail", - "", + "uses-live-server", test_create_index_fail, NULL, NULL, @@ -6697,14 +6697,14 @@ test_collection_install (TestSuite *suite) test_aggregate_with_batch_size); TestSuite_AddFull (suite, "/Collection/aggregate_is_sent_to_primary_w_dollar_out", - "", + "uses-live-server", test_aggregate_is_sent_to_primary_w_dollar_out, NULL, NULL, test_framework_skip_if_not_replset); TestSuite_AddFull (suite, "/Collection/fam/no_error_on_retry", - "", + "uses-live-server", test_fam_no_error_on_retry, NULL, NULL, diff --git a/src/libmongoc/tests/test-mongoc-command-monitoring.c b/src/libmongoc/tests/test-mongoc-command-monitoring.c index 203a464d792..84070a3d3d5 100644 --- a/src/libmongoc/tests/test-mongoc-command-monitoring.c +++ b/src/libmongoc/tests/test-mongoc-command-monitoring.c @@ -1414,7 +1414,7 @@ test_command_monitoring_install (TestSuite *suite) test_client_cmd_op_ids); TestSuite_AddFull (suite, "/command_monitoring/killcursors_deprecated", - "", + "uses-live-server", test_killcursors_deprecated, NULL /* dtor */, NULL /* ctx */, diff --git a/src/libmongoc/tests/test-mongoc-counters.c b/src/libmongoc/tests/test-mongoc-counters.c index a7488b0a442..8ba0723d57e 100644 --- a/src/libmongoc/tests/test-mongoc-counters.c +++ b/src/libmongoc/tests/test-mongoc-counters.c @@ -565,7 +565,7 @@ test_counters_install (TestSuite *suite) #ifdef MONGOC_ENABLE_SHM_COUNTERS TestSuite_AddFull (suite, "/counters/op_msg", - "", + "uses-live-server", test_counters_op_msg, NULL, NULL, @@ -574,7 +574,7 @@ test_counters_install (TestSuite *suite) test_framework_skip_if_compressors); TestSuite_AddFull (suite, "/counters/op_compressed", - "", + "uses-live-server", test_counters_op_compressed, NULL, NULL, @@ -584,7 +584,7 @@ test_counters_install (TestSuite *suite) /* test before OP_MSG. */ TestSuite_AddFull (suite, "/counters/op_query", - "", + "uses-live-server", test_counters_op_query, NULL, NULL, @@ -595,7 +595,7 @@ test_counters_install (TestSuite *suite) /* test before the getMore and killCursors commands were introduced. */ TestSuite_AddFull (suite, "/counters/op_getmore_killcursors", - "", + "uses-live-server", test_counters_op_getmore_killcursors, NULL, NULL, @@ -606,14 +606,14 @@ test_counters_install (TestSuite *suite) TestSuite_AddLive (suite, "/counters/clients", "", test_counters_clients); TestSuite_AddFull (suite, "/counters/streams", - "", + "uses-live-server", test_counters_streams, NULL, NULL, TestSuite_CheckLive); TestSuite_AddFull (suite, "/counters/auth", - "", + "uses-live-server", test_counters_auth, NULL, NULL, diff --git a/src/libmongoc/tests/test-mongoc-crud.c b/src/libmongoc/tests/test-mongoc-crud.c index 79231621f09..12eee5a7859 100644 --- a/src/libmongoc/tests/test-mongoc-crud.c +++ b/src/libmongoc/tests/test-mongoc-crud.c @@ -169,7 +169,7 @@ test_crud_install (TestSuite *suite) TestSuite_AddFull (suite, "/crud/prose_test_1", - "", + "uses-live-server", prose_test_1, NULL, /* dtor */ NULL, /* ctx */ @@ -178,7 +178,7 @@ test_crud_install (TestSuite *suite) TestSuite_AddFull (suite, "/crud/prose_test_2", - "", + "uses-live-server", prose_test_2, NULL, /* dtor */ NULL, /* ctx */ diff --git a/src/libmongoc/tests/test-mongoc-cursor.c b/src/libmongoc/tests/test-mongoc-cursor.c index f977c8104be..6c5e2e8b2aa 100644 --- a/src/libmongoc/tests/test-mongoc-cursor.c +++ b/src/libmongoc/tests/test-mongoc-cursor.c @@ -442,28 +442,28 @@ _make_array_cursor (mongoc_collection_t *coll) return mongoc_client_find_databases_with_opts (coll->client, NULL); } -#define TEST_CURSOR_FIND(prefix, fn) \ - TestSuite_AddFullWithTestFn (suite, \ - prefix "/find", \ - "", \ - fn, \ - NULL, \ - _make_find_cursor, \ +#define TEST_CURSOR_FIND(prefix, fn) \ + TestSuite_AddFullWithTestFn (suite, \ + prefix "/find", \ + "uses-live-server", \ + fn, \ + NULL, \ + _make_find_cursor, \ TestSuite_CheckLive); -#define TEST_CURSOR_CMD(prefix, fn) \ - TestSuite_AddFullWithTestFn (suite, \ - prefix "/cmd", \ - "", \ - fn, \ - NULL, \ - _make_cmd_cursor, \ +#define TEST_CURSOR_CMD(prefix, fn) \ + TestSuite_AddFullWithTestFn (suite, \ + prefix "/cmd", \ + "uses-live-server", \ + fn, \ + NULL, \ + _make_cmd_cursor, \ TestSuite_CheckLive); #define TEST_CURSOR_CMD_DEPRECATED(prefix, fn) \ TestSuite_AddFullWithTestFn (suite, \ prefix "/cmd_deprecated", \ - "", \ + "uses-live-server", \ fn, \ NULL, \ _make_cmd_deprecated_cursor, \ @@ -472,7 +472,7 @@ _make_array_cursor (mongoc_collection_t *coll) #define TEST_CURSOR_ARRAY(prefix, fn) \ TestSuite_AddFullWithTestFn (suite, \ prefix "/array", \ - "", \ + "uses-live-server", \ fn, \ NULL, \ _make_array_cursor, \ @@ -481,7 +481,7 @@ _make_array_cursor (mongoc_collection_t *coll) #define TEST_CURSOR_AGG(prefix, fn) \ TestSuite_AddFullWithTestFn (suite, \ prefix "/agg", \ - "", \ + "uses-live-server", \ fn, \ NULL, \ _make_cmd_cursor_from_agg, \ @@ -2407,14 +2407,14 @@ test_cursor_install (TestSuite *suite) test_cursor_new_from_aggregate_no_initial); TestSuite_AddFull (suite, "/Cursor/new_from_find", - "", + "uses-live-server", test_cursor_new_from_find, NULL, NULL, test_framework_skip_if_max_wire_version_less_than_4); TestSuite_AddFull (suite, "/Cursor/new_from_find_batches", - "", + "uses-live-server", test_cursor_new_from_find_batches, NULL, NULL, diff --git a/src/libmongoc/tests/test-mongoc-database.c b/src/libmongoc/tests/test-mongoc-database.c index ec2c42d99cb..b73c814fc54 100644 --- a/src/libmongoc/tests/test-mongoc-database.c +++ b/src/libmongoc/tests/test-mongoc-database.c @@ -1224,7 +1224,7 @@ test_database_install (TestSuite *suite) test_aggregate_inherit_database); TestSuite_AddFull (suite, "/Database/create_with_write_concern", - "", + "uses-live-server", test_create_with_write_concern, NULL, NULL, diff --git a/src/libmongoc/tests/test-mongoc-exhaust.c b/src/libmongoc/tests/test-mongoc-exhaust.c index 861c9bce0a6..bd2af5f47bf 100644 --- a/src/libmongoc/tests/test-mongoc-exhaust.c +++ b/src/libmongoc/tests/test-mongoc-exhaust.c @@ -663,7 +663,7 @@ test_exhaust_install (TestSuite *suite) { TestSuite_AddFull (suite, "/Client/exhaust_cursor/single", - "", + "uses-live-server", test_exhaust_cursor_single, NULL, NULL, @@ -671,7 +671,7 @@ test_exhaust_install (TestSuite *suite) test_framework_skip_if_no_legacy_opcodes); TestSuite_AddFull (suite, "/Client/exhaust_cursor/pool", - "", + "uses-live-server", test_exhaust_cursor_pool, NULL, NULL, @@ -679,7 +679,7 @@ test_exhaust_install (TestSuite *suite) test_framework_skip_if_no_legacy_opcodes); TestSuite_AddFull (suite, "/Client/exhaust_cursor/batches", - "", + "uses-live-server", test_exhaust_cursor_multi_batch, NULL, NULL, diff --git a/src/libmongoc/tests/test-mongoc-find-and-modify.c b/src/libmongoc/tests/test-mongoc-find-and-modify.c index c6953555042..b39730fce59 100644 --- a/src/libmongoc/tests/test-mongoc-find-and-modify.c +++ b/src/libmongoc/tests/test-mongoc-find-and-modify.c @@ -629,7 +629,7 @@ test_find_and_modify_install (TestSuite *suite) test_find_and_modify_write_concern_wire_pre_32); TestSuite_AddFull (suite, "/find_and_modify/find_and_modify/write_concern_failure", - "", + "uses-live-server", test_find_and_modify_write_concern_wire_32_failure, NULL, NULL, diff --git a/src/libmongoc/tests/test-mongoc-gridfs-bucket.c b/src/libmongoc/tests/test-mongoc-gridfs-bucket.c index fe5fd625eb8..2cae6278f47 100644 --- a/src/libmongoc/tests/test-mongoc-gridfs-bucket.c +++ b/src/libmongoc/tests/test-mongoc-gridfs-bucket.c @@ -1160,7 +1160,7 @@ test_gridfs_bucket_install (TestSuite *suite) test_framework_skip_if_no_auth); TestSuite_AddFull (suite, "/gridfs/find_w_session", - "", + "uses-live-server", test_find_w_session, NULL, NULL, @@ -1168,7 +1168,7 @@ test_gridfs_bucket_install (TestSuite *suite) test_framework_skip_if_no_crypto); TestSuite_AddFull (suite, "/gridfs/find", - "", + "uses-live-server", test_find, NULL, NULL, diff --git a/src/libmongoc/tests/test-mongoc-gridfs.c b/src/libmongoc/tests/test-mongoc-gridfs.c index 476ab6f7f7e..bea725f822c 100644 --- a/src/libmongoc/tests/test-mongoc-gridfs.c +++ b/src/libmongoc/tests/test-mongoc-gridfs.c @@ -1582,7 +1582,7 @@ test_gridfs_install (TestSuite *suite) suite, "/gridfs_old/write_past_end", "", test_write_past_end); TestSuite_AddFull (suite, "/gridfs_old/test_long_seek", - "", + "uses-live-server", test_long_seek, NULL, NULL, @@ -1591,7 +1591,7 @@ test_gridfs_install (TestSuite *suite) suite, "/gridfs_old/remove_by_filename", "", test_remove_by_filename); TestSuite_AddFull (suite, "/gridfs_old/missing_chunk", - "", + "uses-live-server", test_missing_chunk, NULL, NULL, diff --git a/src/libmongoc/tests/test-mongoc-max-staleness.c b/src/libmongoc/tests/test-mongoc-max-staleness.c index 6b68882c998..3cc1097ce36 100644 --- a/src/libmongoc/tests/test-mongoc-max-staleness.c +++ b/src/libmongoc/tests/test-mongoc-max-staleness.c @@ -362,7 +362,7 @@ test_client_max_staleness_install (TestSuite *suite) test_mongos_max_staleness_read_pref); TestSuite_AddFull (suite, "/Client/last_write_date", - "", + "uses-live-server", test_last_write_date, NULL, NULL, @@ -370,7 +370,7 @@ test_client_max_staleness_install (TestSuite *suite) test_framework_skip_if_slow); TestSuite_AddFull (suite, "/Client/last_write_date/pooled", - "", + "uses-live-server", test_last_write_date_pooled, NULL, NULL, @@ -378,14 +378,14 @@ test_client_max_staleness_install (TestSuite *suite) test_framework_skip_if_slow); TestSuite_AddFull (suite, "/Client/last_write_date_absent", - "", + "uses-live-server", test_last_write_date_absent, NULL, NULL, test_framework_skip_if_rs_version_5); TestSuite_AddFull (suite, "/Client/last_write_date_absent/pooled", - "", + "uses-live-server", test_last_write_date_absent_pooled, NULL, NULL, diff --git a/src/libmongoc/tests/test-mongoc-mongos-pinning.c b/src/libmongoc/tests/test-mongoc-mongos-pinning.c index 31d8d8f4a42..109d9019495 100644 --- a/src/libmongoc/tests/test-mongoc-mongos-pinning.c +++ b/src/libmongoc/tests/test-mongoc-mongos-pinning.c @@ -187,7 +187,7 @@ test_mongos_pinning_install (TestSuite *suite) { TestSuite_AddFull (suite, "/mongos_pinning/new_transaction_unpins", - "", + "uses-live-server", test_new_transaction_unpins, NULL, NULL, @@ -198,7 +198,7 @@ test_mongos_pinning_install (TestSuite *suite) TestSuite_AddFull (suite, "/mongos_pinning/non_transaction_unpins", - "", + "uses-live-server", test_non_transaction_unpins, NULL, NULL, diff --git a/src/libmongoc/tests/test-mongoc-primary-stepdown.c b/src/libmongoc/tests/test-mongoc-primary-stepdown.c index 25aec7d2e4a..a10adc0f70f 100644 --- a/src/libmongoc/tests/test-mongoc-primary-stepdown.c +++ b/src/libmongoc/tests/test-mongoc-primary-stepdown.c @@ -475,7 +475,7 @@ test_primary_stepdown_install (TestSuite *suite) { TestSuite_AddFull (suite, "/Stepdown/getmore", - "", + "uses-live-server", test_getmore_iteration_runner, NULL, NULL, @@ -484,7 +484,7 @@ test_primary_stepdown_install (TestSuite *suite) TestSuite_AddFull (suite, "/Stepdown/not_primary_keep", - "", + "uses-live-server", test_not_primary_keep_pool_runner, NULL, NULL, @@ -493,7 +493,7 @@ test_primary_stepdown_install (TestSuite *suite) TestSuite_AddFull (suite, "/Stepdown/not_primary_reset", - "", + "uses-live-server", test_not_primary_reset_pool_runner, NULL, NULL, @@ -502,7 +502,7 @@ test_primary_stepdown_install (TestSuite *suite) TestSuite_AddFull (suite, "/Stepdown/shutdown_reset_pool", - "", + "uses-live-server", test_shutdown_reset_pool_runner, NULL, NULL, @@ -511,7 +511,7 @@ test_primary_stepdown_install (TestSuite *suite) TestSuite_AddFull (suite, "/Stepdown/interrupt_shutdown", - "", + "uses-live-server", test_interrupted_shutdown_reset_pool_runner, NULL, NULL, diff --git a/src/libmongoc/tests/test-mongoc-retryable-reads.c b/src/libmongoc/tests/test-mongoc-retryable-reads.c index fbfad59fe0f..2da1b0a7e93 100644 --- a/src/libmongoc/tests/test-mongoc-retryable-reads.c +++ b/src/libmongoc/tests/test-mongoc-retryable-reads.c @@ -298,7 +298,7 @@ test_retryable_reads_install (TestSuite *suite) /* Since we need failpoints, require wire version 7 */ TestSuite_AddFull (suite, "/retryable_reads/cmd_helpers", - "", + "uses-live-server", test_cmd_helpers, NULL, NULL, @@ -307,7 +307,7 @@ test_retryable_reads_install (TestSuite *suite) test_framework_skip_if_no_failpoint); TestSuite_AddFull (suite, "/retryable_reads/retry_off", - "", + "uses-live-server", test_retry_reads_off, NULL, NULL, diff --git a/src/libmongoc/tests/test-mongoc-retryable-writes.c b/src/libmongoc/tests/test-mongoc-retryable-writes.c index 998f76a2b93..f87e35105d8 100644 --- a/src/libmongoc/tests/test-mongoc-retryable-writes.c +++ b/src/libmongoc/tests/test-mongoc-retryable-writes.c @@ -681,7 +681,7 @@ test_retryable_writes_install (TestSuite *suite) test_framework_skip_if_no_crypto); TestSuite_AddFull (suite, "/retryable_writes/command_with_opts", - "", + "uses-live-server", test_command_with_opts, NULL, NULL, @@ -714,7 +714,7 @@ test_retryable_writes_install (TestSuite *suite) test_framework_skip_if_no_crypto); TestSuite_AddFull (suite, "/retryable_writes/no_crypto", - "", + "uses-live-server", test_retry_no_crypto, NULL, NULL, @@ -727,7 +727,7 @@ test_retryable_writes_install (TestSuite *suite) test_framework_skip_if_no_crypto); TestSuite_AddFull (suite, "/retryable_writes/bulk_tracks_new_server", - "", + "uses-live-server", test_bulk_retry_tracks_new_server, NULL /* dtor */, NULL /* ctx */, diff --git a/src/libmongoc/tests/test-mongoc-sample-commands.c b/src/libmongoc/tests/test-mongoc-sample-commands.c index 5cdf474ac49..e88fea30078 100644 --- a/src/libmongoc/tests/test-mongoc-sample-commands.c +++ b/src/libmongoc/tests/test-mongoc-sample-commands.c @@ -3967,7 +3967,7 @@ test_samples_install (TestSuite *suite) TestSuite_AddLive (suite, "/Samples", "", test_sample_commands); TestSuite_AddFull (suite, "/Samples/with_txn", - "", + "uses-live-server", test_with_txn_example, NULL, NULL, diff --git a/src/libmongoc/tests/test-mongoc-sdam.c b/src/libmongoc/tests/test-mongoc-sdam.c index fc5a6c7d12e..82eeb7c86c5 100644 --- a/src/libmongoc/tests/test-mongoc-sdam.c +++ b/src/libmongoc/tests/test-mongoc-sdam.c @@ -915,28 +915,28 @@ test_sdam_install (TestSuite *suite) test_all_spec_tests (suite); TestSuite_AddFull (suite, "/server_discovery_and_monitoring/topology/discovery", - "", + "uses-live-server", test_topology_discovery, NULL /* dtor */, NULL /* ctx */, test_framework_skip_if_not_replset); TestSuite_AddFull (suite, "/server_discovery_and_monitoring/directconnection", - "", + "uses-live-server", test_direct_connection, NULL /* dtor */, NULL /* ctx */, test_framework_skip_if_not_replset); TestSuite_AddFull (suite, "/server_discovery_and_monitoring/existing/behavior", - "", + "uses-live-server", test_existing_behavior, NULL /* dtor */, NULL /* ctx */, test_framework_skip_if_not_replset); TestSuite_AddFull (suite, "/server_discovery_and_monitoring/prose/rtt", - "", + "uses-live-server", test_prose_rtt, NULL /* dtor */, NULL /* ctx */, diff --git a/src/libmongoc/tests/test-mongoc-server-selection-errors.c b/src/libmongoc/tests/test-mongoc-server-selection-errors.c index 98b85e786c6..f1745c24e7e 100644 --- a/src/libmongoc/tests/test-mongoc-server-selection-errors.c +++ b/src/libmongoc/tests/test-mongoc-server-selection-errors.c @@ -308,14 +308,14 @@ test_server_selection_errors_install (TestSuite *suite) test_framework_skip_if_slow); TestSuite_AddFull (suite, "/server_selection/errors/dns/multi/success/single", - "", + "uses-live-server", test_server_selection_error_dns_multi_success_single, NULL, NULL, test_framework_skip_if_single); TestSuite_AddFull (suite, "/server_selection/errors/dns/multi/success/pooled", - "", + "uses-live-server", test_server_selection_error_dns_multi_success_pooled, NULL, NULL, diff --git a/src/libmongoc/tests/test-mongoc-topology-reconcile.c b/src/libmongoc/tests/test-mongoc-topology-reconcile.c index 669ceeb747f..307a6468122 100644 --- a/src/libmongoc/tests/test-mongoc-topology-reconcile.c +++ b/src/libmongoc/tests/test-mongoc-topology-reconcile.c @@ -682,7 +682,7 @@ test_topology_reconcile_install (TestSuite *suite) test_topology_reconcile_sharded_single); TestSuite_AddFull (suite, "/TOPOLOGY/reconcile/from_handshake", - "", + "uses-live-server", test_topology_reconcile_from_handshake, NULL, NULL, diff --git a/src/libmongoc/tests/test-mongoc-topology-scanner.c b/src/libmongoc/tests/test-mongoc-topology-scanner.c index 8b0498af1c8..a16f76627ef 100644 --- a/src/libmongoc/tests/test-mongoc-topology-scanner.c +++ b/src/libmongoc/tests/test-mongoc-topology-scanner.c @@ -747,7 +747,7 @@ test_topology_scanner_install (TestSuite *suite) test_topology_retired_fails_to_initiate); TestSuite_AddFull (suite, "/TOPOLOGY/scanner/renegotiate/single", - "", + "uses-live-server", test_topology_scanner_does_not_renegotiate_single, NULL, NULL, @@ -755,7 +755,7 @@ test_topology_scanner_install (TestSuite *suite) test_framework_skip_if_valgrind); TestSuite_AddFull (suite, "/TOPOLOGY/scanner/renegotiate/pooled", - "", + "uses-live-server", test_topology_scanner_does_not_renegotiate_pooled, NULL, NULL, diff --git a/src/libmongoc/tests/test-mongoc-topology.c b/src/libmongoc/tests/test-mongoc-topology.c index b5421f5150e..4c05298b90b 100644 --- a/src/libmongoc/tests/test-mongoc-topology.c +++ b/src/libmongoc/tests/test-mongoc-topology.c @@ -2454,28 +2454,28 @@ test_topology_install (TestSuite *suite) suite, "/Topology/start_stop", "", test_topology_thread_start_stop); TestSuite_AddFull (suite, "/Topology/server_selection_try_once_option", - "", + "uses-live-server", test_server_selection_try_once_option, NULL, NULL, test_framework_skip_if_slow); TestSuite_AddFull (suite, "/Topology/server_selection_try_once", - "", + "uses-live-server", test_server_selection_try_once, NULL, NULL, test_framework_skip_if_slow); TestSuite_AddFull (suite, "/Topology/server_selection_try_once_false", - "", + "uses-live-server", test_server_selection_try_once_false, NULL, NULL, test_framework_skip_if_slow); TestSuite_AddFull (suite, "/Topology/invalidate_server/single", - "", + "uses-live-server", test_topology_invalidate_server_single, NULL, NULL, @@ -2483,7 +2483,7 @@ test_topology_install (TestSuite *suite) test_framework_skip_if_valgrind); TestSuite_AddFull (suite, "/Topology/invalidate_server/pooled", - "", + "uses-live-server", test_topology_invalidate_server_pooled, NULL, NULL, @@ -2491,14 +2491,14 @@ test_topology_install (TestSuite *suite) test_framework_skip_if_valgrind); TestSuite_AddFull (suite, "/Topology/invalid_cluster_node", - "", + "uses-live-server", test_invalid_cluster_node, NULL, NULL, test_framework_skip_if_slow_or_live); TestSuite_AddFull (suite, "/Topology/max_wire_version_race_condition", - "", + "uses-live-server", test_max_wire_version_race_condition, NULL, NULL, @@ -2526,7 +2526,7 @@ test_topology_install (TestSuite *suite) test_framework_skip_if_slow); TestSuite_AddFull (suite, "/Topology/multiple_selection_errors", - "", + "uses-live-server", test_multiple_selection_errors, NULL, NULL, @@ -2555,7 +2555,7 @@ test_topology_install (TestSuite *suite) test_server_removed_during_handshake_pooled); TestSuite_AddFull (suite, "/Topology/rtt", - "", + "uses-live-server", test_rtt, NULL, NULL, diff --git a/src/libmongoc/tests/test-mongoc-transactions.c b/src/libmongoc/tests/test-mongoc-transactions.c index 562f30a982f..741d8d3dfa4 100644 --- a/src/libmongoc/tests/test-mongoc-transactions.c +++ b/src/libmongoc/tests/test-mongoc-transactions.c @@ -1186,14 +1186,14 @@ test_transactions_install (TestSuite *suite) TestSuite_AddFull (suite, "/transactions/supported", - "", + "uses-live-server", test_transactions_supported, NULL, NULL, test_framework_skip_if_no_txns); TestSuite_AddFull (suite, "/transactions/in_transaction", - "", + "uses-live-server", test_in_transaction, NULL, NULL, @@ -1215,14 +1215,14 @@ test_transactions_install (TestSuite *suite) test_framework_skip_if_no_crypto); TestSuite_AddFull (suite, "/transactions/cursor_primary_read_pref", - "", + "uses-live-server", test_cursor_primary_read_pref, NULL, NULL, test_framework_skip_if_no_txns); TestSuite_AddFull (suite, "/transactions/inherit_from_client", - "", + "uses-live-server", test_inherit_from_client, NULL, NULL, @@ -1231,7 +1231,7 @@ test_transactions_install (TestSuite *suite) suite, "/transactions/" "transaction_fails_on_unsupported_version_or_sharded_cluster", - "", + "uses-live-server", test_transaction_fails_on_unsupported_version_or_sharded_cluster, NULL, NULL, @@ -1239,7 +1239,7 @@ test_transactions_install (TestSuite *suite) test_framework_skip_if_no_crypto); TestSuite_AddFull (suite, "/transactions/recovery_token_cleared", - "", + "uses-live-server", test_transaction_recovery_token_cleared, NULL, NULL, @@ -1249,7 +1249,7 @@ test_transactions_install (TestSuite *suite) test_framework_skip_if_not_mongos); TestSuite_AddFull (suite, "/transactions/selected_server_pinned_to_mongos", - "", + "uses-live-server", test_selected_server_is_pinned_to_mongos, NULL, NULL, @@ -1263,7 +1263,7 @@ test_transactions_install (TestSuite *suite) test_framework_skip_if_no_crypto); TestSuite_AddFull (suite, "/transactions/max_commit_time_ms_is_reset", - "", + "uses-live-server", test_max_commit_time_ms_is_reset, NULL, NULL, diff --git a/src/libmongoc/tests/test-mongoc-with-transaction.c b/src/libmongoc/tests/test-mongoc-with-transaction.c index ebbf03b528a..bafd7001b72 100644 --- a/src/libmongoc/tests/test-mongoc-with-transaction.c +++ b/src/libmongoc/tests/test-mongoc-with-transaction.c @@ -81,7 +81,7 @@ test_with_transaction_install (TestSuite *suite) { TestSuite_AddFull (suite, "/with_transaction/timeout_tests", - "", + "uses-live-server", test_with_transaction_timeout, NULL, NULL, diff --git a/src/libmongoc/tests/test-mongoc-write-commands.c b/src/libmongoc/tests/test-mongoc-write-commands.c index b828c768dcb..b6852afb3e0 100644 --- a/src/libmongoc/tests/test-mongoc-write-commands.c +++ b/src/libmongoc/tests/test-mongoc-write-commands.c @@ -762,7 +762,7 @@ test_write_command_install (TestSuite *suite) test_invalid_write_concern); TestSuite_AddFull (suite, "/WriteCommand/bypass_validation", - "", + "uses-live-server", test_bypass_validation, NULL, NULL, @@ -790,7 +790,7 @@ test_write_command_install (TestSuite *suite) test_w0_legacy_update_and_replace_validation); TestSuite_AddFull (suite, "/WriteCommand/invalid_wc_server_error", - "", + "uses-live-server", _test_invalid_wc_server_error, NULL, NULL, diff --git a/src/libmongoc/tests/test-mongoc-write-concern.c b/src/libmongoc/tests/test-mongoc-write-concern.c index f9cbad4f6c1..1a8eb430d61 100644 --- a/src/libmongoc/tests/test-mongoc-write-concern.c +++ b/src/libmongoc/tests/test-mongoc-write-concern.c @@ -786,14 +786,14 @@ test_write_concern_install (TestSuite *suite) test_write_concern_unacknowledged); TestSuite_AddFull (suite, "/WriteConcern/inherited_fam", - "", + "uses-live-server", test_fam_no_session_no_txn, NULL, NULL, test_framework_skip_if_max_wire_version_less_than_4); TestSuite_AddFull (suite, "/WriteConcern/inherited_fam_session_no_txn", - "", + "uses-live-server", test_fam_session_no_txn, NULL, NULL, @@ -801,7 +801,7 @@ test_write_concern_install (TestSuite *suite) test_framework_skip_if_no_txns); TestSuite_AddFull (suite, "/WriteConcern/inherited_fam_txn", - "", + "uses-live-server", test_fam_session_txn, NULL, NULL, From e77a13e02a8119edeb2d7c259308cad7ad1fc158 Mon Sep 17 00:00:00 2001 From: vector-of-bool Date: Wed, 5 Jan 2022 23:01:28 +0000 Subject: [PATCH 24/52] Update doc func name --- src/libmongoc/src/mongoc/mongoc-topology-description.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libmongoc/src/mongoc/mongoc-topology-description.c b/src/libmongoc/src/mongoc/mongoc-topology-description.c index c87c1ce6990..bd70a74d462 100644 --- a/src/libmongoc/src/mongoc/mongoc-topology-description.c +++ b/src/libmongoc/src/mongoc/mongoc-topology-description.c @@ -1935,7 +1935,7 @@ transition_t gSDAMTransitionTable /* *-------------------------------------------------------------------------- * - * _mongoc_topology_description_type -- + * _tpld_type_str -- * * Get this topology's type, one of the types defined in the Server * Discovery And Monitoring Spec. From 48c50770ad7f2f8fee0888a49b8b0bf9af5766ee Mon Sep 17 00:00:00 2001 From: vector-of-bool Date: Wed, 5 Jan 2022 23:01:44 +0000 Subject: [PATCH 25/52] Some GCC versions emit an uninit warning --- src/libmongoc/tests/test-conveniences.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libmongoc/tests/test-conveniences.c b/src/libmongoc/tests/test-conveniences.c index 5e849ea3e86..8da26cd2803 100644 --- a/src/libmongoc/tests/test-conveniences.c +++ b/src/libmongoc/tests/test-conveniences.c @@ -941,7 +941,7 @@ match_bson_with_ctx (const bson_t *doc, const bson_t *pattern, match_ctx_t *ctx) bool is_empty_operator; bool is_type_operator; bool exists; - bool empty; + bool empty = false; bson_type_t bson_type = (bson_type_t) 0; bool found; bson_iter_t doc_iter; From 285cd829e8cb47e41ff4933067c5e291c1f369c8 Mon Sep 17 00:00:00 2001 From: vector-of-bool Date: Thu, 6 Jan 2022 00:06:39 +0000 Subject: [PATCH 26/52] No magic zero --- src/libmongoc/src/mongoc/mongoc-cluster.c | 2 +- src/libmongoc/src/mongoc/mongoc-cmd.c | 6 +++--- src/libmongoc/src/mongoc/mongoc-read-prefs.h | 1 + src/libmongoc/src/mongoc/mongoc-server-stream.c | 2 +- src/libmongoc/src/mongoc/mongoc-topology-description.c | 2 +- 5 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/libmongoc/src/mongoc/mongoc-cluster.c b/src/libmongoc/src/mongoc/mongoc-cluster.c index f46dd976f13..084e76205c6 100644 --- a/src/libmongoc/src/mongoc/mongoc-cluster.c +++ b/src/libmongoc/src/mongoc/mongoc-cluster.c @@ -2764,7 +2764,7 @@ _mongoc_cluster_stream_for_optype (mongoc_cluster_t *cluster, mongoc_server_stream_t *server_stream; uint32_t server_id; mongoc_topology_t *topology = cluster->client->topology; - mongoc_read_mode_t chosen_read_mode = (mongoc_read_mode_t) 0; + mongoc_read_mode_t chosen_read_mode = MONGOC_READ_UNSET; ENTRY; diff --git a/src/libmongoc/src/mongoc/mongoc-cmd.c b/src/libmongoc/src/mongoc/mongoc-cmd.c index 06f82f8a818..e9fb366e1dc 100644 --- a/src/libmongoc/src/mongoc/mongoc-cmd.c +++ b/src/libmongoc/src/mongoc/mongoc-cmd.c @@ -474,7 +474,7 @@ _mongoc_cmd_parts_assemble_mongos (mongoc_cmd_parts_t *parts, hedge = mongoc_read_prefs_get_hedge (parts->read_prefs); } - if (server_stream->effective_read_mode != (mongoc_read_mode_t) 0) { + if (server_stream->effective_read_mode != MONGOC_READ_UNSET) { /* Server selection may have overriden the read mode used to generate this * server stream. This has effects on the body of the message that we send * to the server */ @@ -827,7 +827,7 @@ mongoc_cmd_parts_assemble (mongoc_cmd_parts_t *parts, const char *cmd_name; bool is_get_more; const mongoc_read_prefs_t *prefs_ptr; - mongoc_read_mode_t mode = (mongoc_read_mode_t) 0; + mongoc_read_mode_t mode = MONGOC_READ_UNSET; bool ret = false; ENTRY; @@ -887,7 +887,7 @@ mongoc_cmd_parts_assemble (mongoc_cmd_parts_t *parts, } mode = mongoc_read_prefs_get_mode (prefs_ptr); - if (server_stream->effective_read_mode != (mongoc_read_mode_t) 0) { + if (server_stream->effective_read_mode != MONGOC_READ_UNSET) { /* Server selection may have overriden the read mode used to generate this * server stream. This has effects on the body of the message that we send * to the server */ diff --git a/src/libmongoc/src/mongoc/mongoc-read-prefs.h b/src/libmongoc/src/mongoc/mongoc-read-prefs.h index 7180548b1d3..58196de86d8 100644 --- a/src/libmongoc/src/mongoc/mongoc-read-prefs.h +++ b/src/libmongoc/src/mongoc/mongoc-read-prefs.h @@ -34,6 +34,7 @@ typedef struct _mongoc_read_prefs_t mongoc_read_prefs_t; typedef enum { + MONGOC_READ_UNSET = 0, MONGOC_READ_PRIMARY = (1 << 0), MONGOC_READ_SECONDARY = (1 << 1), MONGOC_READ_PRIMARY_PREFERRED = (1 << 2) | MONGOC_READ_PRIMARY, diff --git a/src/libmongoc/src/mongoc/mongoc-server-stream.c b/src/libmongoc/src/mongoc/mongoc-server-stream.c index 52aa36fc9c6..5846ed205ba 100644 --- a/src/libmongoc/src/mongoc/mongoc-server-stream.c +++ b/src/libmongoc/src/mongoc/mongoc-server-stream.c @@ -37,7 +37,7 @@ mongoc_server_stream_new (const mongoc_topology_description_t *td, bson_copy_to (&td->cluster_time, &server_stream->cluster_time); server_stream->sd = sd; /* becomes owned */ server_stream->stream = stream; /* merely borrowed */ - server_stream->effective_read_mode = (mongoc_read_mode_t) 0; + server_stream->effective_read_mode = MONGOC_READ_UNSET; return server_stream; } diff --git a/src/libmongoc/src/mongoc/mongoc-topology-description.c b/src/libmongoc/src/mongoc/mongoc-topology-description.c index bd70a74d462..a33783c6664 100644 --- a/src/libmongoc/src/mongoc/mongoc-topology-description.c +++ b/src/libmongoc/src/mongoc/mongoc-topology-description.c @@ -687,7 +687,7 @@ _calc_effective_read_mode (const mongoc_topology_description_t *td, } switch (optype) { case MONGOC_SS_WRITE: - return (mongoc_read_mode_t) 0; + return MONGOC_READ_UNSET; case MONGOC_SS_READ: return requested_read_mode; case MONGOC_SS_AGGREGATE_WITH_WRITE: { From d97feada64ba1728e7e2645dc5df813cbf3e0d6b Mon Sep 17 00:00:00 2001 From: vector-of-bool Date: Thu, 6 Jan 2022 00:07:03 +0000 Subject: [PATCH 27/52] Fix duplicate doc comments --- src/libmongoc/src/mongoc/mongoc-cursor.c | 2 +- src/libmongoc/src/mongoc/mongoc-topology.c | 40 ++-------------------- 2 files changed, 3 insertions(+), 39 deletions(-) diff --git a/src/libmongoc/src/mongoc/mongoc-cursor.c b/src/libmongoc/src/mongoc/mongoc-cursor.c index 53dc69c9e74..dc0ef569931 100644 --- a/src/libmongoc/src/mongoc/mongoc-cursor.c +++ b/src/libmongoc/src/mongoc/mongoc-cursor.c @@ -656,7 +656,7 @@ _mongoc_cursor_fetch_stream (mongoc_cursor_t *cursor) if (cursor->server_id) { /* We already did server selection once before. Reuse the prior - * selection to create a new stream in a new stream. */ + * selection to create a new stream on the same server. */ server_stream = mongoc_cluster_stream_for_server (&cursor->client->cluster, cursor->server_id, diff --git a/src/libmongoc/src/mongoc/mongoc-topology.c b/src/libmongoc/src/mongoc/mongoc-topology.c index d1d17f3abb2..f292cddc465 100644 --- a/src/libmongoc/src/mongoc/mongoc-topology.c +++ b/src/libmongoc/src/mongoc/mongoc-topology.c @@ -1000,32 +1000,7 @@ _mongoc_server_selection_error (const char *msg, } } -/* - *------------------------------------------------------------------------- - * - * mongoc_topology_select -- - * - * Selects a server description for an operation based on @optype - * and @read_prefs. - * - * NOTE: this method returns a copy of the original server - * description. Callers must own and clean up this copy. - * - * Parameters: - * @topology: The topology. - * @optype: Whether we are selecting for a read or write operation. - * @read_prefs: Required, the read preferences for the command. - * @error: Required, out pointer for error info. - * - * Returns: - * A mongoc_server_description_t, or NULL on failure, in which case - * @error will be set. - * - * Side effects: - * @error may be set. This function may update the topology description. - * - *------------------------------------------------------------------------- - */ + mongoc_server_description_t * mongoc_topology_select (mongoc_topology_t *topology, mongoc_ss_optype_t optype, @@ -1141,18 +1116,7 @@ _mongoc_topology_select_server_id_loadbalanced (mongoc_topology_t *topology, return selected_server_id; } -/* - *------------------------------------------------------------------------- - * - * mongoc_topology_select_server_id -- - * - * Alternative to mongoc_topology_select when you only need the id. - * - * Returns: - * A server id, or 0 on failure, in which case @error will be set. - * - *------------------------------------------------------------------------- - */ + uint32_t mongoc_topology_select_server_id (mongoc_topology_t *topology, mongoc_ss_optype_t optype, From c0692ebe60b6ba3bd6e001e9ab0f9dc2c5df295c Mon Sep 17 00:00:00 2001 From: vector-of-bool Date: Thu, 6 Jan 2022 00:07:58 +0000 Subject: [PATCH 28/52] Consolidate duplicate state in suitable_servers() --- .../src/mongoc/mongoc-topology-description.c | 50 +++++++++---------- 1 file changed, 24 insertions(+), 26 deletions(-) diff --git a/src/libmongoc/src/mongoc/mongoc-topology-description.c b/src/libmongoc/src/mongoc/mongoc-topology-description.c index a33783c6664..26634309d36 100644 --- a/src/libmongoc/src/mongoc/mongoc-topology-description.c +++ b/src/libmongoc/src/mongoc/mongoc-topology-description.c @@ -730,29 +730,26 @@ mongoc_topology_description_suitable_servers ( size_t local_threshold_ms) { mongoc_suitable_data_t data; - const mongoc_server_description_t **candidates; const mongoc_set_t *td_servers = mc_tpld_servers_const (topology); int64_t nearest = -1; int i; const mongoc_read_mode_t given_read_mode = mongoc_read_prefs_get_mode (read_pref); - const mongoc_read_mode_t effective_read_mode = + + data.primary = NULL; + data.topology_type = topology->type; + data.has_secondary = false; + data.read_mode = _calc_effective_read_mode (topology, optype, given_read_mode); + data.candidates_len = 0; + data.candidates = bson_malloc0 (sizeof (mongoc_server_description_t *) * + td_servers->items_len); if (chosen_read_mode) { - *chosen_read_mode = effective_read_mode; + *chosen_read_mode = data.read_mode; } - candidates = bson_malloc0 (sizeof (*candidates) * td_servers->items_len); - - data.read_mode = effective_read_mode; - data.topology_type = topology->type; - data.primary = NULL; - data.candidates = candidates; - data.candidates_len = 0; - data.has_secondary = false; - /* Single server -- * Either it is suitable or it isn't */ if (topology->type == MONGOC_TOPOLOGY_SINGLE) { @@ -766,7 +763,7 @@ mongoc_topology_description_suitable_servers ( "Rejected [%s] [%s] for read mode [%s] with topology type Single", mongoc_server_description_type (server), server->host.host_and_port, - _mongoc_read_mode_as_str (effective_read_mode)); + _mongoc_read_mode_as_str (data.read_mode)); } goto DONE; } @@ -809,13 +806,13 @@ mongoc_topology_description_suitable_servers ( if (data.read_mode == MONGOC_READ_SECONDARY) { for (i = 0; i < data.candidates_len; i++) { - if (candidates[i] && - candidates[i]->type != MONGOC_SERVER_RS_SECONDARY) { + if (data.candidates[i] && + data.candidates[i]->type != MONGOC_SERVER_RS_SECONDARY) { TRACE ("Rejected [%s] [%s] for mode [%s] with RS topology", - mongoc_server_description_type (candidates[i]), - candidates[i]->host.host_and_port, - _mongoc_read_mode_as_str (effective_read_mode)); - candidates[i] = NULL; + mongoc_server_description_type (data.candidates[i]), + data.candidates[i]->host.host_and_port, + _mongoc_read_mode_as_str (data.read_mode)); + data.candidates[i] = NULL; } } } @@ -872,22 +869,23 @@ mongoc_topology_description_suitable_servers ( * Find the nearest, then select within the window */ for (i = 0; i < data.candidates_len; i++) { - if (candidates[i] && - (nearest == -1 || nearest > candidates[i]->round_trip_time_msec)) { - nearest = candidates[i]->round_trip_time_msec; + if (data.candidates[i] && + (nearest == -1 || + nearest > data.candidates[i]->round_trip_time_msec)) { + nearest = data.candidates[i]->round_trip_time_msec; } } for (i = 0; i < data.candidates_len; i++) { - if (candidates[i] && (candidates[i]->round_trip_time_msec <= - nearest + local_threshold_ms)) { - _mongoc_array_append_val (set, candidates[i]); + if (data.candidates[i] && (data.candidates[i]->round_trip_time_msec <= + nearest + local_threshold_ms)) { + _mongoc_array_append_val (set, data.candidates[i]); } } DONE: - bson_free ((mongoc_server_description_t *) candidates); + bson_free ((mongoc_server_description_t *) data.candidates); return; } From fa4e531f977382b9740574371b7868b0016a701a Mon Sep 17 00:00:00 2001 From: vector-of-bool Date: Thu, 6 Jan 2022 00:08:15 +0000 Subject: [PATCH 29/52] Less magic numbers --- .../src/mongoc/mongoc-topology-description.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/libmongoc/src/mongoc/mongoc-topology-description.c b/src/libmongoc/src/mongoc/mongoc-topology-description.c index 26634309d36..034359e18ff 100644 --- a/src/libmongoc/src/mongoc/mongoc-topology-description.c +++ b/src/libmongoc/src/mongoc/mongoc-topology-description.c @@ -655,12 +655,12 @@ _mongoc_topology_description_validate_max_staleness ( } static bool -_check_any_server_less_than_wire_version_13 (const void *sd_, - void *any_too_old_) +_check_any_server_less_than_wire_version_v5_0 (const void *sd_, + void *any_too_old_) { const mongoc_server_description_t *sd = sd_; bool *any_too_old = any_too_old_; - if (sd->max_wire_version < 13) { + if (sd->max_wire_version < WIRE_VERSION_5_0) { *any_too_old = true; } return true; @@ -671,8 +671,8 @@ _check_any_server_less_than_wire_version_13 (const void *sd_, * requested and what is available in the topology. * * Per the CRUD spec, if the requested read mode is *not* primary, and *any* - * server in the topology has a wire version <13, we must override the read - * mode preference with "primary." Wire version 13 indicates support on a + * server in the topology has a wire version < server v5.0, we must override the + * read mode preference with "primary." Server v5.0 indicates support on a * secondary server for using aggregate pipelines that contain writing stages * (i.e. '$out' and '$merge'). */ @@ -693,7 +693,7 @@ _calc_effective_read_mode (const mongoc_topology_description_t *td, case MONGOC_SS_AGGREGATE_WITH_WRITE: { bool any_too_old = false; mongoc_set_for_each_const (mc_tpld_servers_const (td), - _check_any_server_less_than_wire_version_13, + _check_any_server_less_than_wire_version_v5_0, &any_too_old); if (any_too_old) { return MONGOC_READ_PRIMARY; From 1e5d039230c0acf35c0e182463872857fd13a140 Mon Sep 17 00:00:00 2001 From: vector-of-bool Date: Thu, 6 Jan 2022 00:15:44 +0000 Subject: [PATCH 30/52] Unhandled switch cases --- src/libmongoc/src/mongoc/mongoc-cmd.c | 1 + src/libmongoc/src/mongoc/mongoc-read-prefs.c | 1 + 2 files changed, 2 insertions(+) diff --git a/src/libmongoc/src/mongoc/mongoc-cmd.c b/src/libmongoc/src/mongoc/mongoc-cmd.c index e9fb366e1dc..0699125ad94 100644 --- a/src/libmongoc/src/mongoc/mongoc-cmd.c +++ b/src/libmongoc/src/mongoc/mongoc-cmd.c @@ -514,6 +514,7 @@ _mongoc_cmd_parts_assemble_mongos (mongoc_cmd_parts_t *parts, case MONGOC_READ_PRIMARY_PREFERRED: case MONGOC_READ_SECONDARY: case MONGOC_READ_NEAREST: + case MONGOC_READ_UNSET: default: parts->assembled.query_flags |= MONGOC_QUERY_SECONDARY_OK; add_read_prefs = true; diff --git a/src/libmongoc/src/mongoc/mongoc-read-prefs.c b/src/libmongoc/src/mongoc/mongoc-read-prefs.c index 492c23cf92f..ee62dae1e0e 100644 --- a/src/libmongoc/src/mongoc/mongoc-read-prefs.c +++ b/src/libmongoc/src/mongoc/mongoc-read-prefs.c @@ -211,6 +211,7 @@ _mongoc_read_mode_as_str (mongoc_read_mode_t mode) return "secondaryPreferred"; case MONGOC_READ_NEAREST: return "nearest"; + case MONGOC_READ_UNSET: default: return ""; } From 79d8c7e9e087f1b4ed7d1dbab71c882aedca81cb Mon Sep 17 00:00:00 2001 From: vector-of-bool Date: Thu, 6 Jan 2022 20:32:18 +0000 Subject: [PATCH 31/52] Better commentary about what is happening with effective read mode --- src/libmongoc/src/mongoc/mongoc-read-prefs.c | 5 +++ src/libmongoc/src/mongoc/mongoc-read-prefs.h | 6 ++++ .../src/mongoc/mongoc-topology-description.c | 32 ++++++++++++++++--- 3 files changed, 39 insertions(+), 4 deletions(-) diff --git a/src/libmongoc/src/mongoc/mongoc-read-prefs.c b/src/libmongoc/src/mongoc/mongoc-read-prefs.c index ee62dae1e0e..d357615a77c 100644 --- a/src/libmongoc/src/mongoc/mongoc-read-prefs.c +++ b/src/libmongoc/src/mongoc/mongoc-read-prefs.c @@ -164,6 +164,11 @@ mongoc_read_prefs_is_valid (const mongoc_read_prefs_t *read_prefs) return false; } + if (read_prefs->mode == MONGOC_READ_UNSET) { + /* A mode is required */ + return false; + } + return true; } diff --git a/src/libmongoc/src/mongoc/mongoc-read-prefs.h b/src/libmongoc/src/mongoc/mongoc-read-prefs.h index 58196de86d8..db869b11156 100644 --- a/src/libmongoc/src/mongoc/mongoc-read-prefs.h +++ b/src/libmongoc/src/mongoc/mongoc-read-prefs.h @@ -34,11 +34,17 @@ typedef struct _mongoc_read_prefs_t mongoc_read_prefs_t; typedef enum { + /** Represents the absence of a read mode preference */ MONGOC_READ_UNSET = 0, + /** Represents $readPreference.mode of 'primary' */ MONGOC_READ_PRIMARY = (1 << 0), + /** Represents $readPreference.mode of 'secondary' */ MONGOC_READ_SECONDARY = (1 << 1), + /** Represents $readPreference.mode of 'primaryPreferred' */ MONGOC_READ_PRIMARY_PREFERRED = (1 << 2) | MONGOC_READ_PRIMARY, + /** Represents $readPreference.mode of 'secondaryPreferred' */ MONGOC_READ_SECONDARY_PREFERRED = (1 << 2) | MONGOC_READ_SECONDARY, + /** Represents $readPreference.mode of 'nearest' */ MONGOC_READ_NEAREST = (1 << 3) | MONGOC_READ_SECONDARY, } mongoc_read_mode_t; diff --git a/src/libmongoc/src/mongoc/mongoc-topology-description.c b/src/libmongoc/src/mongoc/mongoc-topology-description.c index 034359e18ff..53bb0b86e48 100644 --- a/src/libmongoc/src/mongoc/mongoc-topology-description.c +++ b/src/libmongoc/src/mongoc/mongoc-topology-description.c @@ -681,23 +681,33 @@ _calc_effective_read_mode (const mongoc_topology_description_t *td, mongoc_ss_optype_t optype, mongoc_read_mode_t requested_read_mode) { - if (requested_read_mode == MONGOC_READ_PRIMARY || - requested_read_mode == MONGOC_READ_PRIMARY_PREFERRED) { + if (requested_read_mode == MONGOC_READ_PRIMARY) { + /* We never alter from a primary read mode. This early-return is just an + * optimization to skip scanning for old servers, as we would end up + * returning MONGOC_READ_PRIMARY regardless. */ return requested_read_mode; } switch (optype) { case MONGOC_SS_WRITE: + /* We don't deal with write operations */ return MONGOC_READ_UNSET; case MONGOC_SS_READ: + /* Maintain the requested read mode if it is a regular read operation */ return requested_read_mode; case MONGOC_SS_AGGREGATE_WITH_WRITE: { + /* Check if any of the servers are too old to support the + * aggregate-with-write on a secondary server */ bool any_too_old = false; mongoc_set_for_each_const (mc_tpld_servers_const (td), _check_any_server_less_than_wire_version_v5_0, &any_too_old); if (any_too_old) { + /* Force the read preference back to reading from a primary server, as + * one or more servers in the system may not support the operation */ return MONGOC_READ_PRIMARY; } + /* We're okay to send an aggr-with-write to a secondary server, so permit + * the caller's read mode preference */ return requested_read_mode; } default: @@ -740,13 +750,27 @@ mongoc_topology_description_suitable_servers ( data.primary = NULL; data.topology_type = topology->type; data.has_secondary = false; - data.read_mode = - _calc_effective_read_mode (topology, optype, given_read_mode); data.candidates_len = 0; data.candidates = bson_malloc0 (sizeof (mongoc_server_description_t *) * td_servers->items_len); + /* The "effective" read mode is the read mode that we should behave for, and + * depends on the user's provided read mode, the type of operation that the + * user wishes to perform, and the server versions that we are talking to. + * + * If the operation is a write operation, the "effective" read mode is UNSET + * and irrelevant. + * + * If the operation is a regular read, we just use the caller's read mode. + * + * If the operation is an aggregate that contains writing stages, we need to + * be more careful about selecting an appropriate server. + */ + data.read_mode = + _calc_effective_read_mode (topology, optype, given_read_mode); + if (chosen_read_mode) { + /* The caller wants to know what effective read mode we are using */ *chosen_read_mode = data.read_mode; } From 50d5d685db4d9b54e89816f622d55439cd591ddd Mon Sep 17 00:00:00 2001 From: vector-of-bool Date: Fri, 7 Jan 2022 22:21:24 +0000 Subject: [PATCH 32/52] Make bool-to-binary-enum conversion explicit --- src/libmongoc/src/mongoc/mongoc-aggregate.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/libmongoc/src/mongoc/mongoc-aggregate.c b/src/libmongoc/src/mongoc/mongoc-aggregate.c index 376ea2bcf97..392b8634eb7 100644 --- a/src/libmongoc/src/mongoc/mongoc-aggregate.c +++ b/src/libmongoc/src/mongoc/mongoc-aggregate.c @@ -278,7 +278,8 @@ _mongoc_aggregate (mongoc_client_t *client, /* This has an important effect on server selection when * readPreferences=secondary. Keep track of this fact for later use. */ - cursor->is_aggr_with_write_stage = has_write_key; + cursor->is_aggr_with_write_stage = + has_write_key ? AGGR_WITH_WRITE_STAGE : NOT_AGGR_WITH_WRITE_STAGE; /* server id isn't enough. ensure we're connected & know wire version */ server_stream = _mongoc_cursor_fetch_stream (cursor); From 0e2d04a1ef7a04812c4810c5789e01b3b3198e8b Mon Sep 17 00:00:00 2001 From: vector-of-bool Date: Fri, 14 Jan 2022 17:21:38 +0000 Subject: [PATCH 33/52] Clarify wire version checks --- .../src/mongoc/mongoc-topology-description.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/libmongoc/src/mongoc/mongoc-topology-description.c b/src/libmongoc/src/mongoc/mongoc-topology-description.c index 53bb0b86e48..4690153a4c1 100644 --- a/src/libmongoc/src/mongoc/mongoc-topology-description.c +++ b/src/libmongoc/src/mongoc/mongoc-topology-description.c @@ -655,15 +655,17 @@ _mongoc_topology_description_validate_max_staleness ( } static bool -_check_any_server_less_than_wire_version_v5_0 (const void *sd_, - void *any_too_old_) +_check_any_server_less_than_wire_version_13 (const void *sd_, + void *any_too_old_) { const mongoc_server_description_t *sd = sd_; bool *any_too_old = any_too_old_; - if (sd->max_wire_version < WIRE_VERSION_5_0) { + if (sd->max_wire_version < 13) { *any_too_old = true; + return false /* Stop searching */; } - return true; + + return true /* Keep searching */; } /** @@ -699,7 +701,7 @@ _calc_effective_read_mode (const mongoc_topology_description_t *td, * aggregate-with-write on a secondary server */ bool any_too_old = false; mongoc_set_for_each_const (mc_tpld_servers_const (td), - _check_any_server_less_than_wire_version_v5_0, + _check_any_server_less_than_wire_version_13, &any_too_old); if (any_too_old) { /* Force the read preference back to reading from a primary server, as From bb4f07bb0e764da040f37e56a8d0702e5781c9d6 Mon Sep 17 00:00:00 2001 From: vector-of-bool Date: Fri, 14 Jan 2022 17:49:08 +0000 Subject: [PATCH 34/52] Use 'bool' instead of enum types to represent forced read mode --- src/libmongoc/src/mongoc/mongoc-aggregate.c | 3 +- .../src/mongoc/mongoc-change-stream.c | 13 +++--- src/libmongoc/src/mongoc/mongoc-client.c | 20 ++++++--- .../src/mongoc/mongoc-cluster-private.h | 15 ++----- src/libmongoc/src/mongoc/mongoc-cluster.c | 25 ++++------- src/libmongoc/src/mongoc/mongoc-cmd.c | 13 +++--- src/libmongoc/src/mongoc/mongoc-collection.c | 13 +++--- .../src/mongoc/mongoc-cursor-private.h | 11 +++-- src/libmongoc/src/mongoc/mongoc-cursor.c | 11 +++-- src/libmongoc/src/mongoc/mongoc-read-prefs.c | 5 --- src/libmongoc/src/mongoc/mongoc-read-prefs.h | 2 - .../src/mongoc/mongoc-server-stream-private.h | 5 +-- .../src/mongoc/mongoc-server-stream.c | 2 +- .../mongoc-topology-description-private.h | 4 +- .../src/mongoc/mongoc-topology-description.c | 45 +++++++++---------- .../src/mongoc/mongoc-topology-private.h | 18 ++++---- src/libmongoc/src/mongoc/mongoc-topology.c | 12 ++--- src/libmongoc/tests/test-mongoc-cluster.c | 2 +- src/libmongoc/tests/test-mongoc-cyrus.c | 2 +- src/libmongoc/tests/test-mongoc-topology.c | 8 ++-- 20 files changed, 105 insertions(+), 124 deletions(-) diff --git a/src/libmongoc/src/mongoc/mongoc-aggregate.c b/src/libmongoc/src/mongoc/mongoc-aggregate.c index 392b8634eb7..376ea2bcf97 100644 --- a/src/libmongoc/src/mongoc/mongoc-aggregate.c +++ b/src/libmongoc/src/mongoc/mongoc-aggregate.c @@ -278,8 +278,7 @@ _mongoc_aggregate (mongoc_client_t *client, /* This has an important effect on server selection when * readPreferences=secondary. Keep track of this fact for later use. */ - cursor->is_aggr_with_write_stage = - has_write_key ? AGGR_WITH_WRITE_STAGE : NOT_AGGR_WITH_WRITE_STAGE; + cursor->is_aggr_with_write_stage = has_write_key; /* server id isn't enough. ensure we're connected & know wire version */ server_stream = _mongoc_cursor_fetch_stream (cursor); diff --git a/src/libmongoc/src/mongoc/mongoc-change-stream.c b/src/libmongoc/src/mongoc/mongoc-change-stream.c index b712c0cf3c6..2daba263e1b 100644 --- a/src/libmongoc/src/mongoc/mongoc-change-stream.c +++ b/src/libmongoc/src/mongoc/mongoc-change-stream.c @@ -279,12 +279,13 @@ _make_cursor (mongoc_change_stream_t *stream) goto cleanup; } - server_stream = mongoc_cluster_stream_for_reads (&stream->client->cluster, - stream->read_prefs, - cs, - &reply, - NOT_AGGR_WITH_WRITE_STAGE, - &stream->err); + server_stream = + mongoc_cluster_stream_for_reads (&stream->client->cluster, + stream->read_prefs, + cs, + &reply, + /* Not aggregate-with-write */ false, + &stream->err); if (!server_stream) { bson_destroy (&stream->err_doc); bson_copy_to (&reply, &stream->err_doc); diff --git a/src/libmongoc/src/mongoc/mongoc-client.c b/src/libmongoc/src/mongoc/mongoc-client.c index 2d8eed420e0..46a3c504e9e 100644 --- a/src/libmongoc/src/mongoc/mongoc-client.c +++ b/src/libmongoc/src/mongoc/mongoc-client.c @@ -1791,7 +1791,7 @@ _mongoc_client_retryable_read_command_with_stream ( parts->read_prefs, parts->assembled.session, NULL, - NOT_AGGR_WITH_WRITE_STAGE, + /* Not aggregate-with-write */ false, &ignored_error); if (retry_server_stream && retry_server_stream->sd->max_wire_version >= @@ -1879,8 +1879,13 @@ mongoc_client_command_simple (mongoc_client_t *client, * configuration. The generic command method SHOULD allow an optional read * preference argument." */ - server_stream = mongoc_cluster_stream_for_reads ( - cluster, read_prefs, NULL, reply, NOT_AGGR_WITH_WRITE_STAGE, error); + server_stream = + mongoc_cluster_stream_for_reads (cluster, + read_prefs, + NULL, + reply, + /* Not aggregate-with-write */ false, + error); if (server_stream) { ret = _mongoc_client_command_with_stream ( @@ -2039,8 +2044,13 @@ _mongoc_client_command_with_opts (mongoc_client_t *client, server_stream = mongoc_cluster_stream_for_writes (cluster, cs, reply_ptr, error); } else { - server_stream = mongoc_cluster_stream_for_reads ( - cluster, prefs, cs, reply_ptr, NOT_AGGR_WITH_WRITE_STAGE, error); + server_stream = + mongoc_cluster_stream_for_reads (cluster, + prefs, + cs, + reply_ptr, + /* Not aggregate-with-write */ false, + error); } if (!server_stream) { diff --git a/src/libmongoc/src/mongoc/mongoc-cluster-private.h b/src/libmongoc/src/mongoc/mongoc-cluster-private.h index 9ad72bc7012..675102f93ce 100644 --- a/src/libmongoc/src/mongoc/mongoc-cluster-private.h +++ b/src/libmongoc/src/mongoc/mongoc-cluster-private.h @@ -44,7 +44,8 @@ BSON_BEGIN_DECLS typedef struct _mongoc_cluster_node_t { mongoc_stream_t *stream; char *connection_address; - /* handshake_sd is a server description created from the handshake on the stream. */ + /* handshake_sd is a server description created from the handshake on the + * stream. */ mongoc_server_description_t *handshake_sd; } mongoc_cluster_node_t; @@ -105,16 +106,6 @@ mongoc_cluster_try_recv (mongoc_cluster_t *cluster, mongoc_server_stream_t *server_stream, bson_error_t *error); -/** - * @brief Flag telling whether an aggregate operation has a write stage or not - */ -typedef enum aggr_with_write_stage_flag { - /** The operation is not an aggregate with a write stage */ - NOT_AGGR_WITH_WRITE_STAGE, - /** The intended operation is an aggregate with a write stage */ - AGGR_WITH_WRITE_STAGE -} aggr_with_write_stage_flag; - /** * @brief Obtain a server stream appropriate for read operations on the * cluster. @@ -132,7 +123,7 @@ mongoc_cluster_stream_for_reads (mongoc_cluster_t *cluster, const mongoc_read_prefs_t *read_prefs, mongoc_client_session_t *cs, bson_t *reply, - aggr_with_write_stage_flag with_write_stage, + bool is_aggr_with_write, bson_error_t *error); /** diff --git a/src/libmongoc/src/mongoc/mongoc-cluster.c b/src/libmongoc/src/mongoc/mongoc-cluster.c index 084e76205c6..d27d78201ac 100644 --- a/src/libmongoc/src/mongoc/mongoc-cluster.c +++ b/src/libmongoc/src/mongoc/mongoc-cluster.c @@ -2707,7 +2707,7 @@ _mongoc_cluster_select_server_id (mongoc_client_session_t *cs, mongoc_topology_t *topology, mongoc_ss_optype_t optype, const mongoc_read_prefs_t *read_prefs, - mongoc_read_mode_t *chosen_read_mode, + bool *must_use_primary, bson_error_t *error) { uint32_t server_id; @@ -2716,14 +2716,14 @@ _mongoc_cluster_select_server_id (mongoc_client_session_t *cs, server_id = cs->server_id; if (!server_id) { server_id = mongoc_topology_select_server_id ( - topology, optype, read_prefs, chosen_read_mode, error); + topology, optype, read_prefs, must_use_primary, error); if (server_id) { _mongoc_client_session_pin (cs, server_id); } } } else { server_id = mongoc_topology_select_server_id ( - topology, optype, read_prefs, chosen_read_mode, error); + topology, optype, read_prefs, must_use_primary, error); /* Transactions Spec: Additionally, any non-transaction operation using a * pinned ClientSession MUST unpin the session and the operation MUST * perform normal server selection. */ @@ -2764,14 +2764,14 @@ _mongoc_cluster_stream_for_optype (mongoc_cluster_t *cluster, mongoc_server_stream_t *server_stream; uint32_t server_id; mongoc_topology_t *topology = cluster->client->topology; - mongoc_read_mode_t chosen_read_mode = MONGOC_READ_UNSET; + bool must_use_primary = false; ENTRY; BSON_ASSERT (cluster); server_id = _mongoc_cluster_select_server_id ( - cs, topology, optype, read_prefs, &chosen_read_mode, error); + cs, topology, optype, read_prefs, &must_use_primary, error); if (!server_id) { _mongoc_bson_init_with_transient_txn_error (cs, reply); @@ -2781,7 +2781,7 @@ _mongoc_cluster_stream_for_optype (mongoc_cluster_t *cluster, if (!mongoc_cluster_check_interval (cluster, server_id)) { /* Server Selection Spec: try once more */ server_id = _mongoc_cluster_select_server_id ( - cs, topology, optype, read_prefs, &chosen_read_mode, error); + cs, topology, optype, read_prefs, &must_use_primary, error); if (!server_id) { _mongoc_bson_init_with_transient_txn_error (cs, reply); @@ -2793,7 +2793,7 @@ _mongoc_cluster_stream_for_optype (mongoc_cluster_t *cluster, server_stream = _mongoc_cluster_stream_for_server ( cluster, server_id, true /* reconnect_ok */, cs, reply, error); if (server_stream) { - server_stream->effective_read_mode = chosen_read_mode; + server_stream->must_use_primary = must_use_primary; } RETURN (server_stream); @@ -2804,7 +2804,7 @@ mongoc_cluster_stream_for_reads (mongoc_cluster_t *cluster, const mongoc_read_prefs_t *read_prefs, mongoc_client_session_t *cs, bson_t *reply, - aggr_with_write_stage_flag with_write_stage, + bool has_write_stage, bson_error_t *error) { const mongoc_read_prefs_t *prefs_override = read_prefs; @@ -2814,14 +2814,7 @@ mongoc_cluster_stream_for_reads (mongoc_cluster_t *cluster, } return _mongoc_cluster_stream_for_optype ( - cluster, - with_write_stage == NOT_AGGR_WITH_WRITE_STAGE - ? MONGOC_SS_READ - : MONGOC_SS_AGGREGATE_WITH_WRITE, - prefs_override, - cs, - reply, - error); + cluster, has_write_stage, prefs_override, cs, reply, error); } mongoc_server_stream_t * diff --git a/src/libmongoc/src/mongoc/mongoc-cmd.c b/src/libmongoc/src/mongoc/mongoc-cmd.c index 0699125ad94..3a71e8e1f27 100644 --- a/src/libmongoc/src/mongoc/mongoc-cmd.c +++ b/src/libmongoc/src/mongoc/mongoc-cmd.c @@ -474,11 +474,11 @@ _mongoc_cmd_parts_assemble_mongos (mongoc_cmd_parts_t *parts, hedge = mongoc_read_prefs_get_hedge (parts->read_prefs); } - if (server_stream->effective_read_mode != MONGOC_READ_UNSET) { - /* Server selection may have overriden the read mode used to generate this + if (server_stream->must_use_primary) { + /* Server selection has overriden the read mode used to generate this * server stream. This has effects on the body of the message that we send * to the server */ - mode = server_stream->effective_read_mode; + mode = MONGOC_READ_PRIMARY; } /* Server Selection Spec says: @@ -514,7 +514,6 @@ _mongoc_cmd_parts_assemble_mongos (mongoc_cmd_parts_t *parts, case MONGOC_READ_PRIMARY_PREFERRED: case MONGOC_READ_SECONDARY: case MONGOC_READ_NEAREST: - case MONGOC_READ_UNSET: default: parts->assembled.query_flags |= MONGOC_QUERY_SECONDARY_OK; add_read_prefs = true; @@ -828,7 +827,7 @@ mongoc_cmd_parts_assemble (mongoc_cmd_parts_t *parts, const char *cmd_name; bool is_get_more; const mongoc_read_prefs_t *prefs_ptr; - mongoc_read_mode_t mode = MONGOC_READ_UNSET; + mongoc_read_mode_t mode = mongoc_read_prefs_get_mode (parts->read_prefs); bool ret = false; ENTRY; @@ -888,11 +887,11 @@ mongoc_cmd_parts_assemble (mongoc_cmd_parts_t *parts, } mode = mongoc_read_prefs_get_mode (prefs_ptr); - if (server_stream->effective_read_mode != MONGOC_READ_UNSET) { + if (server_stream->must_use_primary) { /* Server selection may have overriden the read mode used to generate this * server stream. This has effects on the body of the message that we send * to the server */ - mode = server_stream->effective_read_mode; + mode = MONGOC_READ_PRIMARY; } if (server_stream->sd->max_wire_version >= WIRE_VERSION_OP_MSG) { diff --git a/src/libmongoc/src/mongoc/mongoc-collection.c b/src/libmongoc/src/mongoc/mongoc-collection.c index fa24e9a9152..38a2377ab0c 100644 --- a/src/libmongoc/src/mongoc/mongoc-collection.c +++ b/src/libmongoc/src/mongoc/mongoc-collection.c @@ -861,12 +861,13 @@ mongoc_collection_estimated_document_count ( BSON_ASSERT_PARAM (coll); - server_stream = mongoc_cluster_stream_for_reads (&coll->client->cluster, - read_prefs, - NULL, - reply, - NOT_AGGR_WITH_WRITE_STAGE, - error); + server_stream = + mongoc_cluster_stream_for_reads (&coll->client->cluster, + read_prefs, + NULL, + reply, + /* Not aggregate-with-write */ false, + error); if (opts && bson_has_field (opts, "sessionId")) { bson_set_error (error, diff --git a/src/libmongoc/src/mongoc/mongoc-cursor-private.h b/src/libmongoc/src/mongoc/mongoc-cursor-private.h index 4e3133f0d09..b41962495c9 100644 --- a/src/libmongoc/src/mongoc/mongoc-cursor-private.h +++ b/src/libmongoc/src/mongoc/mongoc-cursor-private.h @@ -133,15 +133,14 @@ struct _mongoc_cursor_t { mongoc_write_concern_t *write_concern; /** If the cursor was created for an operation that might have overridden the - * user's read preferences' read mode, the actually-used read mode will be - * stored here. Otherwise, this is zero. This value should be restored to - * server_stream objects that are created from this cursor when the stream - * was created using the memoized 'server_id' of the cursor. */ - mongoc_read_mode_t effective_read_mode; + * user's read preferences' read mode, then server selection forced the + * cursor to use a read preference mode of 'primary' server. Whether this + * force occurred is stored here: */ + bool must_use_primary; /** Whether this cursor corresponds to an aggregate command that contains a * writing-stage */ - aggr_with_write_stage_flag is_aggr_with_write_stage; + bool is_aggr_with_write_stage; bool explicit_session; mongoc_client_session_t *client_session; diff --git a/src/libmongoc/src/mongoc/mongoc-cursor.c b/src/libmongoc/src/mongoc/mongoc-cursor.c index dc0ef569931..0ce98971fce 100644 --- a/src/libmongoc/src/mongoc/mongoc-cursor.c +++ b/src/libmongoc/src/mongoc/mongoc-cursor.c @@ -251,7 +251,7 @@ _mongoc_cursor_new_with_opts (mongoc_client_t *client, cursor->client = client; cursor->state = UNPRIMED; cursor->client_generation = client->generation; - cursor->is_aggr_with_write_stage = NOT_AGGR_WITH_WRITE_STAGE; + cursor->is_aggr_with_write_stage = false; bson_init (&cursor->opts); bson_init (&cursor->error_doc); @@ -666,7 +666,7 @@ _mongoc_cursor_fetch_stream (mongoc_cursor_t *cursor) &cursor->error); /* Also restore the effective read mode that was used on that prior * selection */ - server_stream->effective_read_mode = cursor->effective_read_mode; + server_stream->must_use_primary = cursor->must_use_primary; } else { server_stream = mongoc_cluster_stream_for_reads (&cursor->client->cluster, @@ -680,7 +680,7 @@ _mongoc_cursor_fetch_stream (mongoc_cursor_t *cursor) /* Remember the selected server_id and the effective read mode so that * we can re-create an equivalent server_stream at a later time */ cursor->server_id = server_stream->sd->id; - cursor->effective_read_mode = server_stream->effective_read_mode; + cursor->must_use_primary = server_stream->must_use_primary; } } @@ -1094,8 +1094,7 @@ _mongoc_cursor_run_command (mongoc_cursor_t *cursor, mongoc_server_stream_cleanup (server_stream); - BSON_ASSERT (cursor->is_aggr_with_write_stage == - NOT_AGGR_WITH_WRITE_STAGE && + BSON_ASSERT (!cursor->is_aggr_with_write_stage && "Cannot attempt a retry on an aggregate operation that " "contains write stages"); server_stream = @@ -1103,7 +1102,7 @@ _mongoc_cursor_run_command (mongoc_cursor_t *cursor, cursor->read_prefs, cursor->client_session, reply, - NOT_AGGR_WITH_WRITE_STAGE, + /* Not aggregate-with-write */ false, &cursor->error); if (server_stream && diff --git a/src/libmongoc/src/mongoc/mongoc-read-prefs.c b/src/libmongoc/src/mongoc/mongoc-read-prefs.c index d357615a77c..7a250bdf015 100644 --- a/src/libmongoc/src/mongoc/mongoc-read-prefs.c +++ b/src/libmongoc/src/mongoc/mongoc-read-prefs.c @@ -164,10 +164,6 @@ mongoc_read_prefs_is_valid (const mongoc_read_prefs_t *read_prefs) return false; } - if (read_prefs->mode == MONGOC_READ_UNSET) { - /* A mode is required */ - return false; - } return true; } @@ -216,7 +212,6 @@ _mongoc_read_mode_as_str (mongoc_read_mode_t mode) return "secondaryPreferred"; case MONGOC_READ_NEAREST: return "nearest"; - case MONGOC_READ_UNSET: default: return ""; } diff --git a/src/libmongoc/src/mongoc/mongoc-read-prefs.h b/src/libmongoc/src/mongoc/mongoc-read-prefs.h index db869b11156..c378adbe579 100644 --- a/src/libmongoc/src/mongoc/mongoc-read-prefs.h +++ b/src/libmongoc/src/mongoc/mongoc-read-prefs.h @@ -34,8 +34,6 @@ typedef struct _mongoc_read_prefs_t mongoc_read_prefs_t; typedef enum { - /** Represents the absence of a read mode preference */ - MONGOC_READ_UNSET = 0, /** Represents $readPreference.mode of 'primary' */ MONGOC_READ_PRIMARY = (1 << 0), /** Represents $readPreference.mode of 'secondary' */ diff --git a/src/libmongoc/src/mongoc/mongoc-server-stream-private.h b/src/libmongoc/src/mongoc/mongoc-server-stream-private.h index fa053d50166..29109dc0a27 100644 --- a/src/libmongoc/src/mongoc/mongoc-server-stream-private.h +++ b/src/libmongoc/src/mongoc/mongoc-server-stream-private.h @@ -35,9 +35,8 @@ typedef struct _mongoc_server_stream_t { bson_t cluster_time; /* owned */ mongoc_stream_t *stream; /* borrowed */ /** If the stream was created in a way that may have overwritten the user's - * readPreference, the effective read mode is stored here, otherwise this is - * just zero. */ - mongoc_read_mode_t effective_read_mode; + * readPreference, we need to know if server selection forced that change. */ + bool must_use_primary; } mongoc_server_stream_t; diff --git a/src/libmongoc/src/mongoc/mongoc-server-stream.c b/src/libmongoc/src/mongoc/mongoc-server-stream.c index 5846ed205ba..84f21a36966 100644 --- a/src/libmongoc/src/mongoc/mongoc-server-stream.c +++ b/src/libmongoc/src/mongoc/mongoc-server-stream.c @@ -37,7 +37,7 @@ mongoc_server_stream_new (const mongoc_topology_description_t *td, bson_copy_to (&td->cluster_time, &server_stream->cluster_time); server_stream->sd = sd; /* becomes owned */ server_stream->stream = stream; /* merely borrowed */ - server_stream->effective_read_mode = MONGOC_READ_UNSET; + server_stream->must_use_primary = false; return server_stream; } diff --git a/src/libmongoc/src/mongoc/mongoc-topology-description-private.h b/src/libmongoc/src/mongoc/mongoc-topology-description-private.h index c85c2b31bcd..3a12b103472 100644 --- a/src/libmongoc/src/mongoc/mongoc-topology-description-private.h +++ b/src/libmongoc/src/mongoc/mongoc-topology-description-private.h @@ -113,7 +113,7 @@ mongoc_topology_description_select ( const mongoc_topology_description_t *description, mongoc_ss_optype_t optype, const mongoc_read_prefs_t *read_pref, - mongoc_read_mode_t *chosen_read_mode, + bool *must_use_primary, int64_t local_threshold_ms); mongoc_server_description_t * @@ -148,7 +148,7 @@ mongoc_topology_description_suitable_servers ( mongoc_ss_optype_t optype, const mongoc_topology_description_t *topology, const mongoc_read_prefs_t *read_pref, - mongoc_read_mode_t *chosen_read_mode, + bool *must_use_primary, size_t local_threshold_ms); bool diff --git a/src/libmongoc/src/mongoc/mongoc-topology-description.c b/src/libmongoc/src/mongoc/mongoc-topology-description.c index 4690153a4c1..3293f39632e 100644 --- a/src/libmongoc/src/mongoc/mongoc-topology-description.c +++ b/src/libmongoc/src/mongoc/mongoc-topology-description.c @@ -485,7 +485,7 @@ static void _mongoc_try_mode_secondary (mongoc_array_t *set, /* OUT */ const mongoc_topology_description_t *topology, const mongoc_read_prefs_t *read_pref, - mongoc_read_mode_t *chosen_read_mode, + bool *must_use_primary, size_t local_threshold_ms) { mongoc_read_prefs_t *secondary; @@ -497,7 +497,7 @@ _mongoc_try_mode_secondary (mongoc_array_t *set, /* OUT */ MONGOC_SS_READ, topology, secondary, - chosen_read_mode, + must_use_primary, local_threshold_ms); mongoc_read_prefs_destroy (secondary); @@ -678,10 +678,10 @@ _check_any_server_less_than_wire_version_13 (const void *sd_, * secondary server for using aggregate pipelines that contain writing stages * (i.e. '$out' and '$merge'). */ -static mongoc_read_mode_t -_calc_effective_read_mode (const mongoc_topology_description_t *td, - mongoc_ss_optype_t optype, - mongoc_read_mode_t requested_read_mode) +static bool +_force_read_primary (const mongoc_topology_description_t *td, + mongoc_ss_optype_t optype, + mongoc_read_mode_t requested_read_mode) { if (requested_read_mode == MONGOC_READ_PRIMARY) { /* We never alter from a primary read mode. This early-return is just an @@ -692,10 +692,10 @@ _calc_effective_read_mode (const mongoc_topology_description_t *td, switch (optype) { case MONGOC_SS_WRITE: /* We don't deal with write operations */ - return MONGOC_READ_UNSET; + return false; case MONGOC_SS_READ: /* Maintain the requested read mode if it is a regular read operation */ - return requested_read_mode; + return false; case MONGOC_SS_AGGREGATE_WITH_WRITE: { /* Check if any of the servers are too old to support the * aggregate-with-write on a secondary server */ @@ -706,15 +706,14 @@ _calc_effective_read_mode (const mongoc_topology_description_t *td, if (any_too_old) { /* Force the read preference back to reading from a primary server, as * one or more servers in the system may not support the operation */ - return MONGOC_READ_PRIMARY; + return true; } /* We're okay to send an aggr-with-write to a secondary server, so permit * the caller's read mode preference */ - return requested_read_mode; + return false; } default: - BSON_UNREACHABLE ( - "Invalid mongoc_ss_optype_t for _calc_effective_read_mode()"); + BSON_UNREACHABLE ("Invalid mongoc_ss_optype_t for _force_read_primary()"); } } @@ -738,7 +737,7 @@ mongoc_topology_description_suitable_servers ( mongoc_ss_optype_t optype, const mongoc_topology_description_t *topology, const mongoc_read_prefs_t *read_pref, - mongoc_read_mode_t *chosen_read_mode, + bool *must_use_primary, size_t local_threshold_ms) { mongoc_suitable_data_t data; @@ -748,6 +747,8 @@ mongoc_topology_description_suitable_servers ( int i; const mongoc_read_mode_t given_read_mode = mongoc_read_prefs_get_mode (read_pref); + const bool override_use_primary = + _force_read_primary (topology, optype, given_read_mode); data.primary = NULL; data.topology_type = topology->type; @@ -760,8 +761,7 @@ mongoc_topology_description_suitable_servers ( * depends on the user's provided read mode, the type of operation that the * user wishes to perform, and the server versions that we are talking to. * - * If the operation is a write operation, the "effective" read mode is UNSET - * and irrelevant. + * If the operation is a write operation, read mode is irrelevant. * * If the operation is a regular read, we just use the caller's read mode. * @@ -769,11 +769,10 @@ mongoc_topology_description_suitable_servers ( * be more careful about selecting an appropriate server. */ data.read_mode = - _calc_effective_read_mode (topology, optype, given_read_mode); - - if (chosen_read_mode) { - /* The caller wants to know what effective read mode we are using */ - *chosen_read_mode = data.read_mode; + override_use_primary ? MONGOC_READ_PRIMARY : given_read_mode; + if (must_use_primary) { + /* The caller wants to know if we have overriden their read preference */ + *must_use_primary = override_use_primary; } /* Single server -- @@ -820,7 +819,7 @@ mongoc_topology_description_suitable_servers ( if (data.read_mode == MONGOC_READ_SECONDARY_PREFERRED) { /* try read_mode SECONDARY */ _mongoc_try_mode_secondary ( - set, topology, read_pref, chosen_read_mode, local_threshold_ms); + set, topology, read_pref, must_use_primary, local_threshold_ms); /* otherwise fall back to primary */ if (!set->len && data.primary) { @@ -967,7 +966,7 @@ mongoc_topology_description_select ( const mongoc_topology_description_t *topology, mongoc_ss_optype_t optype, const mongoc_read_prefs_t *read_pref, - mongoc_read_mode_t *chosen_read_mode, + bool *must_use_primary, int64_t local_threshold_ms) { mongoc_array_t suitable_servers; @@ -994,7 +993,7 @@ mongoc_topology_description_select ( optype, topology, read_pref, - chosen_read_mode, + must_use_primary, local_threshold_ms); if (suitable_servers.len != 0) { rand_n = _mongoc_rand_simple ((unsigned *) &topology->rand_seed); diff --git a/src/libmongoc/src/mongoc/mongoc-topology-private.h b/src/libmongoc/src/mongoc/mongoc-topology-private.h index 0be92ed1e97..d269f1ad2b9 100644 --- a/src/libmongoc/src/mongoc/mongoc-topology-private.h +++ b/src/libmongoc/src/mongoc/mongoc-topology-private.h @@ -234,10 +234,9 @@ mongoc_topology_compatible (const mongoc_topology_description_t *td, * @param topology The topology to inspect and/or update. * @param optype The operation that is intended to be performed. * @param read_prefs The read preferences for the command. - * @param chosen_read_mode An option output parameter. If server selection might - * need to override the caller's read preferences' read mode, the actually-used - * read mode will be written to this pointer. If no overriding takes place, then - * the pointed-to value remains unchanged. + * @param must_use_primary An optional output parameter. Server selection might + * need to override the caller's read preferences' read mode to 'primary'. + * Whether or not that takes place will be set through this pointer. * @param error An output parameter for any error information. * @return mongoc_server_description_t* A copy of the topology's server * description that matches the request, or NULL if there is no such server. @@ -251,7 +250,7 @@ mongoc_server_description_t * mongoc_topology_select (mongoc_topology_t *topology, mongoc_ss_optype_t optype, const mongoc_read_prefs_t *read_prefs, - mongoc_read_mode_t *chosen_read_mode, + bool *must_use_primary, bson_error_t *error); /** @@ -263,10 +262,9 @@ mongoc_topology_select (mongoc_topology_t *topology, * @param topology The topology to inspect and/or update. * @param optype The operation that is intended to be performed. * @param read_prefs The read preferences for the command. - * @param chosen_read_mode An option output parameter. If server selection might - * need to override the caller's read preferences' read mode, the actually-used - * read mode will be written to this pointer. If no overriding takes place, then - * the pointed-to value remains unchanged. + * @param must_use_primary An optional output parameter. Server selection might + * need to override the caller's read preferences' read mode to 'primary'. + * Whether or not that takes place will be set through this pointer. * @param error An output parameter for any error information. * @return uint32_t A non-zero integer ID of the server description. In case of * error, sets `error` and returns zero. @@ -277,7 +275,7 @@ uint32_t mongoc_topology_select_server_id (mongoc_topology_t *topology, mongoc_ss_optype_t optype, const mongoc_read_prefs_t *read_prefs, - mongoc_read_mode_t *chosen_read_mode, + bool *must_use_primary, bson_error_t *error); /** diff --git a/src/libmongoc/src/mongoc/mongoc-topology.c b/src/libmongoc/src/mongoc/mongoc-topology.c index f292cddc465..a9bca4f1fa9 100644 --- a/src/libmongoc/src/mongoc/mongoc-topology.c +++ b/src/libmongoc/src/mongoc/mongoc-topology.c @@ -1005,11 +1005,11 @@ mongoc_server_description_t * mongoc_topology_select (mongoc_topology_t *topology, mongoc_ss_optype_t optype, const mongoc_read_prefs_t *read_prefs, - mongoc_read_mode_t *chosen_read_mode, + bool *must_use_primary, bson_error_t *error) { uint32_t server_id = mongoc_topology_select_server_id ( - topology, optype, read_prefs, chosen_read_mode, error); + topology, optype, read_prefs, must_use_primary, error); if (server_id) { /* new copy of the server description */ @@ -1121,7 +1121,7 @@ uint32_t mongoc_topology_select_server_id (mongoc_topology_t *topology, mongoc_ss_optype_t optype, const mongoc_read_prefs_t *read_prefs, - mongoc_read_mode_t *chosen_read_mode, + bool *must_use_primary, bson_error_t *error) { static const char *timeout_msg = @@ -1237,7 +1237,7 @@ mongoc_topology_select_server_id (mongoc_topology_t *topology, } selected_server = mongoc_topology_description_select ( - td.ptr, optype, read_prefs, chosen_read_mode, local_threshold_ms); + td.ptr, optype, read_prefs, must_use_primary, local_threshold_ms); if (selected_server) { server_id = selected_server->id; @@ -1283,7 +1283,7 @@ mongoc_topology_select_server_id (mongoc_topology_t *topology, } selected_server = mongoc_topology_description_select ( - td.ptr, optype, read_prefs, chosen_read_mode, local_threshold_ms); + td.ptr, optype, read_prefs, must_use_primary, local_threshold_ms); if (selected_server) { server_id = selected_server->id; @@ -1299,7 +1299,7 @@ mongoc_topology_select_server_id (mongoc_topology_t *topology, * occurred while we were waiting on the lock. */ mc_tpld_renew_ref (&td, topology); selected_server = mongoc_topology_description_select ( - td.ptr, optype, read_prefs, chosen_read_mode, local_threshold_ms); + td.ptr, optype, read_prefs, must_use_primary, local_threshold_ms); if (selected_server) { server_id = selected_server->id; bson_mutex_unlock (&topology->tpld_modification_mtx); diff --git a/src/libmongoc/tests/test-mongoc-cluster.c b/src/libmongoc/tests/test-mongoc-cluster.c index ef7d4ea17a8..1d372d5ecd7 100644 --- a/src/libmongoc/tests/test-mongoc-cluster.c +++ b/src/libmongoc/tests/test-mongoc-cluster.c @@ -26,7 +26,7 @@ server_id_for_reads (mongoc_cluster_t *cluster) uint32_t id; server_stream = mongoc_cluster_stream_for_reads ( - cluster, NULL, NULL, NULL, NOT_AGGR_WITH_WRITE_STAGE, &error); + cluster, NULL, NULL, NULL, false, &error); ASSERT_OR_PRINT (server_stream, error); id = server_stream->sd->id; diff --git a/src/libmongoc/tests/test-mongoc-cyrus.c b/src/libmongoc/tests/test-mongoc-cyrus.c index 7290949440c..79bde26bff7 100644 --- a/src/libmongoc/tests/test-mongoc-cyrus.c +++ b/src/libmongoc/tests/test-mongoc-cyrus.c @@ -75,7 +75,7 @@ test_sasl_canonicalize_hostname (void *ctx) client = test_framework_new_default_client (); ss = mongoc_cluster_stream_for_reads ( - &client->cluster, NULL, NULL, NULL, NOT_AGGR_WITH_WRITE_STAGE, &error); + &client->cluster, NULL, NULL, NULL, false, &error); ASSERT_OR_PRINT (ss, error); BSON_ASSERT (_mongoc_sasl_get_canonicalized_name ( diff --git a/src/libmongoc/tests/test-mongoc-topology.c b/src/libmongoc/tests/test-mongoc-topology.c index b79a038586e..0b97f8e19a4 100644 --- a/src/libmongoc/tests/test-mongoc-topology.c +++ b/src/libmongoc/tests/test-mongoc-topology.c @@ -181,7 +181,7 @@ test_topology_client_creation (void) /* ensure that we are sharing streams with the client */ server_stream = mongoc_cluster_stream_for_reads ( - &client_a->cluster, NULL, NULL, NULL, NOT_AGGR_WITH_WRITE_STAGE, &error); + &client_a->cluster, NULL, NULL, NULL, false, &error); ASSERT_OR_PRINT (server_stream, error); node = mongoc_topology_scanner_get_node (client_a->topology->scanner, @@ -486,7 +486,7 @@ _test_topology_invalidate_server (bool pooled) /* call explicitly */ server_stream = mongoc_cluster_stream_for_reads ( - &client->cluster, NULL, NULL, NULL, NOT_AGGR_WITH_WRITE_STAGE, &error); + &client->cluster, NULL, NULL, NULL, false, &error); ASSERT_OR_PRINT (server_stream, error); sd = server_stream->sd; id = server_stream->sd->id; @@ -587,7 +587,7 @@ test_invalid_cluster_node (void *ctx) /* load stream into cluster */ server_stream = mongoc_cluster_stream_for_reads ( - &client->cluster, NULL, NULL, NULL, NOT_AGGR_WITH_WRITE_STAGE, &error); + &client->cluster, NULL, NULL, NULL, false, &error); ASSERT_OR_PRINT (server_stream, error); id = server_stream->sd->id; mongoc_server_stream_cleanup (server_stream); @@ -658,7 +658,7 @@ test_max_wire_version_race_condition (void *ctx) /* load stream into cluster */ server_stream = mongoc_cluster_stream_for_reads ( - &client->cluster, NULL, NULL, NULL, NOT_AGGR_WITH_WRITE_STAGE, &error); + &client->cluster, NULL, NULL, NULL, false, &error); ASSERT_OR_PRINT (server_stream, error); id = server_stream->sd->id; mongoc_server_stream_cleanup (server_stream); From a9c228219a77e302eb7cb2e6ef3d33d771629644 Mon Sep 17 00:00:00 2001 From: vector-of-bool Date: Wed, 19 Jan 2022 00:47:04 +0000 Subject: [PATCH 35/52] Remove refernce to "effective read moe" --- src/libmongoc/src/mongoc/mongoc-cursor.c | 7 ++++--- .../src/mongoc/mongoc-topology-description.c | 12 ++++++------ 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/src/libmongoc/src/mongoc/mongoc-cursor.c b/src/libmongoc/src/mongoc/mongoc-cursor.c index 0ce98971fce..800d1fcd043 100644 --- a/src/libmongoc/src/mongoc/mongoc-cursor.c +++ b/src/libmongoc/src/mongoc/mongoc-cursor.c @@ -664,7 +664,7 @@ _mongoc_cursor_fetch_stream (mongoc_cursor_t *cursor) cursor->client_session, &reply, &cursor->error); - /* Also restore the effective read mode that was used on that prior + /* Also restore whether primary read preference was forced by server * selection */ server_stream->must_use_primary = cursor->must_use_primary; } else { @@ -677,8 +677,9 @@ _mongoc_cursor_fetch_stream (mongoc_cursor_t *cursor) &cursor->error); if (server_stream) { - /* Remember the selected server_id and the effective read mode so that - * we can re-create an equivalent server_stream at a later time */ + /* Remember the selected server_id and whether primary read mode was + * forced so that we can re-create an equivalent server_stream at a + * later time */ cursor->server_id = server_stream->sd->id; cursor->must_use_primary = server_stream->must_use_primary; } diff --git a/src/libmongoc/src/mongoc/mongoc-topology-description.c b/src/libmongoc/src/mongoc/mongoc-topology-description.c index 3293f39632e..2ba90466c94 100644 --- a/src/libmongoc/src/mongoc/mongoc-topology-description.c +++ b/src/libmongoc/src/mongoc/mongoc-topology-description.c @@ -660,7 +660,7 @@ _check_any_server_less_than_wire_version_13 (const void *sd_, { const mongoc_server_description_t *sd = sd_; bool *any_too_old = any_too_old_; - if (sd->max_wire_version < 13) { + if (sd->max_wire_version < WIRE_VERSION_5_0) { *any_too_old = true; return false /* Stop searching */; } @@ -679,9 +679,9 @@ _check_any_server_less_than_wire_version_13 (const void *sd_, * (i.e. '$out' and '$merge'). */ static bool -_force_read_primary (const mongoc_topology_description_t *td, - mongoc_ss_optype_t optype, - mongoc_read_mode_t requested_read_mode) +_must_use_primary (const mongoc_topology_description_t *td, + mongoc_ss_optype_t optype, + mongoc_read_mode_t requested_read_mode) { if (requested_read_mode == MONGOC_READ_PRIMARY) { /* We never alter from a primary read mode. This early-return is just an @@ -713,7 +713,7 @@ _force_read_primary (const mongoc_topology_description_t *td, return false; } default: - BSON_UNREACHABLE ("Invalid mongoc_ss_optype_t for _force_read_primary()"); + BSON_UNREACHABLE ("Invalid mongoc_ss_optype_t for _must_use_primary()"); } } @@ -748,7 +748,7 @@ mongoc_topology_description_suitable_servers ( const mongoc_read_mode_t given_read_mode = mongoc_read_prefs_get_mode (read_pref); const bool override_use_primary = - _force_read_primary (topology, optype, given_read_mode); + _must_use_primary (topology, optype, given_read_mode); data.primary = NULL; data.topology_type = topology->type; From 5b5a4889a196d48bf6e5a7bdafa39c1b32691905 Mon Sep 17 00:00:00 2001 From: vector-of-bool Date: Wed, 19 Jan 2022 00:49:12 +0000 Subject: [PATCH 36/52] Fix bool-to-enum conversion in server selection --- src/libmongoc/src/mongoc/mongoc-cluster.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/libmongoc/src/mongoc/mongoc-cluster.c b/src/libmongoc/src/mongoc/mongoc-cluster.c index d27d78201ac..82cfe44dc03 100644 --- a/src/libmongoc/src/mongoc/mongoc-cluster.c +++ b/src/libmongoc/src/mongoc/mongoc-cluster.c @@ -2814,7 +2814,13 @@ mongoc_cluster_stream_for_reads (mongoc_cluster_t *cluster, } return _mongoc_cluster_stream_for_optype ( - cluster, has_write_stage, prefs_override, cs, reply, error); + cluster, + /* Narrow down the optype if this is an aggregate op with a write stage */ + has_write_stage ? MONGOC_SS_AGGREGATE_WITH_WRITE : MONGOC_SS_READ, + prefs_override, + cs, + reply, + error); } mongoc_server_stream_t * From 2754eb24a5b8c05d467524a3dba1819923d100a0 Mon Sep 17 00:00:00 2001 From: vector-of-bool Date: Tue, 25 Jan 2022 02:37:21 +0000 Subject: [PATCH 37/52] Doc comment in mdb-ctl --- build/cmake/mdb-ctrl.cmake | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/build/cmake/mdb-ctrl.cmake b/build/cmake/mdb-ctrl.cmake index 5fc0a08275f..d890b023630 100644 --- a/build/cmake/mdb-ctrl.cmake +++ b/build/cmake/mdb-ctrl.cmake @@ -1,3 +1,41 @@ +#[[ + +This CMake script is intended to be executed with '-P' to control a MongoDB +server executable as a test fixture. It uses the following arguments: + +DO={START,STOP} (required) + The action to perform. Must be 'START' or 'STOP' + +RUNDIR= (required) + A base directory in which to base all server executions. + +FIXTURE_NAME= (required) + A unique name of the fixture server to control. The name is arbitrary, but + should be unique. + +MDB_EXE= (required) + The path to a MongoDB server executable to use to control the test fixture. + +MDB_PORT= (required for DO=START) + An integer TCP port on which the server should bind. + +SERVER_ARGS= (optional for DO=START) + Additional arguments that should be given to the server executable when it + is started. MAY NOT be any of `--port`, `--pidfilepath`, `--fork`, + `--verbose`, `--logpath`, `--dbpath`, or `--shutdown`, as those options are + controlled by this script. + +--- + +If DO=START, and this script detects that there was a prior server test fixture +with the given name, it will ensure that the test fixture is not running before +trying to start it again. + +If DO=STOP, this script will attempt to stop the server test fixture. If it +fails to stop, then this script will exit with an error + +]] + # Fixture properties: get_filename_component (__fixture_dir "${RUNDIR}/_test-db/${FIXTURE_NAME}" ABSOLUTE) set (__mongod_exe "${MDB_EXE}") From 1b433e0952c0be70e8750b34ea303447bc939423 Mon Sep 17 00:00:00 2001 From: vector-of-bool Date: Tue, 25 Jan 2022 02:37:51 +0000 Subject: [PATCH 38/52] Support replSet test fixtures --- CMakeLists.txt | 12 ++- build/cmake/FindMongoDB.cmake | 184 +++++++++++++++++++++++++++------- build/cmake/LoadTests.cmake | 6 +- 3 files changed, 160 insertions(+), 42 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 800d9f98b9e..cd91199dcd6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -87,7 +87,17 @@ include (CCache) include (LLDLinker) find_package (MongoDB) -mongodb_setup_fixtures () +mongodb_setup_default_fixtures () + +get_property(versions GLOBAL PROPERTY MONGODB_FOUND_VERSIONS) +foreach (ver IN ITEMS 4.1.6 5.1.1) + message (STATUS "Setup for version ${ver}") + mongodb_create_replset_fixture(mdb/fixture/replSet/${ver} + VERSION "${ver}" + REPLSET_NAME rs-${ver} + DEFAULT + ) +endforeach() set (BUILD_VERSION "0.0.0" CACHE STRING "Library version (for both libbson and libmongoc)") diff --git a/build/cmake/FindMongoDB.cmake b/build/cmake/FindMongoDB.cmake index dcbd99773b1..f4b26ca99db 100644 --- a/build/cmake/FindMongoDB.cmake +++ b/build/cmake/FindMongoDB.cmake @@ -1,8 +1,24 @@ +#[[ + +Find MongoDB executables on the system, and define utilities for using them. + +This attempts to find as many MongoDB executables as possible. It scans ENV{PATH}, +as well as ENV{M_PREFIX} (if you have 'm' installed, all installed versions will +be found by this module.) + +This module defines a global property `MONGODB_FOUND_VERSIONS`, which is a list +of every unique MongoDB version that it found. For each version 'XYZ' that it +found, it will define an additional global property 'MONGODB_${XYZ}_PATH' that +contains the absolute path to the mongod server executable for that version. + +]] + if (MongoDB_FIND_COMPONENTS) message (SEND_ERROR "FindMongoDB does not take any components") endif () include (FindPackageHandleStandardArgs) +include (CMakeParseArguments) define_property (GLOBAL PROPERTY MONGODB_FOUND_VERSIONS BRIEF_DOCS "Versions of MongoDB that have been found" @@ -14,7 +30,11 @@ set(MONGODB_DEFAULT_TEST_FIXTURE_VERSIONS "List of MongoDB server versions against which to generate default test fixtures" ) -function (_get_mongod_version mongod_exe) +#[[ + Attempt to discern the MongoDB version of the given MongoDB server + executable, and save that information in a global property for later use. +]] +function (_mdb_discover_exe mongod_exe) # Create an ident for the filepath, since cache variables need to be cleanly named string (MAKE_C_IDENTIFIER "${mongod_exe}" mongod_exe_id) # The outupt from the executable will be cached in this variable: @@ -78,20 +98,23 @@ function (_get_mongod_version mongod_exe) set_property (GLOBAL APPEND PROPERTY MONGODB_FOUND_VERSIONS "${version}") endfunction () +#[[ Scan in 'bindir' for any mongod executables with the given 'extension' file extension ]] macro (_scan_for_mdb bindir extension) set (__bindir "${bindir}") set (__ext "${extension}") get_filename_component (candidate "${__bindir}/mongod${__ext}" ABSOLUTE) if (EXISTS "${candidate}") - _get_mongod_version ("${candidate}") + _mdb_discover_exe ("${candidate}") endif () endmacro () +#[[ Find them all ]] function (_mongodb_find) # Check if the user has 'm' installed: if (DEFINED ENV{M_PREFIX}) set (m_prefix "$ENV{M_PREFIX}") else () + # It may be in /usr/local, if not overriden set (m_prefix "/usr/local") endif () @@ -110,16 +133,20 @@ function (_mongodb_find) # Scan for executables foreach (bindir IN LISTS paths) if (DEFINED ENV{PATHEXT}) + # Windows defines PATHEXT as part of its executable search algorithm foreach (ext IN LISTS ENV{PATHEXT}) _scan_for_mdb ("${bindir}" "${ext}") endforeach () else () + # Other platforms do not use extensions, so use an empty string _scan_for_mdb ("${bindir}" "") endif () endforeach () + # Print versions of MongoDB that we have found. get_property (found GLOBAL PROPERTY MONGODB_FOUND_VERSIONS) set (new_found "${found}") + # Only print new ones, if we are running another time. list (REMOVE_ITEM new_found ~~~ ${_MDB_PREVIOUSLY_FOUND_VERSIONS}) if (new_found) set_property (GLOBAL PROPERTY MONGODB_FOUND_VERSIONS "${new_found}") @@ -129,11 +156,14 @@ function (_mongodb_find) message (STATUS " - ${version}:") message (STATUS " ${path}") endforeach () - set (MongoDB_FOUND TRUE PARENT_SCOPE) endif () set (_MDB_PREVIOUSLY_FOUND_VERSIONS "${found}" CACHE INTERNAL "") + if (found) + set (MongoDB_FOUND TRUE PARENT_SCOPE) + endif () endfunction () +# Do the finding _mongodb_find () #[[ @@ -141,17 +171,16 @@ _mongodb_find () determined by the MONGODB_FOUND_VERSIONS global property. The generated fixtures are named as 'default-' for each '' that was found. ]] -function (mongodb_setup_fixtures) +function (mongodb_setup_default_fixtures) set (versions ${MONGODB_DEFAULT_TEST_FIXTURE_VERSIONS}) if (versions STREQUAL "ALL") get_cmake_property (versions MONGODB_FOUND_VERSIONS) endif () foreach (ver IN LISTS versions) mongodb_create_fixture ( - "default-${ver}" - AUTOUSE - VERSION "${ver}" + "mdb/fixture/default/${ver}" VERSION "${ver}" SERVER_ARGS --setParameter enableTestCommands=1 + DEFAULT ) endforeach () endfunction () @@ -161,15 +190,15 @@ endfunction () instance for other tests. mongodb_create_fixture( - - VERSION + VERSION + [DEFAULT] [PORT_VARIABLE ] [SERVER_ARGS ...] ) and are the only required arguments. VERSION must specify a MongoDB server version that has a known path. There must be a - MONGODB__PATH global property that defines the path to a mongod + MONGODB__PATH global property that defines the path to a mongod executable file. These global properties are set by the FindMongoDB.cmake module when it is first imported. The list of available versions can be found in the MONGODB_FOUND_VERSIONS global property. @@ -185,10 +214,14 @@ endfunction () The fixture can then be associated with tests via the FIXTURES_REQUIRED test property. + + If [DEFAULT] is specified, then the fixture will be added to a default list + that will be used to populate live-server tests that do not otherwise + specify a server test fixture ]] function (mongodb_create_fixture name) cmake_parse_arguments (ARG - "AUTOUSE" + "DEFAULT" "PORT_VARIABLE;VERSION" "SERVER_ARGS" ${ARGN} @@ -204,7 +237,7 @@ function (mongodb_create_fixture name) get_cmake_property (port "_MDB_UNUSED_PORT") math (EXPR next "${port} + 3") set_property (GLOBAL PROPERTY _MDB_UNUSED_PORT "${next}") - add_test (NAME mdb/fixture/${name}/setup + add_test (NAME ${name}/setup COMMAND "${CMAKE_COMMAND}" -D "FIXTURE_NAME=${name}" -D "RUNDIR=${PROJECT_BINARY_DIR}" @@ -214,7 +247,7 @@ function (mongodb_create_fixture name) -D "SERVER_ARGS=${ARG_SERVER_ARGS}" -P ${_MDB_SCRIPT_DIR}/mdb-ctrl.cmake ) - add_test (NAME mdb/fixture/${name}/cleanup + add_test (NAME ${name}/cleanup COMMAND "${CMAKE_COMMAND}" -D "FIXTURE_NAME=${name}" -D "RUNDIR=${PROJECT_BINARY_DIR}" @@ -222,46 +255,121 @@ function (mongodb_create_fixture name) -D DO=STOP -P ${_MDB_SCRIPT_DIR}/mdb-ctrl.cmake ) - set_property (TEST mdb/fixture/${name}/setup PROPERTY FIXTURES_SETUP "${name}") - set_property (TEST mdb/fixture/${name}/cleanup PROPERTY FIXTURES_CLEANUP "${name}") + set_property (TEST ${name}/setup PROPERTY FIXTURES_SETUP "${name}") + set_property (TEST ${name}/cleanup PROPERTY FIXTURES_CLEANUP "${name}") set_property ( - TEST mdb/fixture/${name}/setup mdb/fixture/${name}/cleanup + TEST ${name}/setup ${name}/cleanup PROPERTY TIMEOUT 10) if (ARG_PORT_VARIABLE) - set ("${ARG_PORT_VARIABLE}" "${port}") + set ("${ARG_PORT_VARIABLE}" "${port}" PARENT_SCOPE) endif () - set_property (TARGET _mdb-test-meta - APPEND PROPERTY _CONTENT + set_property (TARGET __mdb-meta + APPEND PROPERTY _CTestData_CONTENT "# Test fixture '${name}'" "set(_fxt [[${name}]])" - "list(APPEND _MDB_TEST_FIXTURES [[${name}]])" - "set(\"_MDB_FIXTURE_\${_fxt}_PORT\" ${port})" + "set(\"_MDB_FIXTURE_\${_fxt}_PORT\" ${port})\n" ) - if (ARG_AUTOUSE) - set_property (GLOBAL APPEND PROPERTY MDB_TEST_AUTOUSE_FIXTURES "${name}") - set_property (TARGET _mdb-test-meta - APPEND PROPERTY _CONTENT - "list(APPEND _MDB_TEST_FIXTURES_AUTO_USE [[${name}]])" - ) + set_property(TARGET __mdb-meta APPEND PROPERTY _ALL_FIXTURES "${name}") + if (ARG_DEFAULT) + set_property (TARGET __mdb-meta APPEND PROPERTY _DEFAULT_FIXTURES "${name}") endif () endfunction () -include (CMakeParseArguments) +function (mongodb_create_replset_fixture name) + cmake_parse_arguments (ARG + "DEFAULT" + "PORT_VARIABLE;VERSION;COUNT;REPLSET_NAME" + "SERVER_ARGS" + ${ARGN} + ) + if (NOT ARG_COUNT) + set (ARG_COUNT 3) + endif () + set (children) + set(members) + set(_id 0) + foreach (n RANGE 1 "${ARG_COUNT}") + mongodb_create_fixture("${name}/rs${n}" + VERSION "${ARG_VERSION}" + SERVER_ARGS ${SERVER_ARGS} + --replSet "${ARG_REPLSET_NAME}" + --setParameter enableTestCommands=1 + PORT_VARIABLE final_port + ) + list (APPEND children "${name}/rs${n}") + list(APPEND members "{_id: ${_id}, host: 'localhost:${final_port}'}") + math(EXPR _id "${_id}+1") + endforeach() + get_cmake_property(mdb_exe MONGODB_${ARG_VERSION}_PATH) + get_filename_component(mdb_dir "${mdb_exe}/" DIRECTORY) + unset(_msh_path CACHE) + find_program(_msh_path + NAMES mongosh mongo + HINTS "${mdb_dir}" + NAMES_PER_DIR) + set(init_js "${CMAKE_CURRENT_BINARY_DIR}/_replset-${name}-init.js") + string(REPLACE ";" ", " members "${members}") + file(WRITE "${init_js}" + "var mems = [${members}]; + rs.initiate({ + _id: '${ARG_REPLSET_NAME}', + members: mems, + }); + var i = 0; + for (;;) { + if (rs.config().members.length == mems.length) + break; + sleep(1); + ++i; + if (i == 10000) { + assert(false, 'Members did not connect') + } + } + ") + add_test ( + NAME "${name}" + COMMAND "${_msh_path}" + --port ${final_port} + --norc "${init_js}" + ) + set_tests_properties ("${name}" + PROPERTIES FIXTURES_REQUIRED "${children}" + FIXTURES_SETUP "${name}" + ) + set_property(TARGET __mdb-meta APPEND PROPERTY _ALL_FIXTURES "${name}") + if (ARG_DEFAULT) + set_property(TARGET __mdb-meta APPEND PROPERTY _DEFAULT_FIXTURES "${name}") + endif () + set_property(TARGET __mdb-meta + APPEND PROPERTY _CTestData_CONTENT + "# replSet fixture '${name}'" + "set(_fxt [[${name}]])" + "set(\"_MDB_FIXTURE_\${_fxt}_PORT\" ${final_port})" + "set(\"_MDB_TRANSITIVE_FIXTURES_OF_\${_fxt}\" [[${children}]])\n" + ) +endfunction () set (_MDB_SCRIPT_DIR "${CMAKE_CURRENT_LIST_DIR}") -set_property (GLOBAL PROPERTY _MDB_UNUSED_PORT 51231) -set_property (GLOBAL PROPERTY MDB_TEST_AUTOUSE_FIXTURES "") +set_property (GLOBAL PROPERTY _MDB_UNUSED_PORT 21231) -if (NOT TARGET _mdb-test-meta) - add_custom_target (_mdb-test-meta) +# The __mdb-meta target is used only for attaching metadata to be used as part of generator expressions +if (NOT TARGET __mdb-meta) + add_custom_target (__mdb-meta) + set (lines + [[# THIS FILE IS GENERATED. DO NOT EDIT.]] + "set(_MDB_ALL_TEST_FIXTURES [[$]])" + "set(_MDB_DEFAULT_TEST_FIXTURES [[$]])" + "" + "$,\n>\n" + ) + string (REPLACE ";" "\n" content "${lines}") file (GENERATE OUTPUT "${PROJECT_BINARY_DIR}/MongoDB-CTestData.cmake" - CONTENT "$,\n>\n") - set_property(TARGET _mdb-test-meta - PROPERTY _CONTENT - [[# THIS FILE IS GENERATED. DO NOT EDIT.]] - "set(_MDB_TEST_FIXTURES)" - "set(_MDB_TEST_FIXTURES_AUTO_USE)\n" + CONTENT "${content}") + set_target_properties (__mdb-meta PROPERTIES + _ALL_FIXTURES "" + _DEFAULT_FIXTURES "" + _CTestData_CONTENT "" ) set_property (DIRECTORY APPEND PROPERTY TEST_INCLUDE_FILES "${PROJECT_BINARY_DIR}/MongoDB-CTestData.cmake") endif () diff --git a/build/cmake/LoadTests.cmake b/build/cmake/LoadTests.cmake index d3fd6a11f57..bbd19332933 100644 --- a/build/cmake/LoadTests.cmake +++ b/build/cmake/LoadTests.cmake @@ -52,18 +52,18 @@ foreach (line IN LISTS lines) set (meta "${listing}") list (REMOVE_AT meta 0) set (test "mongoc${test_name}") - if (NOT _MDB_TEST_FIXTURES_AUTO_USE OR NOT (meta MATCHES "uses-live-server")) + if (NOT _MDB_DEFAULT_TEST_FIXTURES OR NOT (meta MATCHES "uses-live-server")) _register_test ("${test}" "${test_name}") set_tests_properties ("${test}" PROPERTIES TIMEOUT 15 LABELS "${meta}" ) else () - foreach (fxt IN LISTS _MDB_TEST_FIXTURES_AUTO_USE) + foreach (fxt IN LISTS _MDB_DEFAULT_TEST_FIXTURES) set (qualname "${fxt}/${test}") _register_test ("${qualname}" "${test_name}") set_tests_properties ("${qualname}" PROPERTIES - FIXTURES_REQUIRED "${fxt}" + FIXTURES_REQUIRED "${fxt};${_MDB_TRANSITIVE_FIXTURES_OF_${fxt}}" RESOURCE_LOCK "${fxt}" ENVIRONMENT "MONGOC_TEST_URI=mongodb://localhost:${_MDB_FIXTURE_${fxt}_PORT}" TIMEOUT 15 From e065ea6fc61212d8c183b0f011fedc55500e2270 Mon Sep 17 00:00:00 2001 From: vector-of-bool Date: Wed, 26 Jan 2022 17:47:27 +0000 Subject: [PATCH 39/52] With Python instead --- build/cmake/FindMongoDB.cmake | 55 +++++------ build/cmake/mdb-ctrl.cmake | 102 -------------------- build/mdb-ctl.py | 170 ++++++++++++++++++++++++++++++++++ 3 files changed, 195 insertions(+), 132 deletions(-) delete mode 100644 build/cmake/mdb-ctrl.cmake create mode 100644 build/mdb-ctl.py diff --git a/build/cmake/FindMongoDB.cmake b/build/cmake/FindMongoDB.cmake index f4b26ca99db..83bbbf67cd5 100644 --- a/build/cmake/FindMongoDB.cmake +++ b/build/cmake/FindMongoDB.cmake @@ -237,29 +237,28 @@ function (mongodb_create_fixture name) get_cmake_property (port "_MDB_UNUSED_PORT") math (EXPR next "${port} + 3") set_property (GLOBAL PROPERTY _MDB_UNUSED_PORT "${next}") + set(fxt_dir "${PROJECT_BINARY_DIR}/_test-db/${name}") add_test (NAME ${name}/setup - COMMAND "${CMAKE_COMMAND}" - -D "FIXTURE_NAME=${name}" - -D "RUNDIR=${PROJECT_BINARY_DIR}" - -D "MDB_EXE=${path}" - -D MDB_PORT=${port} - -D DO=START - -D "SERVER_ARGS=${ARG_SERVER_ARGS}" - -P ${_MDB_SCRIPT_DIR}/mdb-ctrl.cmake + COMMAND + python -u "${_MDB_SCRIPT_DIR}/../mdb-ctl.py" + --mdb-exe "${path}" + start + --fixture-dir "${fxt_dir}" + --port "${port}" + --server-args ${ARG_SERVER_ARGS} ) add_test (NAME ${name}/cleanup - COMMAND "${CMAKE_COMMAND}" - -D "FIXTURE_NAME=${name}" - -D "RUNDIR=${PROJECT_BINARY_DIR}" - -D "MDB_EXE=${path}" - -D DO=STOP - -P ${_MDB_SCRIPT_DIR}/mdb-ctrl.cmake + COMMAND + python -u "${_MDB_SCRIPT_DIR}/../mdb-ctl.py" + --mdb-exe "${path}" + stop + --fixture-dir "${fxt_dir}" ) set_property (TEST ${name}/setup PROPERTY FIXTURES_SETUP "${name}") set_property (TEST ${name}/cleanup PROPERTY FIXTURES_CLEANUP "${name}") set_property ( TEST ${name}/setup ${name}/cleanup - PROPERTY TIMEOUT 10) + PROPERTY TIMEOUT 30) if (ARG_PORT_VARIABLE) set ("${ARG_PORT_VARIABLE}" "${port}" PARENT_SCOPE) endif () @@ -286,27 +285,20 @@ function (mongodb_create_replset_fixture name) set (ARG_COUNT 3) endif () set (children) - set(members) - set(_id 0) + get_cmake_property(first_port _MDB_UNUSED_PORT) + set(port_args) foreach (n RANGE 1 "${ARG_COUNT}") mongodb_create_fixture("${name}/rs${n}" VERSION "${ARG_VERSION}" SERVER_ARGS ${SERVER_ARGS} --replSet "${ARG_REPLSET_NAME}" --setParameter enableTestCommands=1 - PORT_VARIABLE final_port + PORT_VARIABLE node_port ) list (APPEND children "${name}/rs${n}") - list(APPEND members "{_id: ${_id}, host: 'localhost:${final_port}'}") - math(EXPR _id "${_id}+1") + list (APPEND port_args "--node-port=${node_port}") endforeach() get_cmake_property(mdb_exe MONGODB_${ARG_VERSION}_PATH) - get_filename_component(mdb_dir "${mdb_exe}/" DIRECTORY) - unset(_msh_path CACHE) - find_program(_msh_path - NAMES mongosh mongo - HINTS "${mdb_dir}" - NAMES_PER_DIR) set(init_js "${CMAKE_CURRENT_BINARY_DIR}/_replset-${name}-init.js") string(REPLACE ";" ", " members "${members}") file(WRITE "${init_js}" @@ -328,9 +320,12 @@ function (mongodb_create_replset_fixture name) ") add_test ( NAME "${name}" - COMMAND "${_msh_path}" - --port ${final_port} - --norc "${init_js}" + COMMAND + python -u "${_MDB_SCRIPT_DIR}/../mdb-ctl.py" + --mdb-exe "${mdb_exe}" + init-rs + --replset "${ARG_REPLSET_NAME}" + ${port_args} ) set_tests_properties ("${name}" PROPERTIES FIXTURES_REQUIRED "${children}" @@ -344,7 +339,7 @@ function (mongodb_create_replset_fixture name) APPEND PROPERTY _CTestData_CONTENT "# replSet fixture '${name}'" "set(_fxt [[${name}]])" - "set(\"_MDB_FIXTURE_\${_fxt}_PORT\" ${final_port})" + "set(\"_MDB_FIXTURE_\${_fxt}_PORT\" ${first_port})" "set(\"_MDB_TRANSITIVE_FIXTURES_OF_\${_fxt}\" [[${children}]])\n" ) endfunction () diff --git a/build/cmake/mdb-ctrl.cmake b/build/cmake/mdb-ctrl.cmake deleted file mode 100644 index d890b023630..00000000000 --- a/build/cmake/mdb-ctrl.cmake +++ /dev/null @@ -1,102 +0,0 @@ -#[[ - -This CMake script is intended to be executed with '-P' to control a MongoDB -server executable as a test fixture. It uses the following arguments: - -DO={START,STOP} (required) - The action to perform. Must be 'START' or 'STOP' - -RUNDIR= (required) - A base directory in which to base all server executions. - -FIXTURE_NAME= (required) - A unique name of the fixture server to control. The name is arbitrary, but - should be unique. - -MDB_EXE= (required) - The path to a MongoDB server executable to use to control the test fixture. - -MDB_PORT= (required for DO=START) - An integer TCP port on which the server should bind. - -SERVER_ARGS= (optional for DO=START) - Additional arguments that should be given to the server executable when it - is started. MAY NOT be any of `--port`, `--pidfilepath`, `--fork`, - `--verbose`, `--logpath`, `--dbpath`, or `--shutdown`, as those options are - controlled by this script. - ---- - -If DO=START, and this script detects that there was a prior server test fixture -with the given name, it will ensure that the test fixture is not running before -trying to start it again. - -If DO=STOP, this script will attempt to stop the server test fixture. If it -fails to stop, then this script will exit with an error - -]] - -# Fixture properties: -get_filename_component (__fixture_dir "${RUNDIR}/_test-db/${FIXTURE_NAME}" ABSOLUTE) -set (__mongod_exe "${MDB_EXE}") - -# Start up a clean MongoDB server in the fixture directory. Existing data will be deleted. -function (_start port server_argv) - if (IS_DIRECTORY "${__fixture_dir}" - AND NOT EXISTS "${__fixture_dir}/stopped.stamp") - _try_stop (_) - endif () - file (REMOVE_RECURSE "${__fixture_dir}") - file (MAKE_DIRECTORY "${__fixture_dir}/data") - execute_process ( - COMMAND "${__mongod_exe}" - ${server_argv} - --port "${port}" - --pidfilepath "${__fixture_dir}/mdb.pid" - --fork - --verbose - --logpath "${__fixture_dir}/server.log" - --dbpath "${__fixture_dir}/data" - RESULT_VARIABLE retc - ) - if (retc) - message (SEND_ERROR "Failed to start the MongoDB server [${retc}]") - _stop () - endif () - file (REMOVE "${__fixture_dir}/stopped.stamp") -endfunction () - -# Try to stop the fixture server, but not a hard-error if it fails -function (_try_stop okvar) - execute_process( - COMMAND "${__mongod_exe}" ${server_argv} - --pidfilepath "${__fixture_dir}/mdb.pid" - --dbpath "${__fixture_dir}/data" - --shutdown - RESULT_VARIABLE retc - ) - if (retc) - message (STATUS "Failed to stop the MongoDB server [${retc}]") - set ("${okvar}" FALSE PARENT_SCOPE) - else () - set ("${okvar}" TRUE PARENT_SCOPE) - file (WRITE "${__fixture_dir}/stopped.stamp") - endif () -endfunction () - -# Stop the fixture server, or fail the test -function (_stop) - _try_stop (did_stop) - if (NOT did_stop) - message (FATAL_ERROR "Failed to stop the MongoDB server") - endif () -endfunction () - -# Pick the action -if (DO STREQUAL "START") - _start ("${MDB_PORT}" "${SERVER_ARGS}") -elseif (DO STREQUAL "STOP") - _stop () -else () - message (FATAL_ERROR "mdb-ctrl.cmake requires a DO action of 'START' or 'STOP'") -endif () diff --git a/build/mdb-ctl.py b/build/mdb-ctl.py new file mode 100644 index 00000000000..11b91225670 --- /dev/null +++ b/build/mdb-ctl.py @@ -0,0 +1,170 @@ +import argparse +from pathlib import Path +import sys +from typing import NamedTuple, Sequence, cast +import json +import shutil +import subprocess + + +class _CommandArgs(NamedTuple): + mdb_exe: Path + command: str + + +class _StartArgs(_CommandArgs): + port: int + server_args: Sequence[str] + fixture_dir: Path + + +class _StopArgs(_CommandArgs): + fixture_dir: Path + + +class _InitRSArgs(_CommandArgs): + node_ports: Sequence[int] + replset: str + + +def create_argparser() -> argparse.ArgumentParser: + parser = argparse.ArgumentParser() + + parser.add_argument( + '--mdb-exe', + required=True, + type=Path, + help= + 'Path to a MongoD executable to use to run/control the server fixture', + metavar='') + + subs = parser.add_subparsers(required=True, + title='Subcommand', + help='The action to perform', + dest='command') + + start = subs.add_parser('start') + start.add_argument('--port', + type=int, + required=True, + help='The TCP port to which the server will bind') + start.add_argument( + '--server-args', + nargs=argparse.REMAINDER, + help='Additional arguments to pass to the server executable') + start.add_argument('--fixture-dir', + required=True, + type=Path, + help='Directory to the fixture database data', + metavar='DIR') + + stop = subs.add_parser('stop') + stop.add_argument('--fixture-dir', + required=True, + type=Path, + help='Directory to the fixture database data', + metavar='DIR') + + init_rs = subs.add_parser('init-rs') + init_rs.add_argument( + '--node-port', + required=True, + help='Port of a node in the replica set (Provide at least once)', + metavar='PORT', + action='append', + dest='node_ports', + type=int) + init_rs.add_argument('--replset', + help='Name of the replica set', + required=True) + return parser + + +def _try_stop(dir: Path, mdb_exe: Path) -> bool: + retc = subprocess.call([ + str(mdb_exe), + f'--pidfilepath={dir}/mdb.pid', + f'--dbpath={dir}/data', + '--shutdown', + ]) + return retc == 0 + + +def _do_start(args: _StartArgs) -> int: + if args.fixture_dir.is_dir(): + if not args.fixture_dir.joinpath('stopped.stamp').exists(): + _try_stop(args.fixture_dir, args.mdb_exe) + shutil.rmtree(args.fixture_dir) + args.fixture_dir.joinpath('data').mkdir(exist_ok=True, parents=True) + subprocess.check_call([ + str(args.mdb_exe), + f'--port={args.port}', + f'--pidfilepath={args.fixture_dir}/mdb.pid', + '--fork', + '--verbose', + f'--logpath={args.fixture_dir}/server.log', + f'--dbpath={args.fixture_dir}/data', + *args.server_args, + ]) + return 0 + + +def _do_stop(args: _StopArgs) -> int: + if not _try_stop(args.fixture_dir, args.mdb_exe): + raise RuntimeError( + f'Failed to stop the MongoDB server in {args.fixture_dir}') + return 0 + + +def _do_init_rs(args: _InitRSArgs) -> int: + mdb_bin_dir = args.mdb_exe.parent.resolve() + msh_cands = (mdb_bin_dir.joinpath(f) + for f in ['mongo', 'mongosh', 'mongo.exe', 'mongosh.exe']) + mongosh_exe = next(iter(filter(Path.is_file, msh_cands)), None) + if mongosh_exe is None: + raise RuntimeError( + f'No MongoSH executable was found beside the MongoD executable') + members_json = json.dumps([{ + '_id': idx, + 'host': f'localhost:{port}', + } for idx, port in enumerate(args.node_ports)]) + init_js = rf''' + var members = {members_json}; + rs.initiate({{ + _id: {repr(args.replset)}, + members: members, + }}); + var i = 0; + for (;;) {{ + if (rs.config().members.length == members.length) + break; + sleep(1); + if (i == 10000) {{ + assert(false, 'Replica set members did not connect'); + }} + }} + ''' + subprocess.check_call([ + str(mongosh_exe), + f'--port={args.node_ports[0]}', + '--norc', + '--eval', + init_js, + ]) + return 0 + + +def main(argv: Sequence[str]) -> int: + args = cast(_CommandArgs, create_argparser().parse_args(argv)) + if args.command == 'start': + return _do_start(cast(_StartArgs, args)) + if args.command == 'stop': + return _do_stop(cast(_StopArgs, args)) + if args.command == 'init-rs': + return _do_init_rs(cast(_InitRSArgs, args)) + assert 0, f'Unknown command "{args.command}"' + return 1 + + +if __name__ == '__main__': + sys.exit(main(sys.argv[1:])) From 0496e7a15819291f9968938e7ad771891390cbb8 Mon Sep 17 00:00:00 2001 From: vector-of-bool Date: Tue, 1 Feb 2022 00:39:54 +0000 Subject: [PATCH 40/52] Sharded test fixtures --- build/cmake/FindMongoDB.cmake | 74 +++++++++++++++++- build/mdb-ctl.py | 137 ++++++++++++++++++++++++---------- 2 files changed, 171 insertions(+), 40 deletions(-) diff --git a/build/cmake/FindMongoDB.cmake b/build/cmake/FindMongoDB.cmake index 83bbbf67cd5..ea5b11f7f92 100644 --- a/build/cmake/FindMongoDB.cmake +++ b/build/cmake/FindMongoDB.cmake @@ -277,7 +277,7 @@ endfunction () function (mongodb_create_replset_fixture name) cmake_parse_arguments (ARG "DEFAULT" - "PORT_VARIABLE;VERSION;COUNT;REPLSET_NAME" + "PORT_VARIABLE;VERSION;COUNT;REPLSET_NAME;FIXTURES_VARIABLE" "SERVER_ARGS" ${ARGN} ) @@ -290,7 +290,7 @@ function (mongodb_create_replset_fixture name) foreach (n RANGE 1 "${ARG_COUNT}") mongodb_create_fixture("${name}/rs${n}" VERSION "${ARG_VERSION}" - SERVER_ARGS ${SERVER_ARGS} + SERVER_ARGS ${ARG_SERVER_ARGS} --replSet "${ARG_REPLSET_NAME}" --setParameter enableTestCommands=1 PORT_VARIABLE node_port @@ -342,6 +342,76 @@ function (mongodb_create_replset_fixture name) "set(\"_MDB_FIXTURE_\${_fxt}_PORT\" ${first_port})" "set(\"_MDB_TRANSITIVE_FIXTURES_OF_\${_fxt}\" [[${children}]])\n" ) + if (ARG_PORT_VARIABLE) + set ("${ARG_PORT_VARIABLE}" ${first_port} PARENT_SCOPE) + endif () + if (ARG_FIXTURES_VARIABLE) + set ("${ARG_FIXTURES_VARIABLE}" "${children};${name}" PARENT_SCOPE) + endif () +endfunction () + +function (mongodb_create_sharded_fixture name) + cmake_parse_arguments (ARG + "DEFAULT" + "PORT_VARIABLE;VERSION;COUNT" + "SHARD_ARGS;MONGOS_ARGS" + ${ARGN} + ) + mongodb_create_replset_fixture ( + "${name}/data" + PORT_VARIABLE data_port + REPLSET_NAME "${name}-data" + COUNT 2 + FIXTURES_VARIABLE data_fixtures + SERVER_ARGS --shardsvr + VERSION "${ARG_VERSION}" + ) + mongodb_create_replset_fixture ( + "${name}/config" + PORT_VARIABLE config_port + REPLSET_NAME "${name}-config" + COUNT 2 + FIXTURES_VARIABLE config_fixtures + SERVER_ARGS --configsvr + VERSION "${ARG_VERSION}" + ) + get_cmake_property(mdb_exe MONGODB_${ARG_VERSION}_PATH) + get_cmake_property (mongos_port "_MDB_UNUSED_PORT") + math (EXPR next "${mongos_port} + 3") + set_property (GLOBAL PROPERTY _MDB_UNUSED_PORT "${next}") + add_test ( + NAME "${name}" + COMMAND + python -u "${_MDB_SCRIPT_DIR}/../mdb-ctl.py" + --mdb-exe "${mdb_exe}" + init-sharding + --configdb "${name}-config/localhost:${config_port}" + --datadb "${name}-data/localhost:${data_port}" + --port "${mongos_port}" + --scratch-dir "${CMAKE_CURRENT_BINARY_DIR}/${name}" + ) + set_tests_properties("${name}" PROPERTIES + FIXTURES_SETUP "${name}" + FIXTURES_REQUIRED "${config_fixtures};${data_fixtures}" + ) + add_test ( + NAME "${name}/cleanup" + COMMAND python -u "${_MDB_SCRIPT_DIR}/../mdb-ctl.py" + --mdb-exe "${mdb_exe}" + stop-sharding --port "${mongos_port}" + ) + set_tests_properties ("${name}/cleanup" PROPERTIES FIXTURES_CLEANUP "${name}") + set_property(TARGET __mdb-meta + APPEND PROPERTY _CTestData_CONTENT + "# replSet fixture '${name}'" + "set(_fxt [[${name}]])" + "set(\"_MDB_FIXTURE_\${_fxt}_PORT\" ${mongos_port})" + "set(\"_MDB_TRANSITIVE_FIXTURES_OF_\${_fxt}\" [[${config_fixtures};${data_fixtures}]])\n" + ) + set_property(TARGET __mdb-meta APPEND PROPERTY _ALL_FIXTURES "${name}") + if (ARG_DEFAULT) + set_property(TARGET __mdb-meta APPEND PROPERTY _DEFAULT_FIXTURES "${name}") + endif () endfunction () set (_MDB_SCRIPT_DIR "${CMAKE_CURRENT_LIST_DIR}") diff --git a/build/mdb-ctl.py b/build/mdb-ctl.py index 11b91225670..bcaaf1b48a1 100644 --- a/build/mdb-ctl.py +++ b/build/mdb-ctl.py @@ -27,31 +27,33 @@ class _InitRSArgs(_CommandArgs): replset: str +class _InitShardingArgs(_CommandArgs): + configdb: str + datadb: str + port: int + scratch_dir: Path + + +class _StopShardingArgs(_CommandArgs): + port: int + + def create_argparser() -> argparse.ArgumentParser: parser = argparse.ArgumentParser() - parser.add_argument( - '--mdb-exe', - required=True, - type=Path, - help= - 'Path to a MongoD executable to use to run/control the server fixture', - metavar='') + parser.add_argument('--mdb-exe', + required=True, + type=Path, + help='Path to a MongoD executable to use to run/control the server fixture', + metavar='') - subs = parser.add_subparsers(required=True, - title='Subcommand', - help='The action to perform', - dest='command') + subs = parser.add_subparsers(required=True, title='Subcommand', help='The action to perform', dest='command') start = subs.add_parser('start') - start.add_argument('--port', - type=int, - required=True, - help='The TCP port to which the server will bind') - start.add_argument( - '--server-args', - nargs=argparse.REMAINDER, - help='Additional arguments to pass to the server executable') + start.add_argument('--port', type=int, required=True, help='The TCP port to which the server will bind') + start.add_argument('--server-args', + nargs=argparse.REMAINDER, + help='Additional arguments to pass to the server executable') start.add_argument('--fixture-dir', required=True, type=Path, @@ -66,17 +68,29 @@ def create_argparser() -> argparse.ArgumentParser: metavar='DIR') init_rs = subs.add_parser('init-rs') - init_rs.add_argument( - '--node-port', - required=True, - help='Port of a node in the replica set (Provide at least once)', - metavar='PORT', - action='append', - dest='node_ports', - type=int) - init_rs.add_argument('--replset', - help='Name of the replica set', - required=True) + init_rs.add_argument('--node-port', + required=True, + help='Port of a node in the replica set (Provide at least once)', + metavar='PORT', + action='append', + dest='node_ports', + type=int) + init_rs.add_argument('--replset', help='Name of the replica set', required=True) + + init_sharding = subs.add_parser('init-sharding') + init_sharding.add_argument('--configdb', + required=True, + help='The specifier of the config db for mongos', + metavar='/') + init_sharding.add_argument('--datadb', + required=True, + help='The specifier of the data db to connect to the mongos', + metavar='/') + init_sharding.add_argument('--port', required=True, help='The bind port for the mongos instance', type=int) + init_sharding.add_argument('--scratch-dir', required=True, help='Directory for ephemeral and pid files', type=Path) + + stop_sharding = subs.add_parser('stop-sharding') + stop_sharding.add_argument('--port', required=True, help='Port of the mongos server to shutdown', type=int) return parser @@ -111,19 +125,20 @@ def _do_start(args: _StartArgs) -> int: def _do_stop(args: _StopArgs) -> int: if not _try_stop(args.fixture_dir, args.mdb_exe): - raise RuntimeError( - f'Failed to stop the MongoDB server in {args.fixture_dir}') + raise RuntimeError(f'Failed to stop the MongoDB server in {args.fixture_dir}') return 0 -def _do_init_rs(args: _InitRSArgs) -> int: - mdb_bin_dir = args.mdb_exe.parent.resolve() - msh_cands = (mdb_bin_dir.joinpath(f) - for f in ['mongo', 'mongosh', 'mongo.exe', 'mongosh.exe']) +def _find_mongosh(bin_dir: Path) -> Path: + msh_cands = (bin_dir.joinpath(f) for f in ['mongo', 'mongosh', 'mongo.exe', 'mongosh.exe']) mongosh_exe = next(iter(filter(Path.is_file, msh_cands)), None) if mongosh_exe is None: - raise RuntimeError( - f'No MongoSH executable was found beside the MongoD executable') + raise RuntimeError(f'No MongoSH executable was found in {bin_dir}') + return mongosh_exe + + +def _do_init_rs(args: _InitRSArgs) -> int: + mongosh_exe = _find_mongosh(args.mdb_exe.parent) members_json = json.dumps([{ '_id': idx, 'host': f'localhost:{port}', @@ -154,6 +169,48 @@ def _do_init_rs(args: _InitRSArgs) -> int: return 0 +def _do_init_sharding(args: _InitShardingArgs) -> int: + mongosh_exe = _find_mongosh(args.mdb_exe.parent) + mdb_bin_dir = args.mdb_exe.parent.resolve() + ms_cands = (mdb_bin_dir.joinpath(f) for f in ['mongos', 'mongos.exe']) + mongos_exe = next(iter(ms_cands), None) + if mongosh_exe is None: + raise RuntimeError(f'No MongoS executable was found beside the MongoD executable') + + args.scratch_dir.mkdir(exist_ok=True, parents=True) + subprocess.check_call([ + str(mongos_exe), + f'--configdb={args.configdb}', + f'--port={args.port}', + f'--logpath={args.scratch_dir}/mongos.log', + f'--pidfilepath={args.scratch_dir}/mongos.pid', + '--setParameter=enableTestCommands=1', + '--fork', + ]) + + subprocess.check_call([ + str(mongosh_exe), + f'localhost:{args.port}/admin', + '--norc', + '--eval', + f'sh.addShard({args.datadb!r})', + ]) + + return 0 + + +def _do_stop_sharding(args: _StopShardingArgs) -> int: + mongosh_exe = _find_mongosh(args.mdb_exe.parent) + subprocess.check_call([ + str(mongosh_exe), + f'localhost:{args.port}/admin', + '--norc', + '--eval', + 'db.shutdownServer()', + ]) + return 0 + + def main(argv: Sequence[str]) -> int: args = cast(_CommandArgs, create_argparser().parse_args(argv)) if args.command == 'start': @@ -162,6 +219,10 @@ def main(argv: Sequence[str]) -> int: return _do_stop(cast(_StopArgs, args)) if args.command == 'init-rs': return _do_init_rs(cast(_InitRSArgs, args)) + if args.command == 'init-sharding': + return _do_init_sharding(cast(_InitShardingArgs, args)) + if args.command == 'stop-sharding': + return _do_stop_sharding(cast(_StopShardingArgs, args)) assert 0, f'Unknown command "{args.command}"' return 1 From ac41e86a40bcee4d20acbb517ceccbd55927e776 Mon Sep 17 00:00:00 2001 From: vector-of-bool Date: Tue, 27 Sep 2022 01:34:57 +0000 Subject: [PATCH 41/52] Python 3.5 compat for fake_azure --- build/fake_azure.py | 72 +++++++++++++++++++++++---------------------- 1 file changed, 37 insertions(+), 35 deletions(-) diff --git a/build/fake_azure.py b/build/fake_azure.py index 16b408e5057..5ca6d7998ba 100644 --- a/build/fake_azure.py +++ b/build/fake_azure.py @@ -1,19 +1,21 @@ -from __future__ import annotations - +import functools +import json import sys import time -import json import traceback -import functools +from pathlib import Path + import bottle -from bottle import Bottle, HTTPResponse, request +from bottle import Bottle, HTTPResponse imds = Bottle(autojson=True) """An Azure IMDS server""" -from typing import TYPE_CHECKING, Any, Callable, Iterable, overload +from typing import TYPE_CHECKING, Any, Callable, Iterable, cast, overload -if TYPE_CHECKING: +if not TYPE_CHECKING: + from bottle import request +else: from typing import Protocol class _RequestParams(Protocol): @@ -22,7 +24,7 @@ def __getitem__(self, key: str) -> str: ... @overload - def get(self, key: str) -> str | None: + def get(self, key: str) -> 'str | None': ... @overload @@ -31,25 +33,30 @@ def get(self, key: str, default: str) -> str: class _HeadersDict(dict[str, str]): - def raw(self, key: str) -> bytes | None: + def raw(self, key: str) -> 'bytes | None': ... class _Request(Protocol): - query: _RequestParams - params: _RequestParams - headers: _HeadersDict - request: _Request + @property + def query(self) -> _RequestParams: + ... + @property + def params(self) -> _RequestParams: + ... -def parse_qs(qs: str) -> dict[str, str]: - return dict(bottle._parse_qsl(qs)) # type: ignore + @property + def headers(self) -> _HeadersDict: + ... + request = cast('_Request', None) -def require(cond: bool, message: str): - if not cond: - print(f'REQUIREMENT FAILED: {message}') - raise bottle.HTTPError(400, message) + +def parse_qs(qs: str) -> 'dict[str, str]': + # Re-use the bottle.py query string parser. It's a private function, but + # we're using a fixed version of Bottle. + return dict(bottle._parse_qsl(qs)) # type: ignore _HandlerFuncT = Callable[ @@ -58,6 +65,7 @@ def require(cond: bool, message: str): def handle_asserts(fn: _HandlerFuncT) -> _HandlerFuncT: + "Convert assertion failures into HTTP 400s" @functools.wraps(fn) def wrapped(): @@ -72,17 +80,10 @@ def wrapped(): return wrapped -def test_flags() -> dict[str, str]: +def test_params() -> 'dict[str, str]': return parse_qs(request.headers.get('X-MongoDB-HTTP-TestParams', '')) -def maybe_pause(): - pause = int(test_flags().get('pause', '0')) - if pause: - print(f'Pausing for {pause} seconds') - time.sleep(pause) - - @imds.get('/metadata/identity/oauth2/token') @handle_asserts def get_oauth2_token(): @@ -91,10 +92,7 @@ def get_oauth2_token(): resource = request.query['resource'] assert resource == 'https://vault.azure.net', 'Only https://vault.azure.net is supported' - flags = test_flags() - maybe_pause() - - case = flags.get('case') + case = test_params().get('case') print('Case is:', case) if case == '404': return HTTPResponse(status=404) @@ -114,17 +112,18 @@ def get_oauth2_token(): if case == 'slow': return _slow() - assert case is None or case == '', f'Unknown HTTP test case "{case}"' + assert case in (None, ''), 'Unknown HTTP test case "{}"'.format(case) return { 'access_token': 'magic-cookie', - 'expires_in': '60', + 'expires_in': '70', 'token_type': 'Bearer', 'resource': 'https://vault.azure.net', } def _gen_giant() -> Iterable[bytes]: + "Generate a giant message" yield b'{ "item": [' for _ in range(1024 * 256): yield (b'null, null, null, null, null, null, null, null, null, null, ' @@ -136,6 +135,7 @@ def _gen_giant() -> Iterable[bytes]: def _slow() -> Iterable[bytes]: + "Generate a very slow message" yield b'{ "item": [' for _ in range(1000): yield b'null, ' @@ -144,6 +144,8 @@ def _slow() -> Iterable[bytes]: if __name__ == '__main__': - print(f'RECOMMENDED: Run this script using bottle.py in the same ' - f'directory (e.g. [{sys.executable} bottle.py fake_azure:imds])') + print( + 'RECOMMENDED: Run this script using bottle.py (e.g. [{} {}/bottle.py fake_azure:imds])' + .format(sys.executable, + Path(__file__).resolve().parent)) imds.run() From c40539aefa49ed744bde1da78faa9db648ea56aa Mon Sep 17 00:00:00 2001 From: vector-of-bool Date: Tue, 27 Sep 2022 01:36:36 +0000 Subject: [PATCH 42/52] proc-ctl controls child processes --- build/proc-ctl.py | 271 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 271 insertions(+) create mode 100644 build/proc-ctl.py diff --git a/build/proc-ctl.py b/build/proc-ctl.py new file mode 100644 index 00000000000..d118f48c606 --- /dev/null +++ b/build/proc-ctl.py @@ -0,0 +1,271 @@ +""" +Extremely basic subprocess control +""" + +import argparse +import json +import os +import signal +import subprocess +import sys +import traceback +from datetime import datetime, timedelta +from pathlib import Path +from typing import TYPE_CHECKING, NoReturn, Sequence, Union, cast + +if TYPE_CHECKING: + from typing import (Literal, NamedTuple, TypedDict) + +INTERUPT_SIGNAL = signal.SIGINT if os.name != 'nt' else signal.CTRL_C_SIGNAL + + +def create_parser() -> argparse.ArgumentParser: + parser = argparse.ArgumentParser('proc-ctl') + grp = parser.add_subparsers(title='Commands', + dest='command', + metavar='') + + start = grp.add_parser('start', help='Start a new subprocess') + start.add_argument('--ctl-dir', + help='The control directory for the subprocess', + required=True, + type=Path) + start.add_argument('--cwd', + help='The new subdirectory of the spawned process', + type=Path) + start.add_argument( + '--spawn-wait', + help='Number of seconds to wait for child to be running', + type=float, + default=3) + start.add_argument('child_command', + nargs=argparse.REMAINDER, + help='The command to execute', + metavar=' [args...]') + + stop = grp.add_parser('stop', help='Stop a running subprocess') + stop.add_argument('--ctl-dir', + help='The control directory for the subprocess', + required=True, + type=Path) + stop.add_argument('--stop-wait', + help='Number of seconds to wait for stopping', + type=float, + default=5) + stop.add_argument('--if-not-running', + help='Action to take if the child is not running', + choices=['fail', 'ignore'], + default='fail') + + ll_run = grp.add_parser('__run') + ll_run.add_argument('--ctl-dir', type=Path, required=True) + ll_run.add_argument('child_command', nargs=argparse.REMAINDER) + + return parser + + +if TYPE_CHECKING: + StartCommandArgs = NamedTuple('StartCommandArgs', [ + ('command', Literal['start']), + ('ctl_dir', Path), + ('cwd', Path), + ('child_command', Sequence[str]), + ('spawn_wait', int), + ]) + + StopCommandArgs = NamedTuple('StopCommandArgs', [ + ('command', Literal['stop']), + ('ctl_dir', Path), + ('stop_wait', float), + ('if_not_running', Literal['fail', 'ignore']), + ]) + + _RunCommandArgs = NamedTuple('_RunCommandArgs', [ + ('command', Literal['__run']), + ('child_command', Sequence[str]), + ('ctl_dir', Path), + ]) + + CommandArgs = Union[StartCommandArgs, StopCommandArgs, _RunCommandArgs] + + _ResultType = TypedDict('_ResultType', { + 'exit': 'str | int | None', + 'error': 'str | None' + }) + + +def parse_argv(argv: 'Sequence[str]') -> 'CommandArgs': + parser = create_parser() + args = parser.parse_args(argv) + return cast('CommandArgs', args) + + +class _ChildControl: + + def __init__(self, ctl_dir: Path) -> None: + self._ctl_dir = ctl_dir + + @property + def pid_file(self): + """The file containing the child PID""" + return self._ctl_dir / 'pid.txt' + + @property + def result_file(self): + """The file containing the exit result""" + return self._ctl_dir / 'exit.json' + + def set_pid(self, pid: int): + self.pid_file.write_text(str(pid)) + + def get_pid(self) -> 'int | None': + try: + txt = self.pid_file.read_text() + except FileNotFoundError: + return None + return int(txt) + + def set_exit(self, exit: 'str | int | None', error: 'str | None') -> None: + self.result_file.write_text(json.dumps({'exit': exit, 'error': error})) + self._unlink(self.pid_file) + + def get_result(self) -> 'None | _ResultType': + try: + txt = self.result_file.read_text() + except FileNotFoundError: + return None + try: + return json.loads(txt) + except json.JSONDecodeError: + return self.get_result() + + def clear_result(self) -> None: + self._unlink(self.result_file) + + @staticmethod + def _unlink(p: Path) -> None: + try: + p.unlink() + except FileNotFoundError: + pass + + +def _start(args: 'StartCommandArgs') -> int: + ll_run_cmd = [ + sys.executable, + '-u', + '--', + __file__, + '__run', + '--ctl-dir={}'.format(args.ctl_dir), + '--', + *args.child_command[1:], + ] + args.ctl_dir.mkdir(exist_ok=True, parents=True) + child = _ChildControl(args.ctl_dir) + if child.get_pid() is not None: + raise RuntimeError('Child process is already running [PID {}]'.format( + child.get_pid())) + child.clear_result() + # Spawn the child controller + subprocess.Popen( + ll_run_cmd, + cwd=args.cwd, + stderr=subprocess.STDOUT, + stdout=args.ctl_dir.joinpath('.runner-output.txt').open('wb'), + stdin=subprocess.DEVNULL) + expire = datetime.now() + timedelta(seconds=args.spawn_wait) + # Wait for the PID to appear + while child.get_pid() is None and child.get_result() is None: + if expire < datetime.now(): + break + # Check that it actually spawned + if child.get_pid() is None: + result = child.get_result() + if result is None: + raise RuntimeError('Failed to spawn child runner?') + if result['error']: + print(result['error'], file=sys.stderr) + raise RuntimeError('Child exited immediately [Exited {}]'.format( + result['exit'])) + # Wait to see that it is still running after --spawn-wait seconds + while child.get_result() is None: + if expire < datetime.now(): + break + # A final check to see if it is running + result = child.get_result() + if result is not None: + if result['error']: + print(result['error'], file=sys.stderr) + raise RuntimeError('Child exited prematurely [Exited {}]'.format( + result['exit'])) + return 0 + + +def _stop(args: 'StopCommandArgs') -> int: + child = _ChildControl(args.ctl_dir) + pid = child.get_pid() + if pid is None: + if args.if_not_running == 'fail': + raise RuntimeError('Child process is not running') + elif args.if_not_running == 'ignore': + # Nothing to do + return 0 + else: + assert False + os.kill(pid, INTERUPT_SIGNAL) + expire_at = datetime.now() + timedelta(seconds=args.stop_wait) + while expire_at > datetime.now() and child.get_result() is None: + pass + result = child.get_result() + if result is None: + raise RuntimeError( + 'Child process did not exit within the grace period') + return 0 + + +def __run(args: '_RunCommandArgs') -> int: + this = _ChildControl(args.ctl_dir) + try: + pipe = subprocess.Popen( + args.child_command[1:], + stdout=args.ctl_dir.joinpath('child-output.txt').open('wb'), + stderr=subprocess.STDOUT, + stdin=subprocess.DEVNULL) + except: + this.set_exit('spawn-failed', traceback.format_exc()) + raise + this.set_pid(pipe.pid) + retc = None + try: + while 1: + try: + retc = pipe.wait(0.5) + except subprocess.TimeoutExpired: + pass + except KeyboardInterrupt: + pipe.send_signal(INTERUPT_SIGNAL) + if retc is not None: + break + finally: + this.set_exit(retc, None) + return 0 + + +def main(argv: 'Sequence[str]') -> int: + args = parse_argv(argv) + if args.command == 'start': + return _start(args) + if args.command == '__run': + return __run(args) + if args.command == 'stop': + return _stop(args) + return 0 + + +def start_main() -> NoReturn: + sys.exit(main(sys.argv[1:])) + + +if __name__ == '__main__': + start_main() From 0daee537a9767e792853d8e60ca068c1824c953a Mon Sep 17 00:00:00 2001 From: vector-of-bool Date: Tue, 27 Sep 2022 01:36:54 +0000 Subject: [PATCH 43/52] Reorder test cases to behave better with Bottle --- src/libmongoc/tests/test-mcd-azure-imds.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/libmongoc/tests/test-mcd-azure-imds.c b/src/libmongoc/tests/test-mcd-azure-imds.c index 842c1d530a5..70d85816316 100644 --- a/src/libmongoc/tests/test-mcd-azure-imds.c +++ b/src/libmongoc/tests/test-mcd-azure-imds.c @@ -101,16 +101,14 @@ _test_with_mock_server (void *ctx) _run_http_test_case ("", 0, 0, ""); // (No error) _run_http_test_case ("404", MONGOC_ERROR_AZURE, MONGOC_ERROR_AZURE_HTTP, ""); + _run_http_test_case ( + "slow", MONGOC_ERROR_STREAM, MONGOC_ERROR_STREAM_SOCKET, "Timeout"); _run_http_test_case ( "empty-json", MONGOC_ERROR_AZURE, MONGOC_ERROR_AZURE_BAD_JSON, ""); _run_http_test_case ( "bad-json", MONGOC_ERROR_CLIENT, MONGOC_ERROR_STREAM_INVALID_TYPE, ""); - _run_http_test_case ( "giant", MONGOC_ERROR_STREAM, MONGOC_ERROR_STREAM_SOCKET, "too large"); - - _run_http_test_case ( - "slow", MONGOC_ERROR_STREAM, MONGOC_ERROR_STREAM_SOCKET, "Timeout"); } static int From 2a5c64820d9941d163698c8e51cb3ac9558644b3 Mon Sep 17 00:00:00 2001 From: vector-of-bool Date: Tue, 27 Sep 2022 01:53:23 +0000 Subject: [PATCH 44/52] Defining CTest fixtures, including a fake IMDS server --- CMakeLists.txt | 3 +++ build/cmake/LoadTests.cmake | 8 ++++++ build/cmake/TestFixtures.cmake | 49 ++++++++++++++++++++++++++++++++++ 3 files changed, 60 insertions(+) create mode 100644 build/cmake/TestFixtures.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index caaf53499f3..008a3058334 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -223,6 +223,9 @@ include (MakeDistFiles) # Enable CTest include (CTest) +if (BUILD_TESTING) + include (TestFixtures) +endif () # Ensure the default behavior: don't ignore RPATH settings. set (CMAKE_SKIP_BUILD_RPATH OFF) diff --git a/build/cmake/LoadTests.cmake b/build/cmake/LoadTests.cmake index d310899fedb..bf87f55a804 100644 --- a/build/cmake/LoadTests.cmake +++ b/build/cmake/LoadTests.cmake @@ -26,6 +26,12 @@ endif () # Split lines on newlines string (REPLACE "\n" ";" lines "${tests_out}") +# XXX: Allow individual test cases to specify the fixtures they want. +set (all_fixtures "mongoc/fixtures/fake_imds") +set (all_env + MCD_TEST_AZURE_IMDS_HOST=localhost:14987 # Refer: Fixtures.cmake + ) + # Generate the test definitions foreach (line IN LISTS lines) if (NOT line MATCHES "^/") @@ -44,5 +50,7 @@ foreach (line IN LISTS lines) SKIP_REGULAR_EXPRESSION "@@ctest-skipped@@" # 45 seconds of timeout on each test. TIMEOUT 45 + FIXTURES_REQUIRED "${all_fixtures}" + ENVIRONMENT "${all_env}" ) endforeach () diff --git a/build/cmake/TestFixtures.cmake b/build/cmake/TestFixtures.cmake new file mode 100644 index 00000000000..551aafb0a09 --- /dev/null +++ b/build/cmake/TestFixtures.cmake @@ -0,0 +1,49 @@ +find_package (Python3 COMPONENTS Interpreter) + +if (NOT TARGET Python3::Interpreter) + message (STATUS "Python3 was not found, so test fixtures will not be defined") + return () +endif () + +get_filename_component(_MONGOC_BUILD_SCRIPT_DIR "${CMAKE_CURRENT_LIST_DIR}" DIRECTORY) +set (_MONGOC_PROC_CTL_COMMAND "$" -u -- "${_MONGOC_BUILD_SCRIPT_DIR}/proc-ctl.py") + + +function (mongo_define_subprocess_fixture name) + cmake_parse_arguments(PARSE_ARGV 1 ARG "" "SPAWN_WAIT;STOP_WAIT;WORKING_DIRECTORY" "COMMAND") + string (MAKE_C_IDENTIFIER ident "${name}") + if (NOT ARG_SPAWN_WAIT) + set (ARG_SPAWN_WAIT 1) + endif () + if (NOT ARG_STOP_WAIT) + set (ARG_STOP_WAIT 5) + endif () + if (NOT ARG_WORKING_DIRECTORY) + set (ARG_WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}") + endif () + if (NOT ARG_COMMAND) + message (SEND_ERROR "mongo_define_subprocess_fixture(${name}) requires a COMMAND") + return () + endif () + get_filename_component (ctl_dir "${CMAKE_CURRENT_BINARY_DIR}/${ident}.ctl" ABSOLUTE) + add_test (NAME "${name}/start" + COMMAND ${_MONGOC_PROC_CTL_COMMAND} start + "--ctl-dir=${ctl_dir}" + "--cwd=${ARG_WORKING_DIRECTORY}" + "--spawn-wait=${ARG_SPAWN_WAIT}" + -- ${ARG_COMMAND}) + add_test (NAME "${name}/stop" + COMMAND ${_MONGOC_PROC_CTL_COMMAND} stop "--ctl-dir=${ctl_dir}" --if-not-running=ignore) + set_property (TEST "${name}/start" PROPERTY FIXTURES_SETUP "${name}") + set_property (TEST "${name}/stop" PROPERTY FIXTURES_CLEANUP "${name}") +endfunction () + +# Create a fixture that runs a fake Azure IMDS server +mongo_define_subprocess_fixture( + mongoc/fixtures/fake_imds + SPAWN_WAIT 0.2 + COMMAND + "$" -u -- + "${_MONGOC_BUILD_SCRIPT_DIR}/bottle.py" fake_azure:imds + --bind localhost:14987 # Port 14987 chosen arbitrarily + ) From f9f3574521d250f172b4307c8e8b943205241058 Mon Sep 17 00:00:00 2001 From: vector-of-bool Date: Tue, 27 Sep 2022 17:47:51 +0000 Subject: [PATCH 45/52] Missing dist file --- build/cmake/CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/build/cmake/CMakeLists.txt b/build/cmake/CMakeLists.txt index faf4fe295b5..4c3467dcf27 100644 --- a/build/cmake/CMakeLists.txt +++ b/build/cmake/CMakeLists.txt @@ -15,6 +15,7 @@ set (build_cmake_MODULES Sanitizers.cmake CCache.cmake LLDLinker.cmake + TestFixtures.cmake ) set_local_dist (build_cmake_DIST_local From 108f79719c1738d11e934151f13c23b958e03fdc Mon Sep 17 00:00:00 2001 From: vector-of-bool Date: Wed, 28 Sep 2022 18:10:48 +0000 Subject: [PATCH 46/52] Tweaks: - Better handling of subcommand parsing - Sleep a bit while waiting - "Atomic" file write/removal --- build/proc-ctl.py | 73 +++++++++++++++++++++++++++++++++-------------- 1 file changed, 51 insertions(+), 22 deletions(-) diff --git a/build/proc-ctl.py b/build/proc-ctl.py index d118f48c606..9446bf2892f 100644 --- a/build/proc-ctl.py +++ b/build/proc-ctl.py @@ -5,9 +5,11 @@ import argparse import json import os +import random import signal import subprocess import sys +import time import traceback from datetime import datetime, timedelta from pathlib import Path @@ -39,7 +41,7 @@ def create_parser() -> argparse.ArgumentParser: type=float, default=3) start.add_argument('child_command', - nargs=argparse.REMAINDER, + nargs='+', help='The command to execute', metavar=' [args...]') @@ -59,7 +61,7 @@ def create_parser() -> argparse.ArgumentParser: ll_run = grp.add_parser('__run') ll_run.add_argument('--ctl-dir', type=Path, required=True) - ll_run.add_argument('child_command', nargs=argparse.REMAINDER) + ll_run.add_argument('child_command', nargs='+') return parser @@ -70,7 +72,7 @@ def create_parser() -> argparse.ArgumentParser: ('ctl_dir', Path), ('cwd', Path), ('child_command', Sequence[str]), - ('spawn_wait', int), + ('spawn_wait', float), ]) StopCommandArgs = NamedTuple('StopCommandArgs', [ @@ -116,7 +118,7 @@ def result_file(self): return self._ctl_dir / 'exit.json' def set_pid(self, pid: int): - self.pid_file.write_text(str(pid)) + write_text(self.pid_file, str(pid)) def get_pid(self) -> 'int | None': try: @@ -126,28 +128,21 @@ def get_pid(self) -> 'int | None': return int(txt) def set_exit(self, exit: 'str | int | None', error: 'str | None') -> None: - self.result_file.write_text(json.dumps({'exit': exit, 'error': error})) - self._unlink(self.pid_file) + write_text(self.result_file, json.dumps({ + 'exit': exit, + 'error': error + })) + remove_file(self.pid_file) def get_result(self) -> 'None | _ResultType': try: txt = self.result_file.read_text() except FileNotFoundError: return None - try: - return json.loads(txt) - except json.JSONDecodeError: - return self.get_result() + return json.loads(txt) def clear_result(self) -> None: - self._unlink(self.result_file) - - @staticmethod - def _unlink(p: Path) -> None: - try: - p.unlink() - except FileNotFoundError: - pass + remove_file(self.result_file) def _start(args: 'StartCommandArgs') -> int: @@ -159,7 +154,7 @@ def _start(args: 'StartCommandArgs') -> int: '__run', '--ctl-dir={}'.format(args.ctl_dir), '--', - *args.child_command[1:], + *args.child_command, ] args.ctl_dir.mkdir(exist_ok=True, parents=True) child = _ChildControl(args.ctl_dir) @@ -172,13 +167,14 @@ def _start(args: 'StartCommandArgs') -> int: ll_run_cmd, cwd=args.cwd, stderr=subprocess.STDOUT, - stdout=args.ctl_dir.joinpath('.runner-output.txt').open('wb'), + stdout=args.ctl_dir.joinpath('runner-output.txt').open('wb'), stdin=subprocess.DEVNULL) expire = datetime.now() + timedelta(seconds=args.spawn_wait) # Wait for the PID to appear while child.get_pid() is None and child.get_result() is None: if expire < datetime.now(): break + time.sleep(0.1) # Check that it actually spawned if child.get_pid() is None: result = child.get_result() @@ -192,6 +188,7 @@ def _start(args: 'StartCommandArgs') -> int: while child.get_result() is None: if expire < datetime.now(): break + time.sleep(0.1) # A final check to see if it is running result = child.get_result() if result is not None: @@ -216,7 +213,7 @@ def _stop(args: 'StopCommandArgs') -> int: os.kill(pid, INTERUPT_SIGNAL) expire_at = datetime.now() + timedelta(seconds=args.stop_wait) while expire_at > datetime.now() and child.get_result() is None: - pass + time.sleep(0.1) result = child.get_result() if result is None: raise RuntimeError( @@ -228,7 +225,7 @@ def __run(args: '_RunCommandArgs') -> int: this = _ChildControl(args.ctl_dir) try: pipe = subprocess.Popen( - args.child_command[1:], + args.child_command, stdout=args.ctl_dir.joinpath('child-output.txt').open('wb'), stderr=subprocess.STDOUT, stdin=subprocess.DEVNULL) @@ -252,6 +249,38 @@ def __run(args: '_RunCommandArgs') -> int: return 0 +def write_text(fpath: Path, content: str): + """ + "Atomically" write a new file. + + This writes the given ``content`` into a temporary file, then renames that + file into place. This prevents readers from seeing a partial read. + """ + tmp = fpath.with_name(fpath.name + '.tmp') + remove_file(tmp) + tmp.write_text(content) + os.sync() + remove_file(fpath) + tmp.rename(fpath) + + +def remove_file(fpath: Path): + """ + Safely remove a file. + + Because Win32, deletes are asynchronous, so we rename to a random filename, + then delete that file. This ensures the file is "out of the way", even if + it takes some time to delete. + """ + delname = fpath.with_name(fpath.name + '.delete-' + + str(random.randint(0, 999999))) + try: + fpath.rename(delname) + except FileNotFoundError: + return + delname.unlink() + + def main(argv: 'Sequence[str]') -> int: args = parse_argv(argv) if args.command == 'start': From 20311d316d0892aa0524aa73accb8bae6fb3412d Mon Sep 17 00:00:00 2001 From: vector-of-bool Date: Thu, 29 Sep 2022 23:40:59 +0000 Subject: [PATCH 47/52] Update "meta" string on all tests --- src/libmongoc/tests/TestSuite.c | 4 +- src/libmongoc/tests/json-test.c | 2 +- src/libmongoc/tests/test-mcd-azure-imds.c | 23 +-- src/libmongoc/tests/test-mongoc-bulk.c | 22 +-- .../tests/test-mongoc-change-stream.c | 50 +++--- src/libmongoc/tests/test-mongoc-client-pool.c | 2 +- .../tests/test-mongoc-client-session.c | 150 +++++++++--------- src/libmongoc/tests/test-mongoc-client.c | 6 +- .../tests/test-mongoc-collection-find.c | 2 +- src/libmongoc/tests/test-mongoc-collection.c | 36 ++--- .../tests/test-mongoc-command-monitoring.c | 2 +- src/libmongoc/tests/test-mongoc-counters.c | 8 +- src/libmongoc/tests/test-mongoc-crud.c | 4 +- src/libmongoc/tests/test-mongoc-cursor.c | 14 +- src/libmongoc/tests/test-mongoc-database.c | 2 +- src/libmongoc/tests/test-mongoc-exhaust.c | 8 +- .../tests/test-mongoc-find-and-modify.c | 2 +- .../tests/test-mongoc-gridfs-bucket.c | 4 +- src/libmongoc/tests/test-mongoc-gridfs.c | 4 +- .../tests/test-mongoc-long-namespace.c | 2 +- .../tests/test-mongoc-max-staleness.c | 8 +- .../tests/test-mongoc-mongos-pinning.c | 4 +- .../tests/test-mongoc-primary-stepdown.c | 10 +- .../tests/test-mongoc-retryable-reads.c | 4 +- .../tests/test-mongoc-retryable-writes.c | 6 +- .../tests/test-mongoc-sample-commands.c | 2 +- src/libmongoc/tests/test-mongoc-sdam.c | 8 +- .../test-mongoc-server-selection-errors.c | 4 +- .../tests/test-mongoc-topology-reconcile.c | 2 +- .../tests/test-mongoc-topology-scanner.c | 4 +- src/libmongoc/tests/test-mongoc-topology.c | 18 +-- .../tests/test-mongoc-transactions.c | 16 +- .../tests/test-mongoc-with-transaction.c | 2 +- .../tests/test-mongoc-write-commands.c | 4 +- .../tests/test-mongoc-write-concern.c | 6 +- 35 files changed, 217 insertions(+), 228 deletions(-) diff --git a/src/libmongoc/tests/TestSuite.c b/src/libmongoc/tests/TestSuite.c index 6e7e7126eff..ec3978d715d 100644 --- a/src/libmongoc/tests/TestSuite.c +++ b/src/libmongoc/tests/TestSuite.c @@ -290,7 +290,7 @@ TestSuite_AddLive (TestSuite *suite, /* IN */ const char *meta, /* IN */ TestFunc func) /* IN */ { - char *meta1 = bson_strdup_printf ("%s%s", meta, " uses-live-server"); + char *meta1 = bson_strdup_printf ("%s%s", meta, " USES_LIVE_SERVER"); TestSuite_AddFullWithTestFn ( suite, name, meta1, TestSuite_AddHelper, NULL, func, TestSuite_CheckLive); bson_free (meta1); @@ -367,7 +367,7 @@ _TestSuite_AddMockServerTest ( Test *test; va_list ap; - char *meta1 = bson_strdup_printf ("%s%s", meta, " uses-mock-server"); + char *meta1 = bson_strdup_printf ("%s%s", meta, " LABELS uses-mock-server"); va_start (ap, func); test = _V_TestSuite_AddFull ( diff --git a/src/libmongoc/tests/json-test.c b/src/libmongoc/tests/json-test.c index f3d19e44d93..fb422d9dfc4 100644 --- a/src/libmongoc/tests/json-test.c +++ b/src/libmongoc/tests/json-test.c @@ -2060,7 +2060,7 @@ _install_json_test_suite_with_check (TestSuite *suite, va_start (ap, callback); _V_TestSuite_AddFull (suite, skip_json, - "json-test uses-live-server", + "LABELS json-test USES_LIVE_SERVER", (void (*) (void *)) callback, (void (*) (void *)) bson_destroy, test, diff --git a/src/libmongoc/tests/test-mcd-azure-imds.c b/src/libmongoc/tests/test-mcd-azure-imds.c index 4165d4a87c3..2243f117ec0 100644 --- a/src/libmongoc/tests/test-mcd-azure-imds.c +++ b/src/libmongoc/tests/test-mcd-azure-imds.c @@ -65,12 +65,6 @@ _test_http_req (void) bson_string_free (req_str, true); } -static const char * -_get_test_imds_host (void) -{ - return getenv ("MCD_TEST_AZURE_IMDS_HOST"); -} - static void _run_http_test_case (const char *case_, mongoc_error_domain_t expect_domain, @@ -79,8 +73,13 @@ _run_http_test_case (const char *case_, { bson_error_t error = {0}; struct _mongoc_host_list_t host; +#ifdef MONGOC_FAKE_IMDS_HOST _mongoc_host_list_from_string_with_err ( - &host, _get_test_imds_host (), &error); + &host, MONGOC_FAKE_IMDS_HOST, &error); +#else + puts ("@@ctest-skipped@@"); + return; +#endif ASSERT_ERROR_CONTAINS (error, 0, 0, ""); mcd_azure_access_token token = {0}; @@ -111,11 +110,6 @@ _test_with_mock_server (void *ctx) "giant", MONGOC_ERROR_STREAM, MONGOC_ERROR_STREAM_SOCKET, "too large"); } -static int -have_mock_server_env (TestSuite *ctx) -{ - return _get_test_imds_host () != NULL; -} void test_mcd_azure_imds_install (TestSuite *suite) @@ -124,9 +118,8 @@ test_mcd_azure_imds_install (TestSuite *suite) TestSuite_Add (suite, "/azure/imds/http/request", "", _test_http_req); TestSuite_AddFull (suite, "/azure/imds/http/talk", - "", + "USES mongoc/fixtures/fake_imds", _test_with_mock_server, NULL, - NULL, - have_mock_server_env); + NULL); } diff --git a/src/libmongoc/tests/test-mongoc-bulk.c b/src/libmongoc/tests/test-mongoc-bulk.c index b11d23118a0..3a4cc815e61 100644 --- a/src/libmongoc/tests/test-mongoc-bulk.c +++ b/src/libmongoc/tests/test-mongoc-bulk.c @@ -5057,21 +5057,21 @@ test_bulk_install (TestSuite *suite) suite, "/BulkOperation/upsert_unordered", "", test_upsert_unordered); TestSuite_AddFull (suite, "/BulkOperation/upsert_unordered_oversized", - "uses-live-server", + "USES_LIVE_SERVER", test_upsert_unordered_oversized, NULL, NULL, test_framework_skip_if_slow_or_live); TestSuite_AddFull (suite, "/BulkOperation/upsert_large", - "uses-live-server", + "USES_LIVE_SERVER", test_upsert_large, NULL, NULL, test_framework_skip_if_slow_or_live); TestSuite_AddFull (suite, "/BulkOperation/upsert_huge", - "uses-live-server", + "USES_LIVE_SERVER", test_upsert_huge, NULL, NULL, @@ -5096,7 +5096,7 @@ test_bulk_install (TestSuite *suite) test_update_with_opts_validate); TestSuite_AddFull (suite, "/BulkOperation/update_arrayfilters", - "uses-live-server", + "USES_LIVE_SERVER", test_update_arrayfilters, NULL, NULL, @@ -5165,14 +5165,14 @@ test_bulk_install (TestSuite *suite) test_single_error_unordered_bulk); TestSuite_AddFull (suite, "/BulkOperation/oversized/ordered", - "uses-live-server", + "USES_LIVE_SERVER", test_oversized_bulk_op_ordered, NULL, NULL, test_framework_skip_if_slow_or_live); TestSuite_AddFull (suite, "/BulkOperation/oversized/unordered", - "uses-live-server", + "USES_LIVE_SERVER", test_oversized_bulk_op_unordered, NULL, NULL, @@ -5222,28 +5222,28 @@ test_bulk_install (TestSuite *suite) test_wtimeout_plus_duplicate_key_err_write_commands); TestSuite_AddFull (suite, "/BulkOperation/large_inserts_ordered", - "uses-live-server", + "USES_LIVE_SERVER", test_large_inserts_ordered, NULL, NULL, test_framework_skip_if_slow_or_live); TestSuite_AddFull (suite, "/BulkOperation/large_inserts_unordered", - "uses-live-server", + "USES_LIVE_SERVER", test_large_inserts_unordered, NULL, NULL, test_framework_skip_if_slow_or_live); TestSuite_AddFull (suite, "/BulkOperation/numerous_ordered", - "uses-live-server", + "USES_LIVE_SERVER", test_numerous_ordered, NULL, NULL, test_framework_skip_if_slow_or_live); TestSuite_AddFull (suite, "/BulkOperation/numerous_unordered", - "uses-live-server", + "USES_LIVE_SERVER", test_numerous_unordered, NULL, NULL, @@ -5266,7 +5266,7 @@ test_bulk_install (TestSuite *suite) TestSuite_AddLive (suite, "/BulkOperation/split", "", test_bulk_split); TestSuite_AddFull (suite, "/BulkOperation/write_concern/split", - "uses-live-server", + "USES_LIVE_SERVER", test_bulk_write_concern_split, NULL /* dtor */, NULL /* ctx */, diff --git a/src/libmongoc/tests/test-mongoc-change-stream.c b/src/libmongoc/tests/test-mongoc-change-stream.c index 930b25dfc13..f7a0dcf8c1b 100644 --- a/src/libmongoc/tests/test-mongoc-change-stream.c +++ b/src/libmongoc/tests/test-mongoc-change-stream.c @@ -2624,7 +2624,7 @@ test_change_stream_install (TestSuite *suite) TestSuite_AddFull (suite, "/change_stream/live/single_server", - "uses-live-server", + "USES_LIVE_SERVER", test_change_stream_live_single_server, NULL, NULL, @@ -2632,7 +2632,7 @@ test_change_stream_install (TestSuite *suite) TestSuite_AddFull (suite, "/change_stream/live/track_resume_token", - "uses-live-server", + "USES_LIVE_SERVER", test_change_stream_live_track_resume_token, NULL, NULL, @@ -2641,7 +2641,7 @@ test_change_stream_install (TestSuite *suite) TestSuite_AddFull (suite, "/change_stream/live/batch_size", - "uses-live-server", + "USES_LIVE_SERVER", test_change_stream_live_batch_size, NULL, NULL, @@ -2649,7 +2649,7 @@ test_change_stream_install (TestSuite *suite) TestSuite_AddFull (suite, "/change_stream/live/missing_resume_token", - "uses-live-server", + "USES_LIVE_SERVER", test_change_stream_live_missing_resume_token, NULL, NULL, @@ -2657,7 +2657,7 @@ test_change_stream_install (TestSuite *suite) TestSuite_AddFull (suite, "/change_stream/live/invalid_resume_token", - "uses-live-server", + "USES_LIVE_SERVER", test_change_stream_live_invalid_resume_token, NULL, NULL, @@ -2673,7 +2673,7 @@ test_change_stream_install (TestSuite *suite) TestSuite_AddFull (suite, "/change_stream/live/watch", - "uses-live-server", + "USES_LIVE_SERVER", test_change_stream_live_watch, NULL, NULL, @@ -2681,7 +2681,7 @@ test_change_stream_install (TestSuite *suite) TestSuite_AddFull (suite, "/change_stream/live/read_prefs", - "uses-live-server", + "USES_LIVE_SERVER", test_change_stream_live_read_prefs, NULL, NULL, @@ -2695,7 +2695,7 @@ test_change_stream_install (TestSuite *suite) TestSuite_AddFull (suite, "/change_stream/next_after_error", - "uses-live-server", + "USES_LIVE_SERVER", test_change_stream_next_after_error, NULL, NULL, @@ -2703,7 +2703,7 @@ test_change_stream_install (TestSuite *suite) TestSuite_AddFull (suite, "/change_stream/accepts_array", - "uses-live-server", + "USES_LIVE_SERVER", test_change_stream_accepts_array, NULL, NULL, @@ -2712,7 +2712,7 @@ test_change_stream_install (TestSuite *suite) suite, "/change_stream/getmore_errors", "", test_getmore_errors); TestSuite_AddFull (suite, "/change_stream/start_at_operation_time", - "uses-live-server", + "USES_LIVE_SERVER", test_change_stream_start_at_operation_time, NULL, NULL, @@ -2721,7 +2721,7 @@ test_change_stream_install (TestSuite *suite) _skip_if_no_start_at_optime); TestSuite_AddFull (suite, "/change_stream/resume_at_optime", - "uses-live-server", + "USES_LIVE_SERVER", test_change_stream_resume_at_optime, NULL, NULL, @@ -2731,7 +2731,7 @@ test_change_stream_install (TestSuite *suite) test_framework_skip_if_no_failpoint); TestSuite_AddFull (suite, "/change_stream/resume_with_post_batch_resume_token", - "uses-live-server", + "USES_LIVE_SERVER", test_change_stream_resume_with_post_batch_resume_token, NULL, NULL, @@ -2741,14 +2741,14 @@ test_change_stream_install (TestSuite *suite) test_framework_skip_if_no_failpoint); TestSuite_AddFull (suite, "/change_stream/database", - "uses-live-server", + "USES_LIVE_SERVER", test_change_stream_database_watch, NULL, NULL, _skip_if_no_db_watch); TestSuite_AddFull (suite, "/change_stream/client", - "uses-live-server", + "USES_LIVE_SERVER", test_change_stream_client_watch, NULL, NULL, @@ -2762,14 +2762,14 @@ test_change_stream_install (TestSuite *suite) test_resume_cases_with_post_batch_resume_token); TestSuite_AddFull (suite, "/change_stream/error_null_doc", - "uses-live-server", + "USES_LIVE_SERVER", test_error_null_doc, NULL, NULL, _skip_if_no_client_watch); TestSuite_AddFull (suite, "/change_stream/live/prose_test_11", - "uses-live-server", + "USES_LIVE_SERVER", prose_test_11, NULL, NULL, @@ -2777,7 +2777,7 @@ test_change_stream_install (TestSuite *suite) test_framework_skip_if_max_wire_version_less_than_8); TestSuite_AddFull (suite, "/change_stream/live/prose_test_12", - "uses-live-server", + "USES_LIVE_SERVER", prose_test_12, NULL, NULL, @@ -2785,7 +2785,7 @@ test_change_stream_install (TestSuite *suite) test_framework_skip_if_max_wire_version_more_than_7); TestSuite_AddFull (suite, "/change_stream/live/prose_test_13", - "uses-live-server", + "USES_LIVE_SERVER", prose_test_13, NULL, NULL, @@ -2793,20 +2793,16 @@ test_change_stream_install (TestSuite *suite) _skip_if_no_start_at_optime); TestSuite_AddFull (suite, "/change_stream/live/prose_test_14", - "uses-live-server", + "USES_LIVE_SERVER", prose_test_14, NULL, NULL, test_framework_skip_if_mongos, test_framework_skip_if_not_rs_version_7); - TestSuite_AddMockServerTest (suite, - "/change_streams/prose_test_17", - "uses-live-server", - prose_test_17); - TestSuite_AddMockServerTest (suite, - "/change_streams/prose_test_18", - "uses-live-server", - prose_test_18); + TestSuite_AddMockServerTest ( + suite, "/change_streams/prose_test_17", "", prose_test_17); + TestSuite_AddMockServerTest ( + suite, "/change_streams/prose_test_18", "", prose_test_18); install_json_test_suite ( suite, JSON_DIR, "/change_streams/legacy", &test_change_stream_spec_cb); diff --git a/src/libmongoc/tests/test-mongoc-client-pool.c b/src/libmongoc/tests/test-mongoc-client-pool.c index cee8d87be2d..85c678de452 100644 --- a/src/libmongoc/tests/test-mongoc-client-pool.c +++ b/src/libmongoc/tests/test-mongoc-client-pool.c @@ -505,7 +505,7 @@ test_client_pool_install (TestSuite *suite) TestSuite_AddFull (suite, "/ClientPool/create_client_pool_unused_session", - "uses-live-server", + "USES_LIVE_SERVER", test_client_pool_create_unused_session, NULL /* dtor */, NULL /* ctx */, diff --git a/src/libmongoc/tests/test-mongoc-client-session.c b/src/libmongoc/tests/test-mongoc-client-session.c index 28b2f96372c..9195e7055f1 100644 --- a/src/libmongoc/tests/test-mongoc-client-session.c +++ b/src/libmongoc/tests/test-mongoc-client-session.c @@ -2853,7 +2853,7 @@ test_session_install (TestSuite *suite) test_session_opts_causal_consistency_and_snapshot); TestSuite_AddFull (suite, "/Session/no_crypto", - "uses-live-server", + "USES_LIVE_SERVER", test_session_no_crypto, NULL, NULL, @@ -2862,7 +2862,7 @@ test_session_install (TestSuite *suite) test_framework_skip_if_crypto); TestSuite_AddFull (suite, "/Session/lifo/single", - "uses-live-server", + "USES_LIVE_SERVER", test_session_pool_lifo_single, NULL, NULL, @@ -2870,7 +2870,7 @@ test_session_install (TestSuite *suite) test_framework_skip_if_no_crypto); TestSuite_AddFull (suite, "/Session/lifo/pooled", - "uses-live-server", + "USES_LIVE_SERVER", test_session_pool_lifo_pooled, NULL, NULL, @@ -2878,7 +2878,7 @@ test_session_install (TestSuite *suite) test_framework_skip_if_no_crypto); TestSuite_AddFull (suite, "/Session/timeout/single", - "uses-live-server", + "USES_LIVE_SERVER", test_session_pool_timeout_single, NULL, NULL, @@ -2887,7 +2887,7 @@ test_session_install (TestSuite *suite) test_framework_skip_if_slow); TestSuite_AddFull (suite, "/Session/timeout/pooled", - "uses-live-server", + "USES_LIVE_SERVER", test_session_pool_timeout_pooled, NULL, NULL, @@ -2896,7 +2896,7 @@ test_session_install (TestSuite *suite) test_framework_skip_if_slow); TestSuite_AddFull (suite, "/Session/reap/single", - "uses-live-server", + "USES_LIVE_SERVER", test_session_pool_reap_single, NULL, NULL, @@ -2905,7 +2905,7 @@ test_session_install (TestSuite *suite) test_framework_skip_if_slow); TestSuite_AddFull (suite, "/Session/reap/pooled", - "uses-live-server", + "USES_LIVE_SERVER", test_session_pool_reap_pooled, NULL, NULL, @@ -2914,7 +2914,7 @@ test_session_install (TestSuite *suite) test_framework_skip_if_slow); TestSuite_AddFull (suite, "/Session/id_bad", - "uses-live-server", + "USES_LIVE_SERVER", test_session_id_bad, NULL, NULL, @@ -2922,7 +2922,7 @@ test_session_install (TestSuite *suite) test_framework_skip_if_no_crypto); TestSuite_AddFull (suite, "/Session/supported/single", - "uses-live-server", + "USES_LIVE_SERVER", test_session_supported_single, NULL, NULL, @@ -2930,7 +2930,7 @@ test_session_install (TestSuite *suite) test_framework_skip_if_no_crypto); TestSuite_AddFull (suite, "/Session/supported/pooled", - "uses-live-server", + "USES_LIVE_SERVER", test_session_supported_pooled, NULL, NULL, @@ -2953,7 +2953,7 @@ test_session_install (TestSuite *suite) test_framework_skip_if_no_crypto); TestSuite_AddFull (suite, "/Session/end/single", - "uses-live-server", + "USES_LIVE_SERVER", test_end_sessions_single, NULL, NULL, @@ -2961,7 +2961,7 @@ test_session_install (TestSuite *suite) TestSuite_CheckLive); TestSuite_AddFull (suite, "/Session/end/pooled", - "uses-live-server", + "USES_LIVE_SERVER", test_end_sessions_pooled, NULL, NULL, @@ -2969,7 +2969,7 @@ test_session_install (TestSuite *suite) TestSuite_CheckLive); TestSuite_AddFull (suite, "/Session/end/many/single", - "uses-live-server", + "USES_LIVE_SERVER", test_end_sessions_many_single, NULL, NULL, @@ -2978,7 +2978,7 @@ test_session_install (TestSuite *suite) test_framework_skip_if_slow); TestSuite_AddFull (suite, "/Session/end/many/pooled", - "uses-live-server", + "USES_LIVE_SERVER", test_end_sessions_many_pooled, NULL, NULL, @@ -2987,7 +2987,7 @@ test_session_install (TestSuite *suite) test_framework_skip_if_slow); TestSuite_AddFull (suite, "/Session/advance_cluster_time", - "uses-live-server", + "USES_LIVE_SERVER", test_session_advance_cluster_time, NULL, NULL, @@ -2995,7 +2995,7 @@ test_session_install (TestSuite *suite) test_framework_skip_if_no_sessions); TestSuite_AddFull (suite, "/Session/advance_operation_time", - "uses-live-server", + "USES_LIVE_SERVER", test_session_advance_operation_time, NULL, NULL, @@ -3005,118 +3005,118 @@ test_session_install (TestSuite *suite) /* "true" is for tests that expect readConcern: afterClusterTime for causally * consistent sessions, "false" is for tests that prohibit readConcern */ add_session_test ( - suite, "/Session/cmd", "uses-live-server", test_cmd, false); + suite, "/Session/cmd", "USES_LIVE_SERVER", test_cmd, false); add_session_test ( - suite, "/Session/read_cmd", "uses-live-server", test_read_cmd, true); + suite, "/Session/read_cmd", "USES_LIVE_SERVER", test_read_cmd, true); add_session_test ( - suite, "/Session/write_cmd", "uses-live-server", test_write_cmd, false); + suite, "/Session/write_cmd", "USES_LIVE_SERVER", test_write_cmd, false); add_session_test (suite, "/Session/read_write_cmd", - "uses-live-server", + "USES_LIVE_SERVER", test_read_write_cmd, true); add_session_test ( - suite, "/Session/db_cmd", "uses-live-server", test_db_cmd, false); + suite, "/Session/db_cmd", "USES_LIVE_SERVER", test_db_cmd, false); TestSuite_AddFullWithTestFn (suite, "/Session/count", - "uses-live-server", + "USES_LIVE_SERVER", (TestFuncWC) run_count_test, NULL, test_count, test_framework_skip_if_no_cluster_time, test_framework_skip_if_no_crypto); add_session_test ( - suite, "/Session/cursor", "uses-live-server", test_cursor, true); + suite, "/Session/cursor", "USES_LIVE_SERVER", test_cursor, true); add_session_test ( - suite, "/Session/drop", "uses-live-server", test_drop, false); + suite, "/Session/drop", "USES_LIVE_SERVER", test_drop, false); add_session_test ( - suite, "/Session/drop_index", "uses-live-server", test_drop_index, false); + suite, "/Session/drop_index", "USES_LIVE_SERVER", test_drop_index, false); add_session_test (suite, "/Session/create_index", - "uses-live-server", + "USES_LIVE_SERVER", test_create_index, false); add_session_test (suite, "/Session/replace_one", - "uses-live-server", + "USES_LIVE_SERVER", test_replace_one, false); add_session_test ( - suite, "/Session/update_one", "uses-live-server", test_update_one, false); + suite, "/Session/update_one", "USES_LIVE_SERVER", test_update_one, false); add_session_test (suite, "/Session/update_many", - "uses-live-server", + "USES_LIVE_SERVER", test_update_many, false); add_session_test ( - suite, "/Session/insert_one", "uses-live-server", test_insert_one, false); + suite, "/Session/insert_one", "USES_LIVE_SERVER", test_insert_one, false); add_session_test (suite, "/Session/insert_many", - "uses-live-server", + "USES_LIVE_SERVER", test_insert_many, false); add_session_test ( - suite, "/Session/delete_one", "uses-live-server", test_delete_one, false); + suite, "/Session/delete_one", "USES_LIVE_SERVER", test_delete_one, false); add_session_test (suite, "/Session/delete_many", - "uses-live-server", + "USES_LIVE_SERVER", test_delete_many, false); add_session_test ( - suite, "/Session/rename", "uses-live-server", test_rename, false); - add_session_test (suite, "/Session/fam", "uses-live-server", test_fam, true); + suite, "/Session/rename", "USES_LIVE_SERVER", test_rename, false); + add_session_test (suite, "/Session/fam", "USES_LIVE_SERVER", test_fam, true); add_session_test ( - suite, "/Session/db_drop", "uses-live-server", test_db_drop, false); + suite, "/Session/db_drop", "USES_LIVE_SERVER", test_db_drop, false); add_session_test (suite, "/Session/gridfs_find", - "uses-live-server", + "USES_LIVE_SERVER", test_gridfs_find, true); add_session_test (suite, "/Session/gridfs_find_one", - "uses-live-server", + "USES_LIVE_SERVER", test_gridfs_find_one, true); add_session_test_wc (suite, "/Session/watch", - "uses-live-server", + "USES_LIVE_SERVER", test_watch, true, test_framework_skip_if_not_rs_version_6); add_session_test ( - suite, "/Session/aggregate", "uses-live-server", test_aggregate, true); + suite, "/Session/aggregate", "USES_LIVE_SERVER", test_aggregate, true); add_session_test ( - suite, "/Session/create", "uses-live-server", test_create, false); + suite, "/Session/create", "USES_LIVE_SERVER", test_create, false); add_session_test (suite, "/Session/database_names", - "uses-live-server", + "USES_LIVE_SERVER", test_database_names, true); add_session_test (suite, "/Session/find_databases", - "uses-live-server", + "USES_LIVE_SERVER", test_find_databases, true); add_session_test (suite, "/Session/find_collections", - "uses-live-server", + "USES_LIVE_SERVER", test_find_collections, true); add_session_test (suite, "/Session/collection_names", - "uses-live-server", + "USES_LIVE_SERVER", test_collection_names, true); add_session_test ( - suite, "/Session/bulk", "uses-live-server", test_bulk, false); + suite, "/Session/bulk", "USES_LIVE_SERVER", test_bulk, false); add_session_test (suite, "/Session/find_indexes", - "uses-live-server", + "USES_LIVE_SERVER", test_find_indexes, true); TestSuite_AddFullWithTestFn (suite, "/Session/bulk_set_session", - "uses-live-server", + "USES_LIVE_SERVER", run_session_test_bulk_operation, NULL, test_bulk_set_session, @@ -3124,7 +3124,7 @@ test_session_install (TestSuite *suite) test_framework_skip_if_no_crypto); TestSuite_AddFullWithTestFn (suite, "/Session/bulk_set_client", - "uses-live-server", + "USES_LIVE_SERVER", run_session_test_bulk_operation, NULL, test_bulk_set_client, @@ -3132,7 +3132,7 @@ test_session_install (TestSuite *suite) test_framework_skip_if_no_crypto); TestSuite_AddFull (suite, "/Session/cursor_implicit_session", - "uses-live-server", + "USES_LIVE_SERVER", test_cursor_implicit_session, NULL, NULL, @@ -3140,7 +3140,7 @@ test_session_install (TestSuite *suite) test_framework_skip_if_no_crypto); TestSuite_AddFull (suite, "/Session/change_stream_implicit_session", - "uses-live-server", + "USES_LIVE_SERVER", test_change_stream_implicit_session, NULL, NULL, @@ -3148,7 +3148,7 @@ test_session_install (TestSuite *suite) test_framework_skip_if_no_crypto); TestSuite_AddFull (suite, "/Session/cmd_error", - "uses-live-server", + "USES_LIVE_SERVER", test_cmd_error, NULL, NULL, @@ -3156,7 +3156,7 @@ test_session_install (TestSuite *suite) test_framework_skip_if_no_crypto); TestSuite_AddFull (suite, "/Session/read_concern", - "uses-live-server", + "USES_LIVE_SERVER", test_read_concern, NULL, NULL, @@ -3165,56 +3165,56 @@ test_session_install (TestSuite *suite) add_unacknowledged_test ( suite, "/Session/unacknowledged/insert_one/explicit_cs/inherit_wc", - "uses-live-server", + "USES_LIVE_SERVER", test_insert_one, true, true); add_unacknowledged_test ( suite, "/Session/unacknowledged/insert_one/explicit_cs/explicit_wc", - "uses-live-server", + "USES_LIVE_SERVER", test_insert_one, true, false); add_unacknowledged_test ( suite, "/Session/unacknowledged/insert_one/implicit_cs/inherit_wc", - "uses-live-server", + "USES_LIVE_SERVER", test_insert_one, false, true); add_unacknowledged_test ( suite, "/Session/unacknowledged/insert_one/implicit_cs/explicit_wc", - "uses-live-server", + "USES_LIVE_SERVER", test_insert_one, false, false); add_unacknowledged_test ( suite, "/Session/unacknowledged/bulk/explicit_cs/inherit_wc", - "uses-live-server", + "USES_LIVE_SERVER", test_bulk, true, true); add_unacknowledged_test ( suite, "/Session/unacknowledged/bulk/explicit_cs/explicit_wc", - "uses-live-server", + "USES_LIVE_SERVER", test_bulk, true, false); add_unacknowledged_test ( suite, "/Session/unacknowledged/bulk/implicit_cs/inherit_wc", - "uses-live-server", + "USES_LIVE_SERVER", test_bulk, false, true); add_unacknowledged_test ( suite, "/Session/unacknowledged/bulk/implicit_cs/explicit_wc", - "uses-live-server", + "USES_LIVE_SERVER", test_bulk, false, false); @@ -3225,14 +3225,14 @@ test_session_install (TestSuite *suite) add_unacknowledged_test ( suite, "/Session/unacknowledged/find_and_modify/explicit_cs/explicit_wc", - "uses-live-server", + "USES_LIVE_SERVER", test_fam, true, false); add_unacknowledged_test ( suite, "/Session/unacknowledged/find_and_modify/implicit_cs/explicit_wc", - "uses-live-server", + "USES_LIVE_SERVER", test_fam, false, false); @@ -3241,70 +3241,70 @@ test_session_install (TestSuite *suite) add_unacknowledged_test ( suite, "/Session/unacknowledged/db_cmd/explicit_cs/explicit_wc", - "uses-live-server", + "USES_LIVE_SERVER", test_db_cmd, true, false); add_unacknowledged_test ( suite, "/Session/unacknowledged/db_cmd/implicit_cs/explicit_wc", - "uses-live-server", + "USES_LIVE_SERVER", test_db_cmd, false, false); add_unacknowledged_test ( suite, "/Session/unacknowledged/read_write_cmd/explicit_cs/inherit_wc", - "uses-live-server", + "USES_LIVE_SERVER", test_read_write_cmd, true, true); add_unacknowledged_test ( suite, "/Session/unacknowledged/read_write_cmd/explicit_cs/explicit_wc", - "uses-live-server", + "USES_LIVE_SERVER", test_read_write_cmd, true, false); add_unacknowledged_test ( suite, "/Session/unacknowledged/read_write_cmd/implicit_cs/inherit_wc", - "uses-live-server", + "USES_LIVE_SERVER", test_read_write_cmd, false, true); add_unacknowledged_test ( suite, "/Session/unacknowledged/read_write_cmd/implicit_cs/explicit_wc", - "uses-live-server", + "USES_LIVE_SERVER", test_read_write_cmd, false, false); add_unacknowledged_test ( suite, "/Session/unacknowledged/write_cmd/explicit_cs/inherit_wc", - "uses-live-server", + "USES_LIVE_SERVER", test_write_cmd, true, true); add_unacknowledged_test ( suite, "/Session/unacknowledged/write_cmd/explicit_cs/explicit_wc", - "uses-live-server", + "USES_LIVE_SERVER", test_write_cmd, true, false); add_unacknowledged_test ( suite, "/Session/unacknowledged/write_cmd/implicit_cs/inherit_wc", - "uses-live-server", + "USES_LIVE_SERVER", test_write_cmd, false, true); add_unacknowledged_test ( suite, "/Session/unacknowledged/write_cmd/implicit_cs/explicit_wc", - "uses-live-server", + "USES_LIVE_SERVER", test_write_cmd, false, false); @@ -3318,7 +3318,7 @@ test_session_install (TestSuite *suite) TestSuite_AddFull ( suite, "/Session/dirty", - "uses-live-server", + "USES_LIVE_SERVER", test_session_dirty, NULL /* dtor */, NULL /* ctx */, @@ -3329,7 +3329,7 @@ test_session_install (TestSuite *suite) TestSuite_AddFull (suite, "/Session/snapshot/prose_test_1", - "uses-live-server", + "USES_LIVE_SERVER", test_sessions_snapshot_prose_test_1, NULL, NULL, diff --git a/src/libmongoc/tests/test-mongoc-client.c b/src/libmongoc/tests/test-mongoc-client.c index 0ceac2b56f6..91da50ec439 100644 --- a/src/libmongoc/tests/test-mongoc-client.c +++ b/src/libmongoc/tests/test-mongoc-client.c @@ -4267,14 +4267,14 @@ test_client_install (TestSuite *suite) test_client_cmd_w_server_id_sharded); TestSuite_AddFull (suite, "/Client/command_w_server_id/option", - "uses-live-server", + "USES_LIVE_SERVER", test_server_id_option, NULL, NULL, test_framework_skip_if_auth); TestSuite_AddFull (suite, "/Client/command_w_write_concern", - "uses-live-server", + "USES_LIVE_SERVER", test_client_cmd_w_write_concern, NULL, NULL, @@ -4491,7 +4491,7 @@ test_client_install (TestSuite *suite) test_mongoc_client_descriptions_single); TestSuite_AddFull (suite, "/Client/descriptions/pooled", - "uses-live-server", + "USES_LIVE_SERVER", test_mongoc_client_descriptions_pooled, NULL, NULL, diff --git a/src/libmongoc/tests/test-mongoc-collection-find.c b/src/libmongoc/tests/test-mongoc-collection-find.c index c90f473a1e8..56ce42980ff 100644 --- a/src/libmongoc/tests/test-mongoc-collection-find.c +++ b/src/libmongoc/tests/test-mongoc-collection-find.c @@ -1128,7 +1128,7 @@ test_collection_find_install (TestSuite *suite) TestSuite_AddLive (suite, "/Collection/find/fields", "", test_fields); TestSuite_AddFull (suite, "/Collection/find/modifiers/maxscan", - "uses-live-server", + "USES_LIVE_SERVER", test_maxscan, NULL, NULL, diff --git a/src/libmongoc/tests/test-mongoc-collection.c b/src/libmongoc/tests/test-mongoc-collection.c index 2d2557fa608..76cb38f484e 100644 --- a/src/libmongoc/tests/test-mongoc-collection.c +++ b/src/libmongoc/tests/test-mongoc-collection.c @@ -6148,14 +6148,14 @@ test_collection_install (TestSuite *suite) TestSuite_AddFull (suite, "/Collection/aggregate/write_concern", - "uses-live-server", + "USES_LIVE_SERVER", test_aggregate_w_write_concern, NULL, NULL, TestSuite_CheckLive); TestSuite_AddFull (suite, "/Collection/read_prefs_is_valid", - "uses-live-server", + "USES_LIVE_SERVER", test_read_prefs_is_valid, NULL, NULL, @@ -6169,7 +6169,7 @@ test_collection_install (TestSuite *suite) suite, "/Collection/insert/null_string", "", test_insert_null); TestSuite_AddFull (suite, "/Collection/insert/oversize", - "uses-live-server", + "USES_LIVE_SERVER", test_insert_oversize, NULL, NULL, @@ -6193,7 +6193,7 @@ test_collection_install (TestSuite *suite) suite, "/Collection/index_compound", "", test_index_compound); TestSuite_AddFull (suite, "/Collection/index_geo", - "uses-live-server", + "USES_LIVE_SERVER", test_index_geo, NULL, NULL, @@ -6203,7 +6203,7 @@ test_collection_install (TestSuite *suite) TestSuite_AddLive (suite, "/Collection/regex", "", test_regex); TestSuite_AddFull (suite, "/Collection/decimal128", - "uses-live-server", + "USES_LIVE_SERVER", test_decimal128, NULL, NULL, @@ -6211,7 +6211,7 @@ test_collection_install (TestSuite *suite) TestSuite_AddLive (suite, "/Collection/update", "", test_update); TestSuite_AddFull (suite, "/Collection/update_pipeline", - "uses-live-server", + "USES_LIVE_SERVER", test_update_pipeline, NULL, NULL, @@ -6221,7 +6221,7 @@ test_collection_install (TestSuite *suite) suite, "/Collection/update/upsert", "", test_update_upsert); TestSuite_AddFull (suite, "/Collection/update/oversize", - "uses-live-server", + "USES_LIVE_SERVER", test_update_oversize, NULL, NULL, @@ -6230,7 +6230,7 @@ test_collection_install (TestSuite *suite) TestSuite_AddLive (suite, "/Collection/remove/multi", "", test_remove_multi); TestSuite_AddFull (suite, "/Collection/remove/oversize", - "uses-live-server", + "USES_LIVE_SERVER", test_remove_oversize, NULL, NULL, @@ -6246,7 +6246,7 @@ test_collection_install (TestSuite *suite) suite, "/Collection/count/collation", "", test_count_with_collation); TestSuite_AddFull (suite, "/Collection/count/read_concern_live", - "uses-live-server", + "USES_LIVE_SERVER", test_count_read_concern_live, NULL, NULL, @@ -6261,7 +6261,7 @@ test_collection_install (TestSuite *suite) suite, "/Collection/aggregate/large", "", test_aggregate_large); TestSuite_AddFull (suite, "/Collection/aggregate/secondary", - "uses-live-server", + "USES_LIVE_SERVER", test_aggregate_secondary, NULL, NULL, @@ -6276,7 +6276,7 @@ test_collection_install (TestSuite *suite) test_aggregate_read_concern); TestSuite_AddFull (suite, "/Collection/aggregate/bypass_document_validation", - "uses-live-server", + "USES_LIVE_SERVER", test_aggregate_bypass, NULL, NULL, @@ -6295,14 +6295,14 @@ test_collection_install (TestSuite *suite) test_aggregate_w_server_id_sharded); TestSuite_AddFull (suite, "/Collection/aggregate_w_server_id/option", - "uses-live-server", + "USES_LIVE_SERVER", test_aggregate_server_id_option, NULL, NULL, test_framework_skip_if_auth); TestSuite_AddFull (suite, "/Collection/validate", - "uses-live-server", + "USES_LIVE_SERVER", test_validate, NULL, NULL, @@ -6315,7 +6315,7 @@ test_collection_install (TestSuite *suite) suite, "/Collection/find_read_concern", "", test_find_read_concern); TestSuite_AddFull (suite, "/Collection/getmore_read_concern_live", - "uses-live-server", + "USES_LIVE_SERVER", test_getmore_read_concern_live, NULL, NULL, @@ -6328,7 +6328,7 @@ test_collection_install (TestSuite *suite) test_find_and_modify_write_concern); TestSuite_AddFull (suite, "/Collection/large_return", - "uses-live-server", + "USES_LIVE_SERVER", test_large_return, NULL, NULL, @@ -6344,7 +6344,7 @@ test_collection_install (TestSuite *suite) suite, "/Collection/batch_size", "", test_find_batch_size); TestSuite_AddFull (suite, "/Collection/command_fully_qualified", - "uses-live-server", + "USES_LIVE_SERVER", test_command_fq, NULL, NULL, @@ -6357,7 +6357,7 @@ test_collection_install (TestSuite *suite) suite, "/Collection/insert/duplicate_key", "", test_insert_duplicate_key); TestSuite_AddFull (suite, "/Collection/create_index/fail", - "uses-live-server", + "USES_LIVE_SERVER", test_create_index_fail, NULL, NULL, @@ -6405,7 +6405,7 @@ test_collection_install (TestSuite *suite) test_aggregate_with_batch_size); TestSuite_AddFull (suite, "/Collection/fam/no_error_on_retry", - "uses-live-server", + "USES_LIVE_SERVER", test_fam_no_error_on_retry, NULL, NULL, diff --git a/src/libmongoc/tests/test-mongoc-command-monitoring.c b/src/libmongoc/tests/test-mongoc-command-monitoring.c index 7c5326575ca..1934d465a1c 100644 --- a/src/libmongoc/tests/test-mongoc-command-monitoring.c +++ b/src/libmongoc/tests/test-mongoc-command-monitoring.c @@ -1427,7 +1427,7 @@ test_command_monitoring_install (TestSuite *suite) test_client_cmd_op_ids); TestSuite_AddFull (suite, "/command_monitoring/killcursors_deprecated", - "uses-live-server", + "USES_LIVE_SERVER", test_killcursors_deprecated, NULL /* dtor */, NULL /* ctx */, diff --git a/src/libmongoc/tests/test-mongoc-counters.c b/src/libmongoc/tests/test-mongoc-counters.c index 1ab6e09c7fd..26bc6a4c54f 100644 --- a/src/libmongoc/tests/test-mongoc-counters.c +++ b/src/libmongoc/tests/test-mongoc-counters.c @@ -489,7 +489,7 @@ test_counters_install (TestSuite *suite) #ifdef MONGOC_ENABLE_SHM_COUNTERS TestSuite_AddFull (suite, "/counters/op_msg", - "uses-live-server", + "USES_LIVE_SERVER", test_counters_op_msg, NULL, NULL, @@ -497,7 +497,7 @@ test_counters_install (TestSuite *suite) test_framework_skip_if_compressors); TestSuite_AddFull (suite, "/counters/op_compressed", - "uses-live-server", + "USES_LIVE_SERVER", test_counters_op_compressed, NULL, NULL, @@ -507,14 +507,14 @@ test_counters_install (TestSuite *suite) TestSuite_AddLive (suite, "/counters/clients", "", test_counters_clients); TestSuite_AddFull (suite, "/counters/streams", - "uses-live-server", + "USES_LIVE_SERVER", test_counters_streams, NULL, NULL, TestSuite_CheckLive); TestSuite_AddFull (suite, "/counters/auth", - "uses-live-server", + "USES_LIVE_SERVER", test_counters_auth, NULL, NULL, diff --git a/src/libmongoc/tests/test-mongoc-crud.c b/src/libmongoc/tests/test-mongoc-crud.c index 83cd397e50e..f7e10becfd9 100644 --- a/src/libmongoc/tests/test-mongoc-crud.c +++ b/src/libmongoc/tests/test-mongoc-crud.c @@ -173,7 +173,7 @@ test_crud_install (TestSuite *suite) TestSuite_AddFull (suite, "/crud/prose_test_1", - "uses-live-server", + "USES_LIVE_SERVER", prose_test_1, NULL, /* dtor */ NULL, /* ctx */ @@ -182,7 +182,7 @@ test_crud_install (TestSuite *suite) TestSuite_AddFull (suite, "/crud/prose_test_2", - "uses-live-server", + "USES_LIVE_SERVER", prose_test_2, NULL, /* dtor */ NULL, /* ctx */ diff --git a/src/libmongoc/tests/test-mongoc-cursor.c b/src/libmongoc/tests/test-mongoc-cursor.c index b37b3c31a0c..4e260680ae1 100644 --- a/src/libmongoc/tests/test-mongoc-cursor.c +++ b/src/libmongoc/tests/test-mongoc-cursor.c @@ -445,7 +445,7 @@ _make_array_cursor (mongoc_collection_t *coll) #define TEST_CURSOR_FIND(prefix, fn) \ TestSuite_AddFullWithTestFn (suite, \ prefix "/find", \ - "uses-live-server", \ + "USES_LIVE_SERVER", \ fn, \ NULL, \ _make_find_cursor, \ @@ -454,7 +454,7 @@ _make_array_cursor (mongoc_collection_t *coll) #define TEST_CURSOR_CMD(prefix, fn) \ TestSuite_AddFullWithTestFn (suite, \ prefix "/cmd", \ - "uses-live-server", \ + "USES_LIVE_SERVER", \ fn, \ NULL, \ _make_cmd_cursor, \ @@ -463,7 +463,7 @@ _make_array_cursor (mongoc_collection_t *coll) #define TEST_CURSOR_CMD_DEPRECATED(prefix, fn) \ TestSuite_AddFullWithTestFn (suite, \ prefix "/cmd_deprecated", \ - "uses-live-server", \ + "USES_LIVE_SERVER", \ fn, \ NULL, \ _make_cmd_deprecated_cursor, \ @@ -472,7 +472,7 @@ _make_array_cursor (mongoc_collection_t *coll) #define TEST_CURSOR_ARRAY(prefix, fn) \ TestSuite_AddFullWithTestFn (suite, \ prefix "/array", \ - "uses-live-server", \ + "USES_LIVE_SERVER", \ fn, \ NULL, \ _make_array_cursor, \ @@ -481,7 +481,7 @@ _make_array_cursor (mongoc_collection_t *coll) #define TEST_CURSOR_AGG(prefix, fn) \ TestSuite_AddFullWithTestFn (suite, \ prefix "/agg", \ - "uses-live-server", \ + "USES_LIVE_SERVER", \ fn, \ NULL, \ _make_cmd_cursor_from_agg, \ @@ -2368,14 +2368,14 @@ test_cursor_install (TestSuite *suite) test_cursor_new_from_aggregate_no_initial); TestSuite_AddFull (suite, "/Cursor/new_from_find", - "uses-live-server", + "USES_LIVE_SERVER", test_cursor_new_from_find, NULL, NULL, TestSuite_CheckLive); TestSuite_AddFull (suite, "/Cursor/new_from_find_batches", - "uses-live-server", + "USES_LIVE_SERVER", test_cursor_new_from_find_batches, NULL, NULL, diff --git a/src/libmongoc/tests/test-mongoc-database.c b/src/libmongoc/tests/test-mongoc-database.c index 158321e1390..e8d6938c0b3 100644 --- a/src/libmongoc/tests/test-mongoc-database.c +++ b/src/libmongoc/tests/test-mongoc-database.c @@ -1145,7 +1145,7 @@ test_database_install (TestSuite *suite) test_aggregate_inherit_database); TestSuite_AddFull (suite, "/Database/create_with_write_concern", - "uses-live-server", + "USES_LIVE_SERVER", test_create_with_write_concern, NULL, NULL, diff --git a/src/libmongoc/tests/test-mongoc-exhaust.c b/src/libmongoc/tests/test-mongoc-exhaust.c index 2fd1c7f466c..b116782da2d 100644 --- a/src/libmongoc/tests/test-mongoc-exhaust.c +++ b/src/libmongoc/tests/test-mongoc-exhaust.c @@ -714,7 +714,7 @@ test_exhaust_install (TestSuite *suite) { TestSuite_AddFull (suite, "/Client/exhaust_cursor/single", - "uses-live-server", + "USES_LIVE_SERVER", test_exhaust_cursor_single, NULL, NULL, @@ -722,7 +722,7 @@ test_exhaust_install (TestSuite *suite) test_framework_skip_if_no_legacy_opcodes); TestSuite_AddFull (suite, "/Client/exhaust_cursor/pool", - "uses-live-server", + "USES_LIVE_SERVER", test_exhaust_cursor_pool, NULL, NULL, @@ -730,7 +730,7 @@ test_exhaust_install (TestSuite *suite) test_framework_skip_if_no_legacy_opcodes); TestSuite_AddFull (suite, "/Client/exhaust_cursor/batches", - "uses-live-server", + "USES_LIVE_SERVER", test_exhaust_cursor_multi_batch, NULL, NULL, @@ -738,7 +738,7 @@ test_exhaust_install (TestSuite *suite) test_framework_skip_if_no_legacy_opcodes); TestSuite_AddFull (suite, "/Client/exhaust_cursor/fallback", - "uses-live-server", + "USES_LIVE_SERVER", test_exhaust_cursor_fallback, NULL, NULL, diff --git a/src/libmongoc/tests/test-mongoc-find-and-modify.c b/src/libmongoc/tests/test-mongoc-find-and-modify.c index e5baae0b3ce..0ba334c53f3 100644 --- a/src/libmongoc/tests/test-mongoc-find-and-modify.c +++ b/src/libmongoc/tests/test-mongoc-find-and-modify.c @@ -567,7 +567,7 @@ test_find_and_modify_install (TestSuite *suite) test_find_and_modify_write_concern); TestSuite_AddFull (suite, "/find_and_modify/find_and_modify/write_concern_failure", - "", + "USES_LIVE_SERVER", test_find_and_modify_write_concern_failure, NULL, NULL, diff --git a/src/libmongoc/tests/test-mongoc-gridfs-bucket.c b/src/libmongoc/tests/test-mongoc-gridfs-bucket.c index 5c71a3aa179..3537f62dcb1 100644 --- a/src/libmongoc/tests/test-mongoc-gridfs-bucket.c +++ b/src/libmongoc/tests/test-mongoc-gridfs-bucket.c @@ -1173,7 +1173,7 @@ test_gridfs_bucket_install (TestSuite *suite) test_framework_skip_if_no_auth); TestSuite_AddFull (suite, "/gridfs/find_w_session", - "uses-live-server", + "USES_LIVE_SERVER", test_find_w_session, NULL, NULL, @@ -1181,7 +1181,7 @@ test_gridfs_bucket_install (TestSuite *suite) test_framework_skip_if_no_crypto); TestSuite_AddFull (suite, "/gridfs/find", - "uses-live-server", + "USES_LIVE_SERVER", test_find, NULL, NULL, diff --git a/src/libmongoc/tests/test-mongoc-gridfs.c b/src/libmongoc/tests/test-mongoc-gridfs.c index 105308eef59..d483b415fe7 100644 --- a/src/libmongoc/tests/test-mongoc-gridfs.c +++ b/src/libmongoc/tests/test-mongoc-gridfs.c @@ -1600,7 +1600,7 @@ test_gridfs_install (TestSuite *suite) suite, "/gridfs_old/write_past_end", "", test_write_past_end); TestSuite_AddFull (suite, "/gridfs_old/test_long_seek", - "uses-live-server", + "USES_LIVE_SERVER", test_long_seek, NULL, NULL, @@ -1609,7 +1609,7 @@ test_gridfs_install (TestSuite *suite) suite, "/gridfs_old/remove_by_filename", "", test_remove_by_filename); TestSuite_AddFull (suite, "/gridfs_old/missing_chunk", - "uses-live-server", + "USES_LIVE_SERVER", test_missing_chunk, NULL, NULL, diff --git a/src/libmongoc/tests/test-mongoc-long-namespace.c b/src/libmongoc/tests/test-mongoc-long-namespace.c index 578709c1978..081d4b8d78f 100644 --- a/src/libmongoc/tests/test-mongoc-long-namespace.c +++ b/src/libmongoc/tests/test-mongoc-long-namespace.c @@ -576,7 +576,7 @@ unsupported_long_db (void) void test_long_namespace_install (TestSuite *suite) { - const char *common_meta = "uses-live-server"; + const char *common_meta = "USES_LIVE_SERVER"; /* MongoDB 4.4 (wire version 9) introduced support for long namespaces in * SERVER-32959 */ TestSuite_AddFullWithTestFn ( diff --git a/src/libmongoc/tests/test-mongoc-max-staleness.c b/src/libmongoc/tests/test-mongoc-max-staleness.c index b1923c7eff3..9141eacd6e4 100644 --- a/src/libmongoc/tests/test-mongoc-max-staleness.c +++ b/src/libmongoc/tests/test-mongoc-max-staleness.c @@ -379,7 +379,7 @@ test_client_max_staleness_install (TestSuite *suite) test_mongos_max_staleness_read_pref); TestSuite_AddFull (suite, "/Client/last_write_date", - "uses-live-server", + "USES_LIVE_SERVER", test_last_write_date, NULL, NULL, @@ -387,7 +387,7 @@ test_client_max_staleness_install (TestSuite *suite) test_framework_skip_if_slow); TestSuite_AddFull (suite, "/Client/last_write_date/pooled", - "uses-live-server", + "USES_LIVE_SERVER", test_last_write_date_pooled, NULL, NULL, @@ -395,14 +395,14 @@ test_client_max_staleness_install (TestSuite *suite) test_framework_skip_if_slow); TestSuite_AddFull (suite, "/Client/last_write_date_absent", - "uses-live-server", + "USES_LIVE_SERVER", test_last_write_date_absent, NULL, NULL, test_framework_skip_if_replset); TestSuite_AddFull (suite, "/Client/last_write_date_absent/pooled", - "uses-live-server", + "USES_LIVE_SERVER", test_last_write_date_absent_pooled, NULL, NULL, diff --git a/src/libmongoc/tests/test-mongoc-mongos-pinning.c b/src/libmongoc/tests/test-mongoc-mongos-pinning.c index af5c6fdec72..8d8421dbdd2 100644 --- a/src/libmongoc/tests/test-mongoc-mongos-pinning.c +++ b/src/libmongoc/tests/test-mongoc-mongos-pinning.c @@ -191,7 +191,7 @@ test_mongos_pinning_install (TestSuite *suite) { TestSuite_AddFull (suite, "/mongos_pinning/new_transaction_unpins", - "uses-live-server", + "USES_LIVE_SERVER", test_new_transaction_unpins, NULL, NULL, @@ -202,7 +202,7 @@ test_mongos_pinning_install (TestSuite *suite) TestSuite_AddFull (suite, "/mongos_pinning/non_transaction_unpins", - "uses-live-server", + "USES_LIVE_SERVER", test_non_transaction_unpins, NULL, NULL, diff --git a/src/libmongoc/tests/test-mongoc-primary-stepdown.c b/src/libmongoc/tests/test-mongoc-primary-stepdown.c index cc4b08505d9..5e8fcecede9 100644 --- a/src/libmongoc/tests/test-mongoc-primary-stepdown.c +++ b/src/libmongoc/tests/test-mongoc-primary-stepdown.c @@ -494,7 +494,7 @@ test_primary_stepdown_install (TestSuite *suite) { TestSuite_AddFull (suite, "/Stepdown/getmore", - "uses-live-server", + "USES_LIVE_SERVER", test_getmore_iteration_runner, NULL, NULL, @@ -503,7 +503,7 @@ test_primary_stepdown_install (TestSuite *suite) TestSuite_AddFull (suite, "/Stepdown/not_primary_keep", - "uses-live-server", + "USES_LIVE_SERVER", test_not_primary_keep_pool_runner, NULL, NULL, @@ -512,7 +512,7 @@ test_primary_stepdown_install (TestSuite *suite) TestSuite_AddFull (suite, "/Stepdown/not_primary_reset", - "uses-live-server", + "USES_LIVE_SERVER", test_not_primary_reset_pool_runner, NULL, NULL, @@ -521,7 +521,7 @@ test_primary_stepdown_install (TestSuite *suite) TestSuite_AddFull (suite, "/Stepdown/shutdown_reset_pool", - "uses-live-server", + "USES_LIVE_SERVER", test_shutdown_reset_pool_runner, NULL, NULL, @@ -530,7 +530,7 @@ test_primary_stepdown_install (TestSuite *suite) TestSuite_AddFull (suite, "/Stepdown/interrupt_shutdown", - "uses-live-server", + "USES_LIVE_SERVER", test_interrupted_shutdown_reset_pool_runner, NULL, NULL, diff --git a/src/libmongoc/tests/test-mongoc-retryable-reads.c b/src/libmongoc/tests/test-mongoc-retryable-reads.c index 61d97a797be..facc5cf1168 100644 --- a/src/libmongoc/tests/test-mongoc-retryable-reads.c +++ b/src/libmongoc/tests/test-mongoc-retryable-reads.c @@ -302,7 +302,7 @@ test_retryable_reads_install (TestSuite *suite) /* Since we need failpoints, require wire version 7 */ TestSuite_AddFull (suite, "/retryable_reads/cmd_helpers", - "uses-live-server", + "USES_LIVE_SERVER", test_cmd_helpers, NULL, NULL, @@ -311,7 +311,7 @@ test_retryable_reads_install (TestSuite *suite) test_framework_skip_if_no_failpoint); TestSuite_AddFull (suite, "/retryable_reads/retry_off", - "uses-live-server", + "USES_LIVE_SERVER", test_retry_reads_off, NULL, NULL, diff --git a/src/libmongoc/tests/test-mongoc-retryable-writes.c b/src/libmongoc/tests/test-mongoc-retryable-writes.c index 9fe23eebc84..0c51b0b59dc 100644 --- a/src/libmongoc/tests/test-mongoc-retryable-writes.c +++ b/src/libmongoc/tests/test-mongoc-retryable-writes.c @@ -687,7 +687,7 @@ test_retryable_writes_install (TestSuite *suite) test_framework_skip_if_no_crypto); TestSuite_AddFull (suite, "/retryable_writes/command_with_opts", - "uses-live-server", + "USES_LIVE_SERVER", test_command_with_opts, NULL, NULL, @@ -720,7 +720,7 @@ test_retryable_writes_install (TestSuite *suite) test_framework_skip_if_no_crypto); TestSuite_AddFull (suite, "/retryable_writes/no_crypto", - "uses-live-server", + "USES_LIVE_SERVER", test_retry_no_crypto, NULL, NULL, @@ -733,7 +733,7 @@ test_retryable_writes_install (TestSuite *suite) test_framework_skip_if_no_crypto); TestSuite_AddFull (suite, "/retryable_writes/bulk_tracks_new_server", - "uses-live-server", + "USES_LIVE_SERVER", test_bulk_retry_tracks_new_server, NULL /* dtor */, NULL /* ctx */, diff --git a/src/libmongoc/tests/test-mongoc-sample-commands.c b/src/libmongoc/tests/test-mongoc-sample-commands.c index 815a0b4094c..ea44c549bee 100644 --- a/src/libmongoc/tests/test-mongoc-sample-commands.c +++ b/src/libmongoc/tests/test-mongoc-sample-commands.c @@ -4015,7 +4015,7 @@ test_samples_install (TestSuite *suite) TestSuite_AddLive (suite, "/Samples", "", test_sample_commands); TestSuite_AddFull (suite, "/Samples/with_txn", - "uses-live-server", + "USES_LIVE_SERVER", test_with_txn_example, NULL, NULL, diff --git a/src/libmongoc/tests/test-mongoc-sdam.c b/src/libmongoc/tests/test-mongoc-sdam.c index af21b9448f9..638b1d660fa 100644 --- a/src/libmongoc/tests/test-mongoc-sdam.c +++ b/src/libmongoc/tests/test-mongoc-sdam.c @@ -928,28 +928,28 @@ test_sdam_install (TestSuite *suite) test_all_spec_tests (suite); TestSuite_AddFull (suite, "/server_discovery_and_monitoring/topology/discovery", - "uses-live-server", + "USES_LIVE_SERVER", test_topology_discovery, NULL /* dtor */, NULL /* ctx */, test_framework_skip_if_not_replset); TestSuite_AddFull (suite, "/server_discovery_and_monitoring/directconnection", - "uses-live-server", + "USES_LIVE_SERVER", test_direct_connection, NULL /* dtor */, NULL /* ctx */, test_framework_skip_if_not_replset); TestSuite_AddFull (suite, "/server_discovery_and_monitoring/existing/behavior", - "uses-live-server", + "USES_LIVE_SERVER", test_existing_behavior, NULL /* dtor */, NULL /* ctx */, test_framework_skip_if_not_replset); TestSuite_AddFull (suite, "/server_discovery_and_monitoring/prose/rtt", - "uses-live-server", + "USES_LIVE_SERVER", test_prose_rtt, NULL /* dtor */, NULL /* ctx */, diff --git a/src/libmongoc/tests/test-mongoc-server-selection-errors.c b/src/libmongoc/tests/test-mongoc-server-selection-errors.c index c7e681ab052..fc5882d11f3 100644 --- a/src/libmongoc/tests/test-mongoc-server-selection-errors.c +++ b/src/libmongoc/tests/test-mongoc-server-selection-errors.c @@ -327,14 +327,14 @@ test_server_selection_errors_install (TestSuite *suite) test_framework_skip_if_slow); TestSuite_AddFull (suite, "/server_selection/errors/dns/multi/success/single", - "uses-live-server", + "USES_LIVE_SERVER", test_server_selection_error_dns_multi_success_single, NULL, NULL, test_framework_skip_if_single); TestSuite_AddFull (suite, "/server_selection/errors/dns/multi/success/pooled", - "uses-live-server", + "USES_LIVE_SERVER", test_server_selection_error_dns_multi_success_pooled, NULL, NULL, diff --git a/src/libmongoc/tests/test-mongoc-topology-reconcile.c b/src/libmongoc/tests/test-mongoc-topology-reconcile.c index 5c2fa4a2f0f..d4416d44ee1 100644 --- a/src/libmongoc/tests/test-mongoc-topology-reconcile.c +++ b/src/libmongoc/tests/test-mongoc-topology-reconcile.c @@ -698,7 +698,7 @@ test_topology_reconcile_install (TestSuite *suite) test_topology_reconcile_sharded_single); TestSuite_AddFull (suite, "/TOPOLOGY/reconcile/from_handshake", - "uses-live-server", + "USES_LIVE_SERVER", test_topology_reconcile_from_handshake, NULL, NULL, diff --git a/src/libmongoc/tests/test-mongoc-topology-scanner.c b/src/libmongoc/tests/test-mongoc-topology-scanner.c index 2986d7fd0ed..fb2e0de9190 100644 --- a/src/libmongoc/tests/test-mongoc-topology-scanner.c +++ b/src/libmongoc/tests/test-mongoc-topology-scanner.c @@ -769,7 +769,7 @@ test_topology_scanner_install (TestSuite *suite) test_topology_retired_fails_to_initiate); TestSuite_AddFull (suite, "/TOPOLOGY/scanner/renegotiate/single", - "uses-live-server", + "USES_LIVE_SERVER", test_topology_scanner_does_not_renegotiate_single, NULL, NULL, @@ -777,7 +777,7 @@ test_topology_scanner_install (TestSuite *suite) test_framework_skip_if_valgrind); TestSuite_AddFull (suite, "/TOPOLOGY/scanner/renegotiate/pooled", - "uses-live-server", + "USES_LIVE_SERVER", test_topology_scanner_does_not_renegotiate_pooled, NULL, NULL, diff --git a/src/libmongoc/tests/test-mongoc-topology.c b/src/libmongoc/tests/test-mongoc-topology.c index 8d5e35a98d0..88a1c448ec8 100644 --- a/src/libmongoc/tests/test-mongoc-topology.c +++ b/src/libmongoc/tests/test-mongoc-topology.c @@ -2568,28 +2568,28 @@ test_topology_install (TestSuite *suite) suite, "/Topology/start_stop", "", test_topology_thread_start_stop); TestSuite_AddFull (suite, "/Topology/server_selection_try_once_option", - "uses-live-server", + "USES_LIVE_SERVER", test_server_selection_try_once_option, NULL, NULL, test_framework_skip_if_slow); TestSuite_AddFull (suite, "/Topology/server_selection_try_once", - "uses-live-server", + "USES_LIVE_SERVER", test_server_selection_try_once, NULL, NULL, test_framework_skip_if_slow); TestSuite_AddFull (suite, "/Topology/server_selection_try_once_false", - "uses-live-server", + "USES_LIVE_SERVER", test_server_selection_try_once_false, NULL, NULL, test_framework_skip_if_slow); TestSuite_AddFull (suite, "/Topology/invalidate_server/single", - "uses-live-server", + "USES_LIVE_SERVER", test_topology_invalidate_server_single, NULL, NULL, @@ -2597,7 +2597,7 @@ test_topology_install (TestSuite *suite) test_framework_skip_if_valgrind); TestSuite_AddFull (suite, "/Topology/invalidate_server/pooled", - "uses-live-server", + "USES_LIVE_SERVER", test_topology_invalidate_server_pooled, NULL, NULL, @@ -2605,14 +2605,14 @@ test_topology_install (TestSuite *suite) test_framework_skip_if_valgrind); TestSuite_AddFull (suite, "/Topology/invalid_cluster_node", - "uses-live-server", + "USES_LIVE_SERVER", test_invalid_cluster_node, NULL, NULL, test_framework_skip_if_slow_or_live); TestSuite_AddFull (suite, "/Topology/max_wire_version_race_condition", - "uses-live-server", + "USES_LIVE_SERVER", test_max_wire_version_race_condition, NULL, NULL, @@ -2640,7 +2640,7 @@ test_topology_install (TestSuite *suite) test_framework_skip_if_slow); TestSuite_AddFull (suite, "/Topology/multiple_selection_errors", - "uses-live-server", + "USES_LIVE_SERVER", test_multiple_selection_errors, NULL, NULL, @@ -2669,7 +2669,7 @@ test_topology_install (TestSuite *suite) test_server_removed_during_handshake_pooled); TestSuite_AddFull (suite, "/Topology/rtt", - "uses-live-server", + "USES_LIVE_SERVER", test_rtt, NULL, NULL, diff --git a/src/libmongoc/tests/test-mongoc-transactions.c b/src/libmongoc/tests/test-mongoc-transactions.c index 3f67122464f..a047fd8dfce 100644 --- a/src/libmongoc/tests/test-mongoc-transactions.c +++ b/src/libmongoc/tests/test-mongoc-transactions.c @@ -1218,14 +1218,14 @@ test_transactions_install (TestSuite *suite) TestSuite_AddFull (suite, "/transactions/supported", - "uses-live-server", + "USES_LIVE_SERVER", test_transactions_supported, NULL, NULL, test_framework_skip_if_no_txns); TestSuite_AddFull (suite, "/transactions/in_transaction", - "uses-live-server", + "USES_LIVE_SERVER", test_in_transaction, NULL, NULL, @@ -1247,14 +1247,14 @@ test_transactions_install (TestSuite *suite) test_framework_skip_if_no_crypto); TestSuite_AddFull (suite, "/transactions/cursor_primary_read_pref", - "uses-live-server", + "USES_LIVE_SERVER", test_cursor_primary_read_pref, NULL, NULL, test_framework_skip_if_no_txns); TestSuite_AddFull (suite, "/transactions/inherit_from_client", - "uses-live-server", + "USES_LIVE_SERVER", test_inherit_from_client, NULL, NULL, @@ -1263,7 +1263,7 @@ test_transactions_install (TestSuite *suite) suite, "/transactions/" "transaction_fails_on_unsupported_version_or_sharded_cluster", - "uses-live-server", + "USES_LIVE_SERVER", test_transaction_fails_on_unsupported_version_or_sharded_cluster, NULL, NULL, @@ -1271,7 +1271,7 @@ test_transactions_install (TestSuite *suite) test_framework_skip_if_no_crypto); TestSuite_AddFull (suite, "/transactions/recovery_token_cleared", - "uses-live-server", + "USES_LIVE_SERVER", test_transaction_recovery_token_cleared, NULL, NULL, @@ -1281,7 +1281,7 @@ test_transactions_install (TestSuite *suite) test_framework_skip_if_not_mongos); TestSuite_AddFull (suite, "/transactions/selected_server_pinned_to_mongos", - "uses-live-server", + "USES_LIVE_SERVER", test_selected_server_is_pinned_to_mongos, NULL, NULL, @@ -1295,7 +1295,7 @@ test_transactions_install (TestSuite *suite) test_framework_skip_if_no_crypto); TestSuite_AddFull (suite, "/transactions/max_commit_time_ms_is_reset", - "uses-live-server", + "USES_LIVE_SERVER", test_max_commit_time_ms_is_reset, NULL, NULL, diff --git a/src/libmongoc/tests/test-mongoc-with-transaction.c b/src/libmongoc/tests/test-mongoc-with-transaction.c index 0c3e51586a5..44ac4a7e87d 100644 --- a/src/libmongoc/tests/test-mongoc-with-transaction.c +++ b/src/libmongoc/tests/test-mongoc-with-transaction.c @@ -90,7 +90,7 @@ test_with_transaction_install (TestSuite *suite) { TestSuite_AddFull (suite, "/with_transaction/timeout_tests", - "uses-live-server", + "USES_LIVE_SERVER", test_with_transaction_timeout, NULL, NULL, diff --git a/src/libmongoc/tests/test-mongoc-write-commands.c b/src/libmongoc/tests/test-mongoc-write-commands.c index 0f4640def26..8c8f717cd06 100644 --- a/src/libmongoc/tests/test-mongoc-write-commands.c +++ b/src/libmongoc/tests/test-mongoc-write-commands.c @@ -498,7 +498,7 @@ test_write_command_install (TestSuite *suite) test_invalid_write_concern); TestSuite_AddFull (suite, "/WriteCommand/bypass_validation", - "uses-live-server", + "USES_LIVE_SERVER", test_bypass_validation, NULL, NULL, @@ -509,7 +509,7 @@ test_write_command_install (TestSuite *suite) test_disconnect_mid_batch); TestSuite_AddFull (suite, "/WriteCommand/invalid_wc_server_error", - "uses-live-server", + "USES_LIVE_SERVER", _test_invalid_wc_server_error, NULL, NULL, diff --git a/src/libmongoc/tests/test-mongoc-write-concern.c b/src/libmongoc/tests/test-mongoc-write-concern.c index 6f0683359cd..4cc2f5d3dd9 100644 --- a/src/libmongoc/tests/test-mongoc-write-concern.c +++ b/src/libmongoc/tests/test-mongoc-write-concern.c @@ -755,14 +755,14 @@ test_write_concern_install (TestSuite *suite) test_write_concern_unacknowledged); TestSuite_AddFull (suite, "/WriteConcern/inherited_fam", - "uses-live-server", + "USES_LIVE_SERVER", test_fam_no_session_no_txn, NULL, NULL, TestSuite_CheckLive); TestSuite_AddFull (suite, "/WriteConcern/inherited_fam_session_no_txn", - "uses-live-server", + "USES_LIVE_SERVER", test_fam_session_no_txn, NULL, NULL, @@ -770,7 +770,7 @@ test_write_concern_install (TestSuite *suite) test_framework_skip_if_no_txns); TestSuite_AddFull (suite, "/WriteConcern/inherited_fam_txn", - "uses-live-server", + "USES_LIVE_SERVER", test_fam_session_txn, NULL, NULL, From 775ba52721f6b2acf0b8916bc993ef00aeded42f Mon Sep 17 00:00:00 2001 From: vector-of-bool Date: Fri, 30 Sep 2022 00:39:33 +0000 Subject: [PATCH 48/52] "Finish" mdb-ctl.py and the CTest fixture helpers. --- CMakeLists.txt | 12 +- build/cmake/FindMongoDB.cmake | 323 +++++++++++++----------- build/cmake/LoadTests.cmake | 117 ++++++--- build/cmake/QuickFixtures.cmake | 115 +++++++++ build/cmake/TestFixtures.cmake | 82 +++++- build/cmake/TweakMeServerFixtures.cmake | 23 ++ build/mdb-ctl.py | 273 ++++++++++++++------ build/{proc-ctl.py => proc_ctl.py} | 194 ++++++++++---- src/libmongoc/CMakeLists.txt | 8 + src/libmongoc/tests/TestSuite.c | 11 +- 10 files changed, 821 insertions(+), 337 deletions(-) create mode 100644 build/cmake/QuickFixtures.cmake create mode 100644 build/cmake/TweakMeServerFixtures.cmake rename build/{proc-ctl.py => proc_ctl.py} (59%) diff --git a/CMakeLists.txt b/CMakeLists.txt index 63e7a4c95aa..e7dfa80177d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -93,17 +93,6 @@ endif () include (Sanitizers) find_package (MongoDB) -mongodb_setup_default_fixtures () - -get_property(versions GLOBAL PROPERTY MONGODB_FOUND_VERSIONS) -foreach (ver IN ITEMS 4.1.6 5.1.1) - message (STATUS "Setup for version ${ver}") - mongodb_create_replset_fixture(mdb/fixture/replSet/${ver} - VERSION "${ver}" - REPLSET_NAME rs-${ver} - DEFAULT - ) -endforeach() set (BUILD_VERSION "0.0.0" CACHE STRING "Library version (for both libbson and libmongoc)") @@ -238,6 +227,7 @@ include (MakeDistFiles) include (CTest) if (BUILD_TESTING) include (TestFixtures) + include (build/cmake/TweakMeServerFixtures.cmake) endif () # Ensure the default behavior: don't ignore RPATH settings. diff --git a/build/cmake/FindMongoDB.cmake b/build/cmake/FindMongoDB.cmake index ea5b11f7f92..214c75ef885 100644 --- a/build/cmake/FindMongoDB.cmake +++ b/build/cmake/FindMongoDB.cmake @@ -19,16 +19,15 @@ endif () include (FindPackageHandleStandardArgs) include (CMakeParseArguments) +include (QuickFixtures) define_property (GLOBAL PROPERTY MONGODB_FOUND_VERSIONS BRIEF_DOCS "Versions of MongoDB that have been found" FULL_DOCS "List of versions of MongoDB server executables that have been found" ) -set(MONGODB_DEFAULT_TEST_FIXTURE_VERSIONS - "ALL" CACHE STRING - "List of MongoDB server versions against which to generate default test fixtures" - ) +set (_MDB_SCRIPT_DIR "${CMAKE_CURRENT_LIST_DIR}") +set_property (GLOBAL PROPERTY _MDB_UNUSED_PORT 21231) #[[ Attempt to discern the MongoDB version of the given MongoDB server @@ -167,275 +166,315 @@ endfunction () _mongodb_find () #[[ - Generate CTest test fixtures for every MongoDB version that has been found, as - determined by the MONGODB_FOUND_VERSIONS global property. The generated fixtures - are named as 'default-' for each '' that was found. -]] -function (mongodb_setup_default_fixtures) - set (versions ${MONGODB_DEFAULT_TEST_FIXTURE_VERSIONS}) - if (versions STREQUAL "ALL") - get_cmake_property (versions MONGODB_FOUND_VERSIONS) - endif () - foreach (ver IN LISTS versions) - mongodb_create_fixture ( - "mdb/fixture/default/${ver}" VERSION "${ver}" - SERVER_ARGS --setParameter enableTestCommands=1 - DEFAULT - ) - endforeach () -endfunction () - -#[[ - Create a CTest test fixture that will start, stop, and clean up a MongoDB server - instance for other tests. + Create a CTest test fixture that will start, stop, and clean up a MongoDB + server instance for other tests. mongodb_create_fixture( VERSION [DEFAULT] [PORT_VARIABLE ] - [SERVER_ARGS ...] + [SERVER_ARGS ...] ) and are the only required arguments. VERSION must specify a - MongoDB server version that has a known path. There must be a + MongoDB server version that has a known path (i.e. There must be a MONGODB__PATH global property that defines the path to a mongod executable file. These global properties are set by the FindMongoDB.cmake module when it is first imported. The list of available versions can be - found in the MONGODB_FOUND_VERSIONS global property. + found in the MONGODB_FOUND_VERSIONS global property.) - is an output variable name. Each generated fixture uses a different - TCP port when listening so that fixtures can execute in parallel without contending. - This variable will be set in the caller's scope to the integer TCP port that will - be used by the test fixture. + is an output variable name. Each generated fixture uses a + different TCP port when listening so that fixtures can execute in parallel + without contending. This variable will be set in the caller's scope to the + integer TCP port that will be used by the test fixture. - ... is a list of command-line arguments to supply to the server when it is - started. This can be any option *except* '--fork', '--port', '--dbpath', '--logpath', - or '--pidfilepath', all of which are already specified for the test fixture. + ... is a list of command-line arguments to supply to the server when + it is started. This can be any option *EXCEPT* '--fork', '--port', + '--dbpath', '--logpath', or '--pidfilepath', all of which are already + specified for the test fixture. - The fixture can then be associated with tests via the FIXTURES_REQUIRED - test property. + The fixture can then be associated with tests via the + FIXTURES_REQUIRED test property. If [DEFAULT] is specified, then the fixture will be added to a default list that will be used to populate live-server tests that do not otherwise - specify a server test fixture + specify a server test fixture. ]] function (mongodb_create_fixture name) - cmake_parse_arguments (ARG - "DEFAULT" - "PORT_VARIABLE;VERSION" - "SERVER_ARGS" - ${ARGN} - ) + cmake_parse_arguments (PARSE_ARGV 1 ARG "DEFAULT" "PORT_VARIABLE;VERSION" "SERVER_ARGS") + # Require a VERSION if (NOT ARG_VERSION) message (SEND_ERROR "A VERSION is required") return () endif () + # Get the path for that version get_cmake_property (path "MONGODB_${ARG_VERSION}_PATH") if (NOT path) message (SEND_ERROR "Cannot create a test fixture for MongoDB version ${ARG_VERSION}, which is not found") endif () + # Get an unused TCP port for this server instance get_cmake_property (port "_MDB_UNUSED_PORT") math (EXPR next "${port} + 3") set_property (GLOBAL PROPERTY _MDB_UNUSED_PORT "${next}") + # The directory where it will write its scratch data: set(fxt_dir "${PROJECT_BINARY_DIR}/_test-db/${name}") - add_test (NAME ${name}/setup - COMMAND - python -u "${_MDB_SCRIPT_DIR}/../mdb-ctl.py" + # Define the fixture. Refer to mdb-ctl.py for information about these commands. + add_test_fixture ( + "${name}" + # Startup: + SETUP + TIMEOUT 10 + COMMAND python -u "${_MDB_SCRIPT_DIR}/../mdb-ctl.py" --mdb-exe "${path}" start --fixture-dir "${fxt_dir}" --port "${port}" --server-args ${ARG_SERVER_ARGS} - ) - add_test (NAME ${name}/cleanup - COMMAND - python -u "${_MDB_SCRIPT_DIR}/../mdb-ctl.py" + # Shutdown: + CLEANUP + TIMEOUT 30 + COMMAND python -u "${_MDB_SCRIPT_DIR}/../mdb-ctl.py" --mdb-exe "${path}" stop --fixture-dir "${fxt_dir}" - ) - set_property (TEST ${name}/setup PROPERTY FIXTURES_SETUP "${name}") - set_property (TEST ${name}/cleanup PROPERTY FIXTURES_CLEANUP "${name}") - set_property ( - TEST ${name}/setup ${name}/cleanup - PROPERTY TIMEOUT 30) + ) + + # Send the port to the caller if (ARG_PORT_VARIABLE) set ("${ARG_PORT_VARIABLE}" "${port}" PARENT_SCOPE) endif () + + # Update the CTest metadata file with this fixture info set_property (TARGET __mdb-meta APPEND PROPERTY _CTestData_CONTENT "# Test fixture '${name}'" - "set(_fxt [[${name}]])" - "set(\"_MDB_FIXTURE_\${_fxt}_PORT\" ${port})\n" + "set(_fxt [======[${name}]======])" + "set(\"_MDB_FIXTURE_\${_fxt}_PORT\" ${port})" + "set(\"_MDB_FIXTURE_\${_fxt}_TOPO\" single)" + "set(\"_MDB_FIXTURE_\${_fxt}_SERVER_VERSION\" ${ARG_VERSION})\n" ) set_property(TARGET __mdb-meta APPEND PROPERTY _ALL_FIXTURES "${name}") + + # Add this to the default fixtures, if requested if (ARG_DEFAULT) set_property (TARGET __mdb-meta APPEND PROPERTY _DEFAULT_FIXTURES "${name}") endif () endfunction () -function (mongodb_create_replset_fixture name) - cmake_parse_arguments (ARG - "DEFAULT" - "PORT_VARIABLE;VERSION;COUNT;REPLSET_NAME;FIXTURES_VARIABLE" - "SERVER_ARGS" - ${ARGN} + +#[==[ + Define a replicaset as a CTest test fixture. + + mongodb_create_replset_fixture( + VERSION + [DEFAULT] + [REPLSET_NAME ] + [COUNT ] + [PORT_VARIABLE ] + [SERVER_ARGS ...] ) + + REPLSET_NAME can be used to specify a replicaset name. NOTE: Not all + characters are valid in a replicaset name. The default name is a + C-identifier based on . + + COUNT specifies the number of servers that should be created for the + replicaset. The default is three. + + For other arguments, refer ot mongodb_create_fixture() + +]==] +function (mongodb_create_replset_fixture name) + cmake_parse_arguments (PARSE_ARGV 1 ARG "DEFAULT" "PORT_VARIABLE;VERSION;COUNT;REPLSET_NAME" "SERVER_ARGS") + + # Default COUNT is 3 if (NOT ARG_COUNT) set (ARG_COUNT 3) endif () - set (children) + + # Default name for the replicaset + if (NOT ARG_REPLSET_NAME) + string (MAKE_C_IDENTIFIER "${name}" ARG_REPLSET_NAME) + endif () + + # "first_port" will be used as the port of the first-created fixture for the children get_cmake_property(first_port _MDB_UNUSED_PORT) + + # Accumulate a list of --node-port=N arguments for initializing the replicaset set(port_args) + # Accumulate the child fixtures into a list: + set (children) + # Generate the children fixtures: foreach (n RANGE 1 "${ARG_COUNT}") - mongodb_create_fixture("${name}/rs${n}" + mongodb_create_fixture ( + "${name}/rs${n}" VERSION "${ARG_VERSION}" SERVER_ARGS ${ARG_SERVER_ARGS} --replSet "${ARG_REPLSET_NAME}" --setParameter enableTestCommands=1 PORT_VARIABLE node_port ) + # Append to the lists: list (APPEND children "${name}/rs${n}") list (APPEND port_args "--node-port=${node_port}") endforeach() + + # Generate a fixture setup that will initialize the replicaset get_cmake_property(mdb_exe MONGODB_${ARG_VERSION}_PATH) - set(init_js "${CMAKE_CURRENT_BINARY_DIR}/_replset-${name}-init.js") - string(REPLACE ";" ", " members "${members}") - file(WRITE "${init_js}" - "var mems = [${members}]; - rs.initiate({ - _id: '${ARG_REPLSET_NAME}', - members: mems, - }); - var i = 0; - for (;;) { - if (rs.config().members.length == mems.length) - break; - sleep(1); - ++i; - if (i == 10000) { - assert(false, 'Members did not connect') - } - } - ") - add_test ( - NAME "${name}" - COMMAND - python -u "${_MDB_SCRIPT_DIR}/../mdb-ctl.py" + add_test_fixture ( + "${name}" + # Setup and "cleanup" requires all the children to be running: + REQUIRES ${children} + SETUP + # For information on this command, refer to mdb-ctl.py + COMMAND python -u "${_MDB_SCRIPT_DIR}/../mdb-ctl.py" --mdb-exe "${mdb_exe}" init-rs --replset "${ARG_REPLSET_NAME}" + # Tell the script which ports our children are listening on: ${port_args} + # Cleanup is a no-op, but having a cleanup that depends on the children + # enforces the children to continue running until we are ready to + # "cleanup" the replicaset. + CLEANUP COMMAND "${CMAKE_COMMAND}" -E true ) - set_tests_properties ("${name}" - PROPERTIES FIXTURES_REQUIRED "${children}" - FIXTURES_SETUP "${name}" - ) + + # Record this fixtures set_property(TARGET __mdb-meta APPEND PROPERTY _ALL_FIXTURES "${name}") + # If default, add it to the list of defaults if (ARG_DEFAULT) set_property(TARGET __mdb-meta APPEND PROPERTY _DEFAULT_FIXTURES "${name}") endif () + # Append to the CTest metadata about the fixture. set_property(TARGET __mdb-meta APPEND PROPERTY _CTestData_CONTENT "# replSet fixture '${name}'" - "set(_fxt [[${name}]])" + "set(_fxt [======[${name}]======])" "set(\"_MDB_FIXTURE_\${_fxt}_PORT\" ${first_port})" - "set(\"_MDB_TRANSITIVE_FIXTURES_OF_\${_fxt}\" [[${children}]])\n" + "set(\"_MDB_FIXTURE_\${_fxt}_TOPO\" replset)" + "set(\"_MDB_FIXTURE_\${_fxt}_SERVER_VERSION\" ${ARG_VERSION})\n" ) + # Send the port (of the first node) to the caller if (ARG_PORT_VARIABLE) set ("${ARG_PORT_VARIABLE}" ${first_port} PARENT_SCOPE) endif () - if (ARG_FIXTURES_VARIABLE) - set ("${ARG_FIXTURES_VARIABLE}" "${children};${name}" PARENT_SCOPE) - endif () endfunction () -function (mongodb_create_sharded_fixture name) - cmake_parse_arguments (ARG - "DEFAULT" - "PORT_VARIABLE;VERSION;COUNT" - "SHARD_ARGS;MONGOS_ARGS" - ${ARGN} +#[==[ + + Create a CTest fixture that runs a sharded setup of MongoDB. + + mongodb_create_sharded_fixture( + VERSION + [DEFAULT] + [PORT_VARIABLE ] ) + + These arguments have the same meaning as in mongodb_create_fixture(). + + This test fixture generates two replica sets: A "data" and a "config". This + fixture then runs 'mongos' against those replset databases. + +]==] +function (mongodb_create_sharded_fixture name) + cmake_parse_arguments (PARSE_ARGV 1 ARG "DEFAULT" "PORT_VARIABLE;VERSION" "") + # Convert the name to an identifier, as it must be a valid replSet name + string (MAKE_C_IDENTIFIER "${name}" id_name) + # Define the "data" cluster mongodb_create_replset_fixture ( "${name}/data" PORT_VARIABLE data_port - REPLSET_NAME "${name}-data" + REPLSET_NAME "${id_name}-data" COUNT 2 - FIXTURES_VARIABLE data_fixtures SERVER_ARGS --shardsvr VERSION "${ARG_VERSION}" ) + # Define the "config" cluster mongodb_create_replset_fixture ( "${name}/config" PORT_VARIABLE config_port - REPLSET_NAME "${name}-config" + REPLSET_NAME "${id_name}-config" COUNT 2 - FIXTURES_VARIABLE config_fixtures SERVER_ARGS --configsvr VERSION "${ARG_VERSION}" ) - get_cmake_property(mdb_exe MONGODB_${ARG_VERSION}_PATH) + # Allocate a new TCP port for the mongos instance get_cmake_property (mongos_port "_MDB_UNUSED_PORT") math (EXPR next "${mongos_port} + 3") set_property (GLOBAL PROPERTY _MDB_UNUSED_PORT "${next}") - add_test ( - NAME "${name}" - COMMAND - python -u "${_MDB_SCRIPT_DIR}/../mdb-ctl.py" + # Define the setup/cleanup + get_cmake_property(mdb_exe MONGODB_${ARG_VERSION}_PATH) + add_test_fixture ( + "${name}" + # Setup and cleanup require the data and config fixtures to be running + REQUIRES ${name}/data ${name}/config + SETUP + # Starting up sharding can take some time, but may get stuck if misconfigured. + # Timeout after 30s, which should be enough to start up. + TIMEOUT 30 + # For information on this command, refer to mdb-ctl.py + COMMAND python -u "${_MDB_SCRIPT_DIR}/../mdb-ctl.py" --mdb-exe "${mdb_exe}" init-sharding - --configdb "${name}-config/localhost:${config_port}" - --datadb "${name}-data/localhost:${data_port}" --port "${mongos_port}" - --scratch-dir "${CMAKE_CURRENT_BINARY_DIR}/${name}" - ) - set_tests_properties("${name}" PROPERTIES - FIXTURES_SETUP "${name}" - FIXTURES_REQUIRED "${config_fixtures};${data_fixtures}" - ) - add_test ( - NAME "${name}/cleanup" - COMMAND python -u "${_MDB_SCRIPT_DIR}/../mdb-ctl.py" - --mdb-exe "${mdb_exe}" - stop-sharding --port "${mongos_port}" + --fixture-dir "${CMAKE_CURRENT_BINARY_DIR}/${name}/mongos" + # The config database: + --configdb "${id_name}-config/localhost:${config_port}" + # The data database: + --datadb "${id_name}-data/localhost:${data_port}" + CLEANUP + # Shutting down sharding can also take some time, but not as much as starting. + TIMEOUT 10 + COMMAND python -u "${_MDB_SCRIPT_DIR}/../mdb-ctl.py" + --mdb-exe "${mdb_exe}" + stop-sharding --fixture-dir "${CMAKE_CURRENT_BINARY_DIR}/${name}/mongos" ) - set_tests_properties ("${name}/cleanup" PROPERTIES FIXTURES_CLEANUP "${name}") + + # Update the CTest metadata set_property(TARGET __mdb-meta APPEND PROPERTY _CTestData_CONTENT - "# replSet fixture '${name}'" - "set(_fxt [[${name}]])" + "# Sharded fixture '${name}'" + "set(_fxt [======[${name}]======])" "set(\"_MDB_FIXTURE_\${_fxt}_PORT\" ${mongos_port})" - "set(\"_MDB_TRANSITIVE_FIXTURES_OF_\${_fxt}\" [[${config_fixtures};${data_fixtures}]])\n" + "set(\"_MDB_FIXTURE_\${_fxt}_TOPO\" sharded)" + "set(\"_MDB_FIXTURE_\${_fxt}_SERVER_VERSION\" ${ARG_VERSION})\n" ) set_property(TARGET __mdb-meta APPEND PROPERTY _ALL_FIXTURES "${name}") + # Add as a default fixture, if requested if (ARG_DEFAULT) set_property(TARGET __mdb-meta APPEND PROPERTY _DEFAULT_FIXTURES "${name}") endif () + # Send the port (of mongos) to the caller + if (ARG_PORT_VARIABLE) + set ("${ARG_PORT_VARIABLE}" ${mongos_port} PARENT_SCOPE) + endif () endfunction () -set (_MDB_SCRIPT_DIR "${CMAKE_CURRENT_LIST_DIR}") -set_property (GLOBAL PROPERTY _MDB_UNUSED_PORT 21231) - # The __mdb-meta target is used only for attaching metadata to be used as part of generator expressions if (NOT TARGET __mdb-meta) add_custom_target (__mdb-meta) + # Properties are added to the target to allow them to be used in generator expressions + set_target_properties (__mdb-meta PROPERTIES + _ALL_FIXTURES "" + _DEFAULT_FIXTURES "" + _CTestData_CONTENT "" + ) + + # Generate a MongoDB-CTestData.cmake file containing the values that are + # attached to __mdb-meta. set (lines - [[# THIS FILE IS GENERATED. DO NOT EDIT.]] - "set(_MDB_ALL_TEST_FIXTURES [[$]])" - "set(_MDB_DEFAULT_TEST_FIXTURES [[$]])" + [=[#[[ This file is generated FindMongoDB.cmake: DO NOT EDIT. ]]]=] + "set(_MDB_ALL_TEST_FIXTURES [==[$]==])" + "set(_MDB_DEFAULT_TEST_FIXTURES [==[$]==])" "" + # Arbitrary content canbe added with the _CTestData_CONTENT property "$,\n>\n" ) string (REPLACE ";" "\n" content "${lines}") file (GENERATE OUTPUT "${PROJECT_BINARY_DIR}/MongoDB-CTestData.cmake" CONTENT "${content}") - set_target_properties (__mdb-meta PROPERTIES - _ALL_FIXTURES "" - _DEFAULT_FIXTURES "" - _CTestData_CONTENT "" - ) + set_property (DIRECTORY APPEND PROPERTY TEST_INCLUDE_FILES "${PROJECT_BINARY_DIR}/MongoDB-CTestData.cmake") endif () diff --git a/build/cmake/LoadTests.cmake b/build/cmake/LoadTests.cmake index 5f270fd52a5..d0b4cafc381 100644 --- a/build/cmake/LoadTests.cmake +++ b/build/cmake/LoadTests.cmake @@ -13,7 +13,7 @@ endif () # Get the list of tests execute_process ( - COMMAND "${TEST_LIBMONGOC_EXE}" --list-tests --no-fork + COMMAND "${TEST_LIBMONGOC_EXE}" --list-tests --include-meta --no-fork OUTPUT_VARIABLE tests_out WORKING_DIRECTORY "${SRC_ROOT}" RESULT_VARIABLE retc @@ -26,12 +26,6 @@ endif () # Split lines on newlines string (REPLACE "\n" ";" lines "${tests_out}") -# XXX: Allow individual test cases to specify the fixtures they want. -set (all_fixtures "mongoc/fixtures/fake_imds") -set (all_env - MCD_TEST_AZURE_IMDS_HOST=localhost:14987 # Refer: Fixtures.cmake - ) - function (_register_test name ctest_run) # Define the test. Use `--ctest-run` to tell it that CTest is in control. add_test ("${name}" "${TEST_LIBMONGOC_EXE}" --ctest-run "${ctest_run}" ${ARGN}) @@ -41,43 +35,94 @@ function (_register_test name ctest_run) # If a test emits '@@ctest-skipped@@', this tells us that the test is # skipped. SKIP_REGULAR_EXPRESSION "@@ctest-skipped@@" - # 45 seconds of timeout on each test. - TIMEOUT 45 ) endfunction () + +function (_define_test name) + # Parse the "test arguments" that come from the `meta` field of the tests + cmake_parse_arguments( + PARSE_ARGV 1 ARG + "USES_LIVE_SERVER" + "TIMEOUT;RUN_NAME;MIN_SERVER_VERSION;MAX_SERVER_VERSION;USE_SERVER" + "LABELS;USES") + # Default timeout + if (NOT ARG_TIMEOUT) + set (ARG_TIMEOUT 10) + endif () + # Default RUN_NAME (The name passed to --ctest-run) + if (NOT ARG_RUN_NAME) + set (ARG_RUN_NAME "${name}") + endif () + # Generate messages for unrecognized arguments + if (ARG_UNPARSED_ARGUMENTS) + message ("-- NOTE: Test '${name}' gave unrecognized metadata: ${ARG_UNPARSED_ARGUMENTS}") + endif () + + # If this test uses a live server generate a version of the test that runs + # against each of the default server fixtures. + if (ARG_USES_LIVE_SERVER) + set (args "${ARGN}") + list (REMOVE_ITEM args "USES_LIVE_SERVER") + # _MDB_DEFAULT_TEST_FIXTURES comes from MongoDB-CTestData + foreach (fxt IN LISTS _MDB_DEFAULT_TEST_FIXTURES) + _define_test ( + "${name}@${fxt}" + RUN_NAME "${name}" + LABELS ${ARG_LABELS} + "uses-live-server" + "server-version=${_MDB_FIXTURE_${fxt}_SERVER_VERSION}" + USE_SERVER "${fxt}" + MIN_SERVER_VERSION "${ARG_MIN_SERVER_VERSION}" + MAX_SERVER_VERSION "${ARG_MAX_SERVER_VERSION}" + USES ${USES} + ) + endforeach () + if (NOT _MDB_DEFAULT_TEST_FIXTURES) + add_test ("${name}@no-fixtures" nil) + set_tests_properties ( + "${name}@no-fixtures" PROPERTIES + DISABLED TRUE + LABELS "uses-live-server;${ARG_LABELS}" + ) + endif () + return () + endif () + + set (fixtures ${ARG_USES}) + if (ARG_USE_SERVER) + set (fxt "${ARG_USE_SERVER}") + list (APPEND fixtures "${fxt}") + set (server_version "${_MDB_FIXTURE_${fxt}_SERVER_VERSION}") + if (ARG_MIN_SERVER_VERSION AND server_version VERSION_LESS ARG_MIN_SERVER_VERSION) + return () + elseif (ARG_MAX_SERVER_VERSION AND server_version VERSION_GREATER ARG_MAX_SERVER_VERSION) + return () + endif () + endif () + + _register_test ("${name}" "${ARG_RUN_NAME}") + set_tests_properties ("${name}" PROPERTIES + FIXTURES_REQUIRED "${fixtures}" + RESOURCE_LOCK "${fixtures}" + ENVIRONMENT "${all_env};MONGOC_TEST_URI=mongodb://localhost:${_MDB_FIXTURE_${fxt}_PORT}" + LABELS "${ARG_LABELS}" + ) +endfunction () + +if (NOT _MDB_DEFAULT_TEST_FIXTURES) + message ("-- Note: No default test fixtures were defined, so tests requiring a ") + message (" live server will be skipped/disabled.") +endif () + # Generate the test definitions +message ("-- Loading tests (this may take a moment if there are many server fixtures)") foreach (line IN LISTS lines) if (NOT line MATCHES "^/") # Only generate if the line begins with `/`, which all tests should. continue () endif () - # The new test name is prefixed with 'mongoc' separate_arguments (listing UNIX_COMMAND "${line}") - list (GET listing 0 test_name) - set (meta "${listing}") - list (REMOVE_AT meta 0) - set (test "mongoc${test_name}") - if (NOT _MDB_DEFAULT_TEST_FIXTURES OR NOT (meta MATCHES "uses-live-server")) - _register_test ("${test}" "${test_name}") - set_tests_properties ("${test}" PROPERTIES - TIMEOUT 15 - LABELS "${meta}" - ENVIRONMENT "${all_env}" - FIXTURES_REQUIRED "${all_fixtures}" - ) - else () - foreach (fxt IN LISTS _MDB_DEFAULT_TEST_FIXTURES) - set (qualname "${fxt}/${test}") - _register_test ("${qualname}" "${test_name}") - set_tests_properties ("${qualname}" PROPERTIES - FIXTURES_REQUIRED "${fxt};${_MDB_TRANSITIVE_FIXTURES_OF_${fxt}}" - RESOURCE_LOCK "${fxt}" - TIMEOUT 15 - LABELS "${meta}" - ENVIRONMENT "${all_env};MONGOC_TEST_URI=mongodb://localhost:${_MDB_FIXTURE_${fxt}_PORT}" - FIXTURES_REQUIRED "${all_fixtures}" - ) - endforeach () - endif () + _define_test (${listing}) endforeach () + diff --git a/build/cmake/QuickFixtures.cmake b/build/cmake/QuickFixtures.cmake new file mode 100644 index 00000000000..5e3b10d8931 --- /dev/null +++ b/build/cmake/QuickFixtures.cmake @@ -0,0 +1,115 @@ +#[===[ + + Create a simple CTest fixture from a setup/cleanup command pair. + + add_test_fixture( + + [REQUIRES ...] + [WORKING_DIRECTORY ] + [ENVIRONMENT ...] + [SETUP + COMMAND [...] + [TIMEOUT ] + [REQUIRES ...] + [WORKING_DIRECTORY ] + [ENVIRONMENT ...]] + [CLEANUP + COMMAND [...] + [TIMEOUT ] + [REQUIRES ...] + [WORKING_DIRECTORY ] + [ENVIRONMENT ...]] + ) + + Refer: https://cmake.org/cmake/help/latest/prop_test/FIXTURES_REQUIRED.html + +]===] +function (add_test_fixture name) + # Pick out the setup/cleanup arguments + cmake_parse_arguments (PARSE_ARGV 1 ARG "" "" "SETUP;CLEANUP") + # Pick out the common arguments + cmake_parse_arguments (__fxt "" "WORKING_DIRECTORY" "ENVIRONMENT;REQUIRES" ${ARG_UNPARSED_ARGUMENTS}) + # Error if anything else remains: + if (__fxt_UNPARSED_ARGUMENTS) + message (SEND_ERROR "Unhandled arguments for add_test_fixture: ${__fxt_UNPARSED_ARGUMENTS}") + return () + endif () + # __fxt variables are intended to be used by callees + set (__fxt_name "${name}") + if (ARG_SETUP) + _fxt_add_kind (setup SETUP ${ARG_SETUP}) + endif () + if (ARG_CLEANUP) + _fxt_add_kind (cleanup CLEANUP ${ARG_CLEANUP}) + endif () +endfunction () + +# Define a setup/cleanup for a fixture. Used by add_test_fixture +function (_fxt_add_kind kind KIND) + cmake_parse_arguments (PARSE_ARGV 2 ARG "" "WORKING_DIRECTORY;TIMEOUT" "COMMAND;ENVIRONMENT;REQUIRES") + if (ARG_UNPARSED_ARGUMENTS) + message (SEND_ERROR "Unhandled arguments for ${KIND} in add_test_fixture: ${ARG_UNPARSED_ARGUMENTS}") + endif () + + # The "__fxt_*" variables come from the add_test_fixture() caller + set (test "${__fxt_name}:${kind}") + add_test (NAME "${test}" COMMAND ${ARG_COMMAND}) + + # Set environment variables + set_property ( + TEST "${test}" + APPEND PROPERTY ENVIRONMENT + ${__fxt_ENVIRONMENT} # Common + ${ARG_ENVIRONMENT} # For this kind + ) + + # Set working directory + if (__fxt_WORKING_DIRECTORY) + # Common working directory + set_property(TEST "${test}" PROPERTY WORKING_DIRECTORY "${__fxt_WORKING_DIRECTORY}") + endif () + if (ARG_WORKING_DIRECTORY) + # This-kind working directory + set_property(TEST "${test}" PROPERTY WORKING_DIRECTORY "${ARG_WORKING_DIRECTORY}") + endif () + + # Timeout for this kind + if (ARG_TIMEOUT) + set_property(TEST "${test}" PROPERTY TIMEOUT "${ARG_TIMEOUT}") + endif () + + # Assign us as a fixture + add_fixture_dependencies ( + "${test}" + REQUIRES ${__fxt_REQUIRES} ${ARG_REQUIRES} + "${KIND}" "${__fxt_name}" # "KIND" becomes "SETUP" or "CLEANUP" + ) +endfunction () + +#[=[ + + Define fixtures, and the dependencies between fixtures and tests + + add_fixture_dependencies( + [ ...] + [REQUIRES ...] + [SETUP ...] + [CLEANUP ...] + ) + + For each fixture in REQUIRES, each of will be set to depend on those + fixtures. + + For each fixture in SETUP, each of will be marked as a setup-test. + + For each fixture in CLEANUP, each of will be marked as a + cleanup-test. + +]=] +function (add_fixture_dependencies) + cmake_parse_arguments (PARSE_ARGV 0 ARG "" "" "REQUIRES;SETUP;CLEANUP") + # Treat the unparsed arguments as the names of tests + set_property (TEST ${ARG_UNPARSED_ARGUMENTS} APPEND PROPERTY FIXTURES_REQUIRED ${ARG_REQUIRES}) + set_property (TEST ${ARG_UNPARSED_ARGUMENTS} APPEND PROPERTY FIXTURES_SETUP ${ARG_SETUP}) + set_property (TEST ${ARG_UNPARSED_ARGUMENTS} APPEND PROPERTY FIXTURES_CLEANUP ${ARG_CLEANUP}) +endfunction () diff --git a/build/cmake/TestFixtures.cmake b/build/cmake/TestFixtures.cmake index 551aafb0a09..145c917aa6f 100644 --- a/build/cmake/TestFixtures.cmake +++ b/build/cmake/TestFixtures.cmake @@ -1,43 +1,99 @@ +#[[ + This file defines CTest test fixtures used by our tests. +]] +include (QuickFixtures) + +# We use Python to execute the proc_ctl script find_package (Python3 COMPONENTS Interpreter) if (NOT TARGET Python3::Interpreter) - message (STATUS "Python3 was not found, so test fixtures will not be defined") + message (WARNING "Python3 was not found, so test fixtures cannot be defined") return () endif () get_filename_component(_MONGOC_BUILD_SCRIPT_DIR "${CMAKE_CURRENT_LIST_DIR}" DIRECTORY) -set (_MONGOC_PROC_CTL_COMMAND "$" -u -- "${_MONGOC_BUILD_SCRIPT_DIR}/proc-ctl.py") +# The command prefix to execute proc_ctl.py +set (_MONGOC_PROC_CTL_COMMAND "$" -u -- "${_MONGOC_BUILD_SCRIPT_DIR}/proc_ctl.py") + +#[=[ + + Define a simple test fixture that spawns a running process and stops it for + the cleanup. + + mongo_define_subprocess_fixture( + + COMMAND [...] + [SPAWN_WAIT ] + [STOP_WAIT ] + [WORKING_DIRECTORY ] + ) + + Creates a test fixture with name given by . For setup, the + long-running process given by COMMAND will be spawned (using proc_ctl.py). + During cleanup, the process will be stopped by sending it an interupt + signal. + + SPAWN_WAIT specifies a number of seconds that should be waited to ensure the + process continues running. The default is one second. NOTE: A successful + setup phase will ALWAYS wait this long, even if the process is stable within + a shorter period of time. This should only be used to catch processes that + may start up but could fail within a few seconds. + STOP_WAIT specifies a number of seconds that should be waited to allow the + process to stop after we send it a stopping signal. The default is five + seconds. Unlike with SPAWN_WAIT, the cleanup phase will only run for as long + as it takes the process to stop. + + WORKING_DIRECTORY specifies an alternate working directory for the spawned + subprocess. + +]=] function (mongo_define_subprocess_fixture name) cmake_parse_arguments(PARSE_ARGV 1 ARG "" "SPAWN_WAIT;STOP_WAIT;WORKING_DIRECTORY" "COMMAND") - string (MAKE_C_IDENTIFIER ident "${name}") + # Default spawn-wait time is one second if (NOT ARG_SPAWN_WAIT) set (ARG_SPAWN_WAIT 1) endif () + # Default stop-wait time is five seconds if (NOT ARG_STOP_WAIT) set (ARG_STOP_WAIT 5) endif () + # Default working directory is the current binary directory if (NOT ARG_WORKING_DIRECTORY) set (ARG_WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}") endif () + # Require a command: if (NOT ARG_COMMAND) message (SEND_ERROR "mongo_define_subprocess_fixture(${name}) requires a COMMAND") return () endif () + # Other arguments are an error: + if (ARG_UNPARSED_ARGUMENTS) + message (SEND_ERROR "Unknown arguments given to mongo_define_subprocess_fixture(): ${ARG_UNPARSED_ARGUMENTS}") + endif () + # Create a control directory based on the fixture name + string (MAKE_C_IDENTIFIER ident "${name}") get_filename_component (ctl_dir "${CMAKE_CURRENT_BINARY_DIR}/${ident}.ctl" ABSOLUTE) - add_test (NAME "${name}/start" - COMMAND ${_MONGOC_PROC_CTL_COMMAND} start - "--ctl-dir=${ctl_dir}" - "--cwd=${ARG_WORKING_DIRECTORY}" - "--spawn-wait=${ARG_SPAWN_WAIT}" - -- ${ARG_COMMAND}) - add_test (NAME "${name}/stop" - COMMAND ${_MONGOC_PROC_CTL_COMMAND} stop "--ctl-dir=${ctl_dir}" --if-not-running=ignore) - set_property (TEST "${name}/start" PROPERTY FIXTURES_SETUP "${name}") - set_property (TEST "${name}/stop" PROPERTY FIXTURES_CLEANUP "${name}") + # Define the fixture around proc_ctl: + add_test_fixture ("${name}" + SETUP COMMAND + ${_MONGOC_PROC_CTL_COMMAND} start + --ctl-dir=${ctl_dir} + --cwd=${ARG_WORKING_DIRECTORY} + --spawn-wait=${ARG_SPAWN_WAIT} + -- ${ARG_COMMAND} + CLEANUP COMMAND + ${_MONGOC_PROC_CTL_COMMAND} stop + --ctl-dir=${ctl_dir} + --if-not-running=ignore + ) endfunction () +# This variable will later be used to inject the host of the fake IMDS server +# into the appropriate test case. +set (_MONGOC_FAKE_IMDS_HOST "localhost:14987") + # Create a fixture that runs a fake Azure IMDS server mongo_define_subprocess_fixture( mongoc/fixtures/fake_imds diff --git a/build/cmake/TweakMeServerFixtures.cmake b/build/cmake/TweakMeServerFixtures.cmake new file mode 100644 index 00000000000..326e47dc121 --- /dev/null +++ b/build/cmake/TweakMeServerFixtures.cmake @@ -0,0 +1,23 @@ +# TWEAK ME: Define server test fixtures within this file. + +if (0) + # Examples: + set (version 5.2.0) + mongodb_create_fixture ( + "server[topo=single,version=${version}]" + VERSION ${version} + DEFAULT + SERVER_ARGS --setParameter enableTestCommands=1 + ) + mongodb_create_replset_fixture ( + "server[topo=repl,version=${version}]" + VERSION ${version} + REPLSET_NAME rs-${version} + DEFAULT + ) + mongodb_create_sharded_fixture ( + "server[topo=sharded,version=${version}]" + VERSION ${version} + DEFAULT + ) +endif () diff --git a/build/mdb-ctl.py b/build/mdb-ctl.py index bcaaf1b48a1..fbdf563ed28 100644 --- a/build/mdb-ctl.py +++ b/build/mdb-ctl.py @@ -1,59 +1,93 @@ import argparse +from datetime import timedelta, datetime from pathlib import Path +import socket import sys -from typing import NamedTuple, Sequence, cast +import time +from typing import Literal, NamedTuple, Sequence, cast import json import shutil import subprocess +import proc_ctl + class _CommandArgs(NamedTuple): + """Common command argumetns""" mdb_exe: Path - command: str + "The path to the mongod executable. Other program paths will be inferred from this." + command: Literal['start', 'stop', 'init-rs', 'init-sharding', + 'stop-sharding'] + "Which subcommand to run" class _StartArgs(_CommandArgs): + """Arguments for 'start'""" port: int + "The port on which the server should listen" server_args: Sequence[str] + "Additional command-line arguments to the server" fixture_dir: Path + "The fixture directory for database data and control files" class _StopArgs(_CommandArgs): + """Arguments for 'stop'""" fixture_dir: Path + "The fixture directory for database data and control files" class _InitRSArgs(_CommandArgs): + """Arguments for init-rs""" node_ports: Sequence[int] + "The IP ports of all the nodes in the replica set" replset: str + "The name of the replica set" class _InitShardingArgs(_CommandArgs): + """Arguments for init-sharding""" configdb: str + "The --configdb for mongos" datadb: str + "The shard to add to mongos" port: int - scratch_dir: Path + "The IP port on which mongos should listen" + fixture_dir: Path + "The fixture directory for control files" class _StopShardingArgs(_CommandArgs): - port: int + """Arguments for stop-sharding""" + fixture_dir: Path + "The fixture directory for control files" def create_argparser() -> argparse.ArgumentParser: parser = argparse.ArgumentParser() - parser.add_argument('--mdb-exe', - required=True, - type=Path, - help='Path to a MongoD executable to use to run/control the server fixture', - metavar='') + parser.add_argument( + '--mdb-exe', + required=True, + type=Path, + help= + 'Path to a MongoD executable to use to run/control the server fixture', + metavar='') - subs = parser.add_subparsers(required=True, title='Subcommand', help='The action to perform', dest='command') + subs = parser.add_subparsers(required=True, + title='Subcommand', + help='The action to perform', + dest='command') start = subs.add_parser('start') - start.add_argument('--port', type=int, required=True, help='The TCP port to which the server will bind') - start.add_argument('--server-args', - nargs=argparse.REMAINDER, - help='Additional arguments to pass to the server executable') + start.add_argument('--port', + type=int, + required=True, + help='The TCP port to which the server will bind') + start.add_argument( + '--server-args', + nargs=argparse.REMAINDER, + help='Additional arguments to pass to the server executable') start.add_argument('--fixture-dir', required=True, type=Path, @@ -68,69 +102,136 @@ def create_argparser() -> argparse.ArgumentParser: metavar='DIR') init_rs = subs.add_parser('init-rs') - init_rs.add_argument('--node-port', - required=True, - help='Port of a node in the replica set (Provide at least once)', - metavar='PORT', - action='append', - dest='node_ports', - type=int) - init_rs.add_argument('--replset', help='Name of the replica set', required=True) + init_rs.add_argument( + '--node-port', + required=True, + help='Port of a node in the replica set (Provide at least once)', + metavar='PORT', + action='append', + dest='node_ports', + type=int) + init_rs.add_argument('--replset', + help='Name of the replica set', + required=True) init_sharding = subs.add_parser('init-sharding') - init_sharding.add_argument('--configdb', + init_sharding.add_argument( + '--configdb', + required=True, + help='The specifier of the config db for mongos', + metavar='/') + init_sharding.add_argument( + '--datadb', + required=True, + help='The specifier of the data db to connect to the mongos', + metavar='/') + init_sharding.add_argument('--port', required=True, - help='The specifier of the config db for mongos', - metavar='/') - init_sharding.add_argument('--datadb', + help='The bind port for the mongos instance', + type=int) + init_sharding.add_argument('--fixture-dir', required=True, - help='The specifier of the data db to connect to the mongos', - metavar='/') - init_sharding.add_argument('--port', required=True, help='The bind port for the mongos instance', type=int) - init_sharding.add_argument('--scratch-dir', required=True, help='Directory for ephemeral and pid files', type=Path) + help='Directory for ephemeral and pid files', + type=Path) stop_sharding = subs.add_parser('stop-sharding') - stop_sharding.add_argument('--port', required=True, help='Port of the mongos server to shutdown', type=int) + stop_sharding.add_argument('--fixture-dir', + required=True, + help='Directory for ephemeral and pid files', + type=Path) return parser -def _try_stop(dir: Path, mdb_exe: Path) -> bool: - retc = subprocess.call([ - str(mdb_exe), - f'--pidfilepath={dir}/mdb.pid', - f'--dbpath={dir}/data', - '--shutdown', - ]) - return retc == 0 +def _wait_until_connectible(port: int, + *, + timeout: timedelta = timedelta(seconds=10)): + """ + Attempt to connect to the given port over TCP on localhost. + Spin until a connection succeeds + + :raise TimeoutError: If the timeout is reached before a connection is established. + """ + expire = datetime.now() + timeout + while 1: + try: + conn = socket.create_connection(('localhost', port)) + except ConnectionRefusedError: + time.sleep(0.1) + else: + conn.close() + break + if expire < datetime.now(): + raise TimeoutError( + f'Port {port} did not become connectible within the time limit' + ) def _do_start(args: _StartArgs) -> int: - if args.fixture_dir.is_dir(): - if not args.fixture_dir.joinpath('stopped.stamp').exists(): - _try_stop(args.fixture_dir, args.mdb_exe) + """Implements the 'start' command""" + try: + # If there is anything already running here, stop it now. + proc_ctl.ensure_not_running(args.fixture_dir) + except RuntimeError as e: + raise RuntimeError( + f'Failed to stop already-running MongoDB server in [{args.fixture_dir}]' + ) from e + + # Delete any prior data + try: shutil.rmtree(args.fixture_dir) + except FileNotFoundError: + pass + + # Create the data directory args.fixture_dir.joinpath('data').mkdir(exist_ok=True, parents=True) - subprocess.check_call([ - str(args.mdb_exe), - f'--port={args.port}', - f'--pidfilepath={args.fixture_dir}/mdb.pid', - '--fork', - '--verbose', - f'--logpath={args.fixture_dir}/server.log', - f'--dbpath={args.fixture_dir}/data', - *args.server_args, - ]) + + # Spawn the server + state = proc_ctl.start_process( + ctl_dir=args.fixture_dir, + cwd=args.fixture_dir, + command=[ + str(args.mdb_exe), + f'--port={args.port}', + f'--pidfilepath={args.fixture_dir}/mdb.pid', + '--verbose', + f'--logpath={args.fixture_dir}/server.log', + f'--dbpath={args.fixture_dir}/data', + '--setParameter=shutdownTimeoutMillisForSignaledShutdown=500', + *args.server_args, + ]) + + # If it returned non-none, the process is not running + if not isinstance(state, int): + if state['error']: + raise RuntimeError( + f'Failed to spawn MongoDB server process: {state["error"]}') + raise RuntimeError( + f'MongoDB server exited immediately [Exit {state["exit"]}]') + + try: + _wait_until_connectible(args.port) + except TimeoutError as e: + proc_ctl.ensure_not_running(args.fixture_dir) + raise RuntimeError('Failed to spawn MongoDB server') + + state = proc_ctl.get_pid_or_exit_result(args.fixture_dir) + if not isinstance(state, int): + raise RuntimeError(f'MongoDB server exited prematurely [{state}]') return 0 def _do_stop(args: _StopArgs) -> int: - if not _try_stop(args.fixture_dir, args.mdb_exe): - raise RuntimeError(f'Failed to stop the MongoDB server in {args.fixture_dir}') + try: + proc_ctl.ensure_not_running(args.fixture_dir) + except RuntimeError as e: + raise RuntimeError( + f'Failed to stop the MongoDB server in {args.fixture_dir}') from e return 0 def _find_mongosh(bin_dir: Path) -> Path: - msh_cands = (bin_dir.joinpath(f) for f in ['mongo', 'mongosh', 'mongo.exe', 'mongosh.exe']) + msh_cands = (bin_dir.joinpath(f) + for f in ['mongo', 'mongosh', 'mongo.exe', 'mongosh.exe']) mongosh_exe = next(iter(filter(Path.is_file, msh_cands)), None) if mongosh_exe is None: raise RuntimeError(f'No MongoSH executable was found in {bin_dir}') @@ -142,6 +243,7 @@ def _do_init_rs(args: _InitRSArgs) -> int: members_json = json.dumps([{ '_id': idx, 'host': f'localhost:{port}', + 'priority': 0 if idx != 0 else 1, } for idx, port in enumerate(args.node_ports)]) init_js = rf''' var members = {members_json}; @@ -150,14 +252,18 @@ def _do_init_rs(args: _InitRSArgs) -> int: members: members, }}); var i = 0; - for (;;) {{ - if (rs.config().members.length == members.length) - break; + for (i = 0; rs.config().members.length != members.length; ++i) {{ sleep(1); - if (i == 10000) {{ + if (i == 20000) {{ assert(false, 'Replica set members did not connect'); }} }} + for (i = 0; rs.status().members[0].state != 1; ++i) {{ + sleep (1); + if (i == 20000) {{ + assert(false, 'First member did not become elected in time'); + }} + }} ''' subprocess.check_call([ str(mongosh_exe), @@ -175,19 +281,33 @@ def _do_init_sharding(args: _InitShardingArgs) -> int: ms_cands = (mdb_bin_dir.joinpath(f) for f in ['mongos', 'mongos.exe']) mongos_exe = next(iter(ms_cands), None) if mongosh_exe is None: - raise RuntimeError(f'No MongoS executable was found beside the MongoD executable') - - args.scratch_dir.mkdir(exist_ok=True, parents=True) - subprocess.check_call([ - str(mongos_exe), - f'--configdb={args.configdb}', - f'--port={args.port}', - f'--logpath={args.scratch_dir}/mongos.log', - f'--pidfilepath={args.scratch_dir}/mongos.pid', - '--setParameter=enableTestCommands=1', - '--fork', - ]) - + raise RuntimeError( + f'No MongoS executable was found beside the MongoD executable') + + proc_ctl.ensure_not_running(args.fixture_dir) + args.fixture_dir.mkdir(exist_ok=True, parents=True) + proc_ctl.start_process( + ctl_dir=args.fixture_dir, + cwd=Path.cwd(), + command=[ + str(mongos_exe), + f'--configdb={args.configdb}', + f'--port={args.port}', + f'--logpath={args.fixture_dir}/mongos.log', + f'--pidfilepath={args.fixture_dir}/mongos.pid', + '--setParameter=mongosShutdownTimeoutMillisForSignaledShutdown=500', + '--setParameter=enableTestCommands=1', + ]) + + # Starting up mongos can take some time. Spin wait until we can successfully + # open a TCP connection to mongos. + try: + _wait_until_connectible(args.port) + except TimeoutError as e: + proc_ctl.ensure_not_running(args.fixture_dir) + raise RuntimeError('Failed to spawn mongos') from e + + # Now add the datadb to our shards: subprocess.check_call([ str(mongosh_exe), f'localhost:{args.port}/admin', @@ -200,14 +320,7 @@ def _do_init_sharding(args: _InitShardingArgs) -> int: def _do_stop_sharding(args: _StopShardingArgs) -> int: - mongosh_exe = _find_mongosh(args.mdb_exe.parent) - subprocess.check_call([ - str(mongosh_exe), - f'localhost:{args.port}/admin', - '--norc', - '--eval', - 'db.shutdownServer()', - ]) + proc_ctl.ensure_not_running(args.fixture_dir) return 0 diff --git a/build/proc-ctl.py b/build/proc_ctl.py similarity index 59% rename from build/proc-ctl.py rename to build/proc_ctl.py index 9446bf2892f..843296043c2 100644 --- a/build/proc-ctl.py +++ b/build/proc_ctl.py @@ -13,16 +13,18 @@ import traceback from datetime import datetime, timedelta from pathlib import Path -from typing import TYPE_CHECKING, NoReturn, Sequence, Union, cast +from typing import TYPE_CHECKING, NoReturn, Sequence, Union, cast, NewType if TYPE_CHECKING: from typing import (Literal, NamedTuple, TypedDict) INTERUPT_SIGNAL = signal.SIGINT if os.name != 'nt' else signal.CTRL_C_SIGNAL +PID = NewType('PID', int) + def create_parser() -> argparse.ArgumentParser: - parser = argparse.ArgumentParser('proc-ctl') + parser = argparse.ArgumentParser('proc_ctl.py') grp = parser.add_subparsers(title='Commands', dest='command', metavar='') @@ -90,7 +92,7 @@ def create_parser() -> argparse.ArgumentParser: CommandArgs = Union[StartCommandArgs, StopCommandArgs, _RunCommandArgs] - _ResultType = TypedDict('_ResultType', { + ChildExitResult = TypedDict('_ResultType', { 'exit': 'str | int | None', 'error': 'str | None' }) @@ -120,12 +122,12 @@ def result_file(self): def set_pid(self, pid: int): write_text(self.pid_file, str(pid)) - def get_pid(self) -> 'int | None': + def _get_pid(self) -> 'PID | None': try: txt = self.pid_file.read_text() except FileNotFoundError: return None - return int(txt) + return PID(int(txt)) def set_exit(self, exit: 'str | int | None', error: 'str | None') -> None: write_text(self.result_file, json.dumps({ @@ -134,7 +136,10 @@ def set_exit(self, exit: 'str | int | None', error: 'str | None') -> None: })) remove_file(self.pid_file) - def get_result(self) -> 'None | _ResultType': + def state(self) -> 'None | ChildExitResult | PID': + return self._get_pid() or self._get_result() + + def _get_result(self) -> 'None | ChildExitResult': try: txt = self.result_file.read_text() except FileNotFoundError: @@ -144,65 +149,151 @@ def get_result(self) -> 'None | _ResultType': def clear_result(self) -> None: remove_file(self.result_file) + def signal_stop(self) -> None: + pid = self.state() + if not isinstance(pid, int): + raise ProcessLookupError + os.kill(pid, INTERUPT_SIGNAL) -def _start(args: 'StartCommandArgs') -> int: + +def wait_stopped( + ctl_dir: Path, *, + timeout: timedelta = timedelta(seconds=5)) -> 'ChildExitResult': + child = _ChildControl(ctl_dir) + """ + Wait for a child process to exit. + + :raise ProcessLookupError: If there is no running process or exit result + associated with the given directory. + :raise TimeoutError: If the child is still running after the timeout expires. + """ + # Spin around until the state is no longer a PID + expire = datetime.now() + (timeout or timedelta()) + state = child.state() + while isinstance(state, int): + if expire < datetime.now(): + raise TimeoutError(f'Process [{state}] is still running') + time.sleep(0.05) + state = child.state() + + if state is None: + # There was never a child here + raise ProcessLookupError + return state + + +def get_pid_or_exit_result(ctl_dir: Path) -> 'None | ChildExitResult | PID': + """ + Get the state of a child process for the given control directory. + + :returns PID: If there is a child running in this directory. + :returns ChildExitResult: If there was a child spawned for this directory, + but has since exited. + :returns None: If there is no child running nor a record of one having + existed. + """ + return _ChildControl(ctl_dir).state() + + +def ensure_not_running( + ctl_dir: Path, *, + timeout: timedelta = timedelta(seconds=5)) -> 'None | ChildExitResult': + """ + Ensure no child is running for the given control directory. + + If a child is found, it will be asked to stop, and we will wait 'timeout' for it to exit + + :return None: If there was never a child running in this directory. + :return ChildExitResult: The exit result of the child process, if it had + once been running. + :raise TimeoutError: If the process does not exit after the given timeout. + """ + child = _ChildControl(ctl_dir) + try: + child.signal_stop() + except ProcessLookupError: + # The process is not running, or was never started + r = child.state() + assert not isinstance(r, int), (r, ctl_dir, timeout) + return r + return wait_stopped(ctl_dir, timeout=timeout) + + +class ChildStartupError(RuntimeError): + pass + + +def start_process(*, ctl_dir: Path, cwd: Path, + command: Sequence[str]) -> 'PID | ChildExitResult': + """ + Spawn a child process with a result recorder. + + The result of the spawn can later be observed using + :func:`get_pid_or_exit_result` called with the same ``ctl_dir``. + """ ll_run_cmd = [ sys.executable, '-u', '--', __file__, '__run', - '--ctl-dir={}'.format(args.ctl_dir), + '--ctl-dir={}'.format(ctl_dir), '--', - *args.child_command, + *command, ] - args.ctl_dir.mkdir(exist_ok=True, parents=True) - child = _ChildControl(args.ctl_dir) - if child.get_pid() is not None: - raise RuntimeError('Child process is already running [PID {}]'.format( - child.get_pid())) + ctl_dir.mkdir(exist_ok=True, parents=True) + child = _ChildControl(ctl_dir) + state = child.state() + if isinstance(state, int): + raise RuntimeError( + 'Child process is already running [PID {}]'.format(state)) child.clear_result() - # Spawn the child controller - subprocess.Popen( - ll_run_cmd, - cwd=args.cwd, - stderr=subprocess.STDOUT, - stdout=args.ctl_dir.joinpath('runner-output.txt').open('wb'), - stdin=subprocess.DEVNULL) - expire = datetime.now() + timedelta(seconds=args.spawn_wait) - # Wait for the PID to appear - while child.get_pid() is None and child.get_result() is None: + assert child.state() is None + + # Spawn the child controller process + subprocess.Popen(ll_run_cmd, + cwd=cwd, + stderr=subprocess.STDOUT, + stdout=ctl_dir.joinpath('runner-output.txt').open('wb'), + stdin=subprocess.DEVNULL) + + # Wait for a PID or exit result to appear + expire = datetime.now() + timedelta(seconds=5) + state = child.state() + while state is None: if expire < datetime.now(): - break - time.sleep(0.1) + raise TimeoutError(f'Process [{command}] is not starting') + time.sleep(0.05) + state = child.state() + # Check that it actually spawned - if child.get_pid() is None: - result = child.get_result() - if result is None: - raise RuntimeError('Failed to spawn child runner?') - if result['error']: - print(result['error'], file=sys.stderr) - raise RuntimeError('Child exited immediately [Exited {}]'.format( - result['exit'])) - # Wait to see that it is still running after --spawn-wait seconds - while child.get_result() is None: - if expire < datetime.now(): - break - time.sleep(0.1) - # A final check to see if it is running - result = child.get_result() - if result is not None: - if result['error']: - print(result['error'], file=sys.stderr) - raise RuntimeError('Child exited prematurely [Exited {}]'.format( - result['exit'])) + if not isinstance(state, int) and state['error']: + raise ChildStartupError( + f'Error while spawning child process: {state["error"]}') + return state + + +def _start(args: 'StartCommandArgs') -> int: + expire = datetime.now() + timedelta(seconds=args.spawn_wait) + state = start_process(ctl_dir=args.ctl_dir, + cwd=args.cwd, + command=args.child_command) + while not isinstance(state, dict) and expire > datetime.now(): + time.sleep(0.05) + if not isinstance(state, int): + # The child process exited or failed to spawn + if state['error']: + print(state['error'], file=sys.stderr) + raise ChildStartupError('Child exited prematurely [Exited {}]'.format( + state['exit'])) return 0 def _stop(args: 'StopCommandArgs') -> int: child = _ChildControl(args.ctl_dir) - pid = child.get_pid() - if pid is None: + try: + child.signal_stop() + except ProcessLookupError: if args.if_not_running == 'fail': raise RuntimeError('Child process is not running') elif args.if_not_running == 'ignore': @@ -210,11 +301,8 @@ def _stop(args: 'StopCommandArgs') -> int: return 0 else: assert False - os.kill(pid, INTERUPT_SIGNAL) - expire_at = datetime.now() + timedelta(seconds=args.stop_wait) - while expire_at > datetime.now() and child.get_result() is None: - time.sleep(0.1) - result = child.get_result() + result = wait_stopped(args.ctl_dir, + timeout=timedelta(seconds=args.stop_wait)) if result is None: raise RuntimeError( 'Child process did not exit within the grace period') diff --git a/src/libmongoc/CMakeLists.txt b/src/libmongoc/CMakeLists.txt index 6328a2e5943..1e28f47be3d 100644 --- a/src/libmongoc/CMakeLists.txt +++ b/src/libmongoc/CMakeLists.txt @@ -1089,6 +1089,14 @@ if (MONGOC_ENABLE_SASL_CYRUS) ) endif () +if (DEFINED _MONGOC_FAKE_IMDS_HOST) + # This var can be defined in TestFixtures.cmake + # Only one file needs to see it: + set_property ( + SOURCE ${PROJECT_SOURCE_DIR}/tests/test-mcd-azure-imds.c + APPEND PROPERTY COMPILE_DEFINITIONS "MONGOC_FAKE_IMDS_HOST=\"${_MONGOC_FAKE_IMDS_HOST}\"") +endif () + mongoc_add_test (test-libmongoc FALSE ${test-libmongoc-sources}) mongoc_add_test (test-mongoc-gssapi FALSE ${PROJECT_SOURCE_DIR}/tests/test-mongoc-gssapi.c) mongoc_add_test (test-mongoc-cache FALSE ${PROJECT_SOURCE_DIR}/tests/test-mongoc-cache.c) diff --git a/src/libmongoc/tests/TestSuite.c b/src/libmongoc/tests/TestSuite.c index ec3978d715d..81662ca050d 100644 --- a/src/libmongoc/tests/TestSuite.c +++ b/src/libmongoc/tests/TestSuite.c @@ -56,6 +56,7 @@ static TestSuite *gTestSuite; #define TEST_TRACE (1 << 4) #define TEST_VALGRIND (1 << 5) #define TEST_LISTTESTS (1 << 6) +#define TEST_LISTTESTS_WITHMETA (1 << 7) MONGOC_PRINTF_FORMAT (1, 2) static void @@ -169,6 +170,8 @@ TestSuite_Init (TestSuite *suite, const char *name, int argc, char **argv) suite->flags |= TEST_HELPTEXT; } else if (0 == strcmp ("--list-tests", argv[i])) { suite->flags |= TEST_LISTTESTS; + } else if (0 == strcmp ("--include-meta", argv[i])) { + suite->flags |= TEST_LISTTESTS_WITHMETA; } else if ((0 == strcmp ("-s", argv[i])) || (0 == strcmp ("--silent", argv[i]))) { suite->silent = true; @@ -763,8 +766,12 @@ TestSuite_PrintTests (TestSuite *suite) /* IN */ printf ("\nTests:\n"); for (iter = suite->tests; iter; iter = iter->next) { - printf ( - "%s%s %s\n", suite->name, iter->name, iter->meta ? iter->meta : ""); + if (suite->flags & TEST_LISTTESTS_WITHMETA) { + printf ( + "%s%s %s\n", suite->name, iter->name, iter->meta ? iter->meta : ""); + } else { + printf ("%s%s\n", suite->name, iter->name); + } } printf ("\n"); From c3e7a0adefd92ec5d0d682a564151b051eb9dec2 Mon Sep 17 00:00:00 2001 From: vector-of-bool Date: Fri, 30 Sep 2022 02:10:52 +0000 Subject: [PATCH 49/52] Missed a conditionally-defined test --- src/libmongoc/tests/test-mongoc-async.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/libmongoc/tests/test-mongoc-async.c b/src/libmongoc/tests/test-mongoc-async.c index aa374f4d896..8a0fa94c06e 100644 --- a/src/libmongoc/tests/test-mongoc-async.c +++ b/src/libmongoc/tests/test-mongoc-async.c @@ -393,6 +393,7 @@ test_async_install (TestSuite *suite) /* Skip on Windows until CDRIVER-3519 is resolved. */ TestSuite_AddFull (suite, "/Async/large_hello", + "USES_LIVE_SERVER", test_large_hello, NULL /* dtor */, NULL /* ctx */, From 6e8d9a85eeddd9e16fb09efc1492a6c5b864cb3b Mon Sep 17 00:00:00 2001 From: vector-of-bool Date: Fri, 30 Sep 2022 18:03:24 +0000 Subject: [PATCH 50/52] Too many args there --- src/libmongoc/tests/test-mongoc-client-pool.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/libmongoc/tests/test-mongoc-client-pool.c b/src/libmongoc/tests/test-mongoc-client-pool.c index 85c678de452..bd4908ab2de 100644 --- a/src/libmongoc/tests/test-mongoc-client-pool.c +++ b/src/libmongoc/tests/test-mongoc-client-pool.c @@ -514,7 +514,6 @@ test_client_pool_install (TestSuite *suite) TestSuite_Add (suite, "/ClientPool/ssl_disabled", "", - "", test_mongoc_client_pool_ssl_disabled); #endif TestSuite_AddLive (suite, From 06a681baf4fa9b87cd86ea03a3f18853e4b30e56 Mon Sep 17 00:00:00 2001 From: vector-of-bool Date: Fri, 30 Sep 2022 18:11:07 +0000 Subject: [PATCH 51/52] Missing dist listings --- build/CMakeLists.txt | 2 + build/cmake/CMakeLists.txt | 3 + build/proc-ctl.py | 300 ------------------------ src/libmongoc/tests/test-mongoc-cyrus.c | 3 +- 4 files changed, 7 insertions(+), 301 deletions(-) delete mode 100644 build/proc-ctl.py diff --git a/build/CMakeLists.txt b/build/CMakeLists.txt index a9e6f753da8..2ce7406ace1 100644 --- a/build/CMakeLists.txt +++ b/build/CMakeLists.txt @@ -7,6 +7,8 @@ set_local_dist (build_DIST_local generate-uninstall.cmd generate-uninstall.sh mongodl.py + proc_ctl.py + mdb-ctl.py ) set (build_DIST diff --git a/build/cmake/CMakeLists.txt b/build/cmake/CMakeLists.txt index 4c3467dcf27..94839a257d7 100644 --- a/build/cmake/CMakeLists.txt +++ b/build/cmake/CMakeLists.txt @@ -2,6 +2,7 @@ add_subdirectory (make_dist) set (build_cmake_MODULES CheckSchedGetCPU.cmake + FindMongoD.cmake FindResSearch.cmake FindSASL2.cmake FindSnappy.cmake @@ -15,7 +16,9 @@ set (build_cmake_MODULES Sanitizers.cmake CCache.cmake LLDLinker.cmake + QuickFixtures.cmake TestFixtures.cmake + TweakMeServerFixtures.cmake ) set_local_dist (build_cmake_DIST_local diff --git a/build/proc-ctl.py b/build/proc-ctl.py deleted file mode 100644 index 9446bf2892f..00000000000 --- a/build/proc-ctl.py +++ /dev/null @@ -1,300 +0,0 @@ -""" -Extremely basic subprocess control -""" - -import argparse -import json -import os -import random -import signal -import subprocess -import sys -import time -import traceback -from datetime import datetime, timedelta -from pathlib import Path -from typing import TYPE_CHECKING, NoReturn, Sequence, Union, cast - -if TYPE_CHECKING: - from typing import (Literal, NamedTuple, TypedDict) - -INTERUPT_SIGNAL = signal.SIGINT if os.name != 'nt' else signal.CTRL_C_SIGNAL - - -def create_parser() -> argparse.ArgumentParser: - parser = argparse.ArgumentParser('proc-ctl') - grp = parser.add_subparsers(title='Commands', - dest='command', - metavar='') - - start = grp.add_parser('start', help='Start a new subprocess') - start.add_argument('--ctl-dir', - help='The control directory for the subprocess', - required=True, - type=Path) - start.add_argument('--cwd', - help='The new subdirectory of the spawned process', - type=Path) - start.add_argument( - '--spawn-wait', - help='Number of seconds to wait for child to be running', - type=float, - default=3) - start.add_argument('child_command', - nargs='+', - help='The command to execute', - metavar=' [args...]') - - stop = grp.add_parser('stop', help='Stop a running subprocess') - stop.add_argument('--ctl-dir', - help='The control directory for the subprocess', - required=True, - type=Path) - stop.add_argument('--stop-wait', - help='Number of seconds to wait for stopping', - type=float, - default=5) - stop.add_argument('--if-not-running', - help='Action to take if the child is not running', - choices=['fail', 'ignore'], - default='fail') - - ll_run = grp.add_parser('__run') - ll_run.add_argument('--ctl-dir', type=Path, required=True) - ll_run.add_argument('child_command', nargs='+') - - return parser - - -if TYPE_CHECKING: - StartCommandArgs = NamedTuple('StartCommandArgs', [ - ('command', Literal['start']), - ('ctl_dir', Path), - ('cwd', Path), - ('child_command', Sequence[str]), - ('spawn_wait', float), - ]) - - StopCommandArgs = NamedTuple('StopCommandArgs', [ - ('command', Literal['stop']), - ('ctl_dir', Path), - ('stop_wait', float), - ('if_not_running', Literal['fail', 'ignore']), - ]) - - _RunCommandArgs = NamedTuple('_RunCommandArgs', [ - ('command', Literal['__run']), - ('child_command', Sequence[str]), - ('ctl_dir', Path), - ]) - - CommandArgs = Union[StartCommandArgs, StopCommandArgs, _RunCommandArgs] - - _ResultType = TypedDict('_ResultType', { - 'exit': 'str | int | None', - 'error': 'str | None' - }) - - -def parse_argv(argv: 'Sequence[str]') -> 'CommandArgs': - parser = create_parser() - args = parser.parse_args(argv) - return cast('CommandArgs', args) - - -class _ChildControl: - - def __init__(self, ctl_dir: Path) -> None: - self._ctl_dir = ctl_dir - - @property - def pid_file(self): - """The file containing the child PID""" - return self._ctl_dir / 'pid.txt' - - @property - def result_file(self): - """The file containing the exit result""" - return self._ctl_dir / 'exit.json' - - def set_pid(self, pid: int): - write_text(self.pid_file, str(pid)) - - def get_pid(self) -> 'int | None': - try: - txt = self.pid_file.read_text() - except FileNotFoundError: - return None - return int(txt) - - def set_exit(self, exit: 'str | int | None', error: 'str | None') -> None: - write_text(self.result_file, json.dumps({ - 'exit': exit, - 'error': error - })) - remove_file(self.pid_file) - - def get_result(self) -> 'None | _ResultType': - try: - txt = self.result_file.read_text() - except FileNotFoundError: - return None - return json.loads(txt) - - def clear_result(self) -> None: - remove_file(self.result_file) - - -def _start(args: 'StartCommandArgs') -> int: - ll_run_cmd = [ - sys.executable, - '-u', - '--', - __file__, - '__run', - '--ctl-dir={}'.format(args.ctl_dir), - '--', - *args.child_command, - ] - args.ctl_dir.mkdir(exist_ok=True, parents=True) - child = _ChildControl(args.ctl_dir) - if child.get_pid() is not None: - raise RuntimeError('Child process is already running [PID {}]'.format( - child.get_pid())) - child.clear_result() - # Spawn the child controller - subprocess.Popen( - ll_run_cmd, - cwd=args.cwd, - stderr=subprocess.STDOUT, - stdout=args.ctl_dir.joinpath('runner-output.txt').open('wb'), - stdin=subprocess.DEVNULL) - expire = datetime.now() + timedelta(seconds=args.spawn_wait) - # Wait for the PID to appear - while child.get_pid() is None and child.get_result() is None: - if expire < datetime.now(): - break - time.sleep(0.1) - # Check that it actually spawned - if child.get_pid() is None: - result = child.get_result() - if result is None: - raise RuntimeError('Failed to spawn child runner?') - if result['error']: - print(result['error'], file=sys.stderr) - raise RuntimeError('Child exited immediately [Exited {}]'.format( - result['exit'])) - # Wait to see that it is still running after --spawn-wait seconds - while child.get_result() is None: - if expire < datetime.now(): - break - time.sleep(0.1) - # A final check to see if it is running - result = child.get_result() - if result is not None: - if result['error']: - print(result['error'], file=sys.stderr) - raise RuntimeError('Child exited prematurely [Exited {}]'.format( - result['exit'])) - return 0 - - -def _stop(args: 'StopCommandArgs') -> int: - child = _ChildControl(args.ctl_dir) - pid = child.get_pid() - if pid is None: - if args.if_not_running == 'fail': - raise RuntimeError('Child process is not running') - elif args.if_not_running == 'ignore': - # Nothing to do - return 0 - else: - assert False - os.kill(pid, INTERUPT_SIGNAL) - expire_at = datetime.now() + timedelta(seconds=args.stop_wait) - while expire_at > datetime.now() and child.get_result() is None: - time.sleep(0.1) - result = child.get_result() - if result is None: - raise RuntimeError( - 'Child process did not exit within the grace period') - return 0 - - -def __run(args: '_RunCommandArgs') -> int: - this = _ChildControl(args.ctl_dir) - try: - pipe = subprocess.Popen( - args.child_command, - stdout=args.ctl_dir.joinpath('child-output.txt').open('wb'), - stderr=subprocess.STDOUT, - stdin=subprocess.DEVNULL) - except: - this.set_exit('spawn-failed', traceback.format_exc()) - raise - this.set_pid(pipe.pid) - retc = None - try: - while 1: - try: - retc = pipe.wait(0.5) - except subprocess.TimeoutExpired: - pass - except KeyboardInterrupt: - pipe.send_signal(INTERUPT_SIGNAL) - if retc is not None: - break - finally: - this.set_exit(retc, None) - return 0 - - -def write_text(fpath: Path, content: str): - """ - "Atomically" write a new file. - - This writes the given ``content`` into a temporary file, then renames that - file into place. This prevents readers from seeing a partial read. - """ - tmp = fpath.with_name(fpath.name + '.tmp') - remove_file(tmp) - tmp.write_text(content) - os.sync() - remove_file(fpath) - tmp.rename(fpath) - - -def remove_file(fpath: Path): - """ - Safely remove a file. - - Because Win32, deletes are asynchronous, so we rename to a random filename, - then delete that file. This ensures the file is "out of the way", even if - it takes some time to delete. - """ - delname = fpath.with_name(fpath.name + '.delete-' + - str(random.randint(0, 999999))) - try: - fpath.rename(delname) - except FileNotFoundError: - return - delname.unlink() - - -def main(argv: 'Sequence[str]') -> int: - args = parse_argv(argv) - if args.command == 'start': - return _start(args) - if args.command == '__run': - return __run(args) - if args.command == 'stop': - return _stop(args) - return 0 - - -def start_main() -> NoReturn: - sys.exit(main(sys.argv[1:])) - - -if __name__ == '__main__': - start_main() diff --git a/src/libmongoc/tests/test-mongoc-cyrus.c b/src/libmongoc/tests/test-mongoc-cyrus.c index 6f1de5e8e57..3f12eeaac68 100644 --- a/src/libmongoc/tests/test-mongoc-cyrus.c +++ b/src/libmongoc/tests/test-mongoc-cyrus.c @@ -93,9 +93,10 @@ test_sasl_canonicalize_hostname (void *ctx) void test_cyrus_install (TestSuite *suite) { - TestSuite_Add (suite, "/SASL/properties", test_sasl_properties); + TestSuite_Add (suite, "/SASL/properties", "", test_sasl_properties); TestSuite_AddFull (suite, "/SASL/canonicalize", + "USES_LIVE_SERVER", test_sasl_canonicalize_hostname, NULL, NULL, From 853fab4b572771f90a919f0b38271424bc6033a5 Mon Sep 17 00:00:00 2001 From: vector-of-bool Date: Fri, 30 Sep 2022 18:31:42 +0000 Subject: [PATCH 52/52] Use FPHSA.cmake --- build/cmake/CMakeLists.txt | 2 +- build/cmake/FindMongoDB.cmake | 9 +++------ 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/build/cmake/CMakeLists.txt b/build/cmake/CMakeLists.txt index 94839a257d7..87d017d6e97 100644 --- a/build/cmake/CMakeLists.txt +++ b/build/cmake/CMakeLists.txt @@ -2,7 +2,7 @@ add_subdirectory (make_dist) set (build_cmake_MODULES CheckSchedGetCPU.cmake - FindMongoD.cmake + FindMongoDB.cmake FindResSearch.cmake FindSASL2.cmake FindSnappy.cmake diff --git a/build/cmake/FindMongoDB.cmake b/build/cmake/FindMongoDB.cmake index 214c75ef885..0b4199fae06 100644 --- a/build/cmake/FindMongoDB.cmake +++ b/build/cmake/FindMongoDB.cmake @@ -157,9 +157,6 @@ function (_mongodb_find) endforeach () endif () set (_MDB_PREVIOUSLY_FOUND_VERSIONS "${found}" CACHE INTERNAL "") - if (found) - set (MongoDB_FOUND TRUE PARENT_SCOPE) - endif () endfunction () # Do the finding @@ -478,6 +475,6 @@ if (NOT TARGET __mdb-meta) set_property (DIRECTORY APPEND PROPERTY TEST_INCLUDE_FILES "${PROJECT_BINARY_DIR}/MongoDB-CTestData.cmake") endif () -get_cmake_property(versions MONGODB_FOUND_VERSIONS) -string(REPLACE ";" ", " versions "${versions}") -message(STATUS "MongoDB versions ${versions} are available for test fixtures") +get_cmake_property(__found_versions MONGODB_FOUND_VERSIONS) +string(REPLACE ";" ", " __found_versions "${__found_versions}") +find_package_handle_standard_args (MongoDB DEFAULT_MSG __found_versions)