Skip to content

Commit 634c8c6

Browse files
Rethrow Failed Assertion in BlobStoreTestUtils (elastic#53859)
This fixes two issues: 1. Currently, the future here is never resolved on assertion error so a failing test would take a full minute to complete until the future times out. 2. S3 tests overide this method to busy assert on this method. This only works if an assertion error makes it to the calling thread. Closes elastic#53508
1 parent 0a93a93 commit 634c8c6

File tree

1 file changed

+27
-19
lines changed

1 file changed

+27
-19
lines changed

test/framework/src/main/java/org/elasticsearch/repositories/blobstore/BlobStoreTestUtil.java

+27-19
Original file line numberDiff line numberDiff line change
@@ -112,27 +112,35 @@ public static boolean blobExists(BlobContainer container, String blobName) throw
112112
* of this assertion must pass an executor on those when using such an implementation.
113113
*/
114114
public static void assertConsistency(BlobStoreRepository repository, Executor executor) {
115-
final PlainActionFuture<Void> listener = PlainActionFuture.newFuture();
116-
executor.execute(ActionRunnable.run(listener, () -> {
117-
final BlobContainer blobContainer = repository.blobContainer();
118-
final long latestGen;
119-
try (DataInputStream inputStream = new DataInputStream(blobContainer.readBlob("index.latest"))) {
120-
latestGen = inputStream.readLong();
121-
} catch (NoSuchFileException e) {
122-
throw new AssertionError("Could not find index.latest blob for repo [" + repository + "]");
123-
}
124-
assertIndexGenerations(blobContainer, latestGen);
125-
final RepositoryData repositoryData;
126-
try (InputStream blob = blobContainer.readBlob("index-" + latestGen);
127-
XContentParser parser = XContentType.JSON.xContent().createParser(NamedXContentRegistry.EMPTY,
128-
LoggingDeprecationHandler.INSTANCE, blob)) {
129-
repositoryData = RepositoryData.snapshotsFromXContent(parser, latestGen);
115+
final PlainActionFuture<AssertionError> listener = PlainActionFuture.newFuture();
116+
executor.execute(ActionRunnable.supply(listener, () -> {
117+
try {
118+
final BlobContainer blobContainer = repository.blobContainer();
119+
final long latestGen;
120+
try (DataInputStream inputStream = new DataInputStream(blobContainer.readBlob("index.latest"))) {
121+
latestGen = inputStream.readLong();
122+
} catch (NoSuchFileException e) {
123+
throw new AssertionError("Could not find index.latest blob for repo [" + repository + "]");
124+
}
125+
assertIndexGenerations(blobContainer, latestGen);
126+
final RepositoryData repositoryData;
127+
try (InputStream blob = blobContainer.readBlob("index-" + latestGen);
128+
XContentParser parser = XContentType.JSON.xContent().createParser(NamedXContentRegistry.EMPTY,
129+
LoggingDeprecationHandler.INSTANCE, blob)) {
130+
repositoryData = RepositoryData.snapshotsFromXContent(parser, latestGen);
131+
}
132+
assertIndexUUIDs(blobContainer, repositoryData);
133+
assertSnapshotUUIDs(repository, repositoryData);
134+
assertShardIndexGenerations(blobContainer, repositoryData.shardGenerations());
135+
return null;
136+
} catch (AssertionError e) {
137+
return e;
130138
}
131-
assertIndexUUIDs(blobContainer, repositoryData);
132-
assertSnapshotUUIDs(repository, repositoryData);
133-
assertShardIndexGenerations(blobContainer, repositoryData.shardGenerations());
134139
}));
135-
listener.actionGet(TimeValue.timeValueMinutes(1L));
140+
final AssertionError err = listener.actionGet(TimeValue.timeValueMinutes(1L));
141+
if (err != null) {
142+
throw new AssertionError(err);
143+
}
136144
}
137145

138146
private static void assertIndexGenerations(BlobContainer repoRoot, long latestGen) throws IOException {

0 commit comments

Comments
 (0)