Skip to content

Commit 3d0f609

Browse files
authored
CDRIVER-4098 Bump WIRE_VERSION_MIN from 3 to 6 (#926)
* Bump WIRE_VERSION_MIN from 3 to 6 * Assert request parameter for mock_server_replies_to_find() is not null * Update error message for failing to satisfy minimum wire version * Remove Evergreen tasks requiring server version below 3.6 * Update mock servers to forbid max_wire_version < 6 * Update test code conditioned on wire version < 6 * Replace wire version integer literals with feature macros * Replace wire versions in string literals with feature macros * Add mock_server_receives_bulk_msg() * Update mock_server_recieves_command() -> mock_server_recieves_msg()
1 parent 9eba451 commit 3d0f609

Some content is hidden

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

52 files changed

+5186
-11816
lines changed

.evergreen/config.yml

Lines changed: 2541 additions & 7866 deletions
Large diffs are not rendered by default.

.evergreen/integration-tests.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#
44
# Specify the following environment variables:
55
#
6-
# MONGODB_VERSION: latest, 4.2, 4.0, 3.6, 3.4, 3.2, 3.0, 2.6, 2.4
6+
# MONGODB_VERSION: latest, 4.2, 4.0, 3.6
77
# TOPOLOGY: server, replica_set, sharded_cluster
88
# AUTH: auth, noauth
99
# AUTHSOURCE

build/evergreen_config_lib/tasks.py

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -462,9 +462,7 @@ class IntegrationTask(MatrixTask):
462462
axes = OD([('valgrind', ['valgrind', False]),
463463
('sanitizer', ['asan', 'tsan', False]),
464464
('coverage', ['coverage', False]),
465-
('version', ['latest', '5.0',
466-
'4.4', '4.2', '4.0',
467-
'3.6', '3.4', '3.2', '3.0']),
465+
('version', ['latest', '5.0', '4.4', '4.2', '4.0', '3.6']),
468466
('topology', ['server', 'replica_set', 'sharded_cluster']),
469467
('auth', [True, False]),
470468
('sasl', ['sasl', 'sspi', False]),
@@ -759,10 +757,6 @@ def __init__(self, task_name, depends_on='debug-compile-sasl-openssl',
759757
# Verify that retryWrites=true is ignored with standalone.
760758
SpecialIntegrationTask('retry-true-latest-server',
761759
uri='mongodb://localhost/?retryWrites=true'),
762-
# Verify that retryWrites=true is ignored with old server.
763-
SpecialIntegrationTask('retry-true-3.4-replica-set',
764-
version='3.4',
765-
topology='replica_set'),
766760
SpecialIntegrationTask('test-latest-server-hardened',
767761
'hardened-compile',
768762
tags=['hardened', 'latest']),

build/evergreen_config_lib/variants.py

Lines changed: 9 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -93,10 +93,7 @@ def days(n):
9393
'.debug-compile !.sspi .nossl',
9494
'.authentication-tests .openssl',
9595
'.4.0 .openssl !.nosasl .server',
96-
'.3.6 .openssl !.nosasl .server',
97-
'.3.4 .openssl !.nosasl .server',
98-
'.3.2 .openssl !.nosasl .server',
99-
'.3.0 .openssl !.nosasl !.auth'],
96+
'.3.6 .openssl !.nosasl .server'],
10097
{'CC': 'clang'}),
10198
Variant('clang35',
10299
'clang 3.5 (Debian 8.1)',
@@ -147,10 +144,7 @@ def days(n):
147144
'.debug-compile !.sspi .nossl',
148145
'.authentication-tests .openssl',
149146
'.4.0 .nossl',
150-
'.3.6 .nossl',
151-
'.3.4 .nossl',
152-
'.3.2 .nossl',
153-
'.3.0 .nossl .nosasl !.auth'],
147+
'.3.6 .nossl'],
154148
{'CC': 'clang'}),
155149
Variant('clang60-i686',
156150
'clang 6.0 (i686) (Ubuntu 18.04)',
@@ -197,8 +191,6 @@ def days(n):
197191
'.4.2 .openssl !.nosasl .server',
198192
'.4.0 .openssl !.nosasl .server',
199193
'.3.6 .openssl !.nosasl .server',
200-
'.test-coverage .3.2',
201-
'.test-coverage .3.4',
202194
'.test-coverage .3.6'],
203195
{'CC': 'clang'}),
204196
Variant('gcc48ubuntu',
@@ -210,11 +202,7 @@ def days(n):
210202
'.debug-compile !.sspi .nossl',
211203
'.authentication-tests .openssl',
212204
'.4.0 .openssl !.nosasl .server',
213-
'.3.6 .openssl !.nosasl .server',
214-
'.3.4 .openssl !.nosasl .server',
215-
'.3.2 .openssl !.nosasl .server',
216-
'.3.0 .openssl !.nosasl !.auth',
217-
'.test-coverage .3.0'],
205+
'.3.6 .openssl !.nosasl .server'],
218206
{'CC': 'gcc'}),
219207
Variant('gcc82rhel',
220208
'GCC 8.2 (RHEL 8.0)',
@@ -245,10 +233,7 @@ def days(n):
245233
'.4.4 .openssl !.nosasl .server',
246234
'.4.2 .openssl !.nosasl .server',
247235
'.4.0 .openssl !.nosasl .server',
248-
'.3.6 .openssl !.nosasl .server',
249-
'.3.4 .openssl !.nosasl .server',
250-
'.3.2 .openssl !.nosasl .server',
251-
'.3.0 .openssl !.nosasl !.auth'],
236+
'.3.6 .openssl !.nosasl .server'],
252237
{'CC': 'gcc'}),
253238
Variant('gcc49',
254239
'GCC 4.9 (Debian 8.1)',
@@ -341,7 +326,6 @@ def days(n):
341326
'debug-compile-no-align',
342327
'.debug-compile !.sspi .openssl',
343328
'.debug-compile !.sspi .nossl',
344-
'retry-true-3.4-replica-set',
345329
],
346330
{'CC': 'gcc'}),
347331
Variant('darwin',
@@ -366,9 +350,6 @@ def days(n):
366350
'.4.2 .darwinssl !.nosasl .server',
367351
'.4.0 .darwinssl !.nosasl .server',
368352
'.3.6 .darwinssl !.nosasl .server',
369-
'.3.4 .darwinssl !.nosasl .server',
370-
'.3.2 .darwinssl !.nosasl .server',
371-
'.3.2 .nossl',
372353
'test-dns-darwinssl',
373354
'test-dns-auth-darwinssl',
374355
'debug-compile-lto',
@@ -427,10 +408,7 @@ def days(n):
427408
'.authentication-tests .winssl',
428409
'.4.2 .winssl !.nosasl .server',
429410
'.4.0 .winssl !.nosasl .server',
430-
'.3.6 .winssl !.nosasl .server',
431-
'.3.4 .winssl !.nosasl .server',
432-
'.3.2 .winssl !.nosasl .server',
433-
'.3.0 .nossl'],
411+
'.3.6 .winssl !.nosasl .server'],
434412
{'CC': 'Visual Studio 14 2015 Win64'}),
435413
Variant('windows-2015-32',
436414
'Windows (i686) (VS 2015)',
@@ -568,7 +546,7 @@ def days(n):
568546
['.debug-compile !.sspi .openssl !.sasl',
569547
'.debug-compile !.sspi .nossl !.sasl',
570548
'.debug-compile .special .valgrind',
571-
'.test-valgrind !.3.0 !.3.2 !.3.4 !.3.6'],
549+
'.test-valgrind !.3.6'],
572550
{'CC': 'gcc'},
573551
batchtime=days(1)),
574552
Variant('valgrind-ubuntu-1404',
@@ -577,40 +555,25 @@ def days(n):
577555
['.debug-compile !.sspi .openssl !.sasl',
578556
'.debug-compile !.sspi .nossl !.sasl',
579557
'.debug-compile .special .valgrind',
580-
'.test-valgrind .3.0',
581-
'.test-valgrind .3.2',
582-
'.test-valgrind .3.4',
583558
'.test-valgrind .3.6'],
584559
{'CC': 'gcc'},
585560
batchtime=days(1)),
586561
Variant('asan-ubuntu',
587562
'ASAN Tests (Ubuntu 18.04)',
588563
'ubuntu1804-test',
589564
['.debug-compile .asan-clang',
590-
'.test-asan !.3.0 !.3.2 !.3.4 !.3.6'],
565+
'.test-asan !.3.6'],
591566
{'CC': 'clang'},
592567
batchtime=days(1)),
593568
# There is no MongoDB < 4.0 with SSL available on Ubuntu post 16.04.
594-
# So have a variant for ASAN to test against MongoDB 3.2 through 3.6.
569+
# So have a variant for ASAN to test against MongoDB 3.6.
595570
Variant('asan-ubuntu-ubuntu1604',
596571
'ASAN Tests (Ubuntu 16.04)',
597572
'ubuntu1604-test',
598573
['.debug-compile .asan-clang',
599-
'.test-asan .3.2',
600-
'.test-asan .3.4',
601574
'.test-asan .3.6'],
602575
{'CC': 'clang'},
603576
batchtime=days(1)),
604-
# There is no MongoDB 3.0 with SSL available on Ubuntu post 14.04. And MongoDB 4.2 not supported on Ubuntu 14.04.
605-
# So have one variant for ASAN to test against MongoDB 3.0.
606-
Variant('asan-ubuntu-ubuntu1404',
607-
'ASAN Tests - MongoDB 3.0 (Ubuntu 14.04)',
608-
'ubuntu1404-test',
609-
# Omit compiling with client-side-encryption, since tests only run against 4.2+.
610-
['.debug-compile .asan-clang !.client-side-encryption',
611-
'.test-asan .3.0'],
612-
{'CC': 'clang'},
613-
batchtime=days(1)),
614577
Variant ('clang60ubuntu', 'clang 6.0 (Ubuntu 18.04)', 'ubuntu1804-test', [
615578
'debug-compile-aws',
616579
'debug-compile-nosasl-openssl-static',
@@ -662,7 +625,7 @@ def days(n):
662625
Variant('tsan-ubuntu',
663626
'Thread Sanitizer (TSAN) Tests (Ubuntu 18.04)',
664627
'ubuntu1804-small',
665-
['.tsan !.3.2 !.3.4 !.3.6'],
628+
['.tsan !.3.6'],
666629
{'CC': '/opt/mongodbtoolchain/v3/bin/clang'},
667630
batchtime=days(1)),
668631
Variant('versioned-api',

src/libmongoc/src/mongoc/mongoc-client-private.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,10 @@
4141

4242
BSON_BEGIN_DECLS
4343

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

4850
/* first version that supported "find" and "getMore" commands */
@@ -96,6 +98,8 @@ BSON_BEGIN_DECLS
9698
#define WIRE_VERSION_5_0 13
9799
/* first version to support snapshot reads */
98100
#define WIRE_VERSION_SNAPSHOT_READS 13
101+
/* version corresponding to server 5.1 release */
102+
#define WIRE_VERSION_5_1 14
99103

100104
struct _mongoc_collection_t;
101105

src/libmongoc/src/mongoc/mongoc-topology-description.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2097,9 +2097,11 @@ _mongoc_topology_description_check_compatible (
20972097
MONGOC_ERROR_PROTOCOL,
20982098
MONGOC_ERROR_PROTOCOL_BAD_WIRE_VERSION,
20992099
"Server at %s reports wire version %d, but this"
2100-
" version of libmongoc requires at least 3 (MongoDB 3.0)",
2100+
" version of libmongoc requires at least %d (MongoDB %s)",
21012101
sd->host.host_and_port,
2102-
sd->max_wire_version);
2102+
sd->max_wire_version,
2103+
WIRE_VERSION_MIN,
2104+
_mongoc_wire_version_to_server_version (WIRE_VERSION_MIN));
21032105
}
21042106
}
21052107
}

src/libmongoc/src/mongoc/mongoc-util-private.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,9 @@ _mongoc_bson_init_if_set (bson_t *bson);
100100
const char *
101101
_mongoc_bson_type_to_str (bson_type_t t);
102102

103+
const char *
104+
_mongoc_wire_version_to_server_version (int32_t version);
105+
103106
bool
104107
_mongoc_get_server_id_from_opts (const bson_t *opts,
105108
mongoc_error_domain_t domain,

src/libmongoc/src/mongoc/mongoc-util.c

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,48 @@ _mongoc_bson_type_to_str (bson_type_t t)
268268
}
269269

270270

271+
/* Refer to:
272+
* https://github.com/mongodb/specifications/blob/master/source/wireversion-featurelist.rst
273+
* and:
274+
* https://github.com/mongodb/mongo/blob/master/src/mongo/db/wire_version.h#L57
275+
*/
276+
const char *
277+
_mongoc_wire_version_to_server_version (int32_t version)
278+
{
279+
switch (version) {
280+
case 1:
281+
case 2:
282+
return "2.6";
283+
case 3:
284+
return "3.0";
285+
case 4:
286+
return "3.2";
287+
case 5:
288+
return "3.4";
289+
case 6:
290+
return "3.6";
291+
case 7:
292+
return "4.0";
293+
case 8:
294+
return "4.2";
295+
case 9:
296+
return "4.4";
297+
case 10:
298+
return "4.7";
299+
case 11:
300+
return "4.8";
301+
case 12:
302+
return "4.9";
303+
case 13:
304+
return "5.0";
305+
case 14:
306+
return "5.1";
307+
default:
308+
return "Unknown";
309+
}
310+
}
311+
312+
271313
/* Get "serverId" from opts. Sets *server_id to the serverId from "opts" or 0
272314
* if absent. On error, fills out *error with domain and code and return false.
273315
*/

src/libmongoc/tests/mock_server/mock-rs.c

Lines changed: 36 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@
2222

2323
#include "mock-rs.h"
2424
#include "sync-queue.h"
25-
#include "../test-libmongoc.h"
25+
#include "test-libmongoc.h"
26+
#include "TestSuite.h"
2627

2728

2829
struct _mock_rs_t {
@@ -110,35 +111,21 @@ make_uri (mongoc_array_t *servers)
110111

111112
static char *
112113
hello_json (mock_rs_t *rs,
113-
mongoc_server_description_type_t type,
114-
const bson_t *tags)
114+
mongoc_server_description_type_t type,
115+
const bson_t *tags)
115116
{
116117
char *server_type;
117-
char *mongos_36_fields = "";
118118
char *tags_json;
119119
char *hosts_str;
120120
char *json;
121121

122122
if (type == MONGOC_SERVER_RS_PRIMARY) {
123-
server_type = "'isWritablePrimary': true, 'secondary': false, ";
123+
server_type = "'isWritablePrimary': true, 'secondary': false,";
124124
} else if (type == MONGOC_SERVER_RS_SECONDARY) {
125-
server_type = "'isWritablePrimary': false, 'secondary': true, ";
125+
server_type = "'isWritablePrimary': false, 'secondary': true,";
126126
} else {
127127
BSON_ASSERT (type == MONGOC_SERVER_RS_ARBITER);
128-
server_type = "'isWritablePrimary': false, 'arbiterOnly': true, ";
129-
}
130-
131-
if (rs->max_wire_version >= WIRE_VERSION_OP_MSG) {
132-
mongos_36_fields =
133-
"'$clusterTime': {"
134-
" 'clusterTime': {'$timestamp': {'t': 1, 'i': 1}},"
135-
" 'signature': {"
136-
" 'hash': {'$binary': {'subType': '0', 'base64': ''}},"
137-
" 'keyId': {'$numberLong': '6446735049323708417'}"
138-
" },"
139-
" 'operationTime': {'$timestamp': {'t': 1, 'i': 1}}"
140-
"}, "
141-
"'logicalSessionTimeoutMinutes': 30, ";
128+
server_type = "'isWritablePrimary': false, 'arbiterOnly': true,";
142129
}
143130

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

150137
hosts_str = hosts (&rs->servers);
151138

152-
json = bson_strdup_printf ("{'ok': 1, %s %s 'tags': %s,"
153-
" 'maxWireVersion': %d, "
154-
"'setName': 'rs', 'hosts': [%s]}",
155-
server_type,
156-
mongos_36_fields,
157-
tags_json,
158-
rs->max_wire_version,
159-
hosts_str);
139+
json = bson_strdup_printf (
140+
"{'ok': 1,"
141+
" %s"
142+
" '$clusterTime': {"
143+
" 'clusterTime': {'$timestamp': {'t': 1, 'i': 1}},"
144+
" 'signature': {"
145+
" 'hash': {'$binary': {'subType': '0', 'base64': ''}},"
146+
" 'keyId': {'$numberLong': '6446735049323708417'}"
147+
" },"
148+
" 'operationTime': {'$timestamp': {'t': 1, 'i': 1}}"
149+
" },"
150+
"'logicalSessionTimeoutMinutes': 30,"
151+
" 'tags': %s,"
152+
" 'minWireVersion': %d,"
153+
" 'maxWireVersion': %d,"
154+
" 'setName': 'rs',"
155+
" 'hosts': [%s]}",
156+
server_type,
157+
tags_json,
158+
WIRE_VERSION_MIN,
159+
rs->max_wire_version,
160+
hosts_str);
160161

161162
bson_free (tags_json);
162163
bson_free (hosts_str);
@@ -212,6 +213,12 @@ mock_rs_with_auto_hello (int32_t max_wire_version,
212213
int i;
213214
mock_rs_t *rs = (mock_rs_t *) bson_malloc0 (sizeof (mock_rs_t));
214215

216+
ASSERT_WITH_MSG (max_wire_version >= WIRE_VERSION_MIN,
217+
"max_wire_version %" PRId32
218+
" must be greater than or equal to minimum wire version %d",
219+
max_wire_version,
220+
WIRE_VERSION_MIN);
221+
215222
rs->max_wire_version = max_wire_version;
216223
rs->has_primary = has_primary;
217224
rs->n_secondaries = n_secondaries;
@@ -394,9 +401,7 @@ mock_rs_run (mock_rs_t *rs)
394401

395402
bson_free (hello);
396403

397-
if (rs->max_wire_version >= WIRE_VERSION_OP_MSG) {
398-
mock_rs_auto_endsessions (rs);
399-
}
404+
mock_rs_auto_endsessions (rs);
400405
}
401406

402407

0 commit comments

Comments
 (0)