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,15 @@ 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+ if settings .deletion_adjourned_period != 0 :
30+ settings .deletion_adjourned_period = 0
31+ settings .save ()
32+
2433 for project in gl .projects .list ():
2534 logging .info (f"Marking for deletion project: { project .path_with_namespace !r} " )
2635 for deploy_token in project .deploytokens .list ():
@@ -61,13 +70,15 @@ def wait_for_list_size(
6170 test if timeout is exceeded"""
6271 logging .info (f"Checking { description !r} has no more than { max_length } items" )
6372 for count in range (max_iterations ):
64- items = rest_manager .list ()
73+ items = list ( rest_manager .list () )
6574 if len (items ) <= max_length :
6675 break
6776 logging .info (
68- f"Iteration: { count } Waiting for { description !r} items to be deleted: "
69- f"{ [x .name for x in items ]} "
77+ f"Iteration: { count } of { max_iterations } : Waiting for { description !r} "
78+ f"items to be deleted: { [x .name for x in items ]} "
7079 )
80+ for item in items :
81+ logging .info (f"JLV: { item .pprint ()} " )
7182 time .sleep (SLEEP_INTERVAL )
7283
7384 elapsed_time = time .perf_counter () - start_time
@@ -226,6 +237,18 @@ def gl(gitlab_config):
226237 return instance
227238
228239
240+ def is_gitlab_ee (gl : gitlab .Gitlab ) -> bool :
241+ """Determine if we are running with GitLab EE as opposed to GitLab CE"""
242+ try :
243+ license = gl .get_license ()
244+ except gitlab .exceptions .GitlabLicenseError :
245+ license = None
246+ # If we have a license then we assume we are running on GitLab EE
247+ if license :
248+ return True
249+ return False
250+
251+
229252@pytest .fixture (scope = "session" )
230253def gitlab_runner (gl ):
231254 container = "gitlab-runner-test"
0 commit comments