|
12 | 12 | import org.elasticsearch.action.support.master.AcknowledgedResponse;
|
13 | 13 | import org.elasticsearch.cluster.metadata.IndexMetaData;
|
14 | 14 | import org.elasticsearch.protocol.xpack.frozen.FreezeRequest;
|
| 15 | +import org.elasticsearch.protocol.xpack.frozen.FreezeResponse; |
15 | 16 | import org.elasticsearch.xpack.core.frozen.action.FreezeIndexAction;
|
16 | 17 | import org.elasticsearch.xpack.core.ilm.Step.StepKey;
|
17 | 18 | import org.mockito.Mockito;
|
@@ -73,7 +74,7 @@ public void testFreeze() {
|
73 | 74 | assertNotNull(request);
|
74 | 75 | assertEquals(1, request.indices().length);
|
75 | 76 | assertEquals(indexMetaData.getIndex().getName(), request.indices()[0]);
|
76 |
| - listener.onResponse(null); |
| 77 | + listener.onResponse(new FreezeResponse(true, true)); |
77 | 78 | return null;
|
78 | 79 | }).when(indicesClient).execute(Mockito.any(), Mockito.any(), Mockito.any());
|
79 | 80 |
|
@@ -127,4 +128,32 @@ public void onFailure(Exception e) {
|
127 | 128 |
|
128 | 129 | assertThat(exceptionThrown.get(), equalTo(true));
|
129 | 130 | }
|
| 131 | + |
| 132 | + public void testNotAcknowledged() { |
| 133 | + IndexMetaData indexMetaData = getIndexMetaData(); |
| 134 | + |
| 135 | + Mockito.doAnswer(invocation -> { |
| 136 | + @SuppressWarnings("unchecked") |
| 137 | + ActionListener<AcknowledgedResponse> listener = (ActionListener<AcknowledgedResponse>) invocation.getArguments()[2]; |
| 138 | + listener.onResponse(new FreezeResponse(false, false)); |
| 139 | + return null; |
| 140 | + }).when(indicesClient).execute(Mockito.any(), Mockito.any(), Mockito.any()); |
| 141 | + |
| 142 | + SetOnce<Boolean> exceptionThrown = new SetOnce<>(); |
| 143 | + FreezeStep step = createRandomInstance(); |
| 144 | + step.performAction(indexMetaData, emptyClusterState(), null, new AsyncActionStep.Listener() { |
| 145 | + @Override |
| 146 | + public void onResponse(boolean complete) { |
| 147 | + throw new AssertionError("Unexpected method call"); |
| 148 | + } |
| 149 | + |
| 150 | + @Override |
| 151 | + public void onFailure(Exception e) { |
| 152 | + assertEquals("freeze index request failed to be acknowledged", e.getMessage()); |
| 153 | + exceptionThrown.set(true); |
| 154 | + } |
| 155 | + }); |
| 156 | + |
| 157 | + assertThat(exceptionThrown.get(), equalTo(true)); |
| 158 | + } |
130 | 159 | }
|
0 commit comments