Skip to content
Draft
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
6 changes: 3 additions & 3 deletions CONTRIBUTING.rst
Original file line number Diff line number Diff line change
Expand Up @@ -153,18 +153,18 @@ To run these tests:

When developing tests it can be a little frustrating to wait for GitLab to spin
up every run. To prevent the containers from being cleaned up afterwards, pass
``--keep-containers`` to pytest, i.e.:
``--keep-containers-running`` to pytest, i.e.:

.. code-block:: bash

tox -e api_func_v4 -- --keep-containers
tox -e api_func_v4 -- --keep-containers-running

If you then wish to test against a clean slate, you may perform a manual clean
up of the containers by running:

.. code-block:: bash

docker-compose -f tests/functional/fixtures/docker-compose.yml -p pytest-python-gitlab down -v
docker-compose -f gitlab/testing/docker/docker-compose.yml -p pytest-python-gitlab down -v

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
Expand Down
Empty file added gitlab/testing/__init__.py
Empty file.
File renamed without changes.
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ networks:

services:
gitlab:
image: '${GITLAB_IMAGE}:${GITLAB_TAG}'
image: '${GITLAB_IMAGE:-gitlab/gitlab-ee}:${GITLAB_TAG:-latest}'
container_name: 'gitlab-test'
hostname: 'gitlab.test'
privileged: true # Just in case https://gitlab.com/gitlab-org/omnibus-gitlab/-/issues/1350
Expand Down Expand Up @@ -36,15 +36,15 @@ services:
- -c
- ruby /create_license.rb && /assets/wrapper
volumes:
- ${PWD}/tests/functional/fixtures/create_license.rb:/create_license.rb
- ./create_license.rb:/create_license.rb
ports:
- '8080:80'
- '2222:22'
networks:
- gitlab-network

gitlab-runner:
image: '${GITLAB_RUNNER_IMAGE}:${GITLAB_RUNNER_TAG}'
image: '${GITLAB_RUNNER_IMAGE:-gitlab/gitlab-runner}:${GITLAB_RUNNER_TAG:-latest}'
container_name: 'gitlab-runner-test'
depends_on:
- gitlab
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"""

import pytest
import pytest_docker

Check warning on line 7 in gitlab/testing/docker/docker.py

View check run for this annotation

Codecov / codecov/patch

gitlab/testing/docker/docker.py#L7

Added line #L7 was not covered by tests


@pytest.fixture(scope="session")
Expand All @@ -12,15 +13,27 @@
return "pytest-python-gitlab"


pytest_docker.docker_compose_project_name = docker_compose_project_name

Check warning on line 16 in gitlab/testing/docker/docker.py

View check run for this annotation

Codecov / codecov/patch

gitlab/testing/docker/docker.py#L16

Added line #L16 was not covered by tests


@pytest.fixture(scope="session")
def docker_compose_file(fixture_dir):
return fixture_dir / "docker-compose.yml"
def docker_compose_file(docker_assets_dir):

Check warning on line 20 in gitlab/testing/docker/docker.py

View check run for this annotation

Codecov / codecov/patch

gitlab/testing/docker/docker.py#L20

Added line #L20 was not covered by tests
return docker_assets_dir / "docker-compose.yml"


pytest_docker.docker_compose_file = docker_compose_file

Check warning on line 24 in gitlab/testing/docker/docker.py

View check run for this annotation

Codecov / codecov/patch

gitlab/testing/docker/docker.py#L24

Added line #L24 was not covered by tests


@pytest.fixture(scope="session")
def docker_cleanup(request):
"""Conditionally keep containers around by overriding the cleanup command."""
if request.config.getoption("--keep-containers"):
if request.config.getoption("--keep-containers-running"):
# Print version and exit.
return "-v"
return "down -v"
if request.config.getoption("--keep-containers"):
# Stop the containers.
return "stop"

Check warning on line 35 in gitlab/testing/docker/docker.py

View check run for this annotation

Codecov / codecov/patch

gitlab/testing/docker/docker.py#L35

Added line #L35 was not covered by tests
return "down"


pytest_docker.docker_cleanup = docker_cleanup

Check warning on line 39 in gitlab/testing/docker/docker.py

View check run for this annotation

Codecov / codecov/patch

gitlab/testing/docker/docker.py#L39

Added line #L39 was not covered by tests
11 changes: 11 additions & 0 deletions gitlab/testing/docker/install_docker.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
apt-get update
apt-get install -y apt-transport-https ca-certificates curl gnupg2 software-properties-common
curl -fsSL https://download.docker.com/linux/debian/gpg | apt-key add -
apt-get update
echo \
"deb [arch=$(dpkg --print-architecture)] https://download.docker.com/linux/ubuntu \
$(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \
tee /etc/apt/sources.list.d/docker.list > /dev/null
apt-get update
apt-get install -y docker-ce docker-compose
usermod -aG docker gitlab-runner
Empty file.
Loading
Loading