Skip to content

Commit 960760f

Browse files
authored
CDRIVER-4353 unskip /server_discovery_and_monitoring/monitoring/heartbeat/pooled/dns (#1440)
* unskip `/server_discovery_and_monitoring/monitoring/heartbeat/pooled/dns` * use `.invalid` TLD in test To reliably return DNS error * remove unnecessary test skips Test expects to fail DNS lookup. Does not require internet. * remove unused `test_framework_skip_if_rhel8_zseries` * reduce serverSelectionTimeoutMS to speed up test * update comment and expected error * measure duration after destroy client or pool Destroying the client or pool results in sending `endSessions`. This may result in another heartbeat attempt.
1 parent ddbd5a1 commit 960760f

File tree

4 files changed

+11
-50
lines changed

4 files changed

+11
-50
lines changed

.evergreen/etc/skip-tests.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,5 @@
3737
/transactions/legacy/mongos-recovery-token/"commitTransaction retry fails on new mongos" # fails with server selection timeout (CDRIVER-4268)
3838
/transactions/legacy/pin-mongos/"unpin after transient error within a transaction and commit" # (CDRIVER-4351) server selection timeout (on ASAN Tests Ubuntu 18.04 build variant)
3939
/Samples # (CDRIVER-4352) strange "heartbeat failed" error
40-
/server_discovery_and_monitoring/monitoring/heartbeat/pooled/dns # (CDRIVER-4353) this initially seemed like a zSeries w/ RHEL8 issue, but it also appeared on arm64 w/ Ubuntu 18.04
4140

4241
/client_side_encryption/bypass_spawning_mongocryptd/mongocryptdBypassSpawn # Fails if crypt_shared is visible

src/libmongoc/tests/test-libmongoc.c

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1998,31 +1998,6 @@ test_framework_skip_if_offline (void)
19981998
}
19991999

20002000

2001-
int
2002-
test_framework_skip_if_rhel8_zseries (void)
2003-
{
2004-
/* CDRIVER-3923: It appears that when running on RHEL8 on zSeries the
2005-
* /server_discovery_and_monitoring/monitoring/heartbeat/pooled/dns test
2006-
* fails. The best guess is that calling getaddrinfo() on that platform
2007-
* blocks for 5 seconds, while the test expects a server selection error
2008-
* after 3000 ms, or 3 seconds. Skip the test when executing on RHEL8 on
2009-
* zSeries. */
2010-
#ifdef __s390x__
2011-
char *name;
2012-
char *version;
2013-
_mongoc_linux_distro_scanner_get_distro (&name, &version);
2014-
bool rhel = strcmp (name, "Red Hat Enterprise Linux") == 0;
2015-
bool vers8 = version[0] == '8';
2016-
int skip = (rhel && vers8) ? 0 : 1;
2017-
bson_free (name);
2018-
bson_free (version);
2019-
return skip;
2020-
#else
2021-
return 1;
2022-
#endif
2023-
}
2024-
2025-
20262001
int
20272002
test_framework_skip_if_slow (void)
20282003
{

src/libmongoc/tests/test-libmongoc.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -189,8 +189,6 @@ test_framework_skip_if_not_single (void);
189189
int
190190
test_framework_skip_if_offline (void);
191191
int
192-
test_framework_skip_if_rhel8_zseries (void);
193-
int
194192
test_framework_skip_if_slow (void);
195193
int
196194
test_framework_skip_if_slow_or_live (void);

src/libmongoc/tests/test-mongoc-sdam-monitoring.c

Lines changed: 11 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -848,7 +848,7 @@ _test_heartbeat_fails_dns (bool pooled)
848848
* client for a client pool). */
849849
start = bson_get_monotonic_time ();
850850
uri = mongoc_uri_new (
851-
"mongodb://doesntexist.foobar/?serverSelectionTimeoutMS=3000");
851+
"mongodb://doesntexist.invalid/?serverSelectionTimeoutMS=100");
852852
if (pooled) {
853853
pool = test_framework_client_pool_new_from_uri (uri, NULL);
854854
pool_set_heartbeat_event_callbacks (pool, &context);
@@ -862,15 +862,13 @@ _test_heartbeat_fails_dns (bool pooled)
862862
r = mongoc_client_command_simple (
863863
client, "admin", tmp_bson ("{'foo': 1}"), NULL, NULL, &error);
864864

865-
/* This should result in either a DNS failure or connection failure depending
866-
* on the network. We assert the domain/code but not the message string. */
865+
/* Expect a server selection error. */
867866
ASSERT (!r);
868867
ASSERT_ERROR_CONTAINS (error,
869868
MONGOC_ERROR_SERVER_SELECTION,
870869
MONGOC_ERROR_SERVER_SELECTION_FAILURE,
871-
"");
870+
"No suitable servers found");
872871

873-
duration = bson_get_monotonic_time () - start;
874872

875873
if (pooled) {
876874
mongoc_client_pool_push (pool, client);
@@ -879,6 +877,8 @@ _test_heartbeat_fails_dns (bool pooled)
879877
mongoc_client_destroy (client);
880878
}
881879

880+
duration = bson_get_monotonic_time () - start;
881+
882882
durations = &context.heartbeat_failed_durations;
883883

884884
ASSERT_CMPSIZE_T (durations->len, >, (size_t) 0);
@@ -893,18 +893,14 @@ _test_heartbeat_fails_dns (bool pooled)
893893
}
894894

895895
static void
896-
test_heartbeat_fails_dns_single (void *ctx)
896+
test_heartbeat_fails_dns_single (void)
897897
{
898-
BSON_UNUSED (ctx);
899-
900898
_test_heartbeat_fails_dns (false);
901899
}
902900

903901
static void
904-
test_heartbeat_fails_dns_pooled (void *ctx)
902+
test_heartbeat_fails_dns_pooled (void)
905903
{
906-
BSON_UNUSED (ctx);
907-
908904
_test_heartbeat_fails_dns (true);
909905
}
910906

@@ -1054,21 +1050,14 @@ test_sdam_monitoring_install (TestSuite *suite)
10541050
suite,
10551051
"/server_discovery_and_monitoring/monitoring/heartbeat/pooled/failed",
10561052
test_heartbeat_events_pooled_failed);
1057-
TestSuite_AddFull (
1053+
TestSuite_Add (
10581054
suite,
10591055
"/server_discovery_and_monitoring/monitoring/heartbeat/single/dns",
1060-
test_heartbeat_fails_dns_single,
1061-
NULL,
1062-
NULL,
1063-
test_framework_skip_if_offline);
1064-
TestSuite_AddFull (
1056+
test_heartbeat_fails_dns_single);
1057+
TestSuite_Add (
10651058
suite,
10661059
"/server_discovery_and_monitoring/monitoring/heartbeat/pooled/dns",
1067-
test_heartbeat_fails_dns_pooled,
1068-
NULL,
1069-
NULL,
1070-
test_framework_skip_if_offline,
1071-
test_framework_skip_if_rhel8_zseries);
1060+
test_heartbeat_fails_dns_pooled);
10721061
TestSuite_AddMockServerTest (
10731062
suite,
10741063
"/server_discovery_and_monitoring/monitoring/no_duplicates",

0 commit comments

Comments
 (0)