Skip to content

CDRIVER-4098 Bump WIRE_VERSION_MIN from 3 to 6 #926

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 24 commits into from
Jan 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
e9012d9
Format source files
eramongodb Jan 11, 2022
aec5855
Bump WIRE_VERSION_MIN from 3 to 6
eramongodb Jan 11, 2022
17eca57
Assert request parameter for mock_server_replies_to_find() is not null
eramongodb Jan 12, 2022
d2e972f
Update error message for failing to satisfy minimum wire version
eramongodb Jan 11, 2022
04dd838
Remove Evergreen tasks requiring server version below 3.6
eramongodb Jan 11, 2022
9237aed
Update mock servers to forbid max_wire_version < 6
eramongodb Jan 11, 2022
6f0232b
Update test code conditioned on wire version < 6
eramongodb Jan 11, 2022
16b7739
Replace wire version integer literals with feature macros
eramongodb Jan 12, 2022
145722b
Replace wire versions in string literals with feature macros
eramongodb Jan 12, 2022
c401423
Add mock_server_receives_bulk_msg()
eramongodb Jan 11, 2022
d9887f5
Update mock_server_recieves_command() -> mock_server_recieves_msg()
eramongodb Jan 12, 2022
2308343
Add test for wire version -> server version mapping
eramongodb Jan 18, 2022
aecd97e
Remove redundant tasks in asan-ubuntu-ubuntu1404 variant
eramongodb Jan 18, 2022
b1e0ea4
Remove redundant nested conditional branchs
eramongodb Jan 18, 2022
2e478e5
Fix and update comments relating to readPreference
eramongodb Jan 18, 2022
fbb59d4
Revert removal of exhaust cursor in /ReadPrefs/mongos/maxStaleness
eramongodb Jan 18, 2022
4604940
Revert removal of example scope comments
eramongodb Jan 18, 2022
0ca4136
Remove redundant _test_collection_op_query_or_find_command function
eramongodb Jan 18, 2022
869b528
Remove redundant _test_find_command function
eramongodb Jan 18, 2022
ae3368e
Rename /ReadPref test parameters per feedback
eramongodb Jan 18, 2022
ceba875
Add comment justifying addition of log captures
eramongodb Jan 18, 2022
6accf57
Update comment documentation for mock_server_receives_bulk_msg
eramongodb Jan 18, 2022
c4d2fd4
Update /server_stream/ties_server_description tests per feedback
eramongodb Jan 18, 2022
a54b7bc
Update comment in variants to reflect removal of versions < 3.6
eramongodb Jan 18, 2022
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
10,407 changes: 2,541 additions & 7,866 deletions .evergreen/config.yml

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion .evergreen/integration-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#
# Specify the following environment variables:
#
# MONGODB_VERSION: latest, 4.2, 4.0, 3.6, 3.4, 3.2, 3.0, 2.6, 2.4
# MONGODB_VERSION: latest, 4.2, 4.0, 3.6
# TOPOLOGY: server, replica_set, sharded_cluster
# AUTH: auth, noauth
# AUTHSOURCE
Expand Down
8 changes: 1 addition & 7 deletions build/evergreen_config_lib/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -462,9 +462,7 @@ class IntegrationTask(MatrixTask):
axes = OD([('valgrind', ['valgrind', False]),
('sanitizer', ['asan', 'tsan', False]),
('coverage', ['coverage', False]),
('version', ['latest', '5.0',
'4.4', '4.2', '4.0',
'3.6', '3.4', '3.2', '3.0']),
('version', ['latest', '5.0', '4.4', '4.2', '4.0', '3.6']),
('topology', ['server', 'replica_set', 'sharded_cluster']),
('auth', [True, False]),
('sasl', ['sasl', 'sspi', False]),
Expand Down Expand Up @@ -759,10 +757,6 @@ def __init__(self, task_name, depends_on='debug-compile-sasl-openssl',
# Verify that retryWrites=true is ignored with standalone.
SpecialIntegrationTask('retry-true-latest-server',
uri='mongodb://localhost/?retryWrites=true'),
# Verify that retryWrites=true is ignored with old server.
SpecialIntegrationTask('retry-true-3.4-replica-set',
version='3.4',
topology='replica_set'),
SpecialIntegrationTask('test-latest-server-hardened',
'hardened-compile',
tags=['hardened', 'latest']),
Expand Down
55 changes: 9 additions & 46 deletions build/evergreen_config_lib/variants.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,7 @@ def days(n):
'.debug-compile !.sspi .nossl',
'.authentication-tests .openssl',
'.4.0 .openssl !.nosasl .server',
'.3.6 .openssl !.nosasl .server',
'.3.4 .openssl !.nosasl .server',
'.3.2 .openssl !.nosasl .server',
'.3.0 .openssl !.nosasl !.auth'],
'.3.6 .openssl !.nosasl .server'],
{'CC': 'clang'}),
Variant('clang35',
'clang 3.5 (Debian 8.1)',
Expand Down Expand Up @@ -147,10 +144,7 @@ def days(n):
'.debug-compile !.sspi .nossl',
'.authentication-tests .openssl',
'.4.0 .nossl',
'.3.6 .nossl',
'.3.4 .nossl',
'.3.2 .nossl',
'.3.0 .nossl .nosasl !.auth'],
'.3.6 .nossl'],
{'CC': 'clang'}),
Variant('clang60-i686',
'clang 6.0 (i686) (Ubuntu 18.04)',
Expand Down Expand Up @@ -197,8 +191,6 @@ def days(n):
'.4.2 .openssl !.nosasl .server',
'.4.0 .openssl !.nosasl .server',
'.3.6 .openssl !.nosasl .server',
'.test-coverage .3.2',
'.test-coverage .3.4',
'.test-coverage .3.6'],
{'CC': 'clang'}),
Variant('gcc48ubuntu',
Expand All @@ -210,11 +202,7 @@ def days(n):
'.debug-compile !.sspi .nossl',
'.authentication-tests .openssl',
'.4.0 .openssl !.nosasl .server',
'.3.6 .openssl !.nosasl .server',
'.3.4 .openssl !.nosasl .server',
'.3.2 .openssl !.nosasl .server',
'.3.0 .openssl !.nosasl !.auth',
'.test-coverage .3.0'],
'.3.6 .openssl !.nosasl .server'],
{'CC': 'gcc'}),
Variant('gcc82rhel',
'GCC 8.2 (RHEL 8.0)',
Expand Down Expand Up @@ -245,10 +233,7 @@ def days(n):
'.4.4 .openssl !.nosasl .server',
'.4.2 .openssl !.nosasl .server',
'.4.0 .openssl !.nosasl .server',
'.3.6 .openssl !.nosasl .server',
'.3.4 .openssl !.nosasl .server',
'.3.2 .openssl !.nosasl .server',
'.3.0 .openssl !.nosasl !.auth'],
'.3.6 .openssl !.nosasl .server'],
{'CC': 'gcc'}),
Variant('gcc49',
'GCC 4.9 (Debian 8.1)',
Expand Down Expand Up @@ -341,7 +326,6 @@ def days(n):
'debug-compile-no-align',
'.debug-compile !.sspi .openssl',
'.debug-compile !.sspi .nossl',
'retry-true-3.4-replica-set',
],
{'CC': 'gcc'}),
Variant('darwin',
Expand All @@ -366,9 +350,6 @@ def days(n):
'.4.2 .darwinssl !.nosasl .server',
'.4.0 .darwinssl !.nosasl .server',
'.3.6 .darwinssl !.nosasl .server',
'.3.4 .darwinssl !.nosasl .server',
'.3.2 .darwinssl !.nosasl .server',
'.3.2 .nossl',
'test-dns-darwinssl',
'test-dns-auth-darwinssl',
'debug-compile-lto',
Expand Down Expand Up @@ -427,10 +408,7 @@ def days(n):
'.authentication-tests .winssl',
'.4.2 .winssl !.nosasl .server',
'.4.0 .winssl !.nosasl .server',
'.3.6 .winssl !.nosasl .server',
'.3.4 .winssl !.nosasl .server',
'.3.2 .winssl !.nosasl .server',
'.3.0 .nossl'],
'.3.6 .winssl !.nosasl .server'],
{'CC': 'Visual Studio 14 2015 Win64'}),
Variant('windows-2015-32',
'Windows (i686) (VS 2015)',
Expand Down Expand Up @@ -568,7 +546,7 @@ def days(n):
['.debug-compile !.sspi .openssl !.sasl',
'.debug-compile !.sspi .nossl !.sasl',
'.debug-compile .special .valgrind',
'.test-valgrind !.3.0 !.3.2 !.3.4 !.3.6'],
'.test-valgrind !.3.6'],
{'CC': 'gcc'},
batchtime=days(1)),
Variant('valgrind-ubuntu-1404',
Expand All @@ -577,40 +555,25 @@ def days(n):
['.debug-compile !.sspi .openssl !.sasl',
'.debug-compile !.sspi .nossl !.sasl',
'.debug-compile .special .valgrind',
'.test-valgrind .3.0',
'.test-valgrind .3.2',
'.test-valgrind .3.4',
'.test-valgrind .3.6'],
{'CC': 'gcc'},
batchtime=days(1)),
Variant('asan-ubuntu',
'ASAN Tests (Ubuntu 18.04)',
'ubuntu1804-test',
['.debug-compile .asan-clang',
'.test-asan !.3.0 !.3.2 !.3.4 !.3.6'],
'.test-asan !.3.6'],
{'CC': 'clang'},
batchtime=days(1)),
# There is no MongoDB < 4.0 with SSL available on Ubuntu post 16.04.
# So have a variant for ASAN to test against MongoDB 3.2 through 3.6.
# So have a variant for ASAN to test against MongoDB 3.6.
Variant('asan-ubuntu-ubuntu1604',
'ASAN Tests (Ubuntu 16.04)',
'ubuntu1604-test',
['.debug-compile .asan-clang',
'.test-asan .3.2',
'.test-asan .3.4',
'.test-asan .3.6'],
{'CC': 'clang'},
batchtime=days(1)),
# There is no MongoDB 3.0 with SSL available on Ubuntu post 14.04. And MongoDB 4.2 not supported on Ubuntu 14.04.
# So have one variant for ASAN to test against MongoDB 3.0.
Variant('asan-ubuntu-ubuntu1404',
'ASAN Tests - MongoDB 3.0 (Ubuntu 14.04)',
'ubuntu1404-test',
# Omit compiling with client-side-encryption, since tests only run against 4.2+.
['.debug-compile .asan-clang !.client-side-encryption',
'.test-asan .3.0'],
{'CC': 'clang'},
batchtime=days(1)),
Variant ('clang60ubuntu', 'clang 6.0 (Ubuntu 18.04)', 'ubuntu1804-test', [
'debug-compile-aws',
'debug-compile-nosasl-openssl-static',
Expand Down Expand Up @@ -662,7 +625,7 @@ def days(n):
Variant('tsan-ubuntu',
'Thread Sanitizer (TSAN) Tests (Ubuntu 18.04)',
'ubuntu1804-small',
['.tsan !.3.2 !.3.4 !.3.6'],
['.tsan !.3.6'],
{'CC': '/opt/mongodbtoolchain/v3/bin/clang'},
batchtime=days(1)),
Variant('versioned-api',
Expand Down
8 changes: 6 additions & 2 deletions src/libmongoc/src/mongoc/mongoc-client-private.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,10 @@

BSON_BEGIN_DECLS

/* protocol versions this driver can speak */
#define WIRE_VERSION_MIN 3 /* a.k.a. minWireVersion */
/* Range of wire protocol versions this driver supports. Bumping
* WIRE_VERSION_MAX must be accompanied by an update to
* `_mongoc_wire_version_to_server_version`. */
#define WIRE_VERSION_MIN 6 /* a.k.a. minWireVersion */
#define WIRE_VERSION_MAX 14 /* a.k.a. maxWireVersion */

/* first version that supported "find" and "getMore" commands */
Expand Down Expand Up @@ -96,6 +98,8 @@ BSON_BEGIN_DECLS
#define WIRE_VERSION_5_0 13
/* first version to support snapshot reads */
#define WIRE_VERSION_SNAPSHOT_READS 13
/* version corresponding to server 5.1 release */
#define WIRE_VERSION_5_1 14

struct _mongoc_collection_t;

Expand Down
6 changes: 4 additions & 2 deletions src/libmongoc/src/mongoc/mongoc-topology-description.c
Original file line number Diff line number Diff line change
Expand Up @@ -1989,9 +1989,11 @@ _mongoc_topology_description_check_compatible (
MONGOC_ERROR_PROTOCOL,
MONGOC_ERROR_PROTOCOL_BAD_WIRE_VERSION,
"Server at %s reports wire version %d, but this"
" version of libmongoc requires at least 3 (MongoDB 3.0)",
" version of libmongoc requires at least %d (MongoDB %s)",
sd->host.host_and_port,
sd->max_wire_version);
sd->max_wire_version,
WIRE_VERSION_MIN,
_mongoc_wire_version_to_server_version (WIRE_VERSION_MIN));
}
}
}
Expand Down
3 changes: 3 additions & 0 deletions src/libmongoc/src/mongoc/mongoc-util-private.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,9 @@ _mongoc_bson_init_if_set (bson_t *bson);
const char *
_mongoc_bson_type_to_str (bson_type_t t);

const char *
_mongoc_wire_version_to_server_version (int32_t version);

bool
_mongoc_get_server_id_from_opts (const bson_t *opts,
mongoc_error_domain_t domain,
Expand Down
42 changes: 42 additions & 0 deletions src/libmongoc/src/mongoc/mongoc-util.c
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,48 @@ _mongoc_bson_type_to_str (bson_type_t t)
}


/* Refer to:
* https://github.com/mongodb/specifications/blob/master/source/wireversion-featurelist.rst
* and:
* https://github.com/mongodb/mongo/blob/master/src/mongo/db/wire_version.h#L57
*/
const char *
_mongoc_wire_version_to_server_version (int32_t version)
{
switch (version) {
case 1:
case 2:
return "2.6";
case 3:
return "3.0";
case 4:
return "3.2";
case 5:
return "3.4";
case 6:
return "3.6";
case 7:
return "4.0";
case 8:
return "4.2";
case 9:
return "4.4";
case 10:
return "4.7";
case 11:
return "4.8";
case 12:
return "4.9";
case 13:
return "5.0";
case 14:
return "5.1";
default:
return "Unknown";
}
}


/* Get "serverId" from opts. Sets *server_id to the serverId from "opts" or 0
* if absent. On error, fills out *error with domain and code and return false.
*/
Expand Down
67 changes: 36 additions & 31 deletions src/libmongoc/tests/mock_server/mock-rs.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@

#include "mock-rs.h"
#include "sync-queue.h"
#include "../test-libmongoc.h"
#include "test-libmongoc.h"
#include "TestSuite.h"


struct _mock_rs_t {
Expand Down Expand Up @@ -110,35 +111,21 @@ make_uri (mongoc_array_t *servers)

static char *
hello_json (mock_rs_t *rs,
mongoc_server_description_type_t type,
const bson_t *tags)
mongoc_server_description_type_t type,
const bson_t *tags)
{
char *server_type;
char *mongos_36_fields = "";
char *tags_json;
char *hosts_str;
char *json;

if (type == MONGOC_SERVER_RS_PRIMARY) {
server_type = "'isWritablePrimary': true, 'secondary': false, ";
server_type = "'isWritablePrimary': true, 'secondary': false,";
} else if (type == MONGOC_SERVER_RS_SECONDARY) {
server_type = "'isWritablePrimary': false, 'secondary': true, ";
server_type = "'isWritablePrimary': false, 'secondary': true,";
} else {
BSON_ASSERT (type == MONGOC_SERVER_RS_ARBITER);
server_type = "'isWritablePrimary': false, 'arbiterOnly': true, ";
}

if (rs->max_wire_version >= WIRE_VERSION_OP_MSG) {
mongos_36_fields =
"'$clusterTime': {"
" 'clusterTime': {'$timestamp': {'t': 1, 'i': 1}},"
" 'signature': {"
" 'hash': {'$binary': {'subType': '0', 'base64': ''}},"
" 'keyId': {'$numberLong': '6446735049323708417'}"
" },"
" 'operationTime': {'$timestamp': {'t': 1, 'i': 1}}"
"}, "
"'logicalSessionTimeoutMinutes': 30, ";
server_type = "'isWritablePrimary': false, 'arbiterOnly': true,";
}

if (bson_empty0 (tags)) {
Expand All @@ -149,14 +136,28 @@ hello_json (mock_rs_t *rs,

hosts_str = hosts (&rs->servers);

json = bson_strdup_printf ("{'ok': 1, %s %s 'tags': %s,"
" 'maxWireVersion': %d, "
"'setName': 'rs', 'hosts': [%s]}",
server_type,
mongos_36_fields,
tags_json,
rs->max_wire_version,
hosts_str);
json = bson_strdup_printf (
"{'ok': 1,"
" %s"
" '$clusterTime': {"
" 'clusterTime': {'$timestamp': {'t': 1, 'i': 1}},"
" 'signature': {"
" 'hash': {'$binary': {'subType': '0', 'base64': ''}},"
" 'keyId': {'$numberLong': '6446735049323708417'}"
" },"
" 'operationTime': {'$timestamp': {'t': 1, 'i': 1}}"
" },"
"'logicalSessionTimeoutMinutes': 30,"
" 'tags': %s,"
" 'minWireVersion': %d,"
" 'maxWireVersion': %d,"
" 'setName': 'rs',"
" 'hosts': [%s]}",
server_type,
tags_json,
WIRE_VERSION_MIN,
rs->max_wire_version,
hosts_str);

bson_free (tags_json);
bson_free (hosts_str);
Expand Down Expand Up @@ -212,6 +213,12 @@ mock_rs_with_auto_hello (int32_t max_wire_version,
int i;
mock_rs_t *rs = (mock_rs_t *) bson_malloc0 (sizeof (mock_rs_t));

ASSERT_WITH_MSG (max_wire_version >= WIRE_VERSION_MIN,
"max_wire_version %" PRId32
" must be greater than or equal to minimum wire version %d",
max_wire_version,
WIRE_VERSION_MIN);

rs->max_wire_version = max_wire_version;
rs->has_primary = has_primary;
rs->n_secondaries = n_secondaries;
Expand Down Expand Up @@ -394,9 +401,7 @@ mock_rs_run (mock_rs_t *rs)

bson_free (hello);

if (rs->max_wire_version >= WIRE_VERSION_OP_MSG) {
mock_rs_auto_endsessions (rs);
}
mock_rs_auto_endsessions (rs);
}


Expand Down
Loading