Skip to content

Commit

Permalink
PR Feedback:
Browse files Browse the repository at this point in the history
- Add random refresh policy to reloation ITs.
- add back finishing ReplicationTask.

Signed-off-by: Marc Handalian <handalm@amazon.com>
  • Loading branch information
mch2 committed Feb 20, 2023
1 parent 33edf00 commit e360577
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,13 @@ public void testPrimaryRelocation() throws Exception {
final String replica = internalCluster().startNode();
ensureGreen(INDEX_NAME);
final int initialDocCount = scaledRandomIntBetween(100, 1000);
final WriteRequest.RefreshPolicy refreshPolicy = randomFrom(WriteRequest.RefreshPolicy.values());
final List<ActionFuture<IndexResponse>> pendingIndexResponses = new ArrayList<>();
for (int i = 0; i < initialDocCount; i++) {
pendingIndexResponses.add(
client().prepareIndex(INDEX_NAME)
.setId(Integer.toString(i))
.setRefreshPolicy(WriteRequest.RefreshPolicy.WAIT_UNTIL)
.setRefreshPolicy(refreshPolicy)
.setSource("field", "value" + i)
.execute()
);
Expand Down Expand Up @@ -105,7 +106,7 @@ public void testPrimaryRelocation() throws Exception {
pendingIndexResponses.add(
client().prepareIndex(INDEX_NAME)
.setId(Integer.toString(i))
.setRefreshPolicy(WriteRequest.RefreshPolicy.WAIT_UNTIL)
.setRefreshPolicy(refreshPolicy)
.setSource("field", "value" + i)
.execute()
);
Expand All @@ -131,12 +132,13 @@ public void testPrimaryRelocationWithSegRepFailure() throws Exception {
final String replica = internalCluster().startNode();
ensureGreen(INDEX_NAME);
final int initialDocCount = scaledRandomIntBetween(100, 1000);
final WriteRequest.RefreshPolicy refreshPolicy = randomFrom(WriteRequest.RefreshPolicy.values());
final List<ActionFuture<IndexResponse>> pendingIndexResponses = new ArrayList<>();
for (int i = 0; i < initialDocCount; i++) {
pendingIndexResponses.add(
client().prepareIndex(INDEX_NAME)
.setId(Integer.toString(i))
.setRefreshPolicy(WriteRequest.RefreshPolicy.WAIT_UNTIL)
.setRefreshPolicy(refreshPolicy)
.setSource("field", "value" + i)
.execute()
);
Expand Down Expand Up @@ -189,7 +191,7 @@ public void testPrimaryRelocationWithSegRepFailure() throws Exception {
pendingIndexResponses.add(
client().prepareIndex(INDEX_NAME)
.setId(Integer.toString(i))
.setRefreshPolicy(WriteRequest.RefreshPolicy.WAIT_UNTIL)
.setRefreshPolicy(refreshPolicy)
.setSource("field", "value" + i)
.execute()
);
Expand Down Expand Up @@ -297,14 +299,15 @@ public void testRelocateWithQueuedOperationsDuringHandoff() throws Exception {
}
logger.info("--> flush to have segments on disk");
client().admin().indices().prepareFlush().execute().actionGet();
final WriteRequest.RefreshPolicy refreshPolicy = randomFrom(WriteRequest.RefreshPolicy.values());

logger.info("--> index more docs so there are ops in the transaction log");
final List<ActionFuture<IndexResponse>> pendingIndexResponses = new ArrayList<>();
for (int i = 10; i < 20; i++) {
pendingIndexResponses.add(
client().prepareIndex(INDEX_NAME)
.setId(Integer.toString(i))
.setRefreshPolicy(WriteRequest.RefreshPolicy.WAIT_UNTIL)
.setRefreshPolicy(refreshPolicy)
.setSource("field", "value" + i)
.execute()
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ public void onResponse(ReplicationOperation.ReplicaResponse replicaResponse) {
timer.time()
)
);
task.setPhase("finished");
taskManager.unregister(task);
}

Expand Down

0 comments on commit e360577

Please sign in to comment.