Skip to content

Commit e07bc63

Browse files
committed
[timseries] Fix tests
1 parent b85985b commit e07bc63

File tree

22 files changed

+405
-135
lines changed

22 files changed

+405
-135
lines changed

.travis.yml

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,29 +24,28 @@ addons:
2424

2525
services:
2626
- docker
27-
- redis-server
28-
- elasticsearch
2927

3028
branches:
3129
only:
3230
- master
3331
- dev
3432

3533
before_install:
36-
# - docker run -d --name influxdb -e INFLUXDB_DB=openwisp2 -p 8086:8086 influxdb:alpine
37-
# - docker run -p 9200:9200 docker.elastic.co/elasticsearch/elasticsearch:7.8.0
34+
- docker-compose up -d
3835
- pip install -U pip wheel setuptools
3936
- pip install $DJANGO
4037
- pip install -U -r requirements-test.txt
4138

4239
install:
43-
- pip install -e .
40+
- pip install -e .[influxdb,elasticsearch]
4441
- sh install-dev.sh
4542

4643
script:
4744
- ./run-qa-checks
4845
- SAMPLE_APP=1 coverage run --source=openwisp_monitoring runtests.py
4946
- coverage run -a --source=openwisp_monitoring runtests.py
47+
- elasticsearch=1 SAMPLE_APP=1 coverage run -a --source=openwisp_monitoring runtests.py
48+
- elasticsearch=1 coverage run -a --source=openwisp_monitoring runtests.py
5049

5150
jobs:
5251
include:

Dockerfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ WORKDIR /opt/openwisp/tests/
1919
ENV NAME=openwisp-monitoring \
2020
PYTHONBUFFERED=1 \
2121
INFLUXDB_HOST=influxdb \
22-
REDIS_HOST=redis
22+
REDIS_HOST=redis \
23+
ELASTICSEARCH_HOST=es01
2324
CMD ["sh", "docker-entrypoint.sh"]
2425
EXPOSE 8000

docker-compose.yml

Lines changed: 34 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ services:
1111
depends_on:
1212
- influxdb
1313
- redis
14+
- es01
15+
- es02
1416

1517
influxdb:
1618
image: influxdb:1.8-alpine
@@ -23,24 +25,45 @@ services:
2325
INFLUXDB_USER: openwisp
2426
INFLUXDB_USER_PASSWORD: openwisp
2527
# clustered version of elasticsearch is used as that might be used in production
26-
elasticsearch:
28+
es01:
2729
image: docker.elastic.co/elasticsearch/elasticsearch:7.8.0
2830
container_name: es01
2931
environment:
30-
- node.name: openwisp2
31-
- cluster.name: openwisp2
32-
- bootstrap.memory_lock: true
32+
- "node.name=es01"
33+
- "discovery.seed_hosts=es02"
34+
- "cluster.initial_master_nodes=es01,es02"
35+
- "cluster.name=openwisp2"
36+
- "bootstrap.memory_lock=true"
3337
- "ES_JAVA_OPTS=-Xms512m -Xmx512m"
3438
ulimits:
3539
memlock:
3640
soft: -1
3741
hard: -1
3842
volumes:
39-
- data01:/usr/share/elasticsearch/data
43+
- esdata01:/usr/share/elasticsearch/data
4044
ports:
4145
- 9200:9200
4246
networks:
43-
- elastic
47+
- esnet
48+
es02:
49+
image: docker.elastic.co/elasticsearch/elasticsearch:7.8.0
50+
container_name: es02
51+
environment:
52+
- "node.name=es02"
53+
- "discovery.seed_hosts=es01"
54+
- "cluster.initial_master_nodes=es01,es02"
55+
- "cluster.name=openwisp2"
56+
- "bootstrap.memory_lock=true"
57+
- "ES_JAVA_OPTS=-Xms512m -Xmx512m"
58+
ulimits:
59+
memlock:
60+
soft: -1
61+
hard: -1
62+
volumes:
63+
- esdata02:/usr/share/elasticsearch/data
64+
networks:
65+
- esnet
66+
4467
redis:
4568
image: redis:5.0-alpine
4669
ports:
@@ -49,7 +72,10 @@ services:
4972

5073
volumes:
5174
influxdb-data: {}
75+
esdata01:
76+
driver: local
77+
esdata02:
78+
driver: local
5279

5380
networks:
54-
elastic:
55-
driver: bridge
81+
esnet:

openwisp_monitoring/db/backends/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ def load_backend_module(backend_name=TIMESERIES_DB['BACKEND'], module=None):
4949
# The database backend wasn't found. Display a helpful error message
5050
# listing all built-in database backends.
5151
builtin_backends = ['influxdb', 'elasticsearch']
52+
raise e
5253
if backend_name not in [
5354
f'openwisp_monitoring.db.backends.{b}' for b in builtin_backends
5455
]:

0 commit comments

Comments
 (0)