mirror of https://github.com/interlegis/sapl.git
25 changed files with 71 additions and 78 deletions
@ -1,25 +1,38 @@ |
|||
language: python |
|||
|
|||
python: |
|||
- 3.6 |
|||
sudo: required |
|||
|
|||
services: |
|||
- postgresql |
|||
- docker |
|||
|
|||
install: |
|||
- pip install -r requirements/test-requirements.txt |
|||
env: |
|||
global: |
|||
- DOCKER_COMPOSE_VERSION=1.26.2 |
|||
|
|||
before_script: |
|||
- cp sapl/.env_test sapl/.env |
|||
- psql -c "CREATE USER sapl WITH PASSWORD 'sapl'" -U postgres; |
|||
- psql -c "CREATE DATABASE sapl OWNER sapl;" -U postgres |
|||
- ./scripts/django/check_migrations.sh |
|||
before_install: |
|||
# Install latest versions of docker and docker-compose |
|||
- curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - |
|||
- sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" |
|||
- 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: |
|||
- ./manage.py migrate |
|||
- py.test --create-db |
|||
# - ./scripts/django/test_and_check_qa.sh |
|||
- cd $TRAVIS_BUILD_DIR/docker |
|||
# Build master images and run the webserver (tests end to end) |
|||
#- 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: |
|||
hosts: |
|||
- 127.0.0.1 sapldb |
|||
after_script: |
|||
# Cleanup docker containers, images, and volumes |
|||
- docker-compose rm -f -s -v |
|||
- docker system prune -a -f --volumes |
|||
@ -1,5 +1,5 @@ |
|||
DATABASE_URL = postgresql://postgres:@sapldb:/sapl |
|||
KEY |
|||
SECRET_KEY = 'mzp++@i1y-6y8ez_=^sfbr!dzuyry#^@v(3g^2d1k9%f=+mhlb' |
|||
DEBUG = False |
|||
EMAIL_USE_TLS = True |
|||
EMAIL_PORT = 587 |
|||
@ -1,5 +1,5 @@ |
|||
DATABASE_URL = sqlite:///sapl.db |
|||
SECRET_KEY = 'Dockerfile_Key' |
|||
SECRET_KEY = 'mzp++@i1y-6y8ez_=^sfbr!dzuyry#^@v(3g^2d1k9%f=+mhlb' |
|||
DEBUG = False |
|||
EMAIL_USE_TLS = True |
|||
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