From 6e80723e5fa00e8b870ec25d1cb2484d4b5816ca Mon Sep 17 00:00:00 2001 From: Nejc Habjan Date: Sat, 21 Mar 2020 17:45:45 -0400 Subject: [PATCH 1/4] chore: remove references to python2 in test env --- README.rst | 4 ++-- tools/build_test_env.sh | 9 +-------- tox.ini | 4 ++-- 3 files changed, 5 insertions(+), 12 deletions(-) diff --git a/README.rst b/README.rst index c00e0c68f..722964738 100644 --- a/README.rst +++ b/README.rst @@ -129,11 +129,11 @@ You need to install ``tox`` to run unit tests and documentation builds locally: .. code-block:: bash - # run the unit tests for python 2/3, and the pep8 tests: + # run the unit tests for all supported python3 versions, and the pep8 tests: tox # run tests in one environment only: - tox -epy35 + tox -epy36 # build the documentation, the result will be generated in # build/sphinx/html/ diff --git a/tools/build_test_env.sh b/tools/build_test_env.sh index 7468a9a7d..3885c3fa2 100755 --- a/tools/build_test_env.sh +++ b/tools/build_test_env.sh @@ -27,15 +27,14 @@ try() { "$@" || fatal "'$@' failed"; } REUSE_CONTAINER= NOVENV= -PY_VER=3 API_VER=4 GITLAB_IMAGE="gitlab/gitlab-ce" GITLAB_TAG="latest" +VENV_CMD="python3 -m venv" while getopts :knp:a: opt "$@"; do case $opt in k) REUSE_CONTAINER=1;; n) NOVENV=1;; - p) PY_VER=$OPTARG;; a) API_VER=$OPTARG;; t) GITLAB_TAG=$OPTARG;; :) fatal "Option -${OPTARG} requires a value";; @@ -44,12 +43,6 @@ while getopts :knp:a: opt "$@"; do esac done -case $PY_VER in - 2) VENV_CMD=virtualenv;; - 3) VENV_CMD="python3 -m venv";; - *) fatal "Wrong python version (2 or 3)";; -esac - case $API_VER in 4) ;; *) fatal "Wrong API version (4 only)";; diff --git a/tox.ini b/tox.ini index 0aa43f09e..8c5753dca 100644 --- a/tox.ini +++ b/tox.ini @@ -44,7 +44,7 @@ commands = coverage html --omit=*tests* [testenv:cli_func_v4] -commands = {toxinidir}/tools/functional_tests.sh -a 4 -p 2 +commands = {toxinidir}/tools/functional_tests.sh -a 4 [testenv:py_func_v4] -commands = {toxinidir}/tools/py_functional_tests.sh -a 4 -p 2 +commands = {toxinidir}/tools/py_functional_tests.sh -a 4 From 98d3f770c4cc7e15493380e1a2201c63f0a332a2 Mon Sep 17 00:00:00 2001 From: Nejc Habjan Date: Sat, 21 Mar 2020 19:01:23 -0400 Subject: [PATCH 2/4] chore: improve and document testing against different images --- .travis.yml | 18 ++++++++++++++++++ README.rst | 20 ++++++++++++++++++++ tools/build_test_env.sh | 7 ++++--- 3 files changed, 42 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 83d2d3391..d59536111 100644 --- a/.travis.yml +++ b/.travis.yml @@ -39,6 +39,22 @@ jobs: script: - pip3 install tox - tox -e py_func_v4 + - stage: test + name: cli_func_nightly + dist: bionic + python: 3.8 + env: GITLAB_TAG=nightly + script: + - pip3 install tox + - tox -e cli_func_v4 + - stage: test + name: py_func_nightly + dist: bionic + python: 3.8 + env: GITLAB_TAG=nightly + script: + - pip3 install tox + - tox -e py_func_v4 - stage: test name: docs dist: bionic @@ -67,3 +83,5 @@ jobs: script: - pip3 install tox - tox -e py38 + allow_failures: + - env: IMAGE_TAG=nightly diff --git a/README.rst b/README.rst index 722964738..eb11cfc14 100644 --- a/README.rst +++ b/README.rst @@ -156,6 +156,26 @@ To run these tests: # run the python API tests: ./tools/py_functional_tests.sh +By default, the tests run against the ``gitlab/gitlab-ce:latest`` image. You can +override both the image and tag with the ``-i`` and ``-t`` options, or by providing +either the ``GITLAB_IMAGE`` or ``GITLAB_TAG`` environment variables. + +This way you can run tests against different versions, such as ``nightly`` for +features in an upcoming release, or an older release (e.g. ``12.8.0-ce.0``). +The tag must match an exact tag on Docker Hub: + +.. code-block:: bash + + # run tests against `nightly` or specific tag + ./tools/py_functional_tests.sh -t nightly + ./tools/py_functional_tests.sh -t 12.8.0-ce.0 + + # run tests against the latest gitlab EE image + ./tools/py_functional_tests.sh -i gitlab/gitlab-ee + + # override tags with environment variables + GITLAB_TAG=nightly ./tools/py_functional_tests.sh + You can also build a test environment using the following command: .. code-block:: bash diff --git a/tools/build_test_env.sh b/tools/build_test_env.sh index 3885c3fa2..91c289628 100755 --- a/tools/build_test_env.sh +++ b/tools/build_test_env.sh @@ -28,14 +28,15 @@ try() { "$@" || fatal "'$@' failed"; } REUSE_CONTAINER= NOVENV= API_VER=4 -GITLAB_IMAGE="gitlab/gitlab-ce" -GITLAB_TAG="latest" +GITLAB_IMAGE="${GITLAB_IMAGE:-gitlab/gitlab-ce}" +GITLAB_TAG="${GITLAB_TAG:-latest}" VENV_CMD="python3 -m venv" -while getopts :knp:a: opt "$@"; do +while getopts :knp:a:i:t: opt "$@"; do case $opt in k) REUSE_CONTAINER=1;; n) NOVENV=1;; a) API_VER=$OPTARG;; + i) GITLAB_IMAGE=$OPTARG;; t) GITLAB_TAG=$OPTARG;; :) fatal "Option -${OPTARG} requires a value";; '?') fatal "Unknown option: -${OPTARG}";; From e06d33c1bcfa71e0c7b3e478d16b3a0e28e05a23 Mon Sep 17 00:00:00 2001 From: Nejc Habjan Date: Sat, 21 Mar 2020 19:48:43 -0400 Subject: [PATCH 3/4] chore: pass environment variables in tox --- tox.ini | 1 + 1 file changed, 1 insertion(+) diff --git a/tox.ini b/tox.ini index 8c5753dca..92d227d5d 100644 --- a/tox.ini +++ b/tox.ini @@ -4,6 +4,7 @@ skipsdist = True envlist = py38,py37,py36,pep8,black [testenv] +passenv = GITLAB_IMAGE GITLAB_TAG setenv = VIRTUAL_ENV={envdir} whitelist_externals = true usedevelop = True From 265bbddacc25d709a8f13807ed04cae393d9802d Mon Sep 17 00:00:00 2001 From: Nejc Habjan Date: Sun, 22 Mar 2020 01:51:04 +0100 Subject: [PATCH 4/4] chore: fix typo in allow_failures --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index d59536111..a86780e33 100644 --- a/.travis.yml +++ b/.travis.yml @@ -84,4 +84,4 @@ jobs: - pip3 install tox - tox -e py38 allow_failures: - - env: IMAGE_TAG=nightly + - env: GITLAB_TAG=nightly