Skip to content

Commit 2968424

Browse files
committed
Add dockertest including coverage when running tests
1 parent 707f08d commit 2968424

File tree

5 files changed

+48
-2
lines changed

5 files changed

+48
-2
lines changed

Dockerfile

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,18 @@
1+
# VERSION 0.1
2+
# DOCKER-VERSION 0.7.3
3+
# AUTHOR: Sam Alba <[email protected]>
4+
# DESCRIPTION: Image with docker-registry project and dependecies
5+
# TO_BUILD: docker build -rm -t registry .
6+
# TO_RUN: docker run -p 5000:5000 registry
7+
18
FROM stackbrew/ubuntu:13.04
29

310
RUN sed -i 's/main$/main universe/' /etc/apt/sources.list && apt-get update
4-
RUN apt-get install -y git-core python-pip build-essential python-dev libevent1-dev python-openssl liblzma-dev
11+
RUN apt-get install -y git-core build-essential python-dev \
12+
libevent1-dev python-openssl liblzma-dev wget
13+
RUN cd /tmp; wget http://python-distribute.org/distribute_setup.py
14+
RUN cd /tmp; python distribute_setup.py; easy_install pip; \
15+
rm distribute_setup.py
516
ADD . /docker-registry
617
ADD ./config/boto.cfg /etc/boto.cfg
718

test-requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
coverage==3.6
12
hacking==0.7.0
23
mock==1.0.1
34
-e git+https://github.com/locationlabs/mockredis.git#egg=mockredis

test/Dockerfile

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# VERSION 0.1
2+
# DOCKER-VERSION 0.7.3
3+
# AUTHOR: Daniel Mizyrycki <[email protected]>
4+
# DESCRIPTION: Test image with docker-registry project and dependecies
5+
# TO_BUILD: docker build -rm -t docker-registry-test .
6+
# TO_RUN: docker run -rm -i -t docker-registry-test
7+
8+
FROM registry
9+
MAINTAINER Daniel Mizyrycki <[email protected]>
10+
11+
# Add docker-registry testing dependencies
12+
RUN apt-get install -y --no-install-recommends libssl-dev
13+
RUN pip install -r /docker-registry/test-requirements.txt
14+
RUN pip install tox==1.6.1
15+
16+
# Mountpoint used to share coverage results
17+
RUN mkdir /data
18+
19+
CMD ["sh", "-c", "/docker-registry/test/dockertest.sh"]

test/dockertest.sh

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/bin/sh
2+
cat $0
3+
set -x
4+
5+
# Signal coverage report name, parsed by docker-ci
6+
COVERAGE_FILE=$(date +"docker-registry-%Y%m%d%H%M%S")
7+
8+
cd /docker-registry
9+
tox
10+
exit_status=$?
11+
if [ "$exit_status" -eq "0" ]; then
12+
mv reports /data/$COVERAGE_FILE; fi
13+
exit $exit_status
14+

tox.ini

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ setenv = SETTINGS_FLAVOR=test
88
PYTHONPATH=test
99
deps = -r{toxinidir}/requirements.txt
1010
-r{toxinidir}/test-requirements.txt
11-
commands = python -m unittest discover -s {toxinidir}/test {posargs}
11+
commands = coverage run -m unittest discover -s {toxinidir}/test {posargs}
12+
coverage html -d reports --include='./*' --omit='*test*','.tox*'
1213

1314
[testenv:pep8]
1415
commands = flake8 {toxinidir}

0 commit comments

Comments
 (0)