1111import gitlab .base
1212
1313SLEEP_INTERVAL = 0.5
14- TIMEOUT = 60 # seconds before timeout will occur
14+ TIMEOUT = 3 * 60 # seconds before timeout will occur
1515
1616
1717@pytest .fixture (scope = "session" )
@@ -21,6 +21,17 @@ def fixture_dir(test_dir):
2121
2222def reset_gitlab (gl ):
2323 # previously tools/reset_gitlab.py
24+ if is_gitlab_ee (gl ):
25+ logging .info ("GitLab EE detected" )
26+ # NOTE(jlvillal): By default in GitLab EE it will wait 7 days before
27+ # deleting a group. Change it to 0 days.
28+ settings = gl .settings .get ()
29+ logging .info (f"deletion_adjourned_period: { settings .deletion_adjourned_period } " )
30+ if settings .deletion_adjourned_period != 0 :
31+ logging .info (f"Setting deletion_adjourned_period to 0" )
32+ settings .deletion_adjourned_period = 0
33+ settings .save ()
34+
2435 for project in gl .projects .list ():
2536 logging .info (f"Marking for deletion project: { project .path_with_namespace !r} " )
2637 for deploy_token in project .deploytokens .list ():
@@ -65,9 +76,11 @@ def wait_for_list_size(
6576 if len (items ) <= max_length :
6677 break
6778 logging .info (
68- f"Iteration: { count } Waiting for { description !r} items to be deleted: "
69- f"{ [x .name for x in items ]} "
79+ f"Iteration: { count } of { max_iterations } : Waiting for { description !r} "
80+ f"items to be deleted: { [x .name for x in items ]} "
7081 )
82+ for item in items :
83+ logging .info (f"JLV: { item } { item .name } { item .pformat ()} " )
7184 time .sleep (SLEEP_INTERVAL )
7285
7386 elapsed_time = time .perf_counter () - start_time
@@ -238,6 +251,18 @@ def gl(gitlab_config):
238251 return instance
239252
240253
254+ def is_gitlab_ee (gl : gitlab .Gitlab ) -> bool :
255+ """Determine if we are running with GitLab EE as opposed to GitLab CE"""
256+ try :
257+ license = gl .get_license ()
258+ except gitlab .exceptions .GitlabLicenseError :
259+ license = None
260+ # If we have a license then we assume we are running on GitLab EE
261+ if license :
262+ return True
263+ return False
264+
265+
241266@pytest .fixture (scope = "session" )
242267def gitlab_runner (gl ):
243268 container = "gitlab-runner-test"
0 commit comments