@@ -96,10 +96,50 @@ public void testDeleteExpiredData_GivenNothingToDelete() throws Exception {
96
96
client ().execute (DeleteExpiredDataAction .INSTANCE , new DeleteExpiredDataAction .Request ()).get ();
97
97
}
98
98
99
+ @ AwaitsFix ( bugUrl = "https://github.com/elastic/elasticsearch/issues/62699" )
99
100
public void testDeleteExpiredDataNoThrottle () throws Exception {
100
101
testExpiredDeletion (null , 10010 );
101
102
}
102
103
104
+ /**
105
+ * Verifies empty state indices deletion. Here is the summary of indices used by the test:
106
+ *
107
+ * +------------------+--------+----------+-------------------------+
108
+ * | index name | empty? | current? | expected to be removed? |
109
+ * +------------------+--------+----------+-------------------------+
110
+ * | .ml-state | yes | no | yes |
111
+ * | .ml-state-000001 | no | no | no |
112
+ * | .ml-state-000003 | yes | no | yes |
113
+ * | .ml-state-000005 | no | no | no |
114
+ * | .ml-state-000007 | yes | yes | no |
115
+ * +------------------+--------+----------+-------------------------+
116
+ */
117
+ public void testDeleteExpiredDataActionDeletesEmptyStateIndices () throws Exception {
118
+ client ().admin ().indices ().prepareCreate (".ml-state" ).get ();
119
+ client ().admin ().indices ().prepareCreate (".ml-state-000001" ).get ();
120
+ client ().prepareIndex (".ml-state-000001" ).setSource ("field_1" , "value_1" ).get ();
121
+ client ().admin ().indices ().prepareCreate (".ml-state-000003" ).get ();
122
+ client ().admin ().indices ().prepareCreate (".ml-state-000005" ).get ();
123
+ client ().prepareIndex (".ml-state-000005" ).setSource ("field_5" , "value_5" ).get ();
124
+ client ().admin ().indices ().prepareCreate (".ml-state-000007" ).addAlias (new Alias (".ml-state-write" ).isHidden (true )).get ();
125
+ refresh ();
126
+
127
+ GetIndexResponse getIndexResponse = client ().admin ().indices ().prepareGetIndex ().setIndices (".ml-state*" ).get ();
128
+ assertThat (Strings .toString (getIndexResponse ),
129
+ getIndexResponse .getIndices (),
130
+ is (arrayContaining (".ml-state" , ".ml-state-000001" , ".ml-state-000003" , ".ml-state-000005" , ".ml-state-000007" )));
131
+
132
+ client ().execute (DeleteExpiredDataAction .INSTANCE , new DeleteExpiredDataAction .Request ()).get ();
133
+ refresh ();
134
+
135
+ getIndexResponse = client ().admin ().indices ().prepareGetIndex ().setIndices (".ml-state*" ).get ();
136
+ assertThat (Strings .toString (getIndexResponse ),
137
+ getIndexResponse .getIndices (),
138
+ // Only non-empty or current indices should survive deletion process
139
+ is (arrayContaining (".ml-state-000001" , ".ml-state-000005" , ".ml-state-000007" )));
140
+ }
141
+
142
+ @ AwaitsFix ( bugUrl = "https://github.com/elastic/elasticsearch/issues/62699" )
103
143
public void testDeleteExpiredDataWithStandardThrottle () throws Exception {
104
144
testExpiredDeletion (-1.0f , 100 );
105
145
}
0 commit comments