1+ import os
12import tempfile
23import time
34import uuid
@@ -15,6 +16,13 @@ def fixture_dir(test_dir):
1516
1617
1718def 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 ()
1826 # previously tools/reset_gitlab.py
1927 for project in gl .projects .list ():
2028 for deploy_token in project .deploytokens .list ():
@@ -134,7 +142,7 @@ def gitlab_config(check_is_alive, docker_ip, docker_services, temp_dir, fixture_
134142 port = docker_services .port_for ("gitlab" , 80 )
135143
136144 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" )
138146 )
139147
140148 token = set_token ("gitlab-test" , fixture_dir = fixture_dir )
@@ -164,6 +172,25 @@ def gl(gitlab_config):
164172 return instance
165173
166174
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+
167194@pytest .fixture (scope = "session" )
168195def gitlab_runner (gl ):
169196 container = "gitlab-runner-test"
0 commit comments