Skip to content

Commit

Permalink
Fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
Tim-Brooks committed Apr 29, 2023
1 parent cb204ce commit 39ec0ab
Showing 1 changed file with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import org.elasticsearch.index.shard.IndexShard;
import org.elasticsearch.index.shard.IndexShardTestCase;
import org.elasticsearch.index.shard.ReplicationGroup;
import org.elasticsearch.index.shard.ShardId;
import org.elasticsearch.test.transport.MockTransportService;
import org.elasticsearch.threadpool.ThreadPool;
import org.elasticsearch.transport.TransportService;
Expand Down Expand Up @@ -137,8 +138,9 @@ public void testPrimaryWithUnpromotables() throws IOException {

ReplicationGroup replicationGroup = mock(ReplicationGroup.class);
IndexShardRoutingTable routingTable = mock(IndexShardRoutingTable.class);
ShardId shardId = primary.shardId();
ShardRouting routing = ShardRouting.newUnassigned(
primary.shardId(),
shardId,
true,
RecoverySource.EmptyStoreRecoverySource.INSTANCE,
new UnassignedInfo(UnassignedInfo.Reason.INDEX_CREATED, ""),
Expand All @@ -148,13 +150,14 @@ public void testPrimaryWithUnpromotables() throws IOException {
when(primary.getReplicationGroup()).thenReturn(replicationGroup).thenReturn(realReplicationGroup);
when(replicationGroup.getRoutingTable()).thenReturn(routingTable);
ShardRouting shardRouting = ShardRouting.newUnassigned(
primary.shardId(),
shardId,
false,
RecoverySource.PeerRecoverySource.INSTANCE,
new UnassignedInfo(UnassignedInfo.Reason.INDEX_CREATED, "message"),
ShardRouting.Role.SEARCH_ONLY
);
when(routingTable.unpromotableShards()).thenReturn(List.of(shardRouting));
when(routingTable.shardId()).thenReturn(shardId);
WriteRequest.RefreshPolicy policy = randomFrom(WriteRequest.RefreshPolicy.IMMEDIATE, WriteRequest.RefreshPolicy.WAIT_UNTIL);
postWriteRefresh.refreshShard(policy, primary, result.getTranslogLocation(), f, postWriteRefreshTimeout);
final Releasable releasable;
Expand Down

0 comments on commit 39ec0ab

Please sign in to comment.