|
@@ -12,6 +12,7 @@ import org.elasticsearch.action.ActionListener;
|
|
|
import org.elasticsearch.action.support.master.AcknowledgedResponse;
|
|
|
import org.elasticsearch.cluster.metadata.IndexMetaData;
|
|
|
import org.elasticsearch.protocol.xpack.frozen.FreezeRequest;
|
|
|
+import org.elasticsearch.protocol.xpack.frozen.FreezeResponse;
|
|
|
import org.elasticsearch.xpack.core.frozen.action.FreezeIndexAction;
|
|
|
import org.elasticsearch.xpack.core.ilm.Step.StepKey;
|
|
|
import org.mockito.Mockito;
|
|
@@ -73,7 +74,7 @@ public class FreezeStepTests extends AbstractStepMasterTimeoutTestCase<FreezeSte
|
|
|
assertNotNull(request);
|
|
|
assertEquals(1, request.indices().length);
|
|
|
assertEquals(indexMetaData.getIndex().getName(), request.indices()[0]);
|
|
|
- listener.onResponse(null);
|
|
|
+ listener.onResponse(new FreezeResponse(true, true));
|
|
|
return null;
|
|
|
}).when(indicesClient).execute(Mockito.any(), Mockito.any(), Mockito.any());
|
|
|
|
|
@@ -127,4 +128,32 @@ public class FreezeStepTests extends AbstractStepMasterTimeoutTestCase<FreezeSte
|
|
|
|
|
|
assertThat(exceptionThrown.get(), equalTo(true));
|
|
|
}
|
|
|
+
|
|
|
+ public void testNotAcknowledged() {
|
|
|
+ IndexMetaData indexMetaData = getIndexMetaData();
|
|
|
+
|
|
|
+ Mockito.doAnswer(invocation -> {
|
|
|
+ @SuppressWarnings("unchecked")
|
|
|
+ ActionListener<AcknowledgedResponse> listener = (ActionListener<AcknowledgedResponse>) invocation.getArguments()[2];
|
|
|
+ listener.onResponse(new FreezeResponse(false, false));
|
|
|
+ return null;
|
|
|
+ }).when(indicesClient).execute(Mockito.any(), Mockito.any(), Mockito.any());
|
|
|
+
|
|
|
+ SetOnce<Boolean> exceptionThrown = new SetOnce<>();
|
|
|
+ FreezeStep step = createRandomInstance();
|
|
|
+ step.performAction(indexMetaData, emptyClusterState(), null, new AsyncActionStep.Listener() {
|
|
|
+ @Override
|
|
|
+ public void onResponse(boolean complete) {
|
|
|
+ throw new AssertionError("Unexpected method call");
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onFailure(Exception e) {
|
|
|
+ assertEquals("freeze index request failed to be acknowledged", e.getMessage());
|
|
|
+ exceptionThrown.set(true);
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ assertThat(exceptionThrown.get(), equalTo(true));
|
|
|
+ }
|
|
|
}
|