|
@@ -39,6 +39,7 @@ import org.elasticsearch.cluster.routing.ShardRouting;
|
|
|
import org.elasticsearch.cluster.routing.ShardRoutingState;
|
|
|
import org.elasticsearch.cluster.service.ClusterService;
|
|
|
import org.elasticsearch.common.settings.Settings;
|
|
|
+import org.elasticsearch.index.engine.Engine;
|
|
|
import org.elasticsearch.index.seqno.SeqNoStats;
|
|
|
import org.elasticsearch.index.seqno.SequenceNumbers;
|
|
|
import org.elasticsearch.index.shard.IndexShard;
|
|
@@ -56,6 +57,7 @@ import org.junit.After;
|
|
|
import org.junit.AfterClass;
|
|
|
import org.junit.Before;
|
|
|
import org.junit.BeforeClass;
|
|
|
+import org.mockito.ArgumentCaptor;
|
|
|
|
|
|
import java.util.Collections;
|
|
|
import java.util.List;
|
|
@@ -69,6 +71,7 @@ import static org.hamcrest.Matchers.arrayWithSize;
|
|
|
import static org.hamcrest.Matchers.equalTo;
|
|
|
import static org.hamcrest.Matchers.greaterThan;
|
|
|
import static org.hamcrest.Matchers.instanceOf;
|
|
|
+import static org.hamcrest.Matchers.is;
|
|
|
import static org.mockito.Matchers.any;
|
|
|
import static org.mockito.Mockito.mock;
|
|
|
import static org.mockito.Mockito.times;
|
|
@@ -144,9 +147,13 @@ public class TransportVerifyShardBeforeCloseActionTests extends ESTestCase {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- public void testOperationSuccessful() throws Exception {
|
|
|
+ public void testShardIsFlushed() throws Exception {
|
|
|
+ final ArgumentCaptor<FlushRequest> flushRequest = ArgumentCaptor.forClass(FlushRequest.class);
|
|
|
+ when(indexShard.flush(flushRequest.capture())).thenReturn(new Engine.CommitId(new byte[0]));
|
|
|
+
|
|
|
executeOnPrimaryOrReplica();
|
|
|
verify(indexShard, times(1)).flush(any(FlushRequest.class));
|
|
|
+ assertThat(flushRequest.getValue().force(), is(true));
|
|
|
}
|
|
|
|
|
|
public void testOperationFailsWithOnGoingOps() {
|