mirror of
https://github.com/odoo/runbot.git
synced 2025-03-15 15:35:46 +07:00
[FIX] runbot_merge: testsuite compatibility with pytest-xdist
randomise the name of the repositories created so they don't collide and lead to odd results when running concurrent test cases which specify the same repo name (a common property). As a result, ignore the "no delete" flag for creation: there should be no way to land on a pre-existing repo name even if we didn't clean them up. Also stagger the check of a running ngrok process: when pytest starts its worker processes, all workers will run the tunnel fixture, and since the ngrok process takes some time to get into a stable run state chances are multiple workers will fail to connect and try to start ngrok concurrently, which blows up as ngrok just kills the extra processes instead of merging / proxying into an existing session. A proper lockfile would probably be better but... Fixes #297
This commit is contained in:
parent
d0138712bd
commit
b2f9bd697c
14
conftest.py
14
conftest.py
@ -45,6 +45,8 @@ import configparser
|
||||
import copy
|
||||
import itertools
|
||||
import logging
|
||||
import os
|
||||
import random
|
||||
import re
|
||||
import socket
|
||||
import subprocess
|
||||
@ -149,6 +151,8 @@ def tunnel(pytestconfig, port):
|
||||
addr = 'localhost:%d' % port
|
||||
# if ngrok is not running, start it
|
||||
try:
|
||||
# FIXME: use lockfile instead
|
||||
time.sleep(random.randint(1, 10))
|
||||
# FIXME: use config file so we can set web_addr to something else
|
||||
# than localhost:4040 (otherwise we can't disambiguate
|
||||
# between the ngrok we started and an ngrok started by
|
||||
@ -321,17 +325,9 @@ def make_repo(request, config, tunnel, users):
|
||||
|
||||
repos = []
|
||||
def repomaker(name):
|
||||
name = 'ignore_%s_%s' % (name, base64.b64encode(os.urandom(6), b'-_').decode())
|
||||
fullname = '{}/{}'.format(owner, name)
|
||||
repo_url = 'https://api.github.com/repos/{}'.format(fullname)
|
||||
if request.config.getoption('--no-delete'):
|
||||
if github.head(repo_url).ok:
|
||||
pytest.skip("Repository {} already exists".format(fullname))
|
||||
else:
|
||||
# just try to delete the repo, we don't really care
|
||||
if github.delete(repo_url).ok:
|
||||
# if we did delete a repo, wait a bit as gh might need to
|
||||
# propagate the thing?
|
||||
time.sleep(30)
|
||||
|
||||
# create repo
|
||||
r = github.post(endpoint, json={
|
||||
|
Loading…
Reference in New Issue
Block a user