From a909cb631c26c3c3475372322bc30fb2c8e5122d Mon Sep 17 00:00:00 2001 From: Aymeric Ducroquetz Date: Wed, 31 Mar 2021 15:33:21 +0200 Subject: [PATCH] CI: Wait for all deletes to fetch the new object with a dirty cache --- tests/functional/api/test_objectstorage.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/tests/functional/api/test_objectstorage.py b/tests/functional/api/test_objectstorage.py index 29ad71e3e0..e62fa86774 100644 --- a/tests/functional/api/test_objectstorage.py +++ b/tests/functional/api/test_objectstorage.py @@ -22,6 +22,7 @@ from urllib3 import HTTPResponse from oio.api.object_storage import ObjectStorageApi from oio.common import exceptions as exc +from oio.common.cache import get_cached_object_metadata from oio.common.constants import REQID_HEADER from oio.common.storage_functions import _sort_chunks as sort_chunks from oio.common.utils import cid_from_name, request_id, depaginate @@ -2130,14 +2131,22 @@ def test_object_fetch_dirty_cache(self): # Fetch the original object to make sure the cache is filled. self.api.object_fetch( self.account, self.container, self.path) + cached_meta, cached_chunks = get_cached_object_metadata( + account=self.account, reference=self.container, path=self.path, + cache=self.cache) + self.assertIsNotNone(cached_meta) + self.assertIsNotNone(cached_chunks) + # Make the cache invalid by overwriting the object without # clearing the cache. self.api.object_create(self.account, self.container, obj_name=self.path, data='overwritten', cache=None) - # Wait for the original chunks to be deleted. - self.wait_for_event('oio-preserved', - types=(EventTypes.CHUNK_DELETED, ), timeout=5.0) + # Wait until all the original chunks are deleted + for _ in range(len(cached_chunks)): + self.wait_for_event('oio-preserved', + types=(EventTypes.CHUNK_DELETED, ), + timeout=5.0) # Read the object. An error will be raised internally, but the latest # object should be fetched. meta, stream = self.api.object_fetch(