This commit is contained in:
Jannis Leidel 2019-02-11 23:08:32 +01:00
Родитель 32a1c89f9a
Коммит 3e2d8e19d5
11 изменённых файлов: 20 добавлений и 15 удалений

2
.dockerignore Normal file
Просмотреть файл

@ -0,0 +1,2 @@
build
dist

2
.gitignore поставляемый
Просмотреть файл

@ -1,5 +1,3 @@
htmlcov
.tox
.coverage
coverage.xml
.cache

Просмотреть файл

@ -1,10 +1,10 @@
sudo: false
dist: xenial
language: python
python:
- '2.7'
services:
- docker
- redis
install:
- pip install --upgrade pip setuptools wheel
script:

Просмотреть файл

@ -1,15 +1,13 @@
FROM mozilla/redash:latest
COPY . /redash-stmo
ENV PYTHONUNBUFFERED=0 \
PYTHONPATH=/app/ \
PYTHONPATH=/redash-stmo:/redash-stmo/src:/app \
REDASH_LOG_LEVEL="INFO" \
REDASH_REDIS_URL=redis://redis:6379/0 \
REDASH_DATABASE_URL=postgresql://postgres@postgres/postgres
USER root
RUN pip uninstall -y redash-stmo && pip install -e /redash-stmo
RUN pip uninstall -y redash-stmo
USER redash
ENTRYPOINT ["/redash-stmo/bin/docker-entrypoint"]

Просмотреть файл

@ -16,9 +16,8 @@ release: build
test:
docker-compose build --pull
docker-compose up --no-start
docker-compose start postgres
docker-compose run --rm server sh -c "/redash-stmo/bin/wait-for-it.sh postgres:5432 -- python manage.py database create_tables"
docker-compose up -d
docker-compose run --rm server sh -c "/redash-stmo/bin/wait-for-it.sh postgres:5432 -- python /app/manage.py database create_tables"
docker-compose run --rm postgres psql -h postgres -U postgres -c "create database tests;" || echo "Test database exists already."
docker-compose run --rm $(CI_ENV) server tests
docker-compose down

Просмотреть файл

@ -2,6 +2,7 @@
set -e
server() {
pip install --user -e /redash-stmo
exec /usr/local/bin/gunicorn -b 0.0.0.0:5000 --name redash -w${REDASH_WEB_WORKERS:-4} redash.wsgi:app
}
@ -10,6 +11,8 @@ create_db() {
}
tests() {
pip install --user /redash-stmo
pip install --user pytest mock pytest-cov pytest-flake8
export REDASH_DATABASE_URL="postgresql://postgres@postgres/tests"
if [ $# -eq 0 ]; then
@ -24,6 +27,8 @@ tests() {
fi
}
# always install inside the running container
case "$1" in
tests)
shift

Просмотреть файл

@ -22,6 +22,7 @@ services:
environment:
QUEUES: "queries,scheduled_queries,celery"
WORKERS_COUNT: 2
REDASH_REDIS_URL: "redis://redis:6379/0"
redis:
image: redis:3.0-alpine
restart: unless-stopped

Просмотреть файл

@ -1,4 +1,3 @@
[pytest]
norecursedirs = .git .*
addopts = -rsxX --showlocals --tb=native --cov=redash_stmo --cov-report xml --cov-report term --cov-report html --cov-config .coveragerc --cov-config /redash-stmo/.coveragerc
python_paths = .
addopts = --flake8 -rsxX --showlocals --tb=native --cov=redash_stmo --cov-report xml --cov-report term --cov-config .coveragerc --cov-config /redash-stmo/.coveragerc

Просмотреть файл

@ -3,3 +3,6 @@
# 3. If at all possible, it is good practice to do this. If you cannot, you
# will need to generate wheels for each Python version that you support.
universal=1
[flake8]
ignore=E501,E127,E128,E124,W503

Просмотреть файл

@ -66,7 +66,7 @@ def update_health_status():
except NotImplementedError:
logger.info(u"Unable to compute health status without test query for %s", data_source.name)
continue
except Exception as e:
except Exception:
logger.warning(u"Failed health check for the data source: %s", data_source.name, exc_info=1)
statsd_client.incr('update_health_status.error')
logger.info(u"task=update_health_status state=error ds_id=%s runtime=%.2f", data_source.id, time.time() - start_time)

Просмотреть файл

@ -24,7 +24,7 @@ class TestDatasourceVersion(BaseTestCase):
self.patched_runner_type.return_value = runner_type
self.patched_run_query.return_value = (json.dumps({
"rows":
[{ "version": version_string.format(version=expected_version) }]
[{"version": version_string.format(version=expected_version)}]
}), None)
rv = self.make_request('get', '/api/data_sources/{}/version'.format(self.data_source.id), user=self.admin)
self.assertEqual(200, rv.status_code)
@ -58,7 +58,7 @@ class TestDatasourceVersion(BaseTestCase):
self.patched_runner_type.return_value = "pg"
self.patched_run_query.return_value = (json.dumps({
"rows":
[{ "bad_json": "foo" }]
[{"bad_json": "foo"}]
}), None)
rv = self.make_request('get', '/api/data_sources/{}/version'.format(self.data_source.id), user=self.admin)
self.assertEqual(200, rv.status_code)