Skip to content

Commit 82d593a

Browse files
CDRIVER-4645 migrate and run load balancer tests (#1414)
* run simple_http_server.py on port 18000 Port 8000 conflicts with HAProxy started by run-load-balancer.sh in DET * update load_balancers specification tests Update to commit mongodb/specifications@5af2ab7 to fix test failure when an error is expected. * use `hello`, not `isMaster` in test failpoint * add new loadbalanced Evg config * remove legacy load balanced config * regenerate Evergreen config * Sort imports Co-authored-by: Ezra Chung <[email protected]>
1 parent 8b919c3 commit 82d593a

File tree

18 files changed

+580
-501
lines changed

18 files changed

+580
-501
lines changed
Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
from shrub.v3.evg_build_variant import BuildVariant
2+
from shrub.v3.evg_command import EvgCommandType, FunctionCall, expansions_update
3+
from shrub.v3.evg_task import EvgTaskRef, EvgTaskDependency
4+
5+
from config_generator.components.funcs.bootstrap_mongo_orchestration import BootstrapMongoOrchestration
6+
from config_generator.components.funcs.fetch_build import FetchBuild
7+
from config_generator.components.funcs.fetch_det import FetchDET
8+
from config_generator.components.funcs.run_simple_http_server import RunSimpleHTTPServer
9+
from config_generator.components.funcs.run_tests import RunTests
10+
from config_generator.components.funcs.upload_build import UploadBuild
11+
from config_generator.etc.distros import make_distro_str, find_small_distro, find_large_distro
12+
from config_generator.etc.utils import Task, bash_exec
13+
14+
# Use `rhel8.7` distro. `rhel8.7` distro includes necessary dependency: `haproxy`.
15+
_DISTRO_NAME = "rhel87"
16+
_COMPILER = "gcc"
17+
18+
19+
def functions():
20+
return {
21+
'start-load-balancer': [
22+
bash_exec(
23+
command_type=EvgCommandType.SETUP,
24+
script='''\
25+
export DRIVERS_TOOLS=./drivers-evergreen-tools
26+
export MONGODB_URI="${MONGODB_URI}"
27+
$DRIVERS_TOOLS/.evergreen/run-load-balancer.sh start
28+
''',
29+
),
30+
expansions_update(
31+
command_type=EvgCommandType.SETUP,
32+
file='lb-expansion.yml',
33+
)
34+
]
35+
}
36+
37+
38+
def make_test_task(auth: bool, ssl: bool, server_version: str):
39+
auth_str = "auth" if auth else "noauth"
40+
ssl_str = "openssl" if ssl else "nossl"
41+
distro_str = make_distro_str(_DISTRO_NAME, _COMPILER, None)
42+
return Task(
43+
name=f"loadbalanced-{distro_str}-test-{server_version}-{auth_str}-{ssl_str}",
44+
depends_on=[EvgTaskDependency(
45+
name=f"loadbalanced-{distro_str}-compile")],
46+
run_on=find_small_distro(_DISTRO_NAME).name,
47+
tags=['loadbalanced', _DISTRO_NAME, _COMPILER, auth_str, ssl_str],
48+
commands=[
49+
FetchBuild.call(build_name=f"loadbalanced-{distro_str}-compile"),
50+
FetchDET.call(),
51+
BootstrapMongoOrchestration().call(vars={
52+
'AUTH': auth_str,
53+
'SSL': ssl_str,
54+
'MONGODB_VERSION': server_version,
55+
'TOPOLOGY': 'sharded_cluster',
56+
'LOAD_BALANCER': 'on',
57+
}),
58+
RunSimpleHTTPServer.call(),
59+
FunctionCall(func='start-load-balancer', vars={
60+
'MONGODB_URI': 'mongodb://localhost:27017,localhost:27018'
61+
}),
62+
RunTests().call(vars={
63+
'AUTH': auth_str,
64+
'SSL': ssl_str,
65+
'LOADBALANCED': 'loadbalanced',
66+
'CC': _COMPILER,
67+
})
68+
],
69+
)
70+
71+
72+
def tasks():
73+
distro_str = make_distro_str(_DISTRO_NAME, _COMPILER, None)
74+
yield Task(
75+
name=f"loadbalanced-{distro_str}-compile",
76+
run_on=find_large_distro(_DISTRO_NAME).name,
77+
tags=['loadbalanced', _DISTRO_NAME, _COMPILER],
78+
commands=[
79+
bash_exec(
80+
command_type=EvgCommandType.TEST,
81+
env={
82+
'CC': _COMPILER,
83+
'CFLAGS': '-fno-omit-frame-pointer',
84+
'EXTRA_CONFIGURE_FLAGS': '-DENABLE_EXTRA_ALIGNMENT=OFF',
85+
'SSL': 'OPENSSL'
86+
},
87+
working_dir='mongoc',
88+
script='.evergreen/scripts/compile.sh',
89+
),
90+
UploadBuild.call()
91+
],
92+
)
93+
94+
# Satisfy requirements specified in
95+
# https://github.com/mongodb/specifications/blob/14916f76fd92b2686d8e3d1f0e4c2d2ef88ca5a7/source/load-balancers/tests/README.rst#testing-requirements
96+
#
97+
# > For each server version that supports load balanced clusters, drivers
98+
# > MUST add two Evergreen tasks: one with a sharded cluster with both
99+
# > authentication and TLS enabled and one with a sharded cluster with
100+
# > authentication and TLS disabled.
101+
server_versions = ['5.0', '6.0', '7.0', 'latest']
102+
for server_version in server_versions:
103+
yield make_test_task(auth=False, ssl=False, server_version=server_version)
104+
yield make_test_task(auth=True, ssl=True, server_version=server_version)
105+
106+
107+
def variants():
108+
return [
109+
BuildVariant(
110+
name="loadbalanced",
111+
display_name="loadbalanced",
112+
tasks=[EvgTaskRef(name='.loadbalanced')]
113+
),
114+
]

.evergreen/config_generator/etc/cse/test.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,10 @@ def generate_test_tasks(SSL, TAG, MATRIX):
4141

4242
for auth, topology, server_ver in product(auths, topologies, server_vers):
4343
test_tags = tags + [auth, topology, server_ver]
44-
44+
# Do not add `nossl` tag to prevent being selected by legacy config variants.
45+
# Remove the `if` when CDRIVER-4571 is resolved.
46+
if SSL != 'nossl':
47+
test_tags += [SSL]
4548
test_task_name = f'cse-sasl-{sasl}-{SSL}-{distro_str}-test-{server_ver}-{topology}-{auth}'
4649

4750
test_commands = []

.evergreen/config_generator/etc/distros.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,8 @@ def validate_os_ver(cls, value):
8080
Distro(name='rhel80-small', os='rhel', os_type='linux', os_ver='8.0', size='small'),
8181
Distro(name='rhel84-large', os='rhel', os_type='linux', os_ver='8.4', size='large'),
8282
Distro(name='rhel84-small', os='rhel', os_type='linux', os_ver='8.4', size='small'),
83+
Distro(name='rhel87-large', os='rhel', os_type='linux', os_ver='8.7', size='large'),
84+
Distro(name='rhel87-small', os='rhel', os_type='linux', os_ver='8.7', size='small'),
8385
Distro(name='rhel90-large', os='rhel', os_type='linux', os_ver='9.0', size='large'),
8486
Distro(name='rhel90-small', os='rhel', os_type='linux', os_ver='9.0', size='small'),
8587
]
@@ -191,7 +193,7 @@ def validate_os_ver(cls, value):
191193
WINDOWS_DISTROS
192194

193195

194-
def find_distro(name):
196+
def find_distro(name) -> Distro:
195197
candidates = [d for d in ALL_DISTROS if name == d.name]
196198

197199
if not candidates:
@@ -200,7 +202,7 @@ def find_distro(name):
200202
return candidates[0]
201203

202204

203-
def find_large_distro(name):
205+
def find_large_distro(name) -> Distro:
204206
candidates = [d for d in ALL_DISTROS if f'{name}-large' == d.name]
205207

206208
if candidates:
@@ -209,7 +211,7 @@ def find_large_distro(name):
209211
return find_distro(name)
210212

211213

212-
def find_small_distro(name):
214+
def find_small_distro(name) -> Distro:
213215
candidates = [d for d in ALL_DISTROS if f'{name}-small' == d.name]
214216

215217
if candidates:
@@ -218,7 +220,7 @@ def find_small_distro(name):
218220
return find_distro(name)
219221

220222

221-
def make_distro_str(distro_name, compiler, arch):
223+
def make_distro_str(distro_name, compiler, arch) -> str:
222224
if distro_name.startswith('windows-vsCurrent'):
223225
# Rename `windows-vsCurrent-*` distros to `windows-<year>` where`<year>`
224226
# is the Windows Server version used by the distro, e.g.:

.evergreen/config_generator/etc/sanitizers/test.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,10 @@ def generate_test_tasks(SSL, TAG, MATRIX, MORE_COMPILE_TAGS=None, MORE_TEST_TAGS
5555

5656
for auth, topology, server_ver in product(auths, topologies, server_vers):
5757
test_tags = tags + [auth, topology, server_ver] + MORE_TEST_TAGS
58+
# Do not add `nossl` tag to prevent being selected by legacy config variants.
59+
# Remove the `if` when CDRIVER-4571 is resolved.
60+
if SSL != 'nossl':
61+
test_tags += [SSL]
5862
test_task_name = f'{base_task_name}-test-{server_ver}-{topology}-{auth}'
5963

6064
for tag in MORE_TEST_TAGS:

.evergreen/config_generator/etc/sasl/test.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,10 @@ def generate_test_tasks(SSL, TAG, MATRIX):
4141

4242
for auth, topology, server_ver in product(auths, topologies, server_vers):
4343
test_tags = tags + [f'sasl-{sasl}', auth, topology, server_ver]
44+
# Do not add `nossl` tag to prevent being selected by legacy config variants.
45+
# Remove the `if` when CDRIVER-4571 is resolved.
46+
if SSL != 'nossl':
47+
test_tags += [SSL]
4448

4549
test_task_name = f'sasl-{sasl}-{SSL}-{distro_str}-test-{server_ver}-{topology}-{auth}'
4650

.evergreen/generated_configs/functions.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -473,6 +473,21 @@ functions:
473473
args:
474474
- -c
475475
- .evergreen/scripts/compile-scan-build.sh
476+
start-load-balancer:
477+
- command: subprocess.exec
478+
type: setup
479+
params:
480+
binary: bash
481+
args:
482+
- -c
483+
- |
484+
export DRIVERS_TOOLS=./drivers-evergreen-tools
485+
export MONGODB_URI="${MONGODB_URI}"
486+
$DRIVERS_TOOLS/.evergreen/run-load-balancer.sh start
487+
- command: expansions.update
488+
type: setup
489+
params:
490+
file: lb-expansion.yml
476491
std-compile:
477492
- command: subprocess.exec
478493
type: test

0 commit comments

Comments
 (0)