Skip to content

Commit eea8bb7

Browse files
authored
* set loadBalanced=true in URI if testing with load balancer * Update integration-tests.sh and orchestration configs * add LOAD_BALANCER to 'bootstrap mongo-orchestration' function * use /tmp/orchestration-home path This matches expectation of integration-tests.sh. * remove mongoc_global_mock_service_id This was only needed when MongoDB servers did not return a serviceId in the hello response. * update loadBalanced DNS tests Tests were updated in mongodb/specifications commit: 5d1b42a05017ba27ffdbe6fd068a45e93e5b68c5
1 parent 30fdc1c commit eea8bb7

17 files changed

+280
-43
lines changed

.evergreen/config.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -407,7 +407,8 @@ functions:
407407
export ORCHESTRATION_FILE=${ORCHESTRATION_FILE}
408408
export OCSP=${OCSP}
409409
export REQUIRE_API_VERSION=${REQUIRE_API_VERSION}
410-
sh .evergreen/integration-tests.sh
410+
export LOAD_BALANCER=${LOAD_BALANCER}
411+
bash .evergreen/integration-tests.sh
411412
- command: expansions.update
412413
params:
413414
file: mongoc/mo-expansion.yml
@@ -16565,6 +16566,7 @@ tasks:
1656516566
- func: bootstrap mongo-orchestration
1656616567
vars:
1656716568
AUTH: noauth
16569+
LOAD_BALANCER: 'on'
1656816570
SSL: ssl
1656916571
TOPOLOGY: sharded_cluster
1657016572
VERSION: latest
@@ -23941,6 +23943,7 @@ tasks:
2394123943
- func: bootstrap mongo-orchestration
2394223944
vars:
2394323945
AUTH: auth
23946+
LOAD_BALANCER: 'on'
2394423947
SSL: ssl
2394523948
TOPOLOGY: sharded_cluster
2394623949
VERSION: '5.0'
@@ -23967,6 +23970,7 @@ tasks:
2396723970
- func: bootstrap mongo-orchestration
2396823971
vars:
2396923972
AUTH: auth
23973+
LOAD_BALANCER: 'on'
2397023974
SSL: ssl
2397123975
TOPOLOGY: sharded_cluster
2397223976
VERSION: latest
@@ -23993,6 +23997,7 @@ tasks:
2399323997
- func: bootstrap mongo-orchestration
2399423998
vars:
2399523999
AUTH: noauth
24000+
LOAD_BALANCER: 'on'
2399624001
SSL: nossl
2399724002
TOPOLOGY: sharded_cluster
2399824003
VERSION: '5.0'
@@ -24019,6 +24024,7 @@ tasks:
2401924024
- func: bootstrap mongo-orchestration
2402024025
vars:
2402124026
AUTH: noauth
24027+
LOAD_BALANCER: 'on'
2402224028
SSL: nossl
2402324029
TOPOLOGY: sharded_cluster
2402424030
VERSION: latest

.evergreen/integration-tests.sh

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#! /bin/sh
1+
#! /bin/bash
22
# Start up mongo-orchestration (a server to spawn mongodb clusters) and set up a cluster.
33
#
44
# Specify the following environment variables:
@@ -14,12 +14,15 @@
1414
# OCSP: off, on
1515
# REQUIRE_API_VERSION: set to a non-empty string to set the requireApiVersion parameter
1616
# This is currently only supported for standalone servers
17+
# LOAD_BALANCER: off, on
1718
#
1819
# This script may be run locally.
1920
#
2021

2122
set -o errexit # Exit the script with error if any of the commands fail
2223

24+
: "${LOAD_BALANCER:=off}"
25+
2326
DIR=$(dirname $0)
2427
# Functions to fetch MongoDB binaries
2528
. $DIR/download-mongodb.sh
@@ -61,6 +64,10 @@ if [ -z "$ORCHESTRATION_FILE" ]; then
6164
if [ "$SSL" != "nossl" ]; then
6265
ORCHESTRATION_FILE="${ORCHESTRATION_FILE}-ssl"
6366
fi
67+
68+
if [ "$LOAD_BALANCER" = "on" ]; then
69+
ORCHESTRATION_FILE="${ORCHESTRATION_FILE}-load-balancer"
70+
fi
6471
fi
6572

6673
# Set up mongo orchestration home.

build/evergreen_config_lib/functions.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,8 @@
280280
export ORCHESTRATION_FILE=${ORCHESTRATION_FILE}
281281
export OCSP=${OCSP}
282282
export REQUIRE_API_VERSION=${REQUIRE_API_VERSION}
283-
sh .evergreen/integration-tests.sh
283+
export LOAD_BALANCER=${LOAD_BALANCER}
284+
bash .evergreen/integration-tests.sh
284285
''', test=False),
285286
OD([
286287
("command", "expansions.update"),

build/evergreen_config_lib/tasks.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -667,9 +667,15 @@ def to_dict(self):
667667
commands.append(
668668
func('fetch build', BUILD_NAME=self.depends_on['name']))
669669

670-
orchestration = bootstrap(TOPOLOGY='sharded_cluster' if self.loadbalanced else 'replica_set',
671-
AUTH='auth' if self.auth else 'noauth',
672-
SSL='ssl')
670+
if self.loadbalanced:
671+
orchestration = bootstrap(TOPOLOGY='sharded_cluster',
672+
AUTH='auth' if self.auth else 'noauth',
673+
SSL='ssl',
674+
LOAD_BALANCER='on')
675+
else:
676+
orchestration = bootstrap(TOPOLOGY='replica_set',
677+
AUTH='auth' if self.auth else 'noauth',
678+
SSL='ssl')
673679

674680
if self.auth:
675681
orchestration['vars']['AUTHSOURCE'] = 'thisDB'
@@ -1145,7 +1151,8 @@ def to_dict(self):
11451151
orchestration = bootstrap(TOPOLOGY='sharded_cluster',
11461152
AUTH='auth' if self.test_auth else 'noauth',
11471153
SSL='ssl' if self.test_ssl else 'nossl',
1148-
VERSION=self.version)
1154+
VERSION=self.version,
1155+
LOAD_BALANCER='on')
11491156
commands.append(orchestration)
11501157
commands.append(func("clone drivers-evergreen-tools"))
11511158
commands.append(func("start load balancer",
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
{
2+
"id": "shard_cluster_1",
3+
"login": "bob",
4+
"password": "pwd123",
5+
"auth_key": "secret",
6+
"shards": [
7+
{
8+
"id": "sh01",
9+
"shardParams": {
10+
"members": [
11+
{
12+
"procParams": {
13+
"ipv6": true,
14+
"bind_ip": "127.0.0.1,::1",
15+
"shardsvr": true,
16+
"port": 27217
17+
}
18+
},
19+
{
20+
"procParams": {
21+
"ipv6": true,
22+
"bind_ip": "127.0.0.1,::1",
23+
"shardsvr": true,
24+
"port": 27218
25+
}
26+
},
27+
{
28+
"procParams": {
29+
"ipv6": true,
30+
"bind_ip": "127.0.0.1,::1",
31+
"shardsvr": true,
32+
"port": 27219
33+
}
34+
}
35+
]
36+
}
37+
}
38+
],
39+
"routers": [
40+
{
41+
"ipv6": true,
42+
"bind_ip": "127.0.0.1,::1",
43+
"port": 27017,
44+
"setParameter": {
45+
"loadBalancerPort": 27050
46+
}
47+
},
48+
{
49+
"ipv6": true,
50+
"bind_ip": "127.0.0.1,::1",
51+
"port": 27018,
52+
"setParameter": {
53+
"loadBalancerPort": 27051
54+
}
55+
}
56+
]
57+
}
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
{
2+
"id": "shard_cluster_1",
3+
"login": "bob",
4+
"password": "pwd123",
5+
"auth_key": "secret",
6+
"shards": [
7+
{
8+
"id": "sh01",
9+
"shardParams": {
10+
"members": [
11+
{
12+
"procParams": {
13+
"ipv6": true,
14+
"bind_ip": "127.0.0.1,::1",
15+
"shardsvr": true,
16+
"port": 27217
17+
}
18+
},
19+
{
20+
"procParams": {
21+
"ipv6": true,
22+
"bind_ip": "127.0.0.1,::1",
23+
"shardsvr": true,
24+
"port": 27218
25+
}
26+
},
27+
{
28+
"procParams": {
29+
"ipv6": true,
30+
"bind_ip": "127.0.0.1,::1",
31+
"shardsvr": true,
32+
"port": 27219
33+
}
34+
}
35+
]
36+
}
37+
}
38+
],
39+
"routers": [
40+
{
41+
"ipv6": true,
42+
"bind_ip": "127.0.0.1,::1",
43+
"port": 27017,
44+
"setParameter": {
45+
"loadBalancerPort": 27050
46+
}
47+
},
48+
{
49+
"ipv6": true,
50+
"bind_ip": "127.0.0.1,::1",
51+
"port": 27018,
52+
"setParameter": {
53+
"loadBalancerPort": 27051
54+
}
55+
}
56+
],
57+
"sslParams": {
58+
"sslOnNormalPorts": true,
59+
"sslPEMKeyFile": "/tmp/orchestration-home/server.pem",
60+
"sslCAFile": "/tmp/orchestration-home/ca.pem",
61+
"sslWeakCertificateValidation" : true
62+
}
63+
}
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
{
2+
"id": "shard_cluster_1",
3+
"shards": [
4+
{
5+
"id": "sh01",
6+
"shardParams": {
7+
"members": [
8+
{
9+
"procParams": {
10+
"ipv6": true,
11+
"bind_ip": "127.0.0.1,::1",
12+
"shardsvr": true,
13+
"port": 27217
14+
}
15+
},
16+
{
17+
"procParams": {
18+
"ipv6": true,
19+
"bind_ip": "127.0.0.1,::1",
20+
"shardsvr": true,
21+
"port": 27218
22+
}
23+
},
24+
{
25+
"procParams": {
26+
"ipv6": true,
27+
"bind_ip": "127.0.0.1,::1",
28+
"shardsvr": true,
29+
"port": 27219
30+
}
31+
}
32+
]
33+
}
34+
}
35+
],
36+
"routers": [
37+
{
38+
"ipv6": true,
39+
"bind_ip": "127.0.0.1,::1",
40+
"port": 27017,
41+
"setParameter": {
42+
"loadBalancerPort": 27050
43+
}
44+
},
45+
{
46+
"ipv6": true,
47+
"bind_ip": "127.0.0.1,::1",
48+
"port": 27018,
49+
"setParameter": {
50+
"loadBalancerPort": 27051
51+
}
52+
}
53+
]
54+
}
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
{
2+
"id": "shard_cluster_1",
3+
"shards": [
4+
{
5+
"id": "sh01",
6+
"shardParams": {
7+
"members": [
8+
{
9+
"procParams": {
10+
"ipv6": true,
11+
"bind_ip": "127.0.0.1,::1",
12+
"shardsvr": true,
13+
"port": 27217
14+
}
15+
},
16+
{
17+
"procParams": {
18+
"ipv6": true,
19+
"bind_ip": "127.0.0.1,::1",
20+
"shardsvr": true,
21+
"port": 27218
22+
}
23+
},
24+
{
25+
"procParams": {
26+
"ipv6": true,
27+
"bind_ip": "127.0.0.1,::1",
28+
"shardsvr": true,
29+
"port": 27219
30+
}
31+
}
32+
]
33+
}
34+
}
35+
],
36+
"routers": [
37+
{
38+
"ipv6": true,
39+
"bind_ip": "127.0.0.1,::1",
40+
"port": 27017,
41+
"setParameter": {
42+
"loadBalancerPort": 27050
43+
}
44+
},
45+
{
46+
"ipv6": true,
47+
"bind_ip": "127.0.0.1,::1",
48+
"port": 27018,
49+
"setParameter": {
50+
"loadBalancerPort": 27051
51+
}
52+
}
53+
],
54+
"sslParams": {
55+
"sslOnNormalPorts": true,
56+
"sslPEMKeyFile": "/tmp/orchestration-home/server.pem",
57+
"sslCAFile": "/tmp/orchestration-home/ca.pem",
58+
"sslWeakCertificateValidation" : true
59+
}
60+
}

src/libmongoc/src/mongoc/mongoc-server-description-private.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -241,10 +241,4 @@ bool
241241
mongoc_server_description_has_service_id (
242242
const mongoc_server_description_t *description);
243243

244-
/* mongoc_global_mock_service_id is only used for testing. The test runner sets
245-
* this to true when testing against a load balanced deployment to mock the
246-
* presence of a serviceId field in the "hello" response. The purpose of this is
247-
* further described in the Load Balancer test README. */
248-
extern bool mongoc_global_mock_service_id;
249-
250244
#endif

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

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,6 @@ static bson_oid_t kObjectIdZero = {{0}};
3535

3636
const bson_oid_t kZeroServiceId = {{0}};
3737

38-
bool mongoc_global_mock_service_id = false;
39-
4038
static bool
4139
_match_tag_set (const mongoc_server_description_t *sd,
4240
bson_iter_t *tag_set_iter);
@@ -745,16 +743,6 @@ mongoc_server_description_handle_hello (mongoc_server_description_t *sd,
745743
}
746744
}
747745

748-
749-
if (mongoc_global_mock_service_id) {
750-
bson_iter_t pid_iter;
751-
752-
if (bson_iter_init_find (&pid_iter, &sd->topology_version, "processId") &&
753-
BSON_ITER_HOLDS_OID (&pid_iter)) {
754-
bson_oid_copy (bson_iter_oid (&pid_iter), &sd->service_id);
755-
}
756-
}
757-
758746
if (is_shard) {
759747
sd->type = MONGOC_SERVER_MONGOS;
760748
} else if (sd->set_name) {

0 commit comments

Comments
 (0)