Skip to content

Commit d82d267

Browse files
test(functional): update to GitLab 18.6 and resolve issues found
1 parent 4221195 commit d82d267

File tree

7 files changed

+33
-19
lines changed

7 files changed

+33
-19
lines changed

tests/functional/api/test_epics.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,20 @@ def test_epics(group):
1515
assert group.epics.list()
1616

1717

18-
@pytest.mark.xfail(reason="404 on issue.id")
1918
def test_epic_issues(epic, issue):
2019
assert not epic.issues.list()
2120

21+
# FYI: Creating an issue causes a note to be created
2222
epic_issue = epic.issues.create({"issue_id": issue.id})
2323
assert epic.issues.list()
2424

25+
# FYI: Deleting an issue causes a note to be created
2526
epic_issue.delete()
2627

2728

2829
def test_epic_notes(epic):
29-
assert not epic.notes.list()
30+
notes = epic.notes.list(get_all=True)
3031

3132
epic.notes.create({"body": "Test note"})
32-
assert epic.notes.list()
33+
new_notes = epic.notes.list(get_all=True)
34+
assert len(new_notes) == (len(notes) + 1), f"{new_notes} {notes}"

tests/functional/api/test_keys.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,14 @@ def test_keys_deploy(gl, project, DEPLOY_KEY):
3838
key_by_fingerprint = gl.keys.get(fingerprint=fingerprint)
3939
assert key_by_fingerprint.title == key.title
4040
assert key_by_fingerprint.key == key.key
41-
assert len(key_by_fingerprint.deploy_keys_projects) == 1
41+
42+
for key_project in key_by_fingerprint.deploy_keys_projects:
43+
if key_project.get("project_id") == project.id:
44+
break
45+
else:
46+
raise AssertionError(
47+
f"Project {project} not found in 'deploy_keys_projects' "
48+
f"{key_by_fingerprint.pformat()}"
49+
)
4250

4351
key.delete()

tests/functional/api/test_project_job_token_scope.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
import pytest
2+
3+
14
# https://docs.gitlab.com/ee/ci/jobs/ci_job_token.html#allow-any-project-to-access-your-project
25
def test_enable_limit_access_to_this_project(gl, project):
36
scope = project.job_token_scope.get()
@@ -10,6 +13,7 @@ def test_enable_limit_access_to_this_project(gl, project):
1013
assert scope.inbound_enabled
1114

1215

16+
@pytest.mark.xfail(reason="https://gitlab.com/gitlab-org/gitlab/-/issues/582271")
1317
def test_disable_limit_access_to_this_project(gl, project):
1418
scope = project.job_token_scope.get()
1519

tests/functional/api/test_projects.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@ def test_create_project(gl, user):
2626

2727
sudo_project = gl.projects.create({"name": "sudo_project"}, sudo=user.id)
2828

29-
created = gl.projects.list()
29+
created = gl.projects.list(get_all=True)
3030
created_gen = gl.projects.list(iterator=True)
31-
owned = gl.projects.list(owned=True)
31+
owned = gl.projects.list(owned=True, get_all=True)
3232

3333
assert admin_project in created and sudo_project in created
3434
assert admin_project in owned and sudo_project not in owned

tests/functional/fixtures/.env

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
GITLAB_IMAGE=gitlab/gitlab-ee
2-
GITLAB_TAG=17.8.2-ee.0
2+
GITLAB_TAG=18.6.1-ee.0
33
GITLAB_RUNNER_IMAGE=gitlab/gitlab-runner
44
GITLAB_RUNNER_TAG=96856197

tests/functional/fixtures/docker-compose.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ services:
3434
entrypoint:
3535
- /bin/sh
3636
- -c
37-
- ruby /create_license.rb && /assets/wrapper
37+
- ruby /create_license.rb && /assets/init-container
3838
volumes:
3939
- ${PWD}/tests/functional/fixtures/create_license.rb:/create_license.rb
4040
ports:

tests/functional/helpers.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import gitlab
1010
import gitlab.base
1111
import gitlab.exceptions
12+
import gitlab.v4.objects
1213

1314
SLEEP_INTERVAL = 0.5
1415
TIMEOUT = 60 # seconds before timeout will occur
@@ -37,6 +38,11 @@ def safe_delete(object: gitlab.base.RESTObject) -> None:
3738
object = manager.get(object.get_id()) # type: ignore[attr-defined]
3839
except gitlab.exceptions.GitlabGetError:
3940
return
41+
# If object is already marked for deletion we have succeeded
42+
if getattr(object, "marked_for_deletion_on", None) is not None:
43+
# 'Group' and 'Project' objects have a 'marked_for_deletion_on' attribute
44+
logging.info(f"{object!r} is marked for deletion.")
45+
return
4046

4147
if index:
4248
logging.info(f"Attempt {index + 1} to delete {object!r}.")
@@ -52,22 +58,16 @@ def safe_delete(object: gitlab.base.RESTObject) -> None:
5258
# we shouldn't cause test to fail if it still exists
5359
return
5460
elif isinstance(object, gitlab.v4.objects.Project):
55-
# Immediately delete rather than waiting for at least 1day
56-
# https://docs.gitlab.com/ee/api/projects.html#delete-project
57-
object.delete(permanently_remove=True)
58-
pass
61+
# Starting in GitLab 18, projects can't be immediately deleted.
62+
# So this will mark it for deletion.
63+
object.delete()
5964
else:
6065
# We only attempt to delete parent groups to prevent dangling sub-groups
61-
# However parent groups can only be deleted on a delay in Gl 16
66+
# However parent groups can only be deleted on a delay in GitLab 16
6267
# https://docs.gitlab.com/ee/api/groups.html#remove-group
6368
object.delete()
6469
except gitlab.exceptions.GitlabDeleteError:
65-
logging.info(f"{object!r} already deleted or scheduled for deletion.")
66-
if isinstance(object, gitlab.v4.objects.Group):
67-
# Parent groups can never be immediately deleted in GL 16,
68-
# so don't cause test to fail if it still exists
69-
return
70-
pass
70+
logging.exception(f"Error attempting to delete: {object.pformat()}")
7171

7272
time.sleep(SLEEP_INTERVAL)
7373
pytest.fail(f"{object!r} was not deleted")

0 commit comments

Comments
 (0)