Commit 1dc3ca50 by Fred Smith

Dockerize tests

parent d769550d
......@@ -8,3 +8,6 @@ coverage/
# Sqlite Database
*.db
#vim
*.swp
language: python
python: 2.7
sudo: false
install:
- scripts/travis/install.sh
- scripts/travis/setup.sh
- pip install -r requirements/test.txt
- git fetch origin master:refs/remotes/origin/master # https://github.com/edx/diff-cover#troubleshooting
- pip install coveralls
python:
- "3.5"
services:
- docker
sudo: required
before_install:
- make travis_up
script:
- make validate
- make travis_test
after_success:
- coveralls
env:
- ESVER=-
- ESVER=0.90.11
- ESVER=1.4.2
- pip install -U codecov
- docker exec notes /edx/app/notes/notes/.travis/run_coverage.sh
- codecov
version: "2"
services:
db:
image: mysql:5.6
container_name: db
command: mysqld --character-set-server=utf8 --collation-server=utf8_general_ci
environment:
MYSQL_ROOT_PASSWORD: ""
MYSQL_ALLOW_EMPTY_PASSWORD: "yes"
MYSQL_USER: "notes001"
MYSQL_PASSWORD: "secret"
MYSQL_DATABASE: "edx_notes_api"
es:
image: edxops/elasticsearch:0.9.13
container_name: es
notes:
# Uncomment this line to use the official course-discovery base image
image: edxops/notes:latest
# Uncomment the next two lines to build from a local configuration repo
# build: ../configuration/docker/build/discovery/
container_name: edx_notes_api
volumes:
- ..:/edx/app/edx_notes_api/edx_notes_api
command: tail -f /dev/null
depends_on:
- "db"
- "es"
environment:
CONN_MAX_AGE: 60
DB_ENGINE: "django.db.backends.mysql"
DB_HOST: "db"
DB_NAME: "edx_notes_api"
DB_PASSWORD: "secret"
DB_PORT: "3306"
DB_USER: "notes001"
ENABLE_DJANGO_TOOLBAR: 1
ELASTICSEARCH_URL: "http://es:9200"
.PHONY: travis_down travis_start travis_stop travis_test travis_up
travis_up: ## Create containers used to run tests on Travis CI
docker-compose -f .travis/docker-compose-travis.yml up -d
travis_start: ## Start containers stopped by `travis_stop`
docker-compose -f .travis/docker-compose-travis.yml start
travis_test: ## Run tests on Docker containers, as on Travis CI
docker exec -it edx_notes_api env TERM=$(TERM) /edx/app/edx_notes_api/edx_notes_api/.travis/run_tests.sh
travis_stop: ## Stop running containers created by `travis_up` without removing them
docker-compose -f .travis/docker-compose-travis.yml stop
travis_down: ## Stop and remove containers and other resources created by `travis_up`
docker-compose -f .travis/docker-compose-travis.yml down
#!/bin/bash -xe
. /edx/app/edx_notes_api/venvs/edx_notes_api/bin/activate
cd /edx/app/edx_notes_api/edx_notes_api
make validate
PACKAGES = notesserver notesapi
.PHONY: requirements
validate: test.requirements test coverage
include .travis/docker.mk
ifeq ($(ESVER),-)
test_settings = notesserver.settings.test_es_disabled
else
test_settings = notesserver.settings.test
endif
validate: test.requirements test
test: clean
./manage.py test --settings=$(test_settings) --with-coverage --with-ignore-docstrings \
./manage.py test --settings=notesserver.settings.test --with-coverage --with-ignore-docstrings \
--exclude-dir=notesserver/settings --cover-inclusive --cover-branches \
--cover-html --cover-html-dir=build/coverage/html/ \
--cover-xml --cover-xml-file=build/coverage/coverage.xml --verbosity=2 \
......
......@@ -2,8 +2,13 @@ from .common import *
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': 'default.db',
'ENGINE': os.environ.get('DB_ENGINE', 'django.db.backends.sqlite3'),
'NAME': os.environ.get('DB_NAME', 'default.db'),
'USER': os.environ.get('DB_USER', ''),
'PASSWORD': os.environ.get('DB_PASSWORD', ''),
'HOST': os.environ.get('DB_HOST', ''),
'PORT': os.environ.get('DB_PORT', ''),
'CONN_MAX_AGE': int(os.environ.get('CONN_MAX_AGE', 0))
}
}
......@@ -14,7 +19,7 @@ INSTALLED_APPS += ('django_nose',)
HAYSTACK_CONNECTIONS = {
'default': {
'ENGINE': 'notesserver.highlight.ElasticsearchSearchEngine',
'URL': 'http://127.0.0.1:9200/',
'URL': os.environ.get('ELASTICSEARCH_URL', 'http://localhost:9200/'),
'INDEX_NAME': 'notes_index_test',
},
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment