fix(tests): fix flacky tests

This commit is contained in:
RhodeCode Admin 2026-01-13 09:05:20 +01:00
parent 9ecdc7f7e1
commit ed1e9accb8

View file

@ -17,6 +17,8 @@
# and proprietary license terms, please see https://rhodecode.com/licenses/
import os
import time
import pytest
from rhodecode.tests import TEST_USER_ADMIN_LOGIN, TEST_USER_ADMIN_PASS, TEST_USER_REGULAR_LOGIN, TEST_USER_REGULAR_PASS
@ -54,6 +56,12 @@ class TestVCSOperations(object):
branch_permission_setter(repo_name, username, permission=branch_perm)
clone_url = rcstack.repo_clone_url(repo.repo_name, user=username, passwd=password)
# Give VCSServer time to initialize the empty Mercurial repository
# Empty hg repos (unlike git bare repos) need a moment to be fully indexed
# This prevents intermittent "repository is unrelated" errors
time.sleep(0.2)
repo.scm_instance(cache=False) # Force load in VCSServer
Command(os.path.dirname(tmpdir.strpath)).execute("hg clone", clone_url, tmpdir.strpath)
stdout, stderr = _add_files_and_push("hg", tmpdir.strpath, clone_url=clone_url)