Skip to content

Commit 266030a

Browse files
authored
Merge pull request #1178 from python-gitlab/test/cleanup-env
test(env): replace custom scripts with pytest and docker-compose
2 parents 0d89a6e + 40ec2f5 commit 266030a

18 files changed

+187
-321
lines changed

.env

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
GITLAB_IMAGE=gitlab/gitlab-ce
2+
GITLAB_TAG=13.3.5-ce.0

.renovaterc.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
],
55
"regexManagers": [
66
{
7-
"fileMatch": ["^tools/build_test_env.sh$"],
8-
"matchStrings": ["DEFAULT_GITLAB_TAG=(?<currentValue>.*?)\n"],
7+
"fileMatch": ["^.env$"],
8+
"matchStrings": ["GITLAB_TAG=(?<currentValue>.*?)\n"],
99
"depNameTemplate": "gitlab/gitlab-ce",
1010
"datasourceTemplate": "docker",
1111
"versioningTemplate": "loose"

README.rst

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ You need to install ``tox`` to run unit tests and documentation builds locally:
166166
Running integration tests
167167
-------------------------
168168

169-
Two scripts run tests against a running gitlab instance, using a docker
169+
Integration tests run against a running gitlab instance, using a docker
170170
container. You need to have docker installed on the test machine, and your user
171171
must have the correct permissions to talk to the docker daemon.
172172

@@ -180,9 +180,9 @@ To run these tests:
180180
# run the python API tests:
181181
tox -e py_func_v4
182182
183-
By default, the tests run against the ``gitlab/gitlab-ce:latest`` image. You can
184-
override both the image and tag with the ``-i`` and ``-t`` options, or by providing
185-
either the ``GITLAB_IMAGE`` or ``GITLAB_TAG`` environment variables.
183+
By default, the tests run against the latest version of the ``gitlab/gitlab-ce``
184+
image. You can override both the image and tag by providing either the
185+
``GITLAB_IMAGE`` or ``GITLAB_TAG`` environment variables.
186186

187187
This way you can run tests against different versions, such as ``nightly`` for
188188
features in an upcoming release, or an older release (e.g. ``12.8.0-ce.0``).
@@ -191,20 +191,11 @@ The tag must match an exact tag on Docker Hub:
191191
.. code-block:: bash
192192
193193
# run tests against `nightly` or specific tag
194-
./tools/py_functional_tests.sh -t nightly
195-
./tools/py_functional_tests.sh -t 12.8.0-ce.0
194+
GITLAB_TAG=nightly tox -e py_func_v4
195+
GITLAB_TAG=12.8.0-ce.0 tox -e py_func_v4
196196
197197
# run tests against the latest gitlab EE image
198-
./tools/py_functional_tests.sh -i gitlab/gitlab-ee
199-
200-
# override tags with environment variables
201-
GITLAB_TAG=nightly ./tools/py_functional_tests.sh
202-
203-
You can also build a test environment using the following command:
204-
205-
.. code-block:: bash
206-
207-
./tools/build_test_env.sh
198+
GITLAB_IMAGE=gitlab/gitlab-ee tox -e py_func_v4
208199
209200
A freshly configured gitlab container will be available at
210201
http://localhost:8080 (login ``root`` / password ``5iveL!fe``). A configuration

docker-requirements.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
-r requirements.txt
2+
-r test-requirements.txt
3+
pytest-console-scripts
4+
pytest-docker

tools/build_test_env.sh

Lines changed: 0 additions & 158 deletions
This file was deleted.

tools/functional/api/test_gitlab.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
"""
2+
Temporary module to run legacy tests as a single pytest test case
3+
as they're all plain asserts at module level.
4+
"""
5+
6+
7+
def test_api_v4(gl):
8+
from tools.functional import python_test_v4

tools/functional/cli/conftest.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@
22

33

44
@pytest.fixture
5-
def gitlab_cli(script_runner, CONFIG):
5+
def gitlab_cli(script_runner, gitlab_config):
66
"""Wrapper fixture to help make test cases less verbose."""
77

88
def _gitlab_cli(subcommands):
99
"""
1010
Return a script_runner.run method that takes a default gitlab
1111
command, and subcommands passed as arguments inside test cases.
1212
"""
13-
command = ["gitlab", "--config-file", CONFIG]
13+
command = ["gitlab", "--config-file", gitlab_config]
1414

1515
for subcommand in subcommands:
1616
# ensure we get strings (e.g from IDs)

0 commit comments

Comments
 (0)