Skip to content

Commit

Permalink
Fix flaky test S3BlobStoreRepositoryTests.testRequestStats (opensearc…
Browse files Browse the repository at this point in the history
…h-project#13887) (opensearch-project#13898)

If a BlobStoreRepository is created, but the blobStore() method is never
called, then the actual blobStore instance won't be created. This means
the repository will always emit non-detailed empty stats. When we would
try to merge these stats with another repository that was initialized,
it would fail the assertion that they either both have detailed stats or
neither did.

This fix looks like it's checking if the blobStore has been
initialized, but by calling blobStore(), it's making sure that it gets
initialized.

(cherry picked from commit c7e8421)

Signed-off-by: Michael Froh <[email protected]>
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Signed-off-by: kkewwei <[email protected]>
  • Loading branch information
2 people authored and kkewwei committed Jul 24, 2024
1 parent b000f4a commit 61e79b3
Showing 1 changed file with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.stream.StreamSupport;

import fixture.s3.S3HttpHandler;
Expand Down Expand Up @@ -269,7 +268,12 @@ public void testRequestStats() throws Exception {
} catch (RepositoryMissingException e) {
return null;
}
}).filter(Objects::nonNull).map(Repository::stats).reduce(RepositoryStats::merge).get();
}).filter(b -> {
if (b instanceof BlobStoreRepository) {
return ((BlobStoreRepository) b).blobStore() != null;
}
return false;
}).map(Repository::stats).reduce(RepositoryStats::merge).get();

Map<BlobStore.Metric, Map<String, Long>> extendedStats = repositoryStats.extendedStats;
Map<String, Long> aggregatedStats = new HashMap<>();
Expand Down

0 comments on commit 61e79b3

Please sign in to comment.