@@ -15,6 +15,13 @@ def fixture_dir(test_dir):
1515
1616
1717def reset_gitlab (gl ):
18+ if _is_gitlab_ee (gl ):
19+ # NOTE(jlvillal): By default in GitLab EE it will wait 7 days before
20+ # deleting a group. Change it to 0 days.
21+ settings = gl .settings .get ()
22+ if settings .deletion_adjourned_period != 0 :
23+ settings .deletion_adjourned_period = 0
24+ settings .save ()
1825 # previously tools/reset_gitlab.py
1926 for project in gl .projects .list ():
2027 for deploy_token in project .deploytokens .list ():
@@ -29,6 +36,7 @@ def reset_gitlab(gl):
2936 for user in gl .users .list ():
3037 if user .username != "root" :
3138 user .delete (hard_delete = True )
39+ _wait_for_sidekiq (gl = gl )(timeout = 60 )
3240
3341
3442def set_token (container , fixture_dir ):
@@ -106,7 +114,16 @@ def _check(container):
106114
107115
108116@pytest .fixture
109- def wait_for_sidekiq (gl ):
117+ def wait_for_sidekiq (gl : gitlab .Gitlab ):
118+ """
119+ Return a helper function to wait until there are no busy sidekiq processes.
120+
121+ Use this with asserts for slow tasks (group/project/user creation/deletion).
122+ """
123+ return _wait_for_sidekiq (gl = gl )
124+
125+
126+ def _wait_for_sidekiq (gl : gitlab .Gitlab ):
110127 """
111128 Return a helper function to wait until there are no busy sidekiq processes.
112129
@@ -134,7 +151,7 @@ def gitlab_config(check_is_alive, docker_ip, docker_services, temp_dir, fixture_
134151 port = docker_services .port_for ("gitlab" , 80 )
135152
136153 docker_services .wait_until_responsive (
137- timeout = 200 , pause = 5 , check = lambda : check_is_alive ("gitlab-test" )
154+ timeout = 300 , pause = 5 , check = lambda : check_is_alive ("gitlab-test" )
138155 )
139156
140157 token = set_token ("gitlab-test" , fixture_dir = fixture_dir )
@@ -164,6 +181,25 @@ def gl(gitlab_config):
164181 return instance
165182
166183
184+ @pytest .fixture (scope = "session" )
185+ def is_gitlab_ee (gl ) -> bool :
186+ """Fixture to determine if we are running with GitLab EE as opposed to
187+ GitLab CE"""
188+ return _is_gitlab_ee (gl = gl )
189+
190+
191+ def _is_gitlab_ee (gl : gitlab .Gitlab ) -> bool :
192+ """Determine if we are running with GitLab EE as opposed to GitLab CE"""
193+ try :
194+ license = gl .get_license ()
195+ except gitlab .exceptions .GitlabLicenseError :
196+ license = None
197+ # If we have a license then we assume we are running on GitLab EE
198+ if license :
199+ return True
200+ return False
201+
202+
167203@pytest .fixture (scope = "session" )
168204def gitlab_runner (gl ):
169205 container = "gitlab-runner-test"
0 commit comments