-
Notifications
You must be signed in to change notification settings - Fork 140
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#173 Migratig integration tests to OSS repo
* Python modules Signed-off-by: Jean-Louis Leroy <[email protected]> * Integration tests Signed-off-by: Jean-Louis Leroy <[email protected]> * rename Signed-off-by: Jean-Louis Leroy <[email protected]> * simplify Signed-off-by: Jean-Louis Leroy <[email protected]> * adapt tests Signed-off-by: Jean-Louis Leroy <[email protected]> * workspace -> configurator Signed-off-by: Jean-Louis Leroy <[email protected]> * build.yaml Signed-off-by: Jean-Louis Leroy <[email protected]> --------- Signed-off-by: Jean-Louis Leroy <[email protected]>
- Loading branch information
Showing
71 changed files
with
18,594 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,3 +9,4 @@ CMakeUserPresets.json | |
/.vscode/ | ||
/include/ | ||
/lib/ | ||
**/__pycache__/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# BlazingMQ Integration Tests | ||
|
||
[WIP] | ||
|
||
To run the tests: | ||
|
||
* (create and) activate a Python 3.8 (or above) `venv` | ||
* `python -m venv /path/to/venv` | ||
* `source /path/to/venv/bin/activate` | ||
* install required modules | ||
* `pip install -r src/python/requirements.txt` | ||
* run the tests | ||
* `cd src/integration-tests` | ||
* `./run-tests [extra pytest options]` |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,140 @@ | ||
import contextlib | ||
import logging | ||
import pytest | ||
|
||
import blazingmq.dev.it.logging | ||
import blazingmq.util.logging as bul | ||
from blazingmq.dev.pytest import PYTEST_LOG_SPEC_VAR | ||
|
||
|
||
def pytest_addoption(parser): | ||
# Do this here so the 'TRACE' level is available in the command line | ||
# switches. | ||
logging.TRACE = logging.DEBUG - 1 | ||
logging.addLevelName(logging.TRACE, "TRACE") | ||
|
||
help_ = "put combined broker logs and client outputs for failed tests in DIR" | ||
parser.addoption( | ||
"--bmq-log-dir", dest="bmq_log_dir", action="store", metavar="DIR", help=help_ | ||
) | ||
parser.addini("bmq_log_dir", help_, type=None, default=None) | ||
|
||
help_ = "use POLICY in cluster configuration where available" | ||
parser.addoption( | ||
"--bmq-cluster-policy", | ||
dest="bmq_cluster_policy", | ||
action="store", | ||
metavar="POLICY", | ||
help=help_, | ||
) | ||
parser.addini("bmq_cluster_policy", help_, type=None, default=None) | ||
|
||
help_ = "tack ARGS at the end of the bmqbrkr command line" | ||
parser.addoption( | ||
"--bmq-broker-extra-args", | ||
dest="bmq_broker_extra_args", | ||
action="store", | ||
metavar="ARGS", | ||
help=help_, | ||
) | ||
parser.addini("bmq_broker_extra_args", help_, type=None, default=None) | ||
|
||
help_ = "always keep logs" | ||
parser.addoption( | ||
"--bmq-keep-logs", | ||
dest="bmq_keep_logs", | ||
action="store_true", | ||
default=False, | ||
help=help_, | ||
) | ||
parser.addini("bmq_keep_logs", help_, type=None, default=None) | ||
|
||
help_ = "do not delete work directory after test finishes" | ||
parser.addoption( | ||
"--bmq-keep-work-dirs", | ||
dest="bmq_keep_work_dirs", | ||
action="store_true", | ||
default=False, | ||
help=help_, | ||
) | ||
parser.addini("bmq_keep_work_dirs", help_, type=None, default=None) | ||
|
||
help_ = "break before test begins - NOTE: requires -s, no docker, no parallelism" | ||
parser.addoption( | ||
"--bmq-break-before-test", | ||
dest="bmq_break_before_test", | ||
action="store_true", | ||
default=False, | ||
help=help_, | ||
) | ||
|
||
help_ = "do not report process crashes or errors during shutdown" | ||
parser.addoption( | ||
"--bmq-tolerate-dirty-shutdown", | ||
dest="bmq_tolerate_dirty_shutdown", | ||
action="store_true", | ||
default=False, | ||
help=help_, | ||
) | ||
parser.addini("bmq_tolerate_dirty_shutdown", help_, type=None, default=False) | ||
|
||
with contextlib.suppress(Exception): | ||
help_ = "set per-category log level" | ||
parser.addoption( | ||
"--bmq-log-level", | ||
dest=PYTEST_LOG_SPEC_VAR, | ||
action="store", | ||
default=[], | ||
metavar="LEVEL", | ||
help=help_, | ||
) | ||
parser.addini(PYTEST_LOG_SPEC_VAR, help_, type=None, default=None) | ||
|
||
help_ = "run only with the specified order" | ||
parser.addoption( | ||
"--bmq-wave", | ||
type=int, | ||
action="store", | ||
metavar="WAVE", | ||
help=help_, | ||
) | ||
|
||
|
||
def pytest_configure(config): | ||
logging.setLoggerClass(blazingmq.dev.it.logging.BMQLogger) | ||
|
||
level_spec = config.getoption(PYTEST_LOG_SPEC_VAR) or config.getini( | ||
PYTEST_LOG_SPEC_VAR | ||
) | ||
|
||
if level_spec: | ||
levels = bul.normalize_log_levels(level_spec) | ||
bul.apply_normalized_log_levels(levels) | ||
top_level = levels[0] | ||
logging.getLogger("proc").setLevel(top_level) | ||
logging.getLogger("test").setLevel(top_level) | ||
|
||
|
||
def pytest_collection_modifyitems(config, items): | ||
active_wave = config.getoption("bmq_wave") | ||
if active_wave is None: | ||
return | ||
|
||
for item in items: | ||
mark = None | ||
for mark in item.iter_markers(name="order"): | ||
pass | ||
|
||
if mark is None: | ||
order = 0 | ||
else: | ||
order = int(mark.args[0]) | ||
|
||
if order == active_wave: | ||
continue | ||
|
||
item.add_marker( | ||
pytest.mark.skip( | ||
reason=f"order = {order}, running {active_wave} only" | ||
) | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
[MASTER] | ||
disable=attribute-defined-outside-init,disallowed-name,duplicate-code,fixme,invalid-name,line-too-long,missing-class-docstring,missing-function-docstring,missing-module-docstring,redefined-outer-name,too-few-public-methods,too-many-arguments,too-many-branches,too-many-instance-attributes,too-many-lines,too-many-locals,too-many-public-methods,too-many-statements |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
[pytest] | ||
log_cli_format = %(bmqprocess)-16s %(filename)s:%(lineno)d %(message)s | ||
log_level = INFO | ||
log_format = %(bmqprocess16)s %(asctime)s.%(msecs)03d (%(thread)15d) %(levelname)-8s %(name24)s %(filename)10s:%(lineno)-03d %(message)s | ||
log_file_format = %(bmqprocess16)s %(asctime)s.%(msecs)03d (%(thread)15d) %(levelname)-8s %(name24)s %(filename)10s:%(lineno)-03d %(message)s | ||
log_file_level = INFO | ||
log_file_date_format = %d%b%Y_%H:%M:%S | ||
addopts = --strict-markers -p no:cacheprovider | ||
junit_family = legacy | ||
markers = | ||
integrationtest | ||
quick_integrationtest | ||
pr_integrationtest | ||
single | ||
multi | ||
csl_mode | ||
fsm_mode | ||
flakey |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#! /usr/bin/env bash | ||
|
||
set -e | ||
|
||
repo_dir=$(realpath "$0") | ||
repo_dir=${repo_dir%/src/*} | ||
|
||
export PYTHONPATH=$repo_dir/src/python:$PYTHONPATH | ||
cd "$repo_dir/src/integration-tests" | ||
|
||
python -m pytest -m "not csl_mode and not fsm_mode" "$@" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
""" | ||
This suite of test cases exercises admin session connection and some basic | ||
commands. | ||
""" | ||
|
||
import json | ||
import re | ||
|
||
from blazingmq.dev.it.fixtures import Cluster, single_node, order # pylint: disable=unused-import | ||
from blazingmq.dev.it.process.admin import AdminClient | ||
|
||
|
||
def test_admin(single_node: Cluster): | ||
cluster: Cluster = single_node | ||
endpoint: str = cluster.config.definition.nodes[0].transport.tcp.endpoint # type: ignore | ||
|
||
# Extract the (host, port) pair from the config | ||
m = re.match(r".+://(.+):(\d+)", endpoint) # tcp://host:port | ||
assert m is not None | ||
host, port = str(m.group(1)), int(m.group(2)) | ||
|
||
# Start the admin client | ||
admin = AdminClient() | ||
admin.connect(host, port) | ||
|
||
# Check basic "help" command | ||
assert ( | ||
"This process responds to the following CMD subcommands:" | ||
in admin.send_admin("help") | ||
) | ||
|
||
# Check non-existing "invalid cmd" command | ||
assert "Unable to decode command" in admin.send_admin("invalid cmd") | ||
|
||
# Check more complex "brokerconfig dump" command, expect valid json | ||
# with the same "port" value as the one used for this connection | ||
broker_config_str = admin.send_admin("brokerconfig dump") | ||
broker_config = json.loads(broker_config_str) | ||
|
||
assert broker_config["networkInterfaces"]["tcpInterface"]["port"] == port | ||
|
||
# Stop the admin session | ||
admin.stop() |
Oops, something went wrong.