11
11
import gitlab .base
12
12
13
13
SLEEP_INTERVAL = 0.5
14
- TIMEOUT = 60 # seconds before timeout will occur
14
+ TIMEOUT = 3 * 60 # seconds before timeout will occur
15
15
16
16
17
17
@pytest .fixture (scope = "session" )
@@ -21,6 +21,15 @@ def fixture_dir(test_dir):
21
21
22
22
def reset_gitlab (gl ):
23
23
# 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
+
24
33
for project in gl .projects .list ():
25
34
logging .info (f"Marking for deletion project: { project .path_with_namespace !r} " )
26
35
for deploy_token in project .deploytokens .list ():
@@ -61,13 +70,15 @@ def wait_for_list_size(
61
70
test if timeout is exceeded"""
62
71
logging .info (f"Checking { description !r} has no more than { max_length } items" )
63
72
for count in range (max_iterations ):
64
- items = rest_manager .list ()
73
+ items = list ( rest_manager .list () )
65
74
if len (items ) <= max_length :
66
75
break
67
76
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 ]} "
70
79
)
80
+ for item in items :
81
+ logging .info (f"JLV: { item .pprint ()} " )
71
82
time .sleep (SLEEP_INTERVAL )
72
83
73
84
elapsed_time = time .perf_counter () - start_time
@@ -226,6 +237,18 @@ def gl(gitlab_config):
226
237
return instance
227
238
228
239
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
+
229
252
@pytest .fixture (scope = "session" )
230
253
def gitlab_runner (gl ):
231
254
container = "gitlab-runner-test"
0 commit comments