Skip to content

Commit 3e9adec

Browse files
alcaeussamantharitterbenjirewis
authored
CDRIVER-3954 Run all integration tests in Versioned API evergreen tests (#787)
* CDRIVER-3917 route all test client and client_pool creation through the test framework * small fixes * add missing include * rename pool method to match client method * Refactor test framework client factories to accept API version * Revert change in mongoc-cache.c Despite the #include, the linker does not like this: tests/test-mongoc-cache.c.o: In function `ping': src/libmongoc/tests/test-mongoc-cache.c:45: undefined reference to `test_framework_client_new' * Run all tests with requireApiVersion=true * Fix large_ismaster test * Don't set server api when client can't be created * Don't use test clients in tests specifically testing server API behaviour * Print default API version in test output * Set requireApiVersion option earlier * Consider apiVersion field when assembling large bulk operation * Fix wrong comment wording Co-authored-by: Benjamin Rewis <[email protected]> * Fix inaccurate variable name * Remove obsolete todo * Document MONGODB_API_VERSION environment variable in contributing docs * Document new test methods * Fix tests with acceptApiVersion2 * Update newly added test Co-authored-by: samantharitter <[email protected]> Co-authored-by: Benjamin Rewis <[email protected]>
1 parent bc5d37a commit 3e9adec

File tree

71 files changed

+1122
-799
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

71 files changed

+1122
-799
lines changed

.evergreen/config.yml

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -709,8 +709,7 @@ functions:
709709
export DNS=${DNS}
710710
export ASAN=${ASAN}
711711
export MONGODB_API_VERSION=1
712-
# TODO: CDRIVER-3954 Run all integration tests
713-
./src/libmongoc/test-libmongoc --no-fork -l /versioned_api/* -d
712+
sh .evergreen/run-tests.sh
714713
unset MONGODB_API_VERSION
715714
run aws tests:
716715
- command: shell.exec
@@ -17413,9 +17412,6 @@ tasks:
1741317412
depends_on:
1741417413
name: debug-compile-nosasl-openssl
1741517414
commands:
17416-
- func: fetch build
17417-
vars:
17418-
BUILD_NAME: debug-compile-nosasl-openssl
1741917415
- func: fetch build
1742017416
vars:
1742117417
BUILD_NAME: debug-compile-nosasl-openssl
@@ -17434,25 +17430,22 @@ tasks:
1743417430
tags:
1743517431
- versioned-api
1743617432
depends_on:
17437-
name: debug-compile-nosasl-openssl
17433+
name: debug-compile-nosasl-nossl
1743817434
commands:
1743917435
- func: fetch build
1744017436
vars:
17441-
BUILD_NAME: debug-compile-nosasl-openssl
17442-
- func: fetch build
17443-
vars:
17444-
BUILD_NAME: debug-compile-nosasl-openssl
17437+
BUILD_NAME: debug-compile-nosasl-nossl
1744517438
- func: bootstrap mongo-orchestration
1744617439
vars:
17447-
AUTH: auth
17440+
AUTH: noauth
1744817441
ORCHESTRATION_FILE: versioned-api-testing
17449-
SSL: ssl
17442+
SSL: nossl
1745017443
TOPOLOGY: server
1745117444
VERSION: latest
1745217445
- func: test versioned api
1745317446
vars:
17454-
AUTH: auth
17455-
SSL: ssl
17447+
AUTH: noauth
17448+
SSL: nossl
1745617449
- name: build-and-run-authentication-tests-openssl-0.9.8
1745717450
commands:
1745817451
- func: install ssl
@@ -22869,4 +22862,5 @@ buildvariants:
2286922862
run_on: ubuntu1804-test
2287022863
tasks:
2287122864
- debug-compile-nosasl-openssl
22865+
- debug-compile-nosasl-nossl
2287222866
- .versioned-api

.evergreen/integration-tests.sh

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -164,12 +164,13 @@ elif [ "$SSL" != "nossl" ]; then
164164
MONGO_SHELL_CONNECTION_FLAGS="${MONGO_SHELL_CONNECTION_FLAGS} --host localhost --ssl --sslCAFile=$MONGO_ORCHESTRATION_HOME/lib/ca.pem --sslPEMKeyFile=$MONGO_ORCHESTRATION_HOME/lib/client.pem"
165165
fi
166166

167+
if [ ! -z "$REQUIRE_API_VERSION" ]; then
168+
MONGO_SHELL_CONNECTION_FLAGS="${MONGO_SHELL_CONNECTION_FLAGS} --apiVersion=1"
169+
# Set the requireApiVersion parameter.
170+
`pwd`/mongodb/bin/mongo $MONGO_SHELL_CONNECTION_FLAGS $DIR/require-api-version.js
171+
fi
172+
167173
echo $MONGO_SHELL_CONNECTION_FLAGS
168174

169175
`pwd`/mongodb/bin/mongo $MONGO_SHELL_CONNECTION_FLAGS --eval 'printjson(db.serverBuildInfo())' admin
170176
`pwd`/mongodb/bin/mongo $MONGO_SHELL_CONNECTION_FLAGS --eval 'printjson(db.isMaster())' admin
171-
172-
# Set the requireApiVersion parameter.
173-
if [ ! -z "$REQUIRE_API_VERSION" ]; then
174-
`pwd`/mongodb/bin/mongo $MONGO_SHELL_CONNECTION_FLAGS $DIR/require-api-version.js
175-
fi

CONTRIBUTING.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,12 @@ Specification tests may be filtered by their description:
252252

253253
This can be useful in debugging a specific test case in a spec test file with multiple tests.
254254

255+
To test with a declared API version, you can pass the API version using an environment variable:
256+
257+
* `MONGODB_API_VERSION=<string>`
258+
259+
This will ensure that all tests declare the indicated API version when connecting to a server.
260+
255261
All tests should pass before submitting a patch.
256262

257263
## Configuring the test runner

build/evergreen_config_lib/functions.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -506,8 +506,7 @@
506506
export DNS=${DNS}
507507
export ASAN=${ASAN}
508508
export MONGODB_API_VERSION=1
509-
# TODO: CDRIVER-3954 Run all integration tests
510-
./src/libmongoc/test-libmongoc --no-fork -l /versioned_api/* -d
509+
sh .evergreen/run-tests.sh
511510
unset MONGODB_API_VERSION
512511
513512
'''),

build/evergreen_config_lib/tasks.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -842,16 +842,14 @@ def __init__(self, *args, **kwargs):
842842
'test-versioned-api',
843843
tags=['versioned-api'],
844844
depends_on='debug-compile-nosasl-openssl',
845-
commands=[func('fetch build', BUILD_NAME='debug-compile-nosasl-openssl'),
846-
func('bootstrap mongo-orchestration', TOPOLOGY='server', AUTH='auth', SSL='ssl', VERSION='latest', REQUIRE_API_VERSION='true'),
845+
commands=[func('bootstrap mongo-orchestration', TOPOLOGY='server', AUTH='auth', SSL='ssl', VERSION='latest', REQUIRE_API_VERSION='true'),
847846
func('test versioned api', AUTH='auth', SSL='ssl')]),
848847
PostCompileTask(
849848
'test-versioned-api-accept-version-two',
850849
tags=['versioned-api'],
851-
depends_on='debug-compile-nosasl-openssl',
852-
commands=[func('fetch build', BUILD_NAME='debug-compile-nosasl-openssl'),
853-
func('bootstrap mongo-orchestration', TOPOLOGY='server', AUTH='auth', SSL='ssl', VERSION='latest', ORCHESTRATION_FILE='versioned-api-testing'),
854-
func('test versioned api', AUTH='auth', SSL='ssl')]),
850+
depends_on='debug-compile-nosasl-nossl',
851+
commands=[func('bootstrap mongo-orchestration', TOPOLOGY='server', AUTH='noauth', SSL='nossl', VERSION='latest', ORCHESTRATION_FILE='versioned-api-testing'),
852+
func('test versioned api', AUTH='noauth', SSL='nossl')]),
855853
])
856854

857855

build/evergreen_config_lib/variants.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -640,6 +640,7 @@ def days(n):
640640
'Versioned API Tests',
641641
'ubuntu1804-test',
642642
['debug-compile-nosasl-openssl',
643+
'debug-compile-nosasl-nossl',
643644
'.versioned-api'],
644645
{})
645646
]

src/libmongoc/tests/TestSuite.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -808,7 +808,8 @@ TestSuite_PrintJsonHeader (TestSuite *suite, /* IN */
808808
" },\n"
809809
" \"options\": {\n"
810810
" \"fork\": %s,\n"
811-
" \"tracing\": %s\n"
811+
" \"tracing\": %s,\n"
812+
" \"apiVersion\": %s\n"
812813
" },\n"
813814
" \"results\": [\n",
814815
egetenv ("MONGOC_TEST_USER"),
@@ -839,7 +840,8 @@ TestSuite_PrintJsonHeader (TestSuite *suite, /* IN */
839840
: "false",
840841
test_framework_getenv_bool ("MONGOC_CHECK_IPV6") ? "true" : "false",
841842
(suite->flags & TEST_NOFORK) ? "false" : "true",
842-
(suite->flags & TEST_TRACE) ? "true" : "false");
843+
(suite->flags & TEST_TRACE) ? "true" : "false",
844+
egetenv ("MONGODB_API_VERSION"));
843845

844846
bson_free (hostname);
845847
bson_free (udspath);

src/libmongoc/tests/json-test-operations.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2476,7 +2476,7 @@ json_test_operation (json_test_ctx_t *ctx,
24762476
} else if (!strcmp (op_name, "targetedFailPoint")) {
24772477
mongoc_client_t *client;
24782478

2479-
client = mongoc_client_new_from_uri (ctx->client->uri);
2479+
client = test_framework_client_new_from_uri (ctx->client->uri, NULL);
24802480
test_framework_set_ssl_opts (client);
24812481
activate_fail_point (
24822482
client, session->server_id, operation, "arguments.failPoint");
@@ -2502,7 +2502,7 @@ json_test_operation (json_test_ctx_t *ctx,
25022502
mongoc_client_t *client;
25032503
bool exists;
25042504

2505-
client = mongoc_client_new_from_uri (ctx->client->uri);
2505+
client = test_framework_client_new_from_uri (ctx->client->uri, NULL);
25062506
test_framework_set_ssl_opts (client);
25072507
exists = collection_exists (client, operation);
25082508
mongoc_client_destroy (client);
@@ -2512,7 +2512,7 @@ json_test_operation (json_test_ctx_t *ctx,
25122512
mongoc_client_t *client;
25132513
bool exists;
25142514

2515-
client = mongoc_client_new_from_uri (ctx->client->uri);
2515+
client = test_framework_client_new_from_uri (ctx->client->uri, NULL);
25162516
test_framework_set_ssl_opts (client);
25172517
exists = collection_exists (client, operation);
25182518
mongoc_client_destroy (client);
@@ -2522,7 +2522,7 @@ json_test_operation (json_test_ctx_t *ctx,
25222522
mongoc_client_t *client;
25232523
bool exists;
25242524

2525-
client = mongoc_client_new_from_uri (ctx->client->uri);
2525+
client = test_framework_client_new_from_uri (ctx->client->uri, NULL);
25262526
test_framework_set_ssl_opts (client);
25272527
exists = index_exists (client, operation);
25282528
mongoc_client_destroy (client);
@@ -2532,7 +2532,7 @@ json_test_operation (json_test_ctx_t *ctx,
25322532
mongoc_client_t *client;
25332533
bool exists;
25342534

2535-
client = mongoc_client_new_from_uri (ctx->client->uri);
2535+
client = test_framework_client_new_from_uri (ctx->client->uri, NULL);
25362536
test_framework_set_ssl_opts (client);
25372537
exists = index_exists (client, operation);
25382538
mongoc_client_destroy (client);
@@ -2545,7 +2545,7 @@ json_test_operation (json_test_ctx_t *ctx,
25452545
} else if (!strcmp (op_name, "configureFailPoint")) {
25462546
mongoc_client_t *client;
25472547

2548-
client = mongoc_client_new_from_uri (ctx->client->uri);
2548+
client = test_framework_client_new_from_uri (ctx->client->uri, NULL);
25492549
test_framework_set_ssl_opts (client);
25502550
activate_fail_point (
25512551
client, 0 /* primary */, operation, "arguments.failPoint");
@@ -2564,7 +2564,7 @@ json_test_operation (json_test_ctx_t *ctx,
25642564
mongoc_client_t *client;
25652565
mongoc_database_t *admin_db;
25662566

2567-
client = mongoc_client_new_from_uri (ctx->client->uri);
2567+
client = test_framework_client_new_from_uri (ctx->client->uri, NULL);
25682568
test_framework_set_ssl_opts (client);
25692569
admin_db = mongoc_client_get_database (client, "admin");
25702570
bson_destroy (reply);

src/libmongoc/tests/json-test.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1051,7 +1051,7 @@ insert_data (const char *db_name,
10511051
bson_t *majority = tmp_bson ("{'writeConcern': {'w': 'majority'}}");
10521052

10531053
/* use a fresh client to prepare the collection */
1054-
client = test_framework_client_new ();
1054+
client = test_framework_new_default_client ();
10551055

10561056
db = mongoc_client_get_database (client, db_name);
10571057
collection = mongoc_database_get_collection (db, collection_name);
@@ -1210,7 +1210,7 @@ execute_test (const json_test_config_t *config,
12101210

12111211
if (bson_has_field (test, "outcome.collection")) {
12121212
/* Use a fresh client to check the outcome collection. */
1213-
outcome_client = test_framework_client_new ();
1213+
outcome_client = test_framework_new_default_client ();
12141214
if (bson_has_field (test, "outcome.collection.name")) {
12151215
outcome_coll = mongoc_client_get_collection (
12161216
outcome_client,
@@ -1717,7 +1717,7 @@ run_json_general_test (const json_test_config_t *config)
17171717
set_uri_opts_from_bson (uri, &client_opts);
17181718
}
17191719

1720-
client = mongoc_client_new_from_uri (uri);
1720+
client = test_framework_client_new_from_uri (uri, NULL);
17211721
mongoc_client_set_error_api (client, MONGOC_ERROR_API_VERSION_2);
17221722
test_framework_set_ssl_opts (client);
17231723
/* reconnect right away, if a fail point causes a disconnect */

0 commit comments

Comments
 (0)