Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit f000f77

Browse files
CDRIVER-6080 track client streams in connection counting tests (#2095)
* prefer v4 for llvm-symbolizer * add `stream_tracker_t` Update tests checking server-side connections. Intended to fix flaky failures.
1 parent c5d80a1 commit f000f77

File tree

12 files changed

+671
-197
lines changed

12 files changed

+671
-197
lines changed

‎.evergreen/scripts/run-tests.sh

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,12 @@ fi
110110

111111
# Sanitizer environment variables.
112112
export ASAN_OPTIONS="detect_leaks=1 abort_on_error=1 symbolize=1"
113-
export ASAN_SYMBOLIZER_PATH="/opt/mongodbtoolchain/v3/bin/llvm-symbolizer"
113+
export ASAN_SYMBOLIZER_PATH
114+
if command -v "/opt/mongodbtoolchain/v4/bin/llvm-symbolizer" > /dev/null; then
115+
ASAN_SYMBOLIZER_PATH="/opt/mongodbtoolchain/v4/bin/llvm-symbolizer"
116+
elif command -v "/opt/mongodbtoolchain/v3/bin/llvm-symbolizer" > /dev/null; then
117+
ASAN_SYMBOLIZER_PATH="/opt/mongodbtoolchain/v3/bin/llvm-symbolizer"
118+
fi
114119
export TSAN_OPTIONS="suppressions=.tsan-suppressions"
115120

116121
ubsan_opts=(

‎src/libmongoc/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1032,6 +1032,7 @@ set (test-libmongoc-sources
10321032
${PROJECT_SOURCE_DIR}/tests/mock_server/mock-server.c
10331033
${PROJECT_SOURCE_DIR}/tests/mock_server/request.c
10341034
${PROJECT_SOURCE_DIR}/tests/mock_server/sync-queue.c
1035+
${PROJECT_SOURCE_DIR}/tests/stream-tracker.c
10351036
${PROJECT_SOURCE_DIR}/tests/test-conveniences.c
10361037
${PROJECT_SOURCE_DIR}/tests/test-happy-eyeballs.c
10371038
${PROJECT_SOURCE_DIR}/tests/test-libmongoc.c

‎src/libmongoc/src/mongoc/mongoc-client-pool.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -506,6 +506,9 @@ _mongoc_client_pool_set_stream_initiator(mongoc_client_pool_t *pool, mongoc_stre
506506
{
507507
BSON_ASSERT_PARAM(pool);
508508

509+
// Do not permit overriding initializer after calls to `mongoc_client_pool_pop`.
510+
BSON_ASSERT(!pool->client_initialized);
511+
509512
mongoc_topology_scanner_set_stream_initiator(pool->topology->scanner, si, context);
510513
}
511514

‎src/libmongoc/tests/TestSuite.c

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1232,35 +1232,3 @@ test_bulkwriteexception_str(const mongoc_bulkwriteexception_t *bwe)
12321232
tmp_json(mongoc_bulkwriteexception_writeconcernerrors(bwe)),
12331233
tmp_json(mongoc_bulkwriteexception_errorreply(bwe)));
12341234
}
1235-
1236-
int32_t
1237-
get_current_connection_count(const char *host_and_port)
1238-
{
1239-
char *uri_str = bson_strdup_printf("mongodb://%s", host_and_port);
1240-
char *uri_str_with_auth = test_framework_add_user_password_from_env(uri_str);
1241-
mongoc_client_t *client = mongoc_client_new(uri_str_with_auth);
1242-
test_framework_set_ssl_opts(client);
1243-
bson_t *cmd = BCON_NEW("serverStatus", BCON_INT32(1));
1244-
bson_t reply;
1245-
bson_error_t error;
1246-
bool ok = mongoc_client_command_simple(client, "admin", cmd, NULL, &reply, &error);
1247-
if (!ok) {
1248-
printf("serverStatus failed: %s\n", error.message);
1249-
abort();
1250-
}
1251-
int32_t conns;
1252-
// Get `connections.current` from the reply.
1253-
{
1254-
bson_iter_t iter;
1255-
BSON_ASSERT(bson_iter_init_find(&iter, &reply, "connections"));
1256-
BSON_ASSERT(bson_iter_recurse(&iter, &iter));
1257-
BSON_ASSERT(bson_iter_find(&iter, "current"));
1258-
conns = bson_iter_int32(&iter);
1259-
}
1260-
bson_destroy(&reply);
1261-
bson_destroy(cmd);
1262-
mongoc_client_destroy(client);
1263-
bson_free(uri_str_with_auth);
1264-
bson_free(uri_str);
1265-
return conns;
1266-
}

‎src/libmongoc/tests/TestSuite.h

Lines changed: 0 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -623,43 +623,6 @@ test_bulkwriteexception_str(const mongoc_bulkwriteexception_t *bwe);
623623
} else \
624624
(void)0
625625

626-
// `get_current_connection_count` returns the server reported connection count.
627-
int32_t
628-
get_current_connection_count(const char *host_and_port);
629-
630-
#define ASSERT_CONN_COUNT(host, expect) \
631-
if (1) { \
632-
int32_t _got = get_current_connection_count(host); \
633-
if (_got != expect) { \
634-
test_error("Got unexpected connection count to %s:\n" \
635-
" Expected %" PRId32 ", got %" PRId32 "\n", \
636-
host, \
637-
expect, \
638-
_got); \
639-
} \
640-
} else \
641-
(void)0
642-
643-
#define ASSERT_EVENTUAL_CONN_COUNT(host, expect) \
644-
if (1) { \
645-
int64_t _start = bson_get_monotonic_time(); \
646-
while (true) { \
647-
int32_t _got = get_current_connection_count(host); \
648-
if (_got == expect) { \
649-
break; \
650-
} \
651-
int64_t _now = bson_get_monotonic_time(); \
652-
if (_now - _start > 5 * 1000 * 1000 /* five seconds */) { \
653-
test_error("Timed out waiting for expected connection count to %s:\n" \
654-
" Expected %" PRId32 ", got %" PRId32 "\n", \
655-
host, \
656-
expect, \
657-
_got); \
658-
} \
659-
} \
660-
} else \
661-
(void)0
662-
663626
#define MAX_TEST_NAME_LENGTH 500
664627
#define MAX_TEST_CHECK_FUNCS 10
665628

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /