Skip to content

CDRIVER-4645 migrate and run load balancer tests #1414

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 26 commits into from
Oct 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
fd51edf
run simple_http_server.py on port 18000
kevinAlbs Sep 20, 2023
be45ce6
update load_balancers specification tests
kevinAlbs Sep 25, 2023
10b2e82
use `hello`, not `isMaster` in test failpoint
kevinAlbs Sep 26, 2023
8cfab37
add new loadbalanced Evg config
kevinAlbs Sep 27, 2023
7047bf0
remove legacy load balanced config
kevinAlbs Sep 27, 2023
8005cc1
regenerate Evergreen config
kevinAlbs Sep 27, 2023
7076193
Sort imports
kevinAlbs Sep 28, 2023
7f619d4
Use display name "loadbalanced"
kevinAlbs Sep 28, 2023
40aef90
rename task in order of feature importance
kevinAlbs Sep 28, 2023
d374a60
use dashes, not spaces, in function name
kevinAlbs Sep 28, 2023
f3918c9
use `make_distro_str` and apply to task names
kevinAlbs Sep 28, 2023
36e12f3
add missing 'f'
kevinAlbs Sep 28, 2023
986fbfc
add `rhel8.7` distro entries
kevinAlbs Sep 28, 2023
6abfc32
use `find_small_distro` and `find_large_distro`
kevinAlbs Sep 28, 2023
4f70353
add more task tags
kevinAlbs Sep 28, 2023
c07560f
specify return types in distro helpers
kevinAlbs Sep 28, 2023
e3feca9
add SSL tag to other tasks
kevinAlbs Sep 28, 2023
0d91d63
use `openssl`, not `ssl`
kevinAlbs Sep 28, 2023
75558b4
fix arg to FetchBuild
kevinAlbs Sep 28, 2023
899fafa
regenerate config
kevinAlbs Sep 28, 2023
a1da2d9
fix appending to `test_tags`
kevinAlbs Sep 28, 2023
68f2d97
use alias of `rhel8.7` distro
kevinAlbs Sep 28, 2023
3d3dc64
regenerate config
kevinAlbs Sep 28, 2023
5064560
Merge branch 'master' into CDRIVER-4645.schedule-lb
kevinAlbs Oct 11, 2023
5697708
regenerate config
kevinAlbs Oct 11, 2023
26bc018
use `_COMPILER`
kevinAlbs Oct 11, 2023
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
114 changes: 114 additions & 0 deletions .evergreen/config_generator/components/loadbalanced.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
from shrub.v3.evg_build_variant import BuildVariant
from shrub.v3.evg_command import EvgCommandType, FunctionCall, expansions_update
from shrub.v3.evg_task import EvgTaskRef, EvgTaskDependency

from config_generator.components.funcs.bootstrap_mongo_orchestration import BootstrapMongoOrchestration
from config_generator.components.funcs.fetch_build import FetchBuild
from config_generator.components.funcs.fetch_det import FetchDET
from config_generator.components.funcs.run_simple_http_server import RunSimpleHTTPServer
from config_generator.components.funcs.run_tests import RunTests
from config_generator.components.funcs.upload_build import UploadBuild
from config_generator.etc.distros import make_distro_str, find_small_distro, find_large_distro
from config_generator.etc.utils import Task, bash_exec

# Use `rhel8.7` distro. `rhel8.7` distro includes necessary dependency: `haproxy`.
_DISTRO_NAME = "rhel87"
_COMPILER = "gcc"


def functions():
return {
'start-load-balancer': [
bash_exec(
command_type=EvgCommandType.SETUP,
script='''\
export DRIVERS_TOOLS=./drivers-evergreen-tools
export MONGODB_URI="${MONGODB_URI}"
$DRIVERS_TOOLS/.evergreen/run-load-balancer.sh start
''',
),
expansions_update(
command_type=EvgCommandType.SETUP,
file='lb-expansion.yml',
)
]
}


def make_test_task(auth: bool, ssl: bool, server_version: str):
auth_str = "auth" if auth else "noauth"
ssl_str = "openssl" if ssl else "nossl"
distro_str = make_distro_str(_DISTRO_NAME, _COMPILER, None)
return Task(
name=f"loadbalanced-{distro_str}-test-{server_version}-{auth_str}-{ssl_str}",
depends_on=[EvgTaskDependency(
name=f"loadbalanced-{distro_str}-compile")],
run_on=find_small_distro(_DISTRO_NAME).name,
tags=['loadbalanced', _DISTRO_NAME, _COMPILER, auth_str, ssl_str],
commands=[
FetchBuild.call(build_name=f"loadbalanced-{distro_str}-compile"),
FetchDET.call(),
BootstrapMongoOrchestration().call(vars={
'AUTH': auth_str,
'SSL': ssl_str,
'MONGODB_VERSION': server_version,
'TOPOLOGY': 'sharded_cluster',
'LOAD_BALANCER': 'on',
}),
RunSimpleHTTPServer.call(),
FunctionCall(func='start-load-balancer', vars={
'MONGODB_URI': 'mongodb://localhost:27017,localhost:27018'
}),
RunTests().call(vars={
'AUTH': auth_str,
'SSL': ssl_str,
'LOADBALANCED': 'loadbalanced',
'CC': _COMPILER,
})
],
)


def tasks():
distro_str = make_distro_str(_DISTRO_NAME, _COMPILER, None)
yield Task(
name=f"loadbalanced-{distro_str}-compile",
run_on=find_large_distro(_DISTRO_NAME).name,
tags=['loadbalanced', _DISTRO_NAME, _COMPILER],
commands=[
bash_exec(
command_type=EvgCommandType.TEST,
env={
'CC': _COMPILER,
'CFLAGS': '-fno-omit-frame-pointer',
'EXTRA_CONFIGURE_FLAGS': '-DENABLE_EXTRA_ALIGNMENT=OFF',
'SSL': 'OPENSSL'
},
working_dir='mongoc',
script='.evergreen/scripts/compile.sh',
),
UploadBuild.call()
],
)

# Satisfy requirements specified in
# https://github.com/mongodb/specifications/blob/14916f76fd92b2686d8e3d1f0e4c2d2ef88ca5a7/source/load-balancers/tests/README.rst#testing-requirements
#
# > For each server version that supports load balanced clusters, drivers
# > MUST add two Evergreen tasks: one with a sharded cluster with both
# > authentication and TLS enabled and one with a sharded cluster with
# > authentication and TLS disabled.
server_versions = ['5.0', '6.0', '7.0', 'latest']
for server_version in server_versions:
yield make_test_task(auth=False, ssl=False, server_version=server_version)
yield make_test_task(auth=True, ssl=True, server_version=server_version)


def variants():
return [
BuildVariant(
name="loadbalanced",
display_name="loadbalanced",
tasks=[EvgTaskRef(name='.loadbalanced')]
),
]
5 changes: 4 additions & 1 deletion .evergreen/config_generator/etc/cse/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,10 @@ def generate_test_tasks(SSL, TAG, MATRIX):

for auth, topology, server_ver in product(auths, topologies, server_vers):
test_tags = tags + [auth, topology, server_ver]

# Do not add `nossl` tag to prevent being selected by legacy config variants.
# Remove the `if` when CDRIVER-4571 is resolved.
if SSL != 'nossl':
test_tags += [SSL]
test_task_name = f'cse-sasl-{sasl}-{SSL}-{distro_str}-test-{server_ver}-{topology}-{auth}'

test_commands = []
Expand Down
10 changes: 6 additions & 4 deletions .evergreen/config_generator/etc/distros.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ def validate_os_ver(cls, value):
Distro(name='rhel80-small', os='rhel', os_type='linux', os_ver='8.0', size='small'),
Distro(name='rhel84-large', os='rhel', os_type='linux', os_ver='8.4', size='large'),
Distro(name='rhel84-small', os='rhel', os_type='linux', os_ver='8.4', size='small'),
Distro(name='rhel87-large', os='rhel', os_type='linux', os_ver='8.7', size='large'),
Distro(name='rhel87-small', os='rhel', os_type='linux', os_ver='8.7', size='small'),
Distro(name='rhel90-large', os='rhel', os_type='linux', os_ver='9.0', size='large'),
Distro(name='rhel90-small', os='rhel', os_type='linux', os_ver='9.0', size='small'),
]
Expand Down Expand Up @@ -191,7 +193,7 @@ def validate_os_ver(cls, value):
WINDOWS_DISTROS


def find_distro(name):
def find_distro(name) -> Distro:
candidates = [d for d in ALL_DISTROS if name == d.name]

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


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

if candidates:
Expand All @@ -209,7 +211,7 @@ def find_large_distro(name):
return find_distro(name)


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

if candidates:
Expand All @@ -218,7 +220,7 @@ def find_small_distro(name):
return find_distro(name)


def make_distro_str(distro_name, compiler, arch):
def make_distro_str(distro_name, compiler, arch) -> str:
if distro_name.startswith('windows-vsCurrent'):
# Rename `windows-vsCurrent-*` distros to `windows-<year>` where`<year>`
# is the Windows Server version used by the distro, e.g.:
Expand Down
4 changes: 4 additions & 0 deletions .evergreen/config_generator/etc/sanitizers/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ def generate_test_tasks(SSL, TAG, MATRIX, MORE_COMPILE_TAGS=None, MORE_TEST_TAGS

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

for tag in MORE_TEST_TAGS:
Expand Down
4 changes: 4 additions & 0 deletions .evergreen/config_generator/etc/sasl/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ def generate_test_tasks(SSL, TAG, MATRIX):

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

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

Expand Down
15 changes: 15 additions & 0 deletions .evergreen/generated_configs/functions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -473,6 +473,21 @@ functions:
args:
- -c
- .evergreen/scripts/compile-scan-build.sh
start-load-balancer:
- command: subprocess.exec
type: setup
params:
binary: bash
args:
- -c
- |
export DRIVERS_TOOLS=./drivers-evergreen-tools
export MONGODB_URI="${MONGODB_URI}"
$DRIVERS_TOOLS/.evergreen/run-load-balancer.sh start
- command: expansions.update
type: setup
params:
file: lb-expansion.yml
std-compile:
- command: subprocess.exec
type: test
Expand Down
Loading