Skip to content

Commit

Permalink
unifiy test also for reporter
Browse files Browse the repository at this point in the history
* remove unused meta data from timescale geo query response
* unify reporter tests between timescale and crate
* remove MTU from compose
* fix cache naming bug
* allow retry for db setup
  • Loading branch information
chicco785 committed Dec 1, 2020
1 parent 3f9ceef commit efc7c01
Show file tree
Hide file tree
Showing 27 changed files with 651 additions and 562 deletions.
2 changes: 0 additions & 2 deletions docker/docker-compose-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -96,5 +96,3 @@ volumes:

networks:
default:
driver_opts:
com.docker.network.driver.mtu: ${DOCKER_MTU:-1400}
2 changes: 0 additions & 2 deletions docker/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,5 +70,3 @@ volumes:

networks:
default:
driver_opts:
com.docker.network.driver.mtu: ${DOCKER_MTU:-1400}
11 changes: 1 addition & 10 deletions run_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,23 +16,14 @@ tot=$?
cd -

cd src/reporter/tests
test_suite_header "REPORTER (Crate)"
test_suite_header "REPORTER"
sh run_tests.sh
loc=$?
if [ "$tot" -eq 0 ]; then
tot=$loc
fi
cd -

cd src/reporter/tests
test_suite_header "REPORTER (Timescale)"
sh run_tests.timescale.sh
loc=$?
if [ "$tot" -eq 0 ]; then
tot=$loc
fi
cd -

cd src/geocoding/tests
test_suite_header "GEO-CODING"
sh run_tests.sh
Expand Down
6 changes: 6 additions & 0 deletions src/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,12 @@ def insert(self, entity, service=None, service_path=None):
headers=headers(service, service_path))
return r

def update_attr(self, entity_id, attrs, service=None, service_path=None):
r = requests.patch('{}/v2/entities/{}/attrs'.format(self.url, entity_id),
data=json.dumps(attrs),
headers=headers(service, service_path))
return r

def delete(self, entity_id, service=None, service_path=None):
r = requests.delete('{}/v2/entities/{}'.format(self.url, entity_id),
headers=headers(service, service_path))
Expand Down
7 changes: 6 additions & 1 deletion src/geocoding/geojson/wktcodec.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,12 @@ def decode_wkb_hexstr(geom: str) -> dict:
:return: the corresponding GeoJSON.
"""
geom_bytes = bytes.fromhex(geom)
return decode_wkb(geom_bytes)
geojson = decode_wkb(geom_bytes)
if 'meta' in geojson:
geojson.pop('meta')
if 'crs' in geojson:
geojson.pop('crs')
return geojson


# TODO. Use shapely?
Expand Down
114 changes: 0 additions & 114 deletions src/reporter/tests/docker-compose.timescale.yml

This file was deleted.

31 changes: 29 additions & 2 deletions src/reporter/tests/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,39 @@ services:
depends_on:
- orion
- crate
- timescale
volumes:
- ${PWD}/ql-config.yml:/config/ql-config.yml
networks:
- reportertests
environment:
- USE_GEOCODING=True
- USE_GEOCODING=False
- REDIS_HOST=redis
- LOGLEVEL=DEBUG
- LOGLEVEL=INFO
- POSTGRES_HOST=timescale
- QL_CONFIG=/config/ql-config.yml

timescale:
image: timescale/timescaledb-postgis:${TIMESCALE_VERSION}
ports:
- "5432:5432"
networks:
- reportertests
environment:
- POSTGRES_PASSWORD=*

quantumleap-db-setup:
build: ../../../timescale-container/
image: quantumleap-db-setup
depends_on:
- timescale
networks:
- reportertests
environment:
- QL_DB_PASS=*
- QL_DB_INIT_DIR=/ql-db-init
- PG_HOST=timescale
- PG_PASS=*

crate:
image: crate:${CRATE_VERSION}
Expand Down
6 changes: 6 additions & 0 deletions src/reporter/tests/ql-config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
tenants:
t1:
backend: Crate
t2:
backend: Timescale
default-backend: Crate
4 changes: 3 additions & 1 deletion src/reporter/tests/run_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ docker-compose up -d
sleep 20

cd ../../../
pytest src/reporter/ --cov-report= --cov-config=.coveragerc --cov-append --cov=src/
pytest src/reporter/ \
--cov-report= --cov-config=.coveragerc --cov-append --cov=src/ \
--ignore=src/reporter/tests/test_health.py
r=$?
cd -

Expand Down
31 changes: 0 additions & 31 deletions src/reporter/tests/run_tests.timescale.sh

This file was deleted.

2 changes: 2 additions & 0 deletions src/reporter/tests/test_Headers.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from datetime import datetime
from conftest import QL_URL
from utils.common import assert_equal_time_index_arrays
from reporter.tests.utils import delete_entity_type
import copy
import json
import pytest
Expand Down Expand Up @@ -38,6 +39,7 @@ def test_for_valid_headers(notification):
]
}
assert res_get.json() == exp_values
delete_entity_type('test', 'Room')

def test_for_invalid_headers(notification):
notification['data'][0] = {
Expand Down
Loading

0 comments on commit efc7c01

Please sign in to comment.