To support threading mode in the applier, this patch switches taskflow
engine to serial when eventlet is not patched. This avoids an issue
caused by the multiple threads reading/writing Action objects when
running with parallel engine. This limitation should be adressed in
a different patch which may also require a refactoring in database api
and how watcher manages its sessions and contexts.
Changes:
1. Add InlineThread class
- Executes functions synchronously while maintaining thread interface
2. Use serial engine for threading mode
- Switches to taskflow serial engine when eventlet is not patched
3. Replace default GreenThreadPoolExecutor in TriggerActionPlan
- A new executor will be created based on the thread mode configured
4. Adds helper functions to spawn, start, wait and kill threads
- The thread will be handled based on the thread mode configured
5. Threading mode job and tox-threading updated to include applier
- These jobs will now enable threading mode for the applier content
and service
Assisted-By: claude-code sonnet-4.5
Co-Authored-By: Sean Mooney <work@seanmooney.info>
Change-Id: I85926cdd1e4393be42fe6d543af50bf2948b5ce6
Signed-off-by: Douglas Viroel <viroel@gmail.com>
161 lines
4.2 KiB
INI
161 lines
4.2 KiB
INI
[tox]
|
|
minversion = 3.18.0
|
|
envlist = py3,pep8
|
|
ignore_basepython_conflict = True
|
|
|
|
[testenv]
|
|
basepython = python3
|
|
usedevelop = True
|
|
allowlist_externals = find
|
|
rm
|
|
install_command = pip install -c{env:TOX_CONSTRAINTS_FILE:https://releases.openstack.org/constraints/upper/master} {opts} {packages}
|
|
setenv =
|
|
VIRTUAL_ENV={envdir}
|
|
OS_STDOUT_CAPTURE=1
|
|
OS_STDERR_CAPTURE=1
|
|
OS_TEST_TIMEOUT=30
|
|
PYTHONDONTWRITEBYTECODE=1
|
|
# Optionally install package extras via environment variable, e.g. WATCHER_EXTRAS=monasca tox -e py3
|
|
extras = {env:WATCHER_EXTRAS:}
|
|
deps =
|
|
-r{toxinidir}/test-requirements.txt
|
|
-r{toxinidir}/requirements.txt
|
|
python-libmaas>=0.6.8
|
|
commands =
|
|
rm -f .testrepository/times.dbm
|
|
find . -type f -name "*.py[c|o]" -delete
|
|
stestr run {posargs}
|
|
passenv =
|
|
http_proxy
|
|
HTTP_PROXY
|
|
https_proxy
|
|
HTTPS_PROXY
|
|
no_proxy
|
|
NO_PROXY
|
|
OS_DEBUG
|
|
# NOTE(sean-k-mooney) optimization is enabled by default and when enabled
|
|
# asserts are complied out. Disable optimization to allow asserts in
|
|
# nova to fire in unit and functional tests. This can be useful for
|
|
# debugging issue with fixtures and mocks.
|
|
PYTHONOPTIMIZE
|
|
|
|
[testenv:py3-threading]
|
|
setenv =
|
|
OS_WATCHER_DISABLE_EVENTLET_PATCHING=true
|
|
commands =
|
|
rm -f .testrepository/times.dbm
|
|
find . -type f -name "*.py[c|o]" -delete
|
|
stestr run {posargs}
|
|
|
|
[testenv:pep8]
|
|
description =
|
|
Run style checks.
|
|
skip_install = true
|
|
deps =
|
|
pre-commit
|
|
commands =
|
|
pre-commit run --all-files --show-diff-on-failure
|
|
|
|
|
|
[testenv:venv]
|
|
setenv = PYTHONHASHSEED=0
|
|
deps =
|
|
-r{toxinidir}/doc/requirements.txt
|
|
-r{toxinidir}/test-requirements.txt
|
|
-r{toxinidir}/requirements.txt
|
|
commands = {posargs}
|
|
|
|
[testenv:cover]
|
|
setenv =
|
|
PYTHON=coverage run --source watcher --parallel-mode
|
|
commands =
|
|
stestr run {posargs}
|
|
coverage combine
|
|
coverage html -d cover
|
|
coverage xml -o cover/coverage.xml
|
|
coverage report
|
|
|
|
[testenv:docs]
|
|
setenv = PYTHONHASHSEED=0
|
|
deps =
|
|
-r{toxinidir}/doc/requirements.txt
|
|
commands =
|
|
rm -fr doc/build doc/source/api/ .autogenerated
|
|
sphinx-build -W --keep-going -b html doc/source doc/build/html
|
|
|
|
[testenv:api-ref]
|
|
deps = -r{toxinidir}/doc/requirements.txt
|
|
allowlist_externals = bash
|
|
commands =
|
|
bash -c 'rm -rf api-ref/build'
|
|
sphinx-build -W --keep-going -b html -d api-ref/build/doctrees api-ref/source api-ref/build/html
|
|
|
|
[testenv:debug]
|
|
commands = oslo_debug_helper -t watcher/tests {posargs}
|
|
|
|
[testenv:genconfig]
|
|
sitepackages = False
|
|
commands =
|
|
oslo-config-generator --config-file etc/watcher/oslo-config-generator/watcher.conf
|
|
|
|
[testenv:genpolicy]
|
|
commands =
|
|
oslopolicy-sample-generator --config-file etc/watcher/oslo-policy-generator/watcher-policy-generator.conf
|
|
|
|
[testenv:wheel]
|
|
commands = python setup.py bdist_wheel
|
|
|
|
[testenv:pdf-docs]
|
|
deps = {[testenv:docs]deps}
|
|
allowlist_externals =
|
|
rm
|
|
make
|
|
commands =
|
|
rm -rf doc/build/pdf
|
|
sphinx-build -W --keep-going -b latex doc/source doc/build/pdf
|
|
make -C doc/build/pdf
|
|
|
|
[testenv:releasenotes]
|
|
deps = {[testenv:docs]deps}
|
|
commands =
|
|
rm -rf releasenotes/build
|
|
sphinx-build -W --keep-going -b html -j auto releasenotes/source releasenotes/build/html
|
|
|
|
[testenv:bandit]
|
|
skip_install = true
|
|
deps = {[testenv:pep8]deps}
|
|
commands =
|
|
pre-commit run --all-files --show-diff-on-failure bandit
|
|
|
|
[flake8]
|
|
filename = *.py,app.wsgi
|
|
show-source=True
|
|
# W504 line break after binary operator
|
|
ignore= H105,E123,E226,N320,H202,W504
|
|
builtins= _
|
|
enable-extensions = H106,H203,H904
|
|
exclude=.venv,.git,.tox,dist,doc,*lib/python*,*egg,build,*sqlalchemy/alembic/versions/*,demo/,releasenotes
|
|
|
|
[hacking]
|
|
import_exceptions = watcher._i18n
|
|
|
|
[flake8:local-plugins]
|
|
extension =
|
|
N319 = checks:no_translate_debug_logs
|
|
N321 = checks:use_jsonutils
|
|
N322 = checks:check_assert_called_once_with
|
|
N325 = checks:check_python3_xrange
|
|
N326 = checks:check_no_basestring
|
|
N327 = checks:check_python3_no_iteritems
|
|
N328 = checks:check_asserttrue
|
|
N329 = checks:check_assertfalse
|
|
N330 = checks:check_assertempty
|
|
N331 = checks:check_assertisinstance
|
|
N332 = checks:check_assertequal_for_httpcode
|
|
N333 = checks:check_log_warn_deprecated
|
|
N340 = checks:check_oslo_i18n_wrapper
|
|
N341 = checks:check_builtins_gettext
|
|
N342 = checks:no_redundant_import_alias
|
|
N366 = checks:import_stock_mock
|
|
paths = ./watcher/hacking
|