Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 2 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ Added
Contributed by @amanda11
* Ensure `.pth` files in the st2 virtualenv get loaded by pack virtualenvs. #6183
Contributed by @cognifloyd
* Allow `st2-rule-tester` to run without a mongo connection if user is testing against local `rule`/`trigger-instance` files. #6208
Contributed by @jk464

* Added a `get_result` method to the `ExecutionResourceManager` Class for st2client
Contributed by @skiedude
Expand Down
19 changes: 18 additions & 1 deletion st2reactor/st2reactor/cmd/rule_tester.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
from st2common import config
from st2common import log as logging
from st2common.config import do_register_cli_opts
from st2common.service_setup import db_setup
from st2common.script_setup import setup as common_setup
from st2common.script_setup import teardown as common_teardown
from st2reactor.rules.tester import RuleTester
Expand All @@ -46,13 +47,29 @@ def _register_cli_opts():
default=None,
help="Id of the Trigger Instance to use for validation.",
),
cfg.BoolOpt(
"offline",
default=False,
help="Run st2-rule-tester without DB connection - can only be used in connection with 'rule' and 'trigger-instance' options",
),
]
do_register_cli_opts(cli_opts)


def main():
_register_cli_opts()
common_setup(config=config, setup_db=True, register_mq_exchanges=False)

common_setup(config=config, setup_db=False, register_mq_exchanges=False)

# Setup DB if not running offline
if not cfg.CONF.offline:
db_setup()
# If running offline check that neither rule_ref or trigger_instance_id are provided as they require the DB.
elif cfg.CONF.rule_ref or cfg.CONF.trigger_instance_id:
LOG.critical(
"'rule-ref' and/or 'trigger-instance-id' cannot be used in 'offline' mode"
)
sys.exit(2)

try:
tester = RuleTester(
Expand Down