Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Speed up unit tests by adding default parallelism #164

Merged
merged 3 commits into from
May 18, 2021
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
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion requirements-dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
12 changes: 6 additions & 6 deletions tests/base_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 :-)
Expand All @@ -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 == [
Expand All @@ -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 :-)
Expand All @@ -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 == [
Expand Down
2 changes: 1 addition & 1 deletion tests/loaders_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See here for more information on why the message has been removed.

with pytest.raises(EAException):
rules = load_conf(test_args)
rules['rules'] = rules['rules_loader'].load(rules)

Expand Down
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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 .

Expand Down