|
18 | 18 | #include "mongoc/mongoc.h"
|
19 | 19 | #include "mongoc/mongoc-client-pool-private.h"
|
20 | 20 | #include "mongoc/mongoc-client-private.h"
|
| 21 | +#include "mongoc/mongoc-handshake-private.h" |
21 | 22 | #include "mongoc/mongoc-server-description-private.h"
|
22 | 23 | #include "mongoc/mongoc-topology-background-monitoring-private.h"
|
23 | 24 | #include "mongoc/mongoc-topology-description-private.h"
|
@@ -390,6 +391,25 @@ test_connect_succeeds (void)
|
390 | 391 | tf_destroy (tf);
|
391 | 392 | }
|
392 | 393 |
|
| 394 | +void |
| 395 | +test_connect_faas_use_polling (void) |
| 396 | +{ |
| 397 | + test_fixture_t *tf; |
| 398 | + mongoc_handshake_t *md = _mongoc_handshake_get (); |
| 399 | + md->env = MONGOC_HANDSHAKE_ENV_AWS; |
| 400 | + |
| 401 | + /* This mock server will not respond to streaming hello, so OBSERVE_SOON |
| 402 | + will timeout if the server monitor doesn't detect ENV_AWS and switch to |
| 403 | + polling */ |
| 404 | + tf = tf_new (TF_AUTO_RESPOND_POLLING_HELLO); |
| 405 | + OBSERVE_SOON (tf, tf->observations->n_heartbeat_succeeded == 2); |
| 406 | + OBSERVE_SOON (tf, tf->observations->n_heartbeat_failed == 0); |
| 407 | + OBSERVE (tf, !tf->observations->awaited); |
| 408 | + |
| 409 | + tf_destroy (tf); |
| 410 | + md->env = MONGOC_HANDSHAKE_ENV_NONE; |
| 411 | +} |
| 412 | + |
393 | 413 | void
|
394 | 414 | test_connect_hangup (void)
|
395 | 415 | {
|
@@ -1134,6 +1154,10 @@ test_monitoring_install (TestSuite *suite)
|
1134 | 1154 | /* Tests for initial connection. */
|
1135 | 1155 | TestSuite_AddMockServerTest (
|
1136 | 1156 | suite, "/server_monitor_thread/connect/succeeds", test_connect_succeeds);
|
| 1157 | + TestSuite_AddMockServerTest ( |
| 1158 | + suite, |
| 1159 | + "/server_monitor_thread/connect/faas_use_polling", |
| 1160 | + test_connect_faas_use_polling); |
1137 | 1161 | TestSuite_AddMockServerTest (
|
1138 | 1162 | suite, "/server_monitor_thread/connect/hangup", test_connect_hangup);
|
1139 | 1163 | TestSuite_AddMockServerTest (
|
|
0 commit comments