|
16 | 16 | import org.elasticsearch.action.admin.indices.refresh.RefreshRequest; |
17 | 17 | import org.elasticsearch.action.admin.indices.rollover.RolloverRequest; |
18 | 18 | import org.elasticsearch.action.admin.indices.settings.get.GetSettingsRequest; |
| 19 | +import org.elasticsearch.action.admin.indices.settings.get.GetSettingsResponse; |
19 | 20 | import org.elasticsearch.action.admin.indices.settings.put.UpdateSettingsRequest; |
20 | 21 | import org.elasticsearch.action.admin.indices.template.delete.DeleteIndexTemplateRequest; |
21 | 22 | import org.elasticsearch.action.admin.indices.template.delete.TransportDeleteIndexTemplateAction; |
|
27 | 28 | import org.elasticsearch.cluster.metadata.ComposableIndexTemplate; |
28 | 29 | import org.elasticsearch.cluster.metadata.IndexMetadata; |
29 | 30 | import org.elasticsearch.cluster.metadata.MappingMetadata; |
| 31 | +import org.elasticsearch.cluster.metadata.MetadataIndexStateService; |
30 | 32 | import org.elasticsearch.cluster.metadata.Template; |
31 | 33 | import org.elasticsearch.common.compress.CompressedXContent; |
32 | 34 | import org.elasticsearch.common.settings.Settings; |
|
50 | 52 | import java.util.Locale; |
51 | 53 | import java.util.Map; |
52 | 54 |
|
| 55 | +import static java.lang.Boolean.parseBoolean; |
53 | 56 | import static org.elasticsearch.cluster.metadata.MetadataIndexTemplateService.DEFAULT_TIMESTAMP_FIELD; |
54 | 57 | import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked; |
55 | 58 | import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertHitCount; |
@@ -147,6 +150,13 @@ public void testSetSourceToBlockWrites() throws Exception { |
147 | 150 | // call reindex |
148 | 151 | client().execute(ReindexDataStreamIndexAction.INSTANCE, new ReindexDataStreamIndexAction.Request(sourceIndex)).actionGet(); |
149 | 152 |
|
| 153 | + // Assert that source index is now read-only but not verified read-only |
| 154 | + GetSettingsResponse getSettingsResponse = admin().indices().getSettings(new GetSettingsRequest().indices(sourceIndex)).actionGet(); |
| 155 | + assertTrue(parseBoolean(getSettingsResponse.getSetting(sourceIndex, IndexMetadata.SETTING_BLOCKS_WRITE))); |
| 156 | + assertFalse( |
| 157 | + parseBoolean(getSettingsResponse.getSetting(sourceIndex, MetadataIndexStateService.VERIFIED_READ_ONLY_SETTING.getKey())) |
| 158 | + ); |
| 159 | + |
150 | 160 | // assert that write to source fails |
151 | 161 | var indexReq = new IndexRequest(sourceIndex).source(jsonBuilder().startObject().field("field", "1").endObject()); |
152 | 162 | assertThrows(ClusterBlockException.class, () -> client().index(indexReq).actionGet()); |
@@ -253,9 +263,9 @@ public void testReadOnlyBlocksNotAddedBack() { |
253 | 263 | .getDestIndex(); |
254 | 264 |
|
255 | 265 | var settingsResponse = indicesAdmin().getSettings(new GetSettingsRequest().indices(destIndex)).actionGet(); |
256 | | - assertFalse(Boolean.parseBoolean(settingsResponse.getSetting(destIndex, IndexMetadata.SETTING_READ_ONLY))); |
257 | | - assertFalse(Boolean.parseBoolean(settingsResponse.getSetting(destIndex, IndexMetadata.SETTING_READ_ONLY_ALLOW_DELETE))); |
258 | | - assertFalse(Boolean.parseBoolean(settingsResponse.getSetting(destIndex, IndexMetadata.SETTING_BLOCKS_WRITE))); |
| 266 | + assertFalse(parseBoolean(settingsResponse.getSetting(destIndex, IndexMetadata.SETTING_READ_ONLY))); |
| 267 | + assertFalse(parseBoolean(settingsResponse.getSetting(destIndex, IndexMetadata.SETTING_READ_ONLY_ALLOW_DELETE))); |
| 268 | + assertFalse(parseBoolean(settingsResponse.getSetting(destIndex, IndexMetadata.SETTING_BLOCKS_WRITE))); |
259 | 269 |
|
260 | 270 | cleanupMetadataBlocks(sourceIndex); |
261 | 271 | cleanupMetadataBlocks(destIndex); |
|
0 commit comments