Skip to content

Commit cbc613d

Browse files
nejchJohnVillalovos
authored andcommitted
test(functional): switch to new runner registration API
1 parent 41eb95d commit cbc613d

File tree

2 files changed

+15
-12
lines changed

2 files changed

+15
-12
lines changed

tests/functional/conftest.py

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import time
99
import uuid
1010
from subprocess import check_output
11-
from typing import Sequence
11+
from typing import Sequence, TYPE_CHECKING
1212

1313
import pytest
1414
import requests
@@ -260,6 +260,7 @@ def gl(gitlab_url: str, gitlab_token: str) -> gitlab.Gitlab:
260260

261261
logging.info("Instantiating python-gitlab gitlab.Gitlab instance")
262262
instance = gitlab.Gitlab(gitlab_url, private_token=gitlab_token)
263+
instance.auth()
263264

264265
logging.info("Reset GitLab")
265266
reset_gitlab(instance)
@@ -291,33 +292,36 @@ def gitlab_ultimate(gitlab_plan, request) -> None:
291292

292293

293294
@pytest.fixture(scope="session")
294-
def gitlab_runner(gl):
295+
def gitlab_runner(gl: gitlab.Gitlab):
295296
container = "gitlab-runner-test"
296-
runner_name = "python-gitlab-runner"
297-
token = "registration-token"
297+
runner_description = "python-gitlab-runner"
298+
if TYPE_CHECKING:
299+
assert gl.user is not None
300+
301+
runner = gl.user.runners.create(
302+
{"runner_type": "instance_type", "run_untagged": True}
303+
)
298304
url = "http://gitlab"
299305

300306
docker_exec = ["docker", "exec", container, "gitlab-runner"]
301307
register = [
302308
"register",
303-
"--run-untagged",
304309
"--non-interactive",
305-
"--registration-token",
306-
token,
307-
"--name",
308-
runner_name,
310+
"--token",
311+
runner.token,
312+
"--description",
313+
runner_description,
309314
"--url",
310315
url,
311316
"--clone-url",
312317
url,
313318
"--executor",
314319
"shell",
315320
]
316-
unregister = ["unregister", "--name", runner_name]
317321

318322
yield check_output(docker_exec + register).decode()
319323

320-
check_output(docker_exec + unregister).decode()
324+
gl.runners.delete(token=runner.token)
321325

322326

323327
@pytest.fixture(scope="module")

tests/functional/fixtures/docker-compose.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ services:
1212
privileged: true # Just in case https://gitlab.com/gitlab-org/omnibus-gitlab/-/issues/1350
1313
environment:
1414
GITLAB_ROOT_PASSWORD: 5iveL!fe
15-
GITLAB_SHARED_RUNNERS_REGISTRATION_TOKEN: registration-token
1615
GITLAB_OMNIBUS_CONFIG: |
1716
external_url 'http://127.0.0.1:8080'
1817
registry['enable'] = false

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy