File tree Expand file tree Collapse file tree 2 files changed +20
-1
lines changed
st2reactor/st2reactor/cmd Expand file tree Collapse file tree 2 files changed +20
-1
lines changed Original file line number Diff line number Diff line change 7070 Contributed by @amanda11
7171* Ensure `.pth ` files in the st2 virtualenv get loaded by pack virtualenvs. #6183
7272 Contributed by @cognifloyd
73+ * Allow `st2-rule-tester ` to run without a mongo connection if user is testing against local `rule `/`trigger-instance ` files. #6208
74+ Contributed by @jk464
7375
7476* Added a `get_result ` method to the `ExecutionResourceManager ` Class for st2client
7577 Contributed by @skiedude
Original file line number Diff line number Diff line change 2121from st2common import config
2222from st2common import log as logging
2323from st2common .config import do_register_cli_opts
24+ from st2common .service_setup import db_setup
2425from st2common .script_setup import setup as common_setup
2526from st2common .script_setup import teardown as common_teardown
2627from st2reactor .rules .tester import RuleTester
@@ -46,13 +47,29 @@ def _register_cli_opts():
4647 default = None ,
4748 help = "Id of the Trigger Instance to use for validation." ,
4849 ),
50+ cfg .BoolOpt (
51+ "offline" ,
52+ default = False ,
53+ help = "Run st2-rule-tester without DB connection - can only be used in connection with 'rule' and 'trigger-instance' options" ,
54+ ),
4955 ]
5056 do_register_cli_opts (cli_opts )
5157
5258
5359def main ():
5460 _register_cli_opts ()
55- common_setup (config = config , setup_db = True , register_mq_exchanges = False )
61+
62+ common_setup (config = config , setup_db = False , register_mq_exchanges = False )
63+
64+ # Setup DB if not running offline
65+ if not cfg .CONF .offline :
66+ db_setup ()
67+ # If running offline check that neither rule_ref or trigger_instance_id are provided as they require the DB.
68+ elif cfg .CONF .rule_ref or cfg .CONF .trigger_instance_id :
69+ LOG .critical (
70+ "'rule-ref' and/or 'trigger-instance-id' cannot be used in 'offline' mode"
71+ )
72+ sys .exit (2 )
5673
5774 try :
5875 tester = RuleTester (
You can’t perform that action at this time.
0 commit comments