|
21 | 21 | import org.elasticsearch.common.xcontent.XContentType;
|
22 | 22 | import org.elasticsearch.common.xcontent.json.JsonXContent;
|
23 | 23 | import org.elasticsearch.common.xcontent.support.XContentMapValues;
|
| 24 | +import org.elasticsearch.index.IndexSettings; |
24 | 25 | import org.elasticsearch.rest.RestStatus;
|
25 | 26 | import org.elasticsearch.rest.action.document.RestGetAction;
|
26 | 27 | import org.elasticsearch.rest.action.document.RestIndexAction;
|
@@ -304,7 +305,7 @@ public void testRollupAfterRestart() throws Exception {
|
304 | 305 | assertRollUpJob("rollup-job-test");
|
305 | 306 | }
|
306 | 307 | }
|
307 |
| - |
| 308 | + |
308 | 309 | public void testSlmStats() throws IOException {
|
309 | 310 | SnapshotLifecyclePolicy slmPolicy = new SnapshotLifecyclePolicy("test-policy", "test-policy", "* * * 31 FEB ? *", "test-repo",
|
310 | 311 | Collections.singletonMap("indices", Collections.singletonList("*")), null);
|
@@ -823,4 +824,41 @@ private Map<String, Object> getJob(Map<String, Object> jobsMap, String targetJob
|
823 | 824 | }
|
824 | 825 | return null;
|
825 | 826 | }
|
| 827 | + |
| 828 | + public void testFrozenIndexAfterRestarted() throws Exception { |
| 829 | + final String index = "test_frozen_index"; |
| 830 | + if (isRunningAgainstOldCluster()) { |
| 831 | + Settings.Builder settings = Settings.builder(); |
| 832 | + if (randomBoolean()) { |
| 833 | + settings.put(IndexSettings.INDEX_SOFT_DELETES_SETTING.getKey(), randomBoolean()); |
| 834 | + } |
| 835 | + String mappings = randomBoolean() ? "\"_source\": { \"enabled\": false}" : null; |
| 836 | + createIndex(index, settings.build(), mappings); |
| 837 | + ensureGreen(index); |
| 838 | + int numDocs = randomIntBetween(10, 500); |
| 839 | + for (int i = 0; i < numDocs; i++) { |
| 840 | + int id = randomIntBetween(0, 100); |
| 841 | + final Request indexRequest = new Request("POST", "/" + index + "/" + "_doc/" + id); |
| 842 | + indexRequest.setJsonEntity(Strings.toString(JsonXContent.contentBuilder().startObject().field("f", "v").endObject())); |
| 843 | + assertOK(client().performRequest(indexRequest)); |
| 844 | + if (rarely()) { |
| 845 | + flush(index, randomBoolean()); |
| 846 | + } |
| 847 | + } |
| 848 | + } else { |
| 849 | + ensureGreen(index); |
| 850 | + final int totalHits = (int) XContentMapValues.extractValue("hits.total.value", |
| 851 | + entityAsMap(client().performRequest(new Request("GET", "/" + index + "/_search")))); |
| 852 | + assertOK(client().performRequest(new Request("POST", index + "/_freeze"))); |
| 853 | + ensureGreen(index); |
| 854 | + assertNoFileBasedRecovery(index, n -> true); |
| 855 | + final Request request = new Request("GET", "/" + index + "/_search"); |
| 856 | + request.addParameter("ignore_throttled", "false"); |
| 857 | + assertThat(XContentMapValues.extractValue("hits.total.value", entityAsMap(client().performRequest(request))), |
| 858 | + equalTo(totalHits)); |
| 859 | + assertOK(client().performRequest(new Request("POST", index + "/_unfreeze"))); |
| 860 | + ensureGreen(index); |
| 861 | + assertNoFileBasedRecovery(index, n -> true); |
| 862 | + } |
| 863 | + } |
826 | 864 | }
|
0 commit comments