Skip to content

test(env): replace custom scripts with pytest and docker-compose #1178

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Sep 16, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
GITLAB_IMAGE=gitlab/gitlab-ce
GITLAB_TAG=13.3.5-ce.0
4 changes: 2 additions & 2 deletions .renovaterc.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
],
"regexManagers": [
{
"fileMatch": ["^tools/build_test_env.sh$"],
"matchStrings": ["DEFAULT_GITLAB_TAG=(?<currentValue>.*?)\n"],
"fileMatch": ["^.env$"],
"matchStrings": ["GITLAB_TAG=(?<currentValue>.*?)\n"],
"depNameTemplate": "gitlab/gitlab-ce",
"datasourceTemplate": "docker",
"versioningTemplate": "loose"
Expand Down
23 changes: 7 additions & 16 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ You need to install ``tox`` to run unit tests and documentation builds locally:
Running integration tests
-------------------------

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

Expand All @@ -180,9 +180,9 @@ To run these tests:
# run the python API tests:
tox -e py_func_v4

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.
By default, the tests run against the latest version of the ``gitlab/gitlab-ce``
image. You can override both the image and tag 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``).
Expand All @@ -191,20 +191,11 @@ 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
GITLAB_TAG=nightly tox -e py_func_v4
GITLAB_TAG=12.8.0-ce.0 tox -e py_func_v4

# 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

./tools/build_test_env.sh
GITLAB_IMAGE=gitlab/gitlab-ee tox -e py_func_v4

A freshly configured gitlab container will be available at
http://localhost:8080 (login ``root`` / password ``5iveL!fe``). A configuration
Expand Down
4 changes: 4 additions & 0 deletions docker-requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
-r requirements.txt
-r test-requirements.txt
pytest-console-scripts
pytest-docker
158 changes: 0 additions & 158 deletions tools/build_test_env.sh

This file was deleted.

8 changes: 8 additions & 0 deletions tools/functional/api/test_gitlab.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
"""
Temporary module to run legacy tests as a single pytest test case
as they're all plain asserts at module level.
"""


def test_api_v4(gl):
from tools.functional import python_test_v4
4 changes: 2 additions & 2 deletions tools/functional/cli/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@


@pytest.fixture
def gitlab_cli(script_runner, CONFIG):
def gitlab_cli(script_runner, gitlab_config):
"""Wrapper fixture to help make test cases less verbose."""

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

for subcommand in subcommands:
# ensure we get strings (e.g from IDs)
Expand Down
Loading