From 0c7a92b710f3c2c9526e3acdc3295f3f202f30c4 Mon Sep 17 00:00:00 2001 From: ziajka Date: Tue, 10 Oct 2017 17:20:27 +0200 Subject: [PATCH] Tests on TravisCI with docker compose --- .travis.yml | 28 ++++++++++++++++------------ DockerfileTests.tpl | 15 +++++++++++++++ docker-compose.yml | 4 ++++ tests/conftest.py | 2 +- 4 files changed, 36 insertions(+), 13 deletions(-) create mode 100644 DockerfileTests.tpl create mode 100644 docker-compose.yml diff --git a/.travis.yml b/.travis.yml index b27dd814..670c9cba 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,17 +1,15 @@ -language: python -python: - - '3.4' - - '3.5' - - '3.6' -sudo: false -cache: pip +sudo: required + +services: + - docker + install: -- pip install -U setuptools pip -- python setup.py install -- pip install -rdev-requirements.txt + - sed -e 's/${PYTHON_VERSION}/'${PYTHON_VERSION}/g DockerfileTests.tpl > /tmp/DockerfileTests + - docker-compose build + script: -- mkdir ‡ -- py.test -v -s tests --basetemp=‡ + - docker-compose run tests + deploy: provider: pypi user: noplay @@ -20,3 +18,9 @@ deploy: on: tags: true repo: GNS3/gns3-server + +env: + matrix: + - PYTHON_VERSION=3.4 + - PYTHON_VERSION=3.5 + - PYTHON_VERSION=3.6 diff --git a/DockerfileTests.tpl b/DockerfileTests.tpl new file mode 100644 index 00000000..d34542e4 --- /dev/null +++ b/DockerfileTests.tpl @@ -0,0 +1,15 @@ +FROM python:${PYTHON_VERSION} + +RUN pip install -U setuptools pip + +ADD requirements.txt /server/requirements.txt +ADD dev-requirements.txt /server/dev-requirements.txt + +RUN pip install -r/server/dev-requirements.txt + +RUN useradd -ms /bin/bash gns3 + +USER gns3 + +ADD . /server +WORKDIR /server diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 00000000..9d30d366 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,4 @@ +tests: + build: . + dockerfile: /tmp/DockerfileTests + command: py.test -v -s tests diff --git a/tests/conftest.py b/tests/conftest.py index aae5d0c0..587c675d 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -83,7 +83,7 @@ def http_server(request, loop, port_manager, monkeypatch, controller): for method, route, handler in Route.get_routes(): app.router.add_route(method, route, handler) - host = "localhost" + host = "127.0.0.1" # We try multiple time. Because on Travis test can fail when because the port is taken by someone else for i in range(0, 5):