88package org .elasticsearch .xpack .migrate .action ;
99
1010import org .elasticsearch .action .admin .indices .create .CreateIndexRequest ;
11- import org .elasticsearch .action .admin .indices .get .GetIndexRequest ;
12- import org .elasticsearch .action .admin .indices .mapping .get .GetMappingsRequest ;
1311import org .elasticsearch .action .admin .indices .settings .get .GetSettingsRequest ;
14- import org .elasticsearch .action .admin .indices .settings .put .UpdateSettingsRequest ;
1512import org .elasticsearch .cluster .metadata .IndexMetadata ;
16- import org .elasticsearch .cluster .metadata .MappingMetadata ;
17- import org .elasticsearch .common .settings .Settings ;
18- import org .elasticsearch .common .xcontent .XContentHelper ;
19- import org .elasticsearch .common .xcontent .support .XContentMapValues ;
2013import org .elasticsearch .datastreams .DataStreamsPlugin ;
21- import org .elasticsearch .index . IndexNotFoundException ;
14+ import org .elasticsearch .ingest . common . IngestCommonPlugin ;
2215import org .elasticsearch .plugins .Plugin ;
2316import org .elasticsearch .reindex .ReindexPlugin ;
2417import org .elasticsearch .test .ESIntegTestCase ;
2518import org .elasticsearch .test .transport .MockTransportService ;
26- import org .elasticsearch .xcontent .json .JsonXContent ;
2719import org .elasticsearch .xpack .migrate .MigratePlugin ;
2820
2921import java .util .Collection ;
3022import java .util .List ;
3123import java .util .Locale ;
32- import java .util .Map ;
3324
3425import static org .elasticsearch .test .hamcrest .ElasticsearchAssertions .assertAcked ;
3526
3627public class CopyIndexMetadataTransportActionIT extends ESIntegTestCase {
3728
3829 @ Override
3930 protected Collection <Class <? extends Plugin >> nodePlugins () {
40- // return List.of();
41- return List .of (MigratePlugin .class , ReindexPlugin .class , MockTransportService .TestPlugin .class , DataStreamsPlugin .class );
31+ return List .of (
32+ MigratePlugin .class ,
33+ ReindexPlugin .class ,
34+ MockTransportService .TestPlugin .class ,
35+ DataStreamsPlugin .class ,
36+ IngestCommonPlugin .class
37+ );
4238 }
4339
4440 public void testCreationDate () throws Exception {
4541 var sourceIndex = randomAlphaOfLength (20 ).toLowerCase (Locale .ROOT );
4642 indicesAdmin ().create (new CreateIndexRequest (sourceIndex )).get ();
4743
4844 // so creation date is different
49- safeSleep (3 );
45+ safeSleep (2 );
5046
5147 var destIndex = randomAlphaOfLength (20 ).toLowerCase (Locale .ROOT );
5248 indicesAdmin ().create (new CreateIndexRequest (destIndex )).get ();
5349
54-
5550 // verify source and dest date are actually different before copying
5651 var settingsResponse = indicesAdmin ().getSettings (new GetSettingsRequest ().indices (sourceIndex , destIndex )).actionGet ();
5752 var indexToSettings = settingsResponse .getIndexToSettings ();
@@ -64,50 +59,17 @@ public void testCreationDate() throws Exception {
6459 }
6560
6661 assertAcked (
67- client ().execute (CopyIndexMetadataAction .INSTANCE , new CopyIndexMetadataAction .Request (TEST_REQUEST_TIMEOUT , sourceIndex , destIndex ))
62+ client ().execute (
63+ CopyIndexMetadataAction .INSTANCE ,
64+ new CopyIndexMetadataAction .Request (TEST_REQUEST_TIMEOUT , sourceIndex , destIndex )
65+ )
6866 );
6967
70- var destDate = indicesAdmin ().getSettings (new GetSettingsRequest ().indices (sourceIndex , destIndex )).actionGet ()
68+ var destDate = indicesAdmin ().getSettings (new GetSettingsRequest ().indices (sourceIndex , destIndex ))
69+ .actionGet ()
7170 .getIndexToSettings ()
7271 .get (destIndex )
7372 .getAsLong (IndexMetadata .SETTING_CREATION_DATE , 0L );
7473 assertEquals (sourceDate , destDate );
7574 }
76-
77-
78-
79- public void testOldSettingsManuallyFiltered () throws Exception {
80- var numShards = randomIntBetween (1 , 10 );
81- var staticSettings = Settings .builder ()
82- // setting to filter
83- .put ("index.soft_deletes.enabled" , true )
84- // good setting to keep
85- .put (IndexMetadata .SETTING_NUMBER_OF_SHARDS , numShards )
86- .build ();
87-
88- // start with a static setting
89- var sourceIndex = randomAlphaOfLength (20 ).toLowerCase (Locale .ROOT );
90- indicesAdmin ().create (new CreateIndexRequest (sourceIndex , staticSettings )).get ();
91-
92- // create from source
93- var destIndex = randomAlphaOfLength (20 ).toLowerCase (Locale .ROOT );
94- assertAcked (
95- client ().execute (CreateIndexFromSourceAction .INSTANCE , new CreateIndexFromSourceAction .Request (sourceIndex , destIndex ))
96- );
97-
98- // assert both static and dynamic settings set on dest index
99- var settingsResponse = indicesAdmin ().getSettings (new GetSettingsRequest ().indices (sourceIndex , destIndex )).actionGet ();
100- var destSettings = settingsResponse .getIndexToSettings ().get (destIndex );
101- var sourceSettings = settingsResponse .getIndexToSettings ().get (sourceIndex );
102-
103- // sanity check that source settings were added
104- assertEquals (true , sourceSettings .getAsBoolean ("index.soft_deletes.enabled" , false ));
105- assertEquals (numShards , Integer .parseInt (destSettings .get (IndexMetadata .SETTING_NUMBER_OF_SHARDS )));
106-
107- // check that old setting was not added to index
108- assertNull (destSettings .get ("index.soft_deletes.enabled" ));
109- assertEquals (numShards , Integer .parseInt (destSettings .get (IndexMetadata .SETTING_NUMBER_OF_SHARDS )));
110- }
111-
112-
11375}
0 commit comments