From 2407e4dfa0017a1d2dff0add8543ce04ef99d516 Mon Sep 17 00:00:00 2001 From: Danny Hermes Date: Wed, 24 Aug 2016 11:44:49 -0700 Subject: [PATCH] Add eventual consistency check for storage list_blobs() Fixes #2180. --- system_tests/storage.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/system_tests/storage.py b/system_tests/storage.py index aeac1c34af83..0d12f7a57ea4 100644 --- a/system_tests/storage.py +++ b/system_tests/storage.py @@ -28,6 +28,7 @@ from system_test_utils import unique_resource_id from retry import RetryErrors +from retry import RetryResult retry_429 = RetryErrors(exceptions.TooManyRequests) @@ -225,8 +226,16 @@ def tearDownClass(cls): blob.delete() def test_list_files(self): - all_blobs = list(self.bucket.list_blobs()) - self.assertEqual(len(all_blobs), len(self.FILENAMES)) + def _all_in_list(blobs): + return len(blobs) == len(self.FILENAMES) + + def _all_blobs(): + return list(self.bucket.list_blobs()) + + retry = RetryResult(_all_in_list) + all_blobs = retry(_all_blobs)() + self.assertEqual(sorted(blob.name for blob in all_blobs), + sorted(self.FILENAMES)) def test_paginate_files(self): truncation_size = 1