Commit 62629fe5 authored by Markus Scheidgen's avatar Markus Scheidgen
Browse files

Fixed broken tests.

parent d3dd9b29
Pipeline #60614 passed with stages
in 19 minutes and 25 seconds
......@@ -159,7 +159,7 @@ class Entry(Document, metaclass=WithDomain):
self.uploader = User.from_user_popo(source.uploader) if source.uploader is not None else None
self.with_embargo = source.with_embargo
self.with_embargo = bool(source.with_embargo)
self.published = source.published
self.authors = [User.from_user_popo(user) for user in source.coauthors]
self.owners = [User.from_user_popo(user) for user in source.shared_with]
......
......@@ -169,9 +169,9 @@ def mongo(mongo_infra):
@pytest.fixture(scope='session')
def elastic_infra():
def elastic_infra(monkeysession):
""" Provides elastic infrastructure to the session """
config.elastic.index_name = 'test_nomad_fairdi_calcs'
monkeysession.setattr('nomad.config.elastic.index_name', 'test_nomad_fairdi_calcs')
try:
return infrastructure.setup_elastic()
except Exception:
......@@ -183,19 +183,14 @@ def elastic_infra():
def clear_elastic(elastic):
for backoff in [0.1, 1, 5, None]:
try:
elastic.delete_by_query(
index='test_nomad_fairdi_calcs', body=dict(query=dict(match_all={})),
wait_for_completion=True, refresh=True)
break
except elasticsearch.exceptions.NotFoundError:
break
except Exception as e:
if backoff is None:
raise e
else:
time.sleep(backoff)
try:
elastic.delete_by_query(
index='test_nomad_fairdi_calcs', body=dict(query=dict(match_all={})),
wait_for_completion=True, refresh=True)
except elasticsearch.exceptions.NotFoundError:
# it is unclear why this happens, but it happens at least once, when all tests
# are executed
infrastructure.setup_elastic()
@pytest.fixture(scope='function')
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment