mirror of
https://github.com/odoo/runbot.git
synced 2025-03-15 15:35:46 +07:00
[IMP] *: store filestore & forwardport checkouts in temp dirs
I'm surprised this ever worked, I guess concurrent tests stopped working long before that? Or I misunderstood some of the historical failures as transient? During the cleanup of the forwardport test, I'd empty out the `user_cache_dir('forwardport') / owner`, except the owner is always the same (more or less) so all the tests check out their repos (and working copies) in the same directory. If one test is cleaning up while an other is performing a forward port, the second will blow up. Also move the filestore to a tempdir, especially during creation of the template db: it gets leaked so over time that generates gigabytes of data which doesn't get cleaned up. But the template db filestore is only "necessary" during the creation of the template, once the template's been created it's of no use and won't be copied to create the test dbs (though it could be, I guess).
This commit is contained in:
parent
3da1874196
commit
32bf0deda6
30
conftest.py
30
conftest.py
@ -271,14 +271,18 @@ class DbDict(dict):
|
||||
self._adpath = adpath
|
||||
def __missing__(self, module):
|
||||
self[module] = db = 'template_%s' % uuid.uuid4()
|
||||
subprocess.run([
|
||||
'odoo', '--no-http',
|
||||
'--addons-path', self._adpath,
|
||||
'-d', db, '-i', module + ',auth_oauth',
|
||||
'--max-cron-threads', '0',
|
||||
'--stop-after-init',
|
||||
'--log-level', 'warn'
|
||||
], check=True)
|
||||
with tempfile.TemporaryDirectory() as d:
|
||||
subprocess.run([
|
||||
'odoo', '--no-http',
|
||||
'--addons-path', self._adpath,
|
||||
'-d', db, '-i', module + ',auth_oauth',
|
||||
'--max-cron-threads', '0',
|
||||
'--stop-after-init',
|
||||
'--log-level', 'warn'
|
||||
],
|
||||
check=True,
|
||||
env={**os.environ, 'XDG_DATA_HOME': d}
|
||||
)
|
||||
return db
|
||||
|
||||
@pytest.fixture(scope='session')
|
||||
@ -355,7 +359,7 @@ def from_role(_):
|
||||
yield dummy_addons_path
|
||||
|
||||
@pytest.fixture
|
||||
def server(request, db, port, module, dummy_addons_path):
|
||||
def server(request, db, port, module, dummy_addons_path, tmpdir):
|
||||
log_handlers = [
|
||||
'odoo.modules.loading:WARNING',
|
||||
]
|
||||
@ -372,7 +376,13 @@ def server(request, db, port, module, dummy_addons_path):
|
||||
'-d', db,
|
||||
'--max-cron-threads', '0', # disable cron threads (we're running crons by hand)
|
||||
*itertools.chain.from_iterable(('--log-handler', h) for h in log_handlers),
|
||||
])
|
||||
], env={
|
||||
**os.environ,
|
||||
# stop putting garbage in the user dirs, and potentially creating conflicts
|
||||
# TODO: way to override this with macOS?
|
||||
'XDG_DATA_HOME': str(tmpdir.mkdir('share')),
|
||||
'XDG_CACHE_HOME': str(tmpdir.mkdir('cache')),
|
||||
})
|
||||
|
||||
try:
|
||||
wait_for_server(db, port, p, module)
|
||||
|
@ -1,12 +1,8 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
import pathlib
|
||||
import re
|
||||
import requests
|
||||
from shutil import rmtree
|
||||
|
||||
import pytest
|
||||
|
||||
from odoo.tools.appdirs import user_cache_dir
|
||||
import requests
|
||||
|
||||
@pytest.fixture
|
||||
def default_crons():
|
||||
@ -47,20 +43,6 @@ def _check_scopes(config):
|
||||
assert token_scopes >= required_scopes, \
|
||||
"%s should have scopes %s, found %s" % (section, token_scopes, required_scopes)
|
||||
|
||||
@pytest.fixture(autouse=True)
|
||||
def _cleanup_cache(config, users):
|
||||
""" forwardport has a repo cache which it assumes is unique per name
|
||||
but tests always use the same repo paths / names for different repos
|
||||
(the repos get re-created), leading to divergent repo histories.
|
||||
|
||||
So clear cache after each test, two tests should not share repos.
|
||||
"""
|
||||
yield
|
||||
cache_root = pathlib.Path(user_cache_dir('forwardport'))
|
||||
rmtree(cache_root / config['github']['owner'], ignore_errors=True)
|
||||
for login in users.values():
|
||||
rmtree(cache_root / login, ignore_errors=True)
|
||||
|
||||
@pytest.fixture()
|
||||
def module():
|
||||
""" When a test function is (going to be) run, selects the containing
|
||||
|
Loading…
Reference in New Issue
Block a user