summaryrefslogtreecommitdiff
path: root/tests/functional/conftest.py
diff options
context:
space:
mode:
authorJohn L. Villalovos <john@sodarock.com>2023-02-18 22:23:08 -0800
committerJohn L. Villalovos <john@sodarock.com>2023-02-18 22:23:08 -0800
commit01569eaca9d635f05c8b7b302e02137ffee94793 (patch)
tree14f12671a09215fef7ff5ed36d9ad0b8f1f6403d /tests/functional/conftest.py
parentd435782f358f0457433a760b7e04126114180931 (diff)
downloadgitlab-jlvillal/bump_ee_version.tar.gz
chore: move to GitLab 15.6.8-ee.0jlvillal/bump_ee_version
Diffstat (limited to 'tests/functional/conftest.py')
-rw-r--r--tests/functional/conftest.py44
1 files changed, 31 insertions, 13 deletions
diff --git a/tests/functional/conftest.py b/tests/functional/conftest.py
index 34b286b..ef551c4 100644
--- a/tests/functional/conftest.py
+++ b/tests/functional/conftest.py
@@ -209,7 +209,32 @@ def check_is_alive():
return _check
-@pytest.fixture
+def wait_for_sidekiq_function(
+ *,
+ gl_instance: gitlab.Gitlab,
+ timeout: int = 30,
+ step: float = 0.5,
+ allow_fail: bool = False,
+) -> bool:
+ """A function that is called to wait for the sidekiq process to finish. As
+ opposed to the fixture."""
+ for count in range(timeout):
+ time.sleep(step)
+ busy = False
+ process_metrics = gl_instance.sidekiq.process_metrics()
+ assert isinstance(process_metrics, dict)
+ processes = process_metrics["processes"]
+ for process in processes:
+ if process["busy"]:
+ busy = True
+ if not busy:
+ return True
+ logging.info(f"sidekiq busy {count} of {timeout}")
+ assert allow_fail, "sidekiq process should have terminated but did not."
+ return False
+
+
+@pytest.fixture(scope="function")
def wait_for_sidekiq(gl):
"""
Return a helper function to wait until there are no busy sidekiq processes.
@@ -218,18 +243,9 @@ def wait_for_sidekiq(gl):
"""
def _wait(timeout: int = 30, step: float = 0.5, allow_fail: bool = False) -> bool:
- for count in range(timeout):
- time.sleep(step)
- busy = False
- processes = gl.sidekiq.process_metrics()["processes"]
- for process in processes:
- if process["busy"]:
- busy = True
- if not busy:
- return True
- logging.info(f"sidekiq busy {count} of {timeout}")
- assert allow_fail, "sidekiq process should have terminated but did not."
- return False
+ return wait_for_sidekiq_function(
+ gl_instance=gl, timeout=timeout, step=step, allow_fail=allow_fail
+ )
return _wait
@@ -529,6 +545,8 @@ def user(gl):
yield user
+ result = wait_for_sidekiq_function(gl_instance=gl, timeout=60)
+ assert result is True, "sidekiq process should have terminated but did not"
# Use `hard_delete=True` or a 'Ghost User' may be created.
helpers.safe_delete(user, hard_delete=True)