1414import org .elasticsearch .cluster .metadata .DataStreamLifecycle ;
1515import org .elasticsearch .common .settings .Settings ;
1616import org .elasticsearch .core .TimeValue ;
17- import org .elasticsearch .datastreams .DataStreamsPlugin ;
1817import org .elasticsearch .datastreams .lifecycle .DataStreamLifecycleService ;
19- import org .elasticsearch .plugins .Plugin ;
2018import org .elasticsearch .search .aggregations .bucket .histogram .DateHistogramInterval ;
21- import org .elasticsearch .test .ESIntegTestCase ;
2219import org .elasticsearch .test .junit .annotations .TestLogging ;
23- import org .elasticsearch .xpack .aggregatemetric .AggregateMetricMapperPlugin ;
24- import org .elasticsearch .xpack .core .LocalStateCompositeXPackPlugin ;
2520
26- import java .util .Collection ;
2721import java .util .HashSet ;
2822import java .util .List ;
2923import java .util .Set ;
3024import java .util .concurrent .TimeUnit ;
3125
3226import static org .elasticsearch .cluster .metadata .ClusterChangedEventUtils .indicesCreated ;
3327import static org .elasticsearch .cluster .metadata .DataStreamTestHelper .backingIndexEqualTo ;
34- import static org .elasticsearch .xpack .downsample .DataStreamLifecycleDriver .getBackingIndices ;
35- import static org .elasticsearch .xpack .downsample .DataStreamLifecycleDriver .putTSDBIndexTemplate ;
28+ import static org .elasticsearch .test .hamcrest .ElasticsearchAssertions .assertAcked ;
3629import static org .hamcrest .Matchers .is ;
3730
38- public class DataStreamLifecycleDownsampleIT extends ESIntegTestCase {
31+ public class DataStreamLifecycleDownsampleIT extends DownsamplingIntegTestCase {
3932 public static final int DOC_COUNT = 50_000 ;
4033
41- @ Override
42- protected Collection <Class <? extends Plugin >> nodePlugins () {
43- return List .of (DataStreamsPlugin .class , LocalStateCompositeXPackPlugin .class , Downsample .class , AggregateMetricMapperPlugin .class );
44- }
45-
4634 @ Override
4735 protected Settings nodeSettings (int nodeOrdinal , Settings otherSettings ) {
4836 Settings .Builder settings = Settings .builder ().put (super .nodeSettings (nodeOrdinal , otherSettings ));
@@ -69,8 +57,7 @@ public void testDownsampling() throws Exception {
6957 )
7058 .buildTemplate ();
7159
72- DataStreamLifecycleDriver .setupTSDBDataStreamAndIngestDocs (
73- client (),
60+ setupTSDBDataStreamAndIngestDocs (
7461 dataStreamName ,
7562 "1986-01-08T23:40:53.384Z" ,
7663 "2022-01-08T23:40:53.384Z" ,
@@ -79,7 +66,7 @@ public void testDownsampling() throws Exception {
7966 "1990-09-09T18:00:00"
8067 );
8168
82- List <String > backingIndices = getBackingIndices ( client (), dataStreamName );
69+ List <String > backingIndices = getDataStreamBackingIndexNames ( dataStreamName );
8370 String firstGenerationBackingIndex = backingIndices .get (0 );
8471 String oneSecondDownsampleIndex = "downsample-5m-" + firstGenerationBackingIndex ;
8572 String tenSecondsDownsampleIndex = "downsample-10m-" + firstGenerationBackingIndex ;
@@ -96,7 +83,7 @@ public void testDownsampling() throws Exception {
9683 });
9784 // before we rollover we update the index template to remove the start/end time boundaries (they're there just to ease with
9885 // testing so DSL doesn't have to wait for the end_time to lapse)
99- putTSDBIndexTemplate (client (), dataStreamName , null , null , lifecycle );
86+ putTSDBIndexTemplate (dataStreamName , null , null , lifecycle );
10087
10188 client ().execute (RolloverAction .INSTANCE , new RolloverRequest (dataStreamName , null )).actionGet ();
10289
@@ -112,7 +99,7 @@ public void testDownsampling() throws Exception {
11299 }, 30 , TimeUnit .SECONDS );
113100
114101 assertBusy (() -> {
115- List <String > dsBackingIndices = getBackingIndices ( client (), dataStreamName );
102+ List <String > dsBackingIndices = getDataStreamBackingIndexNames ( dataStreamName );
116103
117104 assertThat (dsBackingIndices .size (), is (2 ));
118105 String writeIndex = dsBackingIndices .get (1 );
@@ -143,8 +130,7 @@ public void testDownsamplingOnlyExecutesTheLastMatchingRound() throws Exception
143130 )
144131 )
145132 .buildTemplate ();
146- DataStreamLifecycleDriver .setupTSDBDataStreamAndIngestDocs (
147- client (),
133+ setupTSDBDataStreamAndIngestDocs (
148134 dataStreamName ,
149135 "1986-01-08T23:40:53.384Z" ,
150136 "2022-01-08T23:40:53.384Z" ,
@@ -153,7 +139,7 @@ public void testDownsamplingOnlyExecutesTheLastMatchingRound() throws Exception
153139 "1990-09-09T18:00:00"
154140 );
155141
156- List <String > backingIndices = getBackingIndices ( client (), dataStreamName );
142+ List <String > backingIndices = getDataStreamBackingIndexNames ( dataStreamName );
157143 String firstGenerationBackingIndex = backingIndices .get (0 );
158144 String oneSecondDownsampleIndex = "downsample-5m-" + firstGenerationBackingIndex ;
159145 String tenSecondsDownsampleIndex = "downsample-10m-" + firstGenerationBackingIndex ;
@@ -170,7 +156,7 @@ public void testDownsamplingOnlyExecutesTheLastMatchingRound() throws Exception
170156 });
171157 // before we rollover we update the index template to remove the start/end time boundaries (they're there just to ease with
172158 // testing so DSL doesn't have to wait for the end_time to lapse)
173- putTSDBIndexTemplate (client (), dataStreamName , null , null , lifecycle );
159+ putTSDBIndexTemplate (dataStreamName , null , null , lifecycle );
174160 client ().execute (RolloverAction .INSTANCE , new RolloverRequest (dataStreamName , null )).actionGet ();
175161
176162 assertBusy (() -> {
@@ -180,7 +166,7 @@ public void testDownsamplingOnlyExecutesTheLastMatchingRound() throws Exception
180166 }, 30 , TimeUnit .SECONDS );
181167
182168 assertBusy (() -> {
183- List <String > dsBackingIndices = getBackingIndices ( client (), dataStreamName );
169+ List <String > dsBackingIndices = getDataStreamBackingIndexNames ( dataStreamName );
184170
185171 assertThat (dsBackingIndices .size (), is (2 ));
186172 String writeIndex = dsBackingIndices .get (1 );
@@ -212,8 +198,7 @@ public void testUpdateDownsampleRound() throws Exception {
212198 )
213199 .buildTemplate ();
214200
215- DataStreamLifecycleDriver .setupTSDBDataStreamAndIngestDocs (
216- client (),
201+ setupTSDBDataStreamAndIngestDocs (
217202 dataStreamName ,
218203 "1986-01-08T23:40:53.384Z" ,
219204 "2022-01-08T23:40:53.384Z" ,
@@ -222,7 +207,7 @@ public void testUpdateDownsampleRound() throws Exception {
222207 "1990-09-09T18:00:00"
223208 );
224209
225- List <String > backingIndices = getBackingIndices ( client (), dataStreamName );
210+ List <String > backingIndices = getDataStreamBackingIndexNames ( dataStreamName );
226211 String firstGenerationBackingIndex = backingIndices .get (0 );
227212 String oneSecondDownsampleIndex = "downsample-5m-" + firstGenerationBackingIndex ;
228213 String tenSecondsDownsampleIndex = "downsample-10m-" + firstGenerationBackingIndex ;
@@ -239,8 +224,8 @@ public void testUpdateDownsampleRound() throws Exception {
239224 });
240225 // before we rollover we update the index template to remove the start/end time boundaries (they're there just to ease with
241226 // testing so DSL doesn't have to wait for the end_time to lapse)
242- putTSDBIndexTemplate (client (), dataStreamName , null , null , lifecycle );
243- client ().execute (RolloverAction .INSTANCE , new RolloverRequest (dataStreamName , null )). actionGet ( );
227+ putTSDBIndexTemplate (dataStreamName , null , null , lifecycle );
228+ safeGet ( client ().execute (RolloverAction .INSTANCE , new RolloverRequest (dataStreamName , null )));
244229
245230 assertBusy (() -> {
246231 assertThat (witnessedDownsamplingIndices .size (), is (1 ));
@@ -249,7 +234,7 @@ public void testUpdateDownsampleRound() throws Exception {
249234 }, 30 , TimeUnit .SECONDS );
250235
251236 assertBusy (() -> {
252- List <String > dsBackingIndices = getBackingIndices ( client (), dataStreamName );
237+ List <String > dsBackingIndices = getDataStreamBackingIndexNames ( dataStreamName );
253238 assertThat (dsBackingIndices .size (), is (2 ));
254239 String writeIndex = dsBackingIndices .get (1 );
255240 assertThat (writeIndex , backingIndexEqualTo (dataStreamName , 2 ));
@@ -258,7 +243,7 @@ public void testUpdateDownsampleRound() throws Exception {
258243
259244 // update the lifecycle so that it only has one round, for the same `after` parameter as before, but a different interval
260245 // the different interval should yield a different downsample index name so we expect the data stream lifecycle to get the previous
261- // `10s` interval downsample index, downsample it to `30s ` and replace it in the data stream instead of the `10s` one.
246+ // `10s` interval downsample index, downsample it to `20m ` and replace it in the data stream instead of the `10s` one.
262247 DataStreamLifecycle updatedLifecycle = DataStreamLifecycle .dataLifecycleBuilder ()
263248 .downsampling (
264249 List .of (
@@ -269,14 +254,15 @@ public void testUpdateDownsampleRound() throws Exception {
269254 )
270255 )
271256 .build ();
272-
273- client ().execute (
274- PutDataStreamLifecycleAction .INSTANCE ,
275- new PutDataStreamLifecycleAction .Request (
276- TEST_REQUEST_TIMEOUT ,
277- TEST_REQUEST_TIMEOUT ,
278- new String [] { dataStreamName },
279- updatedLifecycle
257+ assertAcked (
258+ client ().execute (
259+ PutDataStreamLifecycleAction .INSTANCE ,
260+ new PutDataStreamLifecycleAction .Request (
261+ TEST_REQUEST_TIMEOUT ,
262+ TEST_REQUEST_TIMEOUT ,
263+ new String [] { dataStreamName },
264+ updatedLifecycle
265+ )
280266 )
281267 );
282268
@@ -285,7 +271,7 @@ public void testUpdateDownsampleRound() throws Exception {
285271 assertBusy (() -> {
286272 assertThat (indexExists (tenSecondsDownsampleIndex ), is (false ));
287273
288- List <String > dsBackingIndices = getBackingIndices ( client (), dataStreamName );
274+ List <String > dsBackingIndices = getDataStreamBackingIndexNames ( dataStreamName );
289275 assertThat (dsBackingIndices .size (), is (2 ));
290276 String writeIndex = dsBackingIndices .get (1 );
291277 assertThat (writeIndex , backingIndexEqualTo (dataStreamName , 2 ));
0 commit comments