From 3ccf749043555cee77bbec89127546a0e0b04419 Mon Sep 17 00:00:00 2001 From: Tim Burke Date: Tue, 4 Feb 2025 16:07:51 -0800 Subject: [PATCH] tests: Fix flaky reconciler test Previously, test_object_move_no_such_object_no_tombstone_ancient would fail intermittently, with an assertion that two timestamps were almost (but not quite) equal. This probably comes down to the fact that it's passing floats as timestamps down into FakeInternalClient's parse(); specifically, values like 1738046018.2900746 and 1738045066.1442454 are known to previously fail. Just fixing the usage doesn't fix the foot-gun, though -- so fix up parse() to be internally consistent, even if passed a float. Change-Id: Ide1271dc4ef54b64d2dc99ef658e8340abb0b6ce --- test/unit/container/test_reconciler.py | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/test/unit/container/test_reconciler.py b/test/unit/container/test_reconciler.py index ebf608be96..576d4c47b8 100644 --- a/test/unit/container/test_reconciler.py +++ b/test/unit/container/test_reconciler.py @@ -12,7 +12,6 @@ # limitations under the License. import json -import numbers import shutil from functools import partial from tempfile import mkdtemp @@ -140,6 +139,8 @@ class FakeInternalClient(reconciler.InternalClient): continue obj_path = swob.str_to_wsgi( container_path + '/' + obj_name) + # some tests setup mock listings using floats, some use + # strings, so normalize here ts = Timestamp(timestamp) headers = {'X-Timestamp': ts.normal, 'X-Backend-Timestamp': ts.internal} @@ -149,17 +150,12 @@ class FakeInternalClient(reconciler.InternalClient): self.app.storage_policy[storage_policy_index].register( 'DELETE', obj_path, swob.HTTPNoContent, {}) # container listing entry - last_modified = timestamp_to_last_modified(timestamp) - # some tests setup mock listings using floats, some use - # strings, so normalize here - if isinstance(timestamp, numbers.Number): - timestamp = '%f' % timestamp obj_data = { 'bytes': 0, # listing data is unicode 'name': obj_name, - 'last_modified': last_modified, - 'hash': timestamp, + 'last_modified': ts.isoformat, + 'hash': ts.internal, 'content_type': content_type, } container_listing_data.append(obj_data)