@@ -79,11 +79,13 @@ public class TimeSeriesLifecycleActionsIT extends ESRestTestCase {
79
79
80
80
private String index ;
81
81
private String policy ;
82
+ private String alias ;
82
83
83
84
@ Before
84
85
public void refreshIndex () {
85
- index = randomAlphaOfLength (10 ).toLowerCase (Locale .ROOT );
86
- policy = randomAlphaOfLength (5 );
86
+ index = "index-" + randomAlphaOfLength (10 ).toLowerCase (Locale .ROOT );
87
+ policy = "policy-" + randomAlphaOfLength (5 );
88
+ alias = "alias-" + randomAlphaOfLength (5 );
87
89
}
88
90
89
91
public static void updatePolicy (String indexName , String policy ) throws IOException {
@@ -101,7 +103,7 @@ public void testFullPolicy() throws Exception {
101
103
createIndexWithSettings (originalIndex , Settings .builder ().put (IndexMetaData .SETTING_NUMBER_OF_SHARDS , 4 )
102
104
.put (IndexMetaData .SETTING_NUMBER_OF_REPLICAS , 0 )
103
105
.put ("index.routing.allocation.include._name" , "integTest-0" )
104
- .put (RolloverAction .LIFECYCLE_ROLLOVER_ALIAS , " alias" ));
106
+ .put (RolloverAction .LIFECYCLE_ROLLOVER_ALIAS , alias ));
105
107
106
108
// create policy
107
109
createFullPolicy (TimeValue .ZERO );
@@ -163,7 +165,7 @@ public void testMoveToRolloverStep() throws Exception {
163
165
createIndexWithSettings (originalIndex , Settings .builder ().put (IndexMetaData .SETTING_NUMBER_OF_SHARDS , 4 )
164
166
.put (IndexMetaData .SETTING_NUMBER_OF_REPLICAS , 0 )
165
167
.put ("index.routing.allocation.include._name" , "integTest-0" )
166
- .put (RolloverAction .LIFECYCLE_ROLLOVER_ALIAS , " alias" ));
168
+ .put (RolloverAction .LIFECYCLE_ROLLOVER_ALIAS , alias ));
167
169
168
170
createFullPolicy (TimeValue .timeValueHours (10 ));
169
171
// update policy on index
@@ -243,7 +245,7 @@ public void testRolloverAction() throws Exception {
243
245
String secondIndex = index + "-000002" ;
244
246
createIndexWithSettings (originalIndex , Settings .builder ().put (IndexMetaData .SETTING_NUMBER_OF_SHARDS , 1 )
245
247
.put (IndexMetaData .SETTING_NUMBER_OF_REPLICAS , 0 )
246
- .put (RolloverAction .LIFECYCLE_ROLLOVER_ALIAS , " alias" ));
248
+ .put (RolloverAction .LIFECYCLE_ROLLOVER_ALIAS , alias ));
247
249
248
250
// create policy
249
251
createNewSingletonPolicy ("hot" , new RolloverAction (null , null , 1L ));
@@ -261,7 +263,7 @@ public void testRolloverActionWithIndexingComplete() throws Exception {
261
263
String secondIndex = index + "-000002" ;
262
264
createIndexWithSettings (originalIndex , Settings .builder ().put (IndexMetaData .SETTING_NUMBER_OF_SHARDS , 1 )
263
265
.put (IndexMetaData .SETTING_NUMBER_OF_REPLICAS , 0 )
264
- .put (RolloverAction .LIFECYCLE_ROLLOVER_ALIAS , " alias" ));
266
+ .put (RolloverAction .LIFECYCLE_ROLLOVER_ALIAS , alias ));
265
267
266
268
Request updateSettingsRequest = new Request ("PUT" , "/" + originalIndex + "/_settings" );
267
269
updateSettingsRequest .setJsonEntity ("{\n " +
@@ -276,7 +278,7 @@ public void testRolloverActionWithIndexingComplete() throws Exception {
276
278
" {\n " +
277
279
" \" add\" : {\n " +
278
280
" \" index\" : \" " + originalIndex + "\" ,\n " +
279
- " \" alias\" : \" alias\" ,\n " +
281
+ " \" alias\" : \" " + alias + " \" ,\n " +
280
282
" \" is_write_index\" : false\n " +
281
283
" }\n " +
282
284
" }\n " +
@@ -352,7 +354,7 @@ public void testWaitForSnapshot() throws Exception {
352
354
request = new Request ("DELETE" , "/_snapshot/" + repo );
353
355
assertOK (client ().performRequest (request ));
354
356
}
355
-
357
+
356
358
public void testWaitForSnapshotSlmExecutedBefore () throws Exception {
357
359
createIndexWithSettings (index , Settings .builder ().put (IndexMetaData .SETTING_NUMBER_OF_SHARDS , 1 )
358
360
.put (IndexMetaData .SETTING_NUMBER_OF_REPLICAS , 0 ));
@@ -776,7 +778,7 @@ public void testRemoveAndReaddPolicy() throws Exception {
776
778
Settings .builder ().put (IndexMetaData .SETTING_NUMBER_OF_SHARDS , 1 )
777
779
.put (IndexMetaData .SETTING_NUMBER_OF_REPLICAS , 0 )
778
780
.put (LifecycleSettings .LIFECYCLE_NAME , policy )
779
- .put (RolloverAction .LIFECYCLE_ROLLOVER_ALIAS , " alias" ));
781
+ .put (RolloverAction .LIFECYCLE_ROLLOVER_ALIAS , alias ));
780
782
781
783
// Index a document
782
784
index (client (), originalIndex , "_id" , "foo" , "bar" );
@@ -794,7 +796,7 @@ public void testRemoveAndReaddPolicy() throws Exception {
794
796
addPolicyRequest .setJsonEntity ("{\n " +
795
797
" \" settings\" : {\n " +
796
798
" \" index.lifecycle.name\" : \" " + policy + "\" ,\n " +
797
- " \" index.lifecycle.rollover_alias\" : \" alias\" \n " +
799
+ " \" index.lifecycle.rollover_alias\" : \" " + alias + " \" \n " +
798
800
" }\n " +
799
801
"}" );
800
802
client ().performRequest (addPolicyRequest );
@@ -811,7 +813,7 @@ public void testMoveToInjectedStep() throws Exception {
811
813
createIndexWithSettings (index , Settings .builder ().put (IndexMetaData .SETTING_NUMBER_OF_SHARDS , 3 )
812
814
.put (IndexMetaData .SETTING_NUMBER_OF_REPLICAS , 0 )
813
815
.put (LifecycleSettings .LIFECYCLE_NAME , policy )
814
- .put (RolloverAction .LIFECYCLE_ROLLOVER_ALIAS , " alias" ));
816
+ .put (RolloverAction .LIFECYCLE_ROLLOVER_ALIAS , alias ));
815
817
816
818
assertBusy (() -> assertThat (getStepKeyForIndex (index ), equalTo (new StepKey ("new" , "complete" , "complete" ))));
817
819
@@ -847,7 +849,7 @@ public void testMoveToStepRereadsPolicy() throws Exception {
847
849
.put (IndexMetaData .SETTING_NUMBER_OF_SHARDS , 1 )
848
850
.put (IndexMetaData .SETTING_NUMBER_OF_REPLICAS , 0 )
849
851
.put (LifecycleSettings .LIFECYCLE_NAME , policy )
850
- .put (RolloverAction .LIFECYCLE_ROLLOVER_ALIAS , " alias" ),
852
+ .put (RolloverAction .LIFECYCLE_ROLLOVER_ALIAS , alias ),
851
853
true );
852
854
853
855
assertBusy (() -> assertThat (getStepKeyForIndex ("test-1" ), equalTo (new StepKey ("hot" , "rollover" , "check-rollover-ready" ))));
@@ -924,7 +926,7 @@ public void testExplainFilters() throws Exception {
924
926
}
925
927
926
928
createIndexWithSettings (goodIndex , Settings .builder ()
927
- .put (RolloverAction .LIFECYCLE_ROLLOVER_ALIAS , " alias" )
929
+ .put (RolloverAction .LIFECYCLE_ROLLOVER_ALIAS , alias )
928
930
.put (IndexMetaData .SETTING_NUMBER_OF_REPLICAS , 0 )
929
931
.put (LifecycleSettings .LIFECYCLE_NAME , policy )
930
932
);
@@ -983,7 +985,7 @@ public void testILMRolloverRetriesOnReadOnlyBlock() throws Exception {
983
985
Settings .builder ().put (IndexMetaData .SETTING_NUMBER_OF_SHARDS , 1 )
984
986
.put (IndexMetaData .SETTING_NUMBER_OF_REPLICAS , 0 )
985
987
.put (LifecycleSettings .LIFECYCLE_NAME , policy )
986
- .put (RolloverAction .LIFECYCLE_ROLLOVER_ALIAS , " alias" )
988
+ .put (RolloverAction .LIFECYCLE_ROLLOVER_ALIAS , alias )
987
989
.put ("index.blocks.read_only" , true ),
988
990
true
989
991
);
@@ -1018,7 +1020,7 @@ public void testILMRolloverOnManuallyRolledIndex() throws Exception {
1018
1020
" \" number_of_shards\" : 1,\n " +
1019
1021
" \" number_of_replicas\" : 0,\n " +
1020
1022
" \" index.lifecycle.name\" : \" " + policy + "\" , \n " +
1021
- " \" index.lifecycle.rollover_alias\" : \" alias\" \n " +
1023
+ " \" index.lifecycle.rollover_alias\" : \" " + alias + " \" \n " +
1022
1024
" }\n " +
1023
1025
"}" );
1024
1026
client ().performRequest (createIndexTemplate );
@@ -1036,7 +1038,7 @@ public void testILMRolloverOnManuallyRolledIndex() throws Exception {
1036
1038
client ().performRequest (refreshOriginalIndex );
1037
1039
1038
1040
// Manual rollover
1039
- Request rolloverRequest = new Request ("POST" , "/alias/_rollover" );
1041
+ Request rolloverRequest = new Request ("POST" , "/" + alias + " /_rollover" );
1040
1042
rolloverRequest .setJsonEntity ("{\n " +
1041
1043
" \" conditions\" : {\n " +
1042
1044
" \" max_docs\" : \" 1\" \n " +
@@ -1057,9 +1059,9 @@ public void testILMRolloverOnManuallyRolledIndex() throws Exception {
1057
1059
assertBusy (() -> assertTrue ((boolean ) explainIndex (secondIndex ).getOrDefault ("managed" , true )));
1058
1060
1059
1061
// index some documents to trigger an ILM rollover
1060
- index (client (), " alias" , "1" , "foo" , "bar" );
1061
- index (client (), " alias" , "2" , "foo" , "bar" );
1062
- index (client (), " alias" , "3" , "foo" , "bar" );
1062
+ index (client (), alias , "1" , "foo" , "bar" );
1063
+ index (client (), alias , "2" , "foo" , "bar" );
1064
+ index (client (), alias , "3" , "foo" , "bar" );
1063
1065
Request refreshSecondIndex = new Request ("POST" , "/" + secondIndex + "/_refresh" );
1064
1066
client ().performRequest (refreshSecondIndex ).getStatusLine ();
1065
1067
@@ -1079,7 +1081,7 @@ public void testRolloverStepRetriesUntilRolledOverIndexIsDeleted() throws Except
1079
1081
rolledIndex ,
1080
1082
Settings .builder ().put (IndexMetaData .SETTING_NUMBER_OF_SHARDS , 1 )
1081
1083
.put (IndexMetaData .SETTING_NUMBER_OF_REPLICAS , 0 )
1082
- .put (RolloverAction .LIFECYCLE_ROLLOVER_ALIAS , " alias" ),
1084
+ .put (RolloverAction .LIFECYCLE_ROLLOVER_ALIAS , alias ),
1083
1085
false
1084
1086
);
1085
1087
@@ -1088,7 +1090,7 @@ public void testRolloverStepRetriesUntilRolledOverIndexIsDeleted() throws Except
1088
1090
Settings .builder ().put (IndexMetaData .SETTING_NUMBER_OF_SHARDS , 1 )
1089
1091
.put (IndexMetaData .SETTING_NUMBER_OF_REPLICAS , 0 )
1090
1092
.put (LifecycleSettings .LIFECYCLE_NAME , policy )
1091
- .put (RolloverAction .LIFECYCLE_ROLLOVER_ALIAS , " alias" ),
1093
+ .put (RolloverAction .LIFECYCLE_ROLLOVER_ALIAS , alias ),
1092
1094
true
1093
1095
);
1094
1096
@@ -1151,7 +1153,7 @@ public void testUpdateRolloverLifecycleDateStepRetriesWhenRolloverInfoIsMissing(
1151
1153
Settings .builder ().put (IndexMetaData .SETTING_NUMBER_OF_SHARDS , 1 )
1152
1154
.put (IndexMetaData .SETTING_NUMBER_OF_REPLICAS , 0 )
1153
1155
.put (LifecycleSettings .LIFECYCLE_NAME , policy )
1154
- .put (RolloverAction .LIFECYCLE_ROLLOVER_ALIAS , " alias" ),
1156
+ .put (RolloverAction .LIFECYCLE_ROLLOVER_ALIAS , alias ),
1155
1157
true
1156
1158
);
1157
1159
@@ -1191,7 +1193,7 @@ public void testUpdateRolloverLifecycleDateStepRetriesWhenRolloverInfoIsMissing(
1191
1193
1192
1194
// manual rollover the index so the "update-rollover-lifecycle-date" ILM step can continue and finish successfully as the index
1193
1195
// will have rollover information now
1194
- Request rolloverRequest = new Request ("POST" , "/alias/_rollover" );
1196
+ Request rolloverRequest = new Request ("POST" , "/" + alias + " /_rollover" );
1195
1197
rolloverRequest .setJsonEntity ("{\n " +
1196
1198
" \" conditions\" : {\n " +
1197
1199
" \" max_docs\" : \" 1\" \n " +
@@ -1207,7 +1209,7 @@ public void testWaitForActiveShardsStep() throws Exception {
1207
1209
String secondIndex = index + "-000002" ;
1208
1210
createIndexWithSettings (originalIndex , Settings .builder ().put (IndexMetaData .SETTING_NUMBER_OF_SHARDS , 1 )
1209
1211
.put (IndexMetaData .SETTING_NUMBER_OF_REPLICAS , 0 )
1210
- .put (RolloverAction .LIFECYCLE_ROLLOVER_ALIAS , " alias" ),
1212
+ .put (RolloverAction .LIFECYCLE_ROLLOVER_ALIAS , alias ),
1211
1213
true );
1212
1214
1213
1215
// create policy
@@ -1249,7 +1251,7 @@ public void testHistoryIsWrittenWithSuccess() throws Exception {
1249
1251
" \" number_of_shards\" : 1,\n " +
1250
1252
" \" number_of_replicas\" : 0,\n " +
1251
1253
" \" index.lifecycle.name\" : \" " + policy + "\" ,\n " +
1252
- " \" index.lifecycle.rollover_alias\" : \" alias\" \n " +
1254
+ " \" index.lifecycle.rollover_alias\" : \" " + alias + " \" \n " +
1253
1255
" }\n " +
1254
1256
"}" );
1255
1257
client ().performRequest (createIndexTemplate );
@@ -1402,7 +1404,7 @@ public void testRefreshablePhaseJson() throws Exception {
1402
1404
" \" number_of_shards\" : 1,\n " +
1403
1405
" \" number_of_replicas\" : 0,\n " +
1404
1406
" \" index.lifecycle.name\" : \" " + policy + "\" ,\n " +
1405
- " \" index.lifecycle.rollover_alias\" : \" alias\" \n " +
1407
+ " \" index.lifecycle.rollover_alias\" : \" " + alias + " \" \n " +
1406
1408
" }\n " +
1407
1409
"}" );
1408
1410
client ().performRequest (createIndexTemplate );
@@ -1584,7 +1586,7 @@ private void createIndexWithSettings(String index, Settings.Builder settings, bo
1584
1586
writeIndexSnippet = "\" is_write_index\" : true" ;
1585
1587
}
1586
1588
request .setJsonEntity ("{\n \" settings\" : " + Strings .toString (settings .build ())
1587
- + ", \" aliases\" : { \" alias\" : { " + writeIndexSnippet + " } } }" );
1589
+ + ", \" aliases\" : { \" " + alias + " \" : { " + writeIndexSnippet + " } } }" );
1588
1590
client ().performRequest (request );
1589
1591
// wait for the shards to initialize
1590
1592
ensureGreen (index );
0 commit comments