4646import org .elasticsearch .index .shard .ShardId ;
4747import org .elasticsearch .indices .IndicesService ;
4848import org .elasticsearch .test .ESIntegTestCase ;
49+ import org .elasticsearch .test .junit .annotations .TestLogging ;
4950
5051import java .io .IOException ;
5152import java .util .Arrays ;
@@ -244,6 +245,12 @@ private void indexDoc(Engine engine, String id) throws IOException {
244245 assertThat (indexResult .getFailure (), nullValue ());
245246 }
246247
248+ private String syncedFlushDescription (ShardsSyncedFlushResult result ) {
249+ return result .shardResponses ().entrySet ().stream ()
250+ .map (e -> "Shard [" + e .getKey () + "], result [" + e .getValue () + "]" )
251+ .collect (Collectors .joining ("," ));
252+ }
253+
247254 public void testSyncedFlushSkipOutOfSyncReplicas () throws Exception {
248255 internalCluster ().ensureAtLeastNumDataNodes (between (2 , 3 ));
249256 final int numberOfReplicas = internalCluster ().numDataNodes () - 1 ;
@@ -269,6 +276,7 @@ public void testSyncedFlushSkipOutOfSyncReplicas() throws Exception {
269276 indexDoc (IndexShardTestCase .getEngine (outOfSyncReplica ), "extra_" + i );
270277 }
271278 final ShardsSyncedFlushResult partialResult = SyncedFlushUtil .attemptSyncedFlush (internalCluster (), shardId );
279+ logger .info ("Partial seal: {}" , syncedFlushDescription (partialResult ));
272280 assertThat (partialResult .totalShards (), equalTo (numberOfReplicas + 1 ));
273281 assertThat (partialResult .successfulShards (), equalTo (numberOfReplicas ));
274282 assertThat (partialResult .shardResponses ().get (outOfSyncReplica .routingEntry ()).failureReason , equalTo (
@@ -284,6 +292,7 @@ public void testSyncedFlushSkipOutOfSyncReplicas() throws Exception {
284292 assertThat (fullResult .successfulShards (), equalTo (numberOfReplicas + 1 ));
285293 }
286294
295+ @ TestLogging ("_root:DEBUG" )
287296 public void testDoNotRenewSyncedFlushWhenAllSealed () throws Exception {
288297 internalCluster ().ensureAtLeastNumDataNodes (between (2 , 3 ));
289298 final int numberOfReplicas = internalCluster ().numDataNodes () - 1 ;
@@ -300,9 +309,11 @@ public void testDoNotRenewSyncedFlushWhenAllSealed() throws Exception {
300309 index ("test" , "doc" , Integer .toString (i ));
301310 }
302311 final ShardsSyncedFlushResult firstSeal = SyncedFlushUtil .attemptSyncedFlush (internalCluster (), shardId );
312+ logger .info ("First seal: {}" , syncedFlushDescription (firstSeal ));
303313 assertThat (firstSeal .successfulShards (), equalTo (numberOfReplicas + 1 ));
304314 // Do not renew synced-flush
305315 final ShardsSyncedFlushResult secondSeal = SyncedFlushUtil .attemptSyncedFlush (internalCluster (), shardId );
316+ logger .info ("Second seal: {}" , syncedFlushDescription (secondSeal ));
306317 assertThat (secondSeal .successfulShards (), equalTo (numberOfReplicas + 1 ));
307318 assertThat (secondSeal .syncId (), equalTo (firstSeal .syncId ()));
308319 // Shards were updated, renew synced flush.
@@ -311,6 +322,7 @@ public void testDoNotRenewSyncedFlushWhenAllSealed() throws Exception {
311322 index ("test" , "doc" , Integer .toString (i ));
312323 }
313324 final ShardsSyncedFlushResult thirdSeal = SyncedFlushUtil .attemptSyncedFlush (internalCluster (), shardId );
325+ logger .info ("Third seal: {}" , syncedFlushDescription (thirdSeal ));
314326 assertThat (thirdSeal .successfulShards (), equalTo (numberOfReplicas + 1 ));
315327 assertThat (thirdSeal .syncId (), not (equalTo (firstSeal .syncId ())));
316328 // Manually remove or change sync-id, renew synced flush.
@@ -326,6 +338,7 @@ public void testDoNotRenewSyncedFlushWhenAllSealed() throws Exception {
326338 assertThat (shard .commitStats ().syncId (), nullValue ());
327339 }
328340 final ShardsSyncedFlushResult forthSeal = SyncedFlushUtil .attemptSyncedFlush (internalCluster (), shardId );
341+ logger .info ("Forth seal: {}" , syncedFlushDescription (forthSeal ));
329342 assertThat (forthSeal .successfulShards (), equalTo (numberOfReplicas + 1 ));
330343 assertThat (forthSeal .syncId (), not (equalTo (thirdSeal .syncId ())));
331344 }
0 commit comments