1
+ import os
1
2
import tempfile
2
3
import time
3
4
import uuid
@@ -15,6 +16,13 @@ def fixture_dir(test_dir):
15
16
16
17
17
18
def reset_gitlab (gl ):
19
+ if _is_gitlab_ee (gl ):
20
+ # NOTE(jlvillal): By default in GitLab EE it will wait 7 days before
21
+ # deleting a group. Change it to 0 days.
22
+ settings = gl .settings .get ()
23
+ if settings .deletion_adjourned_period != 0 :
24
+ settings .deletion_adjourned_period = 0
25
+ settings .save ()
18
26
# previously tools/reset_gitlab.py
19
27
for project in gl .projects .list ():
20
28
for deploy_token in project .deploytokens .list ():
@@ -134,7 +142,7 @@ def gitlab_config(check_is_alive, docker_ip, docker_services, temp_dir, fixture_
134
142
port = docker_services .port_for ("gitlab" , 80 )
135
143
136
144
docker_services .wait_until_responsive (
137
- timeout = 200 , pause = 5 , check = lambda : check_is_alive ("gitlab-test" )
145
+ timeout = 300 , pause = 5 , check = lambda : check_is_alive ("gitlab-test" )
138
146
)
139
147
140
148
token = set_token ("gitlab-test" , fixture_dir = fixture_dir )
@@ -164,6 +172,25 @@ def gl(gitlab_config):
164
172
return instance
165
173
166
174
175
+ @pytest .fixture (scope = "session" )
176
+ def is_gitlab_ee (gl ) -> bool :
177
+ """Fixture to determine if we are running with GitLab EE as opposed to
178
+ GitLab CE"""
179
+ return _is_gitlab_ee (gl = gl )
180
+
181
+
182
+ def _is_gitlab_ee (gl : gitlab .Gitlab ) -> bool :
183
+ """Determine if we are running with GitLab EE as opposed to GitLab CE"""
184
+ try :
185
+ license = gl .get_license ()
186
+ except gitlab .exceptions .GitlabLicenseError :
187
+ license = None
188
+ # If we have a license then we assume we are running on GitLab EE
189
+ if license :
190
+ return True
191
+ return False
192
+
193
+
167
194
@pytest .fixture (scope = "session" )
168
195
def gitlab_runner (gl ):
169
196
container = "gitlab-runner-test"
0 commit comments