|  | @@ -29,6 +29,7 @@ import org.elasticsearch.index.engine.EngineTestCase;
 | 
	
		
			
				|  |  |  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;
 | 
	
	
		
			
				|  | @@ -137,16 +138,26 @@ public class PostWriteRefreshTests extends IndexShardTestCase {
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |              ReplicationGroup replicationGroup = mock(ReplicationGroup.class);
 | 
	
		
			
				|  |  |              IndexShardRoutingTable routingTable = mock(IndexShardRoutingTable.class);
 | 
	
		
			
				|  |  | +            ShardId shardId = primary.shardId();
 | 
	
		
			
				|  |  | +            ShardRouting routing = ShardRouting.newUnassigned(
 | 
	
		
			
				|  |  | +                shardId,
 | 
	
		
			
				|  |  | +                true,
 | 
	
		
			
				|  |  | +                RecoverySource.EmptyStoreRecoverySource.INSTANCE,
 | 
	
		
			
				|  |  | +                new UnassignedInfo(UnassignedInfo.Reason.INDEX_CREATED, ""),
 | 
	
		
			
				|  |  | +                ShardRouting.Role.INDEX_ONLY
 | 
	
		
			
				|  |  | +            );
 | 
	
		
			
				|  |  | +            when(primary.routingEntry()).thenReturn(routing);
 | 
	
		
			
				|  |  |              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;
 |