|
19 | 19 | import org.elasticsearch.index.IndexSettings;
|
20 | 20 | import org.elasticsearch.test.rest.ESRestTestCase;
|
21 | 21 | import org.elasticsearch.xpack.core.ilm.CheckNotDataStreamWriteIndexStep;
|
| 22 | +import org.elasticsearch.xpack.core.ilm.DeleteAction; |
22 | 23 | import org.elasticsearch.xpack.core.ilm.ForceMergeAction;
|
23 | 24 | import org.elasticsearch.xpack.core.ilm.FreezeAction;
|
24 | 25 | import org.elasticsearch.xpack.core.ilm.LifecycleSettings;
|
|
46 | 47 | import static org.elasticsearch.xpack.TimeSeriesRestDriver.getStepKeyForIndex;
|
47 | 48 | import static org.elasticsearch.xpack.TimeSeriesRestDriver.indexDocument;
|
48 | 49 | import static org.elasticsearch.xpack.TimeSeriesRestDriver.rolloverMaxOneDocCondition;
|
| 50 | +import static org.hamcrest.Matchers.containsString; |
49 | 51 | import static org.hamcrest.Matchers.equalTo;
|
50 | 52 | import static org.hamcrest.Matchers.is;
|
51 | 53 |
|
@@ -238,6 +240,18 @@ public void testGetDataStreamReturnsILMPolicy() throws Exception {
|
238 | 240 | assertThat(logsDataStream.get("ilm_policy"), is(policyName));
|
239 | 241 | }
|
240 | 242 |
|
| 243 | + public void testDeleteOnlyIndexInDataStreamDeletesDataStream() throws Exception { |
| 244 | + createNewSingletonPolicy(client(), policyName, "delete", new DeleteAction(false)); |
| 245 | + createComposableTemplate(client(), template, dataStream + "*", getTemplate(policyName)); |
| 246 | + indexDocument(client(), dataStream, true); |
| 247 | + |
| 248 | + assertBusy(() -> { |
| 249 | + Request r = new Request("GET", "/_data_stream/" + dataStream); |
| 250 | + Exception e = expectThrows(Exception.class, () -> client().performRequest(r)); |
| 251 | + assertThat(e.getMessage(), containsString("no such index [" + dataStream + "]")); |
| 252 | + }); |
| 253 | + } |
| 254 | + |
241 | 255 | private static Template getTemplate(String policyName) throws IOException {
|
242 | 256 | return new Template(getLifecycleSettings(policyName), null, null);
|
243 | 257 | }
|
|
0 commit comments