|
27 | 27 | import org.elasticsearch.cluster.metadata.ComposableIndexTemplate; |
28 | 28 | import org.elasticsearch.cluster.metadata.IndexMetadata; |
29 | 29 | import org.elasticsearch.cluster.metadata.MappingMetadata; |
| 30 | +import org.elasticsearch.cluster.metadata.MetadataIndexStateService; |
30 | 31 | import org.elasticsearch.cluster.metadata.Template; |
31 | 32 | import org.elasticsearch.common.compress.CompressedXContent; |
32 | 33 | import org.elasticsearch.common.settings.Settings; |
@@ -76,6 +77,21 @@ protected Collection<Class<? extends Plugin>> nodePlugins() { |
76 | 77 | return List.of(MigratePlugin.class, ReindexPlugin.class, MockTransportService.TestPlugin.class, DataStreamsPlugin.class); |
77 | 78 | } |
78 | 79 |
|
| 80 | + public void testSourceNotVerifiedReadOnly() throws Exception { |
| 81 | + // empty source index |
| 82 | + var sourceIndex = randomAlphaOfLength(20).toLowerCase(Locale.ROOT); |
| 83 | + indicesAdmin().create(new CreateIndexRequest(sourceIndex)).get(); |
| 84 | + |
| 85 | + // call reindex |
| 86 | + client().execute(ReindexDataStreamIndexAction.INSTANCE, new ReindexDataStreamIndexAction.Request(sourceIndex)).actionGet(); |
| 87 | + |
| 88 | + var settingsResponse = indicesAdmin().getSettings(new GetSettingsRequest().indices(sourceIndex)).actionGet(); |
| 89 | + assertTrue(Boolean.parseBoolean(settingsResponse.getSetting(sourceIndex, IndexMetadata.SETTING_BLOCKS_WRITE))); |
| 90 | + assertFalse( |
| 91 | + Boolean.parseBoolean(settingsResponse.getSetting(sourceIndex, MetadataIndexStateService.VERIFIED_READ_ONLY_SETTING.getKey())) |
| 92 | + ); |
| 93 | + } |
| 94 | + |
79 | 95 | public void testDestIndexDeletedIfExists() throws Exception { |
80 | 96 | // empty source index |
81 | 97 | var sourceIndex = randomAlphaOfLength(20).toLowerCase(Locale.ROOT); |
@@ -468,13 +484,4 @@ private static void indexDocs(String index, int numDocs) { |
468 | 484 | private static String formatInstant(Instant instant) { |
469 | 485 | return DateFormatter.forPattern(FormatNames.STRICT_DATE_OPTIONAL_TIME.getName()).format(instant); |
470 | 486 | } |
471 | | - |
472 | | - private static String getIndexUUID(String index) { |
473 | | - return indicesAdmin().getIndex(new GetIndexRequest(TEST_REQUEST_TIMEOUT).indices(index)) |
474 | | - .actionGet() |
475 | | - .getSettings() |
476 | | - .get(index) |
477 | | - .get(IndexMetadata.SETTING_INDEX_UUID); |
478 | | - } |
479 | | - |
480 | 487 | } |
0 commit comments