Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
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 6 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 0 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}'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we maybe extract the preparation changes (everything that can be applied without moving the plugin) into a separate PR that we merge first? Just so we can focus on integration aspects here. Let me know otherwise I can also try that on my end.

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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this definitely work (i.e. it will be relative to the compose config file) regardless of where the tests are executed from? Just making sure, I know that different compose implementations have different behavior 🙇

We had some issues in the past when we tried to migrate to compose v2, so just wanted to check.

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 11 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
Morty Proxy This is a proxified and sanitized view of the page, visit original site.