diff --git a/CHANGELOG.md b/CHANGELOG.md index c5baaa02..6ce88898 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,17 @@ ## Other changes - None +# Unreleased + +## Breaking changes +- None + +## New features +- None + +## Other changes +- Speed up unit tests by adding default parallelism - [164](https://github.com/jertel/elastalert2/pull/164) - @ferozsalam + # 2.1.0 ## Breaking changes diff --git a/requirements-dev.txt b/requirements-dev.txt index a64fe430..c94d8dc3 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -5,7 +5,8 @@ m2r2 pluggy>=0.12.0 pre-commit pylint<2.9 -pytest<3.7.0 +pytest==6.0.0 +pytest-xdist==2.2.1 setuptools sphinx_rtd_theme tox==3.23.1 diff --git a/tests/base_test.py b/tests/base_test.py index b86498b1..cbb41272 100644 --- a/tests/base_test.py +++ b/tests/base_test.py @@ -1159,7 +1159,7 @@ def test_wait_until_responsive(ea): ] -def test_wait_until_responsive_timeout_es_not_available(ea, capsys): +def test_wait_until_responsive_timeout_es_not_available(ea, caplog): """Bail out if ElasticSearch doesn't (quickly) become responsive.""" # Never becomes responsive :-) @@ -1175,8 +1175,8 @@ def test_wait_until_responsive_timeout_es_not_available(ea, capsys): assert exc.value.code == 1 # Ensure we get useful diagnostics. - output, errors = capsys.readouterr() - assert 'Could not reach ElasticSearch at "es:14900".' in errors + user, level, message = caplog.record_tuples[0] + assert 'Could not reach ElasticSearch at "es:14900".' in message # Slept until we passed the deadline. sleep.mock_calls == [ @@ -1186,7 +1186,7 @@ def test_wait_until_responsive_timeout_es_not_available(ea, capsys): ] -def test_wait_until_responsive_timeout_index_does_not_exist(ea, capsys): +def test_wait_until_responsive_timeout_index_does_not_exist(ea, caplog): """Bail out if ElasticSearch doesn't (quickly) become responsive.""" # Never becomes responsive :-) @@ -1202,8 +1202,8 @@ def test_wait_until_responsive_timeout_index_does_not_exist(ea, capsys): assert exc.value.code == 1 # Ensure we get useful diagnostics. - output, errors = capsys.readouterr() - assert 'Writeback alias "wb_a" does not exist, did you run `elastalert-create-index`?' in errors + user, level, message = caplog.record_tuples[0] + assert 'Writeback alias "wb_a" does not exist, did you run `elastalert-create-index`?' in message # Slept until we passed the deadline. sleep.mock_calls == [ diff --git a/tests/loaders_test.py b/tests/loaders_test.py index 834dbc8c..e93a4f69 100644 --- a/tests/loaders_test.py +++ b/tests/loaders_test.py @@ -348,7 +348,7 @@ def test_raises_on_missing_config(): mock_rule_open.return_value = test_rule_copy with mock.patch('os.walk') as mock_walk: mock_walk.return_value = [('', [], ['testrule.yaml'])] - with pytest.raises(EAException, message='key %s should be required' % key): + with pytest.raises(EAException): rules = load_conf(test_args) rules['rules'] = rules['rules_loader'].load(rules) diff --git a/tox.ini b/tox.ini index 47e62caa..52a8cbbe 100644 --- a/tox.ini +++ b/tox.ini @@ -5,7 +5,7 @@ envlist = py39,docs [testenv] deps = -rrequirements-dev.txt commands = - coverage run --source=elastalert/,tests/ -m pytest --strict {posargs} + coverage run --source=elastalert/,tests/ -m pytest --strict -n 4 {posargs} coverage report -m flake8 .