mirror of https://github.com/interlegis/sapl.git
25 changed files with 71 additions and 78 deletions
@ -1,25 +1,38 @@ |
|||||
language: python |
sudo: required |
||||
|
|
||||
python: |
|
||||
- 3.6 |
|
||||
|
|
||||
services: |
services: |
||||
- postgresql |
- docker |
||||
|
|
||||
install: |
env: |
||||
- pip install -r requirements/test-requirements.txt |
global: |
||||
|
- DOCKER_COMPOSE_VERSION=1.26.2 |
||||
|
|
||||
before_script: |
before_install: |
||||
- cp sapl/.env_test sapl/.env |
# Install latest versions of docker and docker-compose |
||||
- psql -c "CREATE USER sapl WITH PASSWORD 'sapl'" -U postgres; |
- curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - |
||||
- psql -c "CREATE DATABASE sapl OWNER sapl;" -U postgres |
- sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" |
||||
- ./scripts/django/check_migrations.sh |
- sudo apt-get update |
||||
|
- sudo apt-get -y -o Dpkg::Options::="--force-confnew" install docker-ce |
||||
|
- sudo rm /usr/local/bin/docker-compose |
||||
|
- curl -L https://github.com/docker/compose/releases/download/${DOCKER_COMPOSE_VERSION}/docker-compose-`uname -s`-`uname -m` > docker-compose |
||||
|
- chmod +x docker-compose |
||||
|
- sudo mv docker-compose /usr/local/bin |
||||
|
- docker --version |
||||
|
- docker-compose --version |
||||
|
|
||||
|
install: |
||||
|
- sudo service postgresql stop || true |
||||
|
|
||||
script: |
script: |
||||
- ./manage.py migrate |
- cd $TRAVIS_BUILD_DIR/docker |
||||
- py.test --create-db |
# Build master images and run the webserver (tests end to end) |
||||
# - ./scripts/django/test_and_check_qa.sh |
#- docker-compose -f docker-compose.test.yml build |
||||
|
#- docker-compose up -d |
||||
|
#- docker logs sapl |
||||
|
#- docker-compose rm -f -s -v |
||||
|
- docker-compose -f docker-compose.yml run --workdir="/var/interlegis/sapl" sapl bash -c "cp docker/config/env_test .env && py.test --create-db" |
||||
|
|
||||
addons: |
after_script: |
||||
hosts: |
# Cleanup docker containers, images, and volumes |
||||
- 127.0.0.1 sapldb |
- docker-compose rm -f -s -v |
||||
|
- docker system prune -a -f --volumes |
||||
@ -1,5 +1,5 @@ |
|||||
DATABASE_URL = postgresql://postgres:@sapldb:/sapl |
DATABASE_URL = postgresql://postgres:@sapldb:/sapl |
||||
KEY |
SECRET_KEY = 'mzp++@i1y-6y8ez_=^sfbr!dzuyry#^@v(3g^2d1k9%f=+mhlb' |
||||
DEBUG = False |
DEBUG = False |
||||
EMAIL_USE_TLS = True |
EMAIL_USE_TLS = True |
||||
EMAIL_PORT = 587 |
EMAIL_PORT = 587 |
||||
@ -1,5 +1,5 @@ |
|||||
DATABASE_URL = sqlite:///sapl.db |
DATABASE_URL = sqlite:///sapl.db |
||||
SECRET_KEY = 'Dockerfile_Key' |
SECRET_KEY = 'mzp++@i1y-6y8ez_=^sfbr!dzuyry#^@v(3g^2d1k9%f=+mhlb' |
||||
DEBUG = False |
DEBUG = False |
||||
EMAIL_USE_TLS = True |
EMAIL_USE_TLS = True |
||||
EMAIL_PORT = 587 |
EMAIL_PORT = 587 |
||||
@ -0,0 +1,9 @@ |
|||||
|
DATABASE_URL=postgresql://postgres:@sapldb:/sapl |
||||
|
SECRET_KEY=test++@i1y-6y8ez_=^sfbr!dzuyry#^@v(3g^2d1k9%f=+mhlb |
||||
|
DEBUG=False |
||||
|
EMAIL_USE_TLS = True |
||||
|
EMAIL_PORT = 587 |
||||
|
EMAIL_HOST = '' |
||||
|
EMAIL_HOST_USER = '' |
||||
|
EMAIL_SEND_USER = '' |
||||
|
EMAIL_HOST_PASSWORD = '' |
||||
@ -1,49 +0,0 @@ |
|||||
from flask import Flask |
|
||||
import requests |
|
||||
import psycopg2 |
|
||||
import json |
|
||||
from sapl.settings import DATABASES, USE_SOLR, SOLR_URL |
|
||||
|
|
||||
|
|
||||
app = Flask(__name__) |
|
||||
|
|
||||
|
|
||||
@app.route('/health') |
|
||||
def health(): |
|
||||
try: |
|
||||
db = DATABASES['default'] |
|
||||
conn = psycopg2.connect(host=db['HOST'], |
|
||||
user=db['USER'], |
|
||||
password=db['PASSWORD'], |
|
||||
database=db['NAME'], |
|
||||
port=db['PORT']) |
|
||||
cursor = conn.cursor() |
|
||||
cursor.execute("SELECT 1;") |
|
||||
resp = {'DATABASE': 'OK'} |
|
||||
except Exception as e: |
|
||||
resp = {'DATABASE': 'ERROR'} |
|
||||
finally: |
|
||||
if cursor: |
|
||||
cursor.close() |
|
||||
conn.close() |
|
||||
|
|
||||
if USE_SOLR: |
|
||||
r = requests.get(SOLR_URL) |
|
||||
if r.ok: |
|
||||
resp.update({'SEARCH_ENGINE': 'OK'}) |
|
||||
else: |
|
||||
resp.update({'SEARCH_ENGINE': 'ERROR'}) |
|
||||
|
|
||||
else: |
|
||||
resp.update({'SEARCH_ENGINE': 'NOT_ENABLED'}) |
|
||||
|
|
||||
return json.dumps(resp) |
|
||||
|
|
||||
|
|
||||
@app.route('/ping') |
|
||||
def ping(): |
|
||||
return "pong" |
|
||||
|
|
||||
|
|
||||
if __name__ == '__main__': |
|
||||
app.run() |
|
||||
Loading…
Reference in new issue