2018-03-27 14:30:46 -04:00
|
|
|
"""The unittest.TestCase for mongos --test."""
|
2017-06-14 20:44:52 -04:00
|
|
|
|
2024-10-10 10:59:18 -07:00
|
|
|
from buildscripts.resmokelib import config, core, logging, utils
|
2020-06-17 17:41:54 +03:00
|
|
|
from buildscripts.resmokelib.testing.testcases import interface
|
2017-06-14 20:44:52 -04:00
|
|
|
|
|
|
|
|
|
2018-03-06 16:28:23 -05:00
|
|
|
class MongosTestCase(interface.ProcessTestCase):
|
2018-03-27 14:30:46 -04:00
|
|
|
"""A TestCase which runs a mongos binary with the given parameters."""
|
2017-06-14 20:44:52 -04:00
|
|
|
|
|
|
|
|
REGISTERED_NAME = "mongos_test"
|
|
|
|
|
|
2025-03-11 16:39:51 -04:00
|
|
|
def __init__(self, logger: logging.Logger, mongos_options: list[dict]):
|
2018-03-27 14:30:46 -04:00
|
|
|
"""Initialize the mongos test and saves the options."""
|
2017-06-14 20:44:52 -04:00
|
|
|
|
2025-03-11 16:39:51 -04:00
|
|
|
assert len(mongos_options) == 1
|
|
|
|
|
|
2024-05-16 18:00:17 -04:00
|
|
|
self.mongos_executable = utils.default_if_none(
|
|
|
|
|
config.MONGOS_EXECUTABLE, config.DEFAULT_MONGOS_EXECUTABLE
|
|
|
|
|
)
|
2017-06-14 20:44:52 -04:00
|
|
|
# Use the executable as the test name.
|
2018-03-06 16:28:23 -05:00
|
|
|
interface.ProcessTestCase.__init__(self, logger, "mongos test", self.mongos_executable)
|
2025-03-11 16:39:51 -04:00
|
|
|
self.options = mongos_options[0].copy()
|
2017-06-14 20:44:52 -04:00
|
|
|
|
|
|
|
|
def configure(self, fixture, *args, **kwargs):
|
2018-03-27 14:30:46 -04:00
|
|
|
"""Ensure the --test option is present in the mongos options."""
|
2017-06-14 20:44:52 -04:00
|
|
|
|
2018-03-07 11:54:58 -05:00
|
|
|
interface.ProcessTestCase.configure(self, fixture, *args, **kwargs)
|
2017-06-14 20:44:52 -04:00
|
|
|
# Always specify test option to ensure the mongos will terminate.
|
|
|
|
|
if "test" not in self.options:
|
|
|
|
|
self.options["test"] = ""
|
|
|
|
|
|
|
|
|
|
def _make_process(self):
|
2024-05-16 18:00:17 -04:00
|
|
|
return core.programs.mongos_program(
|
2025-03-08 16:03:58 -05:00
|
|
|
self.logger,
|
|
|
|
|
self.fixture.job_num,
|
|
|
|
|
executable=self.mongos_executable,
|
|
|
|
|
mongos_options=self.options,
|
|
|
|
|
)[0]
|