Skip to content

Commit

Permalink
Make some tests more reliable
Browse files Browse the repository at this point in the history
  • Loading branch information
fvennetier committed Oct 18, 2019
1 parent 6bbb3e0 commit 55d04f5
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
3 changes: 2 additions & 1 deletion tests/functional/cli/container/test_container.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (C) 2016-2017 OpenIO SAS, as part of OpenIO SDS
# Copyright (C) 2016-2019 OpenIO SAS, as part of OpenIO SDS
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
Expand Down Expand Up @@ -106,6 +106,7 @@ def test_container_refresh_with_cid(self):
self._test_container_refresh(with_cid=True)

def _test_container_snapshot(self, with_cid=False):
self.wait_for_score(('meta2', ))
# Snapshot should reply the name of the snapshot on success
opts = self.get_opts([], 'json')
cid_opt = ''
Expand Down
7 changes: 6 additions & 1 deletion tests/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -500,10 +500,15 @@ def wait_for_score(self, types, timeout=20.0, score_threshold=35):
wait = False
for type_ in types:
try:
for service in self.conscience.all_services(type_):
all_svcs = self.conscience.all_services(type_)
for service in all_svcs:
if int(service['score']) < score_threshold:
wait = True
break
else:
# No service registered yet, must wait.
if not all_svcs:
wait = True
except Exception as err:
logging.warn('Could not check service score: %s', err)
wait = True
Expand Down

0 comments on commit 55d04f5

Please # to comment.