Skip to content

Commit 8173021

Browse files
authored
Merge pull request #1054 from nejch/chore/cleanup-test-env
chore: improve test environment for upcoming features
2 parents 1b8e748 + 265bbdd commit 8173021

File tree

4 files changed

+48
-15
lines changed

4 files changed

+48
-15
lines changed

.travis.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,22 @@ jobs:
3939
script:
4040
- pip3 install tox
4141
- tox -e py_func_v4
42+
- stage: test
43+
name: cli_func_nightly
44+
dist: bionic
45+
python: 3.8
46+
env: GITLAB_TAG=nightly
47+
script:
48+
- pip3 install tox
49+
- tox -e cli_func_v4
50+
- stage: test
51+
name: py_func_nightly
52+
dist: bionic
53+
python: 3.8
54+
env: GITLAB_TAG=nightly
55+
script:
56+
- pip3 install tox
57+
- tox -e py_func_v4
4258
- stage: test
4359
name: docs
4460
dist: bionic
@@ -67,3 +83,5 @@ jobs:
6783
script:
6884
- pip3 install tox
6985
- tox -e py38
86+
allow_failures:
87+
- env: GITLAB_TAG=nightly

README.rst

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,11 +129,11 @@ You need to install ``tox`` to run unit tests and documentation builds locally:
129129

130130
.. code-block:: bash
131131
132-
# run the unit tests for python 2/3, and the pep8 tests:
132+
# run the unit tests for all supported python3 versions, and the pep8 tests:
133133
tox
134134
135135
# run tests in one environment only:
136-
tox -epy35
136+
tox -epy36
137137
138138
# build the documentation, the result will be generated in
139139
# build/sphinx/html/
@@ -156,6 +156,26 @@ To run these tests:
156156
# run the python API tests:
157157
./tools/py_functional_tests.sh
158158
159+
By default, the tests run against the ``gitlab/gitlab-ce:latest`` image. You can
160+
override both the image and tag with the ``-i`` and ``-t`` options, or by providing
161+
either the ``GITLAB_IMAGE`` or ``GITLAB_TAG`` environment variables.
162+
163+
This way you can run tests against different versions, such as ``nightly`` for
164+
features in an upcoming release, or an older release (e.g. ``12.8.0-ce.0``).
165+
The tag must match an exact tag on Docker Hub:
166+
167+
.. code-block:: bash
168+
169+
# run tests against `nightly` or specific tag
170+
./tools/py_functional_tests.sh -t nightly
171+
./tools/py_functional_tests.sh -t 12.8.0-ce.0
172+
173+
# run tests against the latest gitlab EE image
174+
./tools/py_functional_tests.sh -i gitlab/gitlab-ee
175+
176+
# override tags with environment variables
177+
GITLAB_TAG=nightly ./tools/py_functional_tests.sh
178+
159179
You can also build a test environment using the following command:
160180

161181
.. code-block:: bash

tools/build_test_env.sh

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -27,29 +27,23 @@ try() { "$@" || fatal "'$@' failed"; }
2727

2828
REUSE_CONTAINER=
2929
NOVENV=
30-
PY_VER=3
3130
API_VER=4
32-
GITLAB_IMAGE="gitlab/gitlab-ce"
33-
GITLAB_TAG="latest"
34-
while getopts :knp:a: opt "$@"; do
31+
GITLAB_IMAGE="${GITLAB_IMAGE:-gitlab/gitlab-ce}"
32+
GITLAB_TAG="${GITLAB_TAG:-latest}"
33+
VENV_CMD="python3 -m venv"
34+
while getopts :knp:a:i:t: opt "$@"; do
3535
case $opt in
3636
k) REUSE_CONTAINER=1;;
3737
n) NOVENV=1;;
38-
p) PY_VER=$OPTARG;;
3938
a) API_VER=$OPTARG;;
39+
i) GITLAB_IMAGE=$OPTARG;;
4040
t) GITLAB_TAG=$OPTARG;;
4141
:) fatal "Option -${OPTARG} requires a value";;
4242
'?') fatal "Unknown option: -${OPTARG}";;
4343
*) fatal "Internal error: opt=${opt}";;
4444
esac
4545
done
4646

47-
case $PY_VER in
48-
2) VENV_CMD=virtualenv;;
49-
3) VENV_CMD="python3 -m venv";;
50-
*) fatal "Wrong python version (2 or 3)";;
51-
esac
52-
5347
case $API_VER in
5448
4) ;;
5549
*) fatal "Wrong API version (4 only)";;

tox.ini

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ skipsdist = True
44
envlist = py38,py37,py36,pep8,black
55

66
[testenv]
7+
passenv = GITLAB_IMAGE GITLAB_TAG
78
setenv = VIRTUAL_ENV={envdir}
89
whitelist_externals = true
910
usedevelop = True
@@ -44,7 +45,7 @@ commands =
4445
coverage html --omit=*tests*
4546

4647
[testenv:cli_func_v4]
47-
commands = {toxinidir}/tools/functional_tests.sh -a 4 -p 2
48+
commands = {toxinidir}/tools/functional_tests.sh -a 4
4849

4950
[testenv:py_func_v4]
50-
commands = {toxinidir}/tools/py_functional_tests.sh -a 4 -p 2
51+
commands = {toxinidir}/tools/py_functional_tests.sh -a 4

0 commit comments

Comments
 (0)