Skip to content
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
df507fe
prefer v4 for llvm-symbolizer
kevinAlbs Aug 17, 2025
4c51279
add `stream_tracker_t`
kevinAlbs Aug 18, 2025
0173969
remove unused utilities
kevinAlbs Aug 18, 2025
9e57b98
target localhost:27017
kevinAlbs Aug 19, 2025
6dab725
use first host+port for self-test
kevinAlbs Aug 19, 2025
3150ae7
fix leak
kevinAlbs Aug 19, 2025
0a19fdd
restore remove header
kevinAlbs Aug 19, 2025
0a6300f
use parens for `(void)0`
kevinAlbs Aug 19, 2025
7b9b27e
add cumulative count
kevinAlbs Aug 20, 2025
1e0c6cf
use cumulative count in exhaust cursor tests
kevinAlbs Aug 20, 2025
18b5bcc
refactor stepdown tests to use stream tracker
kevinAlbs Aug 20, 2025
57ded78
check connection count after connection created
kevinAlbs Aug 20, 2025
a41775c
update comments: `serverStatus` is no longer used
kevinAlbs Aug 20, 2025
aa00590
use `int` to track count
kevinAlbs Aug 20, 2025
479e77b
use internal linkage
kevinAlbs Aug 20, 2025
07f522c
use longer pause in eventual check
kevinAlbs Aug 20, 2025
fa22744
use variables for hosts
kevinAlbs Aug 20, 2025
3d76a06
rename `count` to `count_active`
kevinAlbs Aug 21, 2025
3032093
track before pop
kevinAlbs Aug 22, 2025
be7a80c
disallow overriding stream initializer after pop
kevinAlbs Aug 22, 2025
53bce0a
replace "cumulative" with "total"
kevinAlbs Aug 22, 2025
7bf7118
add unreachable assert
kevinAlbs Aug 22, 2025
464720c
check return of `mongoc_client_default_stream_initiator`
kevinAlbs Aug 22, 2025
0bf9321
include "active" in assert macro names
kevinAlbs Aug 22, 2025
51b99dd
add `stream_tracker_assert_total_count`
kevinAlbs Aug 22, 2025
9b81684
add total count asserts to tests
kevinAlbs Aug 22, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion .evergreen/scripts/run-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,12 @@ fi

# Sanitizer environment variables.
export ASAN_OPTIONS="detect_leaks=1 abort_on_error=1 symbolize=1"
export ASAN_SYMBOLIZER_PATH="/opt/mongodbtoolchain/v3/bin/llvm-symbolizer"
export ASAN_SYMBOLIZER_PATH
if command -v "/opt/mongodbtoolchain/v4/bin/llvm-symbolizer" > /dev/null; then
ASAN_SYMBOLIZER_PATH="/opt/mongodbtoolchain/v4/bin/llvm-symbolizer"
elif command -v "/opt/mongodbtoolchain/v3/bin/llvm-symbolizer" > /dev/null; then
ASAN_SYMBOLIZER_PATH="/opt/mongodbtoolchain/v3/bin/llvm-symbolizer"
fi
export TSAN_OPTIONS="suppressions=.tsan-suppressions"

ubsan_opts=(
Expand Down
1 change: 1 addition & 0 deletions src/libmongoc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1032,6 +1032,7 @@ set (test-libmongoc-sources
${PROJECT_SOURCE_DIR}/tests/mock_server/mock-server.c
${PROJECT_SOURCE_DIR}/tests/mock_server/request.c
${PROJECT_SOURCE_DIR}/tests/mock_server/sync-queue.c
${PROJECT_SOURCE_DIR}/tests/stream-tracker.c
${PROJECT_SOURCE_DIR}/tests/test-conveniences.c
${PROJECT_SOURCE_DIR}/tests/test-happy-eyeballs.c
${PROJECT_SOURCE_DIR}/tests/test-libmongoc.c
Expand Down
32 changes: 0 additions & 32 deletions src/libmongoc/tests/TestSuite.c
Original file line number Diff line number Diff line change
Expand Up @@ -1232,35 +1232,3 @@ test_bulkwriteexception_str(const mongoc_bulkwriteexception_t *bwe)
tmp_json(mongoc_bulkwriteexception_writeconcernerrors(bwe)),
tmp_json(mongoc_bulkwriteexception_errorreply(bwe)));
}

int32_t
get_current_connection_count(const char *host_and_port)
{
char *uri_str = bson_strdup_printf("mongodb://%s", host_and_port);
char *uri_str_with_auth = test_framework_add_user_password_from_env(uri_str);
mongoc_client_t *client = mongoc_client_new(uri_str_with_auth);
test_framework_set_ssl_opts(client);
bson_t *cmd = BCON_NEW("serverStatus", BCON_INT32(1));
bson_t reply;
bson_error_t error;
bool ok = mongoc_client_command_simple(client, "admin", cmd, NULL, &reply, &error);
if (!ok) {
printf("serverStatus failed: %s\n", error.message);
abort();
}
int32_t conns;
// Get `connections.current` from the reply.
{
bson_iter_t iter;
BSON_ASSERT(bson_iter_init_find(&iter, &reply, "connections"));
BSON_ASSERT(bson_iter_recurse(&iter, &iter));
BSON_ASSERT(bson_iter_find(&iter, "current"));
conns = bson_iter_int32(&iter);
}
bson_destroy(&reply);
bson_destroy(cmd);
mongoc_client_destroy(client);
bson_free(uri_str_with_auth);
bson_free(uri_str);
return conns;
}
37 changes: 0 additions & 37 deletions src/libmongoc/tests/TestSuite.h
Original file line number Diff line number Diff line change
Expand Up @@ -623,43 +623,6 @@ test_bulkwriteexception_str(const mongoc_bulkwriteexception_t *bwe);
} else \
(void)0

// `get_current_connection_count` returns the server reported connection count.
int32_t
get_current_connection_count(const char *host_and_port);

#define ASSERT_CONN_COUNT(host, expect) \
if (1) { \
int32_t _got = get_current_connection_count(host); \
if (_got != expect) { \
test_error("Got unexpected connection count to %s:\n" \
" Expected %" PRId32 ", got %" PRId32 "\n", \
host, \
expect, \
_got); \
} \
} else \
(void)0

#define ASSERT_EVENTUAL_CONN_COUNT(host, expect) \
if (1) { \
int64_t _start = bson_get_monotonic_time(); \
while (true) { \
int32_t _got = get_current_connection_count(host); \
if (_got == expect) { \
break; \
} \
int64_t _now = bson_get_monotonic_time(); \
if (_now - _start > 5 * 1000 * 1000 /* five seconds */) { \
test_error("Timed out waiting for expected connection count to %s:\n" \
" Expected %" PRId32 ", got %" PRId32 "\n", \
host, \
expect, \
_got); \
} \
} \
} else \
(void)0

#define MAX_TEST_NAME_LENGTH 500
#define MAX_TEST_CHECK_FUNCS 10

Expand Down
Loading