From c7d2c740b05e2c32a703c2cf493a92a8cb3dba68 Mon Sep 17 00:00:00 2001 From: Daniel Gryniewicz Date: Mon, 18 Sep 2023 11:47:54 -0400 Subject: [PATCH] RGW - Add wait backoff to posix bucket cache test The CI appears to be really slow, and even a second of wait for inotify sometimes fails. Add an exponential backoff wait of up to ~25 seconds to hopefully make the test pass reliably. Signed-off-by: Daniel Gryniewicz --- src/test/rgw/test_posix_bucket_cache.cc | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/test/rgw/test_posix_bucket_cache.cc b/src/test/rgw/test_posix_bucket_cache.cc index 258650aedd6..be4f7e9a15e 100644 --- a/src/test/rgw/test_posix_bucket_cache.cc +++ b/src/test/rgw/test_posix_bucket_cache.cc @@ -365,10 +365,6 @@ TEST(BucketCache, UpdateInotify1) sf::path ttp{tp / fmt::format("{}{}", fbase, ix)}; sf::remove(ttp); } - - /* this step is async, temporally consistent */ - std::cout << "waiting 1000ms for cache sync" << std::endl; - std::this_thread::sleep_for(1000ms); } /* SetupInotify1 */ TEST(BucketCache, List2Inotify1) @@ -376,6 +372,7 @@ TEST(BucketCache, List2Inotify1) std::string bucket{"inotify1"}; std::string marker{""}; std::vector names; + int timeout = 50; auto f = [&](const rgw_bucket_dir_entry& bde) -> int { //std::cout << fmt::format("called back with {}", bde.key.name) << std::endl; @@ -384,7 +381,17 @@ TEST(BucketCache, List2Inotify1) }; MockSalBucket sb{bucket}; - (void) bucket_cache->list_bucket(dpp, null_yield, &sb, marker, f); + + /* Do a timed backoff up to ~20 seconds to pass on CI */ + while (timeout < 16000) { + (void)bucket_cache->list_bucket(dpp, null_yield, &sb, marker, f); + if (names.size() == 25) + break; + std::cout << fmt::format("waiting for {}ms for cache sync", timeout) << std::endl; + std::this_thread::sleep_for(1000ms); + timeout *= 2; + names.clear(); + } ASSERT_EQ(names.size(), 25); /* check these */ -- 2.39.5