Skip to content

Commit

Permalink
Tidy test files
Browse files Browse the repository at this point in the history
There are a lot of test-specific files that were in the root of the
repository, which makes the repo structure slightly messy and difficult
to understand.

This moves the test-specific configuration into tests/ and makes other
necessary changes to maintain the build instructions.
  • Loading branch information
ferozsalam committed Jun 20, 2021
1 parent 970c1b0 commit 0365278
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 16 deletions.
11 changes: 6 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,23 @@ production:
@true

docs:
tox -e docs
tox -c tests/tox.ini -e docs

dev: $(LOCAL_CONFIG_DIR) $(LOGS_DIR) install-hooks

install-hooks:
pre-commit install -f --install-hooks

test:
tox
tox -c tests/tox.ini

test-elasticsearch:
tox -- --runelasticsearch
tox -c tests/tox.ini -- --runelasticsearch

test-docker:
docker-compose --project-name elastalert build tox
docker-compose --project-name elastalert run --rm tox tox -- $(filter-out $@,$(MAKECMDGOALS))
docker-compose -f tests/docker-compose.yml --project-name elastalert build tox
docker-compose -f tests/docker-compose.yml --project-name elastalert run --rm tox \
tox -c tests/tox.ini -- $(filter-out $@,$(MAKECMDGOALS))

clean:
make -C docs clean
Expand Down
3 changes: 2 additions & 1 deletion requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
-r requirements.txt
docutils<0.17
pytest-cov==2.12.1
flake8
flake8-absolute-import
m2r2
pluggy>=0.12.0
pre-commit
pylint<2.9
pytest==6.2.4
pytest-cov==2.12.1
pytest-xdist==2.3.0
setuptools
sphinx==4.0.2
sphinx_rtd_theme
tox==3.23.1
File renamed without changes.
6 changes: 3 additions & 3 deletions docker-compose.yml → tests/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ version: '2'
services:
tox:
build:
context: ./
dockerfile: Dockerfile-test
context: ../
dockerfile: tests/Dockerfile-test
command: tox
container_name: elastalert_tox
working_dir: /home/elastalert
volumes:
- ./:/home/elastalert/
- ../:/home/elastalert/
2 changes: 1 addition & 1 deletion pytest.ini → tests/pytest.ini
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
markers =
elasticsearch: mark a test as using elasticsearch.
filterwarnings =
ignore::pytest.PytestUnhandledThreadExceptionWarning
ignore::pytest.PytestUnhandledThreadExceptionWarning
11 changes: 5 additions & 6 deletions tox.ini → tests/tox.ini
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
[tox]
project = elastalert
envlist = py39,docs
setupdir = ..

[testenv]
deps = -rrequirements-dev.txt
deps = -r../requirements-dev.txt
commands =
pytest --cov=elastalert --cov-report=term-missing --cov-branch --strict-markers tests/ -n 4 {posargs}
flake8 .
pytest --cov=elastalert --cov-report=term-missing --cov-branch --strict-markers . -n 4 {posargs}
flake8 --config ../setup.cfg .

[testenv:lint]
deps = {[testenv]deps}
pylint
commands =
pylint --rcfile=.pylintrc elastalert
pylint --rcfile=.pylintrc tests
Expand All @@ -24,6 +24,5 @@ norecursedirs = .* virtualenv_run docs build venv env

[testenv:docs]
deps = {[testenv]deps}
sphinx==4.0.2
changedir = docs
changedir = ../docs
commands = sphinx-build -b html -d build/doctrees -W source build/html

0 comments on commit 0365278

Please sign in to comment.