14
14
import org .elasticsearch .cluster .metadata .DataStreamLifecycle ;
15
15
import org .elasticsearch .common .settings .Settings ;
16
16
import org .elasticsearch .core .TimeValue ;
17
- import org .elasticsearch .datastreams .DataStreamsPlugin ;
18
17
import org .elasticsearch .datastreams .lifecycle .DataStreamLifecycleService ;
19
- import org .elasticsearch .plugins .Plugin ;
20
18
import org .elasticsearch .search .aggregations .bucket .histogram .DateHistogramInterval ;
21
- import org .elasticsearch .test .ESIntegTestCase ;
22
19
import org .elasticsearch .test .junit .annotations .TestLogging ;
23
- import org .elasticsearch .xpack .aggregatemetric .AggregateMetricMapperPlugin ;
24
- import org .elasticsearch .xpack .core .LocalStateCompositeXPackPlugin ;
25
20
26
- import java .util .Collection ;
27
21
import java .util .HashSet ;
28
22
import java .util .List ;
29
23
import java .util .Set ;
30
24
import java .util .concurrent .TimeUnit ;
31
25
32
26
import static org .elasticsearch .cluster .metadata .ClusterChangedEventUtils .indicesCreated ;
33
27
import 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 ;
36
29
import static org .hamcrest .Matchers .is ;
37
30
38
- public class DataStreamLifecycleDownsampleIT extends ESIntegTestCase {
31
+ public class DataStreamLifecycleDownsampleIT extends DownsamplingIntegTestCase {
39
32
public static final int DOC_COUNT = 50_000 ;
40
33
41
- @ Override
42
- protected Collection <Class <? extends Plugin >> nodePlugins () {
43
- return List .of (DataStreamsPlugin .class , LocalStateCompositeXPackPlugin .class , Downsample .class , AggregateMetricMapperPlugin .class );
44
- }
45
-
46
34
@ Override
47
35
protected Settings nodeSettings (int nodeOrdinal , Settings otherSettings ) {
48
36
Settings .Builder settings = Settings .builder ().put (super .nodeSettings (nodeOrdinal , otherSettings ));
@@ -69,8 +57,7 @@ public void testDownsampling() throws Exception {
69
57
)
70
58
.buildTemplate ();
71
59
72
- DataStreamLifecycleDriver .setupTSDBDataStreamAndIngestDocs (
73
- client (),
60
+ setupTSDBDataStreamAndIngestDocs (
74
61
dataStreamName ,
75
62
"1986-01-08T23:40:53.384Z" ,
76
63
"2022-01-08T23:40:53.384Z" ,
@@ -79,7 +66,7 @@ public void testDownsampling() throws Exception {
79
66
"1990-09-09T18:00:00"
80
67
);
81
68
82
- List <String > backingIndices = getBackingIndices ( client (), dataStreamName );
69
+ List <String > backingIndices = getDataStreamBackingIndexNames ( dataStreamName );
83
70
String firstGenerationBackingIndex = backingIndices .get (0 );
84
71
String oneSecondDownsampleIndex = "downsample-5m-" + firstGenerationBackingIndex ;
85
72
String tenSecondsDownsampleIndex = "downsample-10m-" + firstGenerationBackingIndex ;
@@ -96,7 +83,7 @@ public void testDownsampling() throws Exception {
96
83
});
97
84
// before we rollover we update the index template to remove the start/end time boundaries (they're there just to ease with
98
85
// 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 );
100
87
101
88
client ().execute (RolloverAction .INSTANCE , new RolloverRequest (dataStreamName , null )).actionGet ();
102
89
@@ -112,7 +99,7 @@ public void testDownsampling() throws Exception {
112
99
}, 30 , TimeUnit .SECONDS );
113
100
114
101
assertBusy (() -> {
115
- List <String > dsBackingIndices = getBackingIndices ( client (), dataStreamName );
102
+ List <String > dsBackingIndices = getDataStreamBackingIndexNames ( dataStreamName );
116
103
117
104
assertThat (dsBackingIndices .size (), is (2 ));
118
105
String writeIndex = dsBackingIndices .get (1 );
@@ -143,8 +130,7 @@ public void testDownsamplingOnlyExecutesTheLastMatchingRound() throws Exception
143
130
)
144
131
)
145
132
.buildTemplate ();
146
- DataStreamLifecycleDriver .setupTSDBDataStreamAndIngestDocs (
147
- client (),
133
+ setupTSDBDataStreamAndIngestDocs (
148
134
dataStreamName ,
149
135
"1986-01-08T23:40:53.384Z" ,
150
136
"2022-01-08T23:40:53.384Z" ,
@@ -153,7 +139,7 @@ public void testDownsamplingOnlyExecutesTheLastMatchingRound() throws Exception
153
139
"1990-09-09T18:00:00"
154
140
);
155
141
156
- List <String > backingIndices = getBackingIndices ( client (), dataStreamName );
142
+ List <String > backingIndices = getDataStreamBackingIndexNames ( dataStreamName );
157
143
String firstGenerationBackingIndex = backingIndices .get (0 );
158
144
String oneSecondDownsampleIndex = "downsample-5m-" + firstGenerationBackingIndex ;
159
145
String tenSecondsDownsampleIndex = "downsample-10m-" + firstGenerationBackingIndex ;
@@ -170,7 +156,7 @@ public void testDownsamplingOnlyExecutesTheLastMatchingRound() throws Exception
170
156
});
171
157
// before we rollover we update the index template to remove the start/end time boundaries (they're there just to ease with
172
158
// 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 );
174
160
client ().execute (RolloverAction .INSTANCE , new RolloverRequest (dataStreamName , null )).actionGet ();
175
161
176
162
assertBusy (() -> {
@@ -180,7 +166,7 @@ public void testDownsamplingOnlyExecutesTheLastMatchingRound() throws Exception
180
166
}, 30 , TimeUnit .SECONDS );
181
167
182
168
assertBusy (() -> {
183
- List <String > dsBackingIndices = getBackingIndices ( client (), dataStreamName );
169
+ List <String > dsBackingIndices = getDataStreamBackingIndexNames ( dataStreamName );
184
170
185
171
assertThat (dsBackingIndices .size (), is (2 ));
186
172
String writeIndex = dsBackingIndices .get (1 );
@@ -212,8 +198,7 @@ public void testUpdateDownsampleRound() throws Exception {
212
198
)
213
199
.buildTemplate ();
214
200
215
- DataStreamLifecycleDriver .setupTSDBDataStreamAndIngestDocs (
216
- client (),
201
+ setupTSDBDataStreamAndIngestDocs (
217
202
dataStreamName ,
218
203
"1986-01-08T23:40:53.384Z" ,
219
204
"2022-01-08T23:40:53.384Z" ,
@@ -222,7 +207,7 @@ public void testUpdateDownsampleRound() throws Exception {
222
207
"1990-09-09T18:00:00"
223
208
);
224
209
225
- List <String > backingIndices = getBackingIndices ( client (), dataStreamName );
210
+ List <String > backingIndices = getDataStreamBackingIndexNames ( dataStreamName );
226
211
String firstGenerationBackingIndex = backingIndices .get (0 );
227
212
String oneSecondDownsampleIndex = "downsample-5m-" + firstGenerationBackingIndex ;
228
213
String tenSecondsDownsampleIndex = "downsample-10m-" + firstGenerationBackingIndex ;
@@ -239,8 +224,8 @@ public void testUpdateDownsampleRound() throws Exception {
239
224
});
240
225
// before we rollover we update the index template to remove the start/end time boundaries (they're there just to ease with
241
226
// 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 )));
244
229
245
230
assertBusy (() -> {
246
231
assertThat (witnessedDownsamplingIndices .size (), is (1 ));
@@ -249,7 +234,7 @@ public void testUpdateDownsampleRound() throws Exception {
249
234
}, 30 , TimeUnit .SECONDS );
250
235
251
236
assertBusy (() -> {
252
- List <String > dsBackingIndices = getBackingIndices ( client (), dataStreamName );
237
+ List <String > dsBackingIndices = getDataStreamBackingIndexNames ( dataStreamName );
253
238
assertThat (dsBackingIndices .size (), is (2 ));
254
239
String writeIndex = dsBackingIndices .get (1 );
255
240
assertThat (writeIndex , backingIndexEqualTo (dataStreamName , 2 ));
@@ -258,7 +243,7 @@ public void testUpdateDownsampleRound() throws Exception {
258
243
259
244
// update the lifecycle so that it only has one round, for the same `after` parameter as before, but a different interval
260
245
// 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.
262
247
DataStreamLifecycle updatedLifecycle = DataStreamLifecycle .dataLifecycleBuilder ()
263
248
.downsampling (
264
249
List .of (
@@ -269,14 +254,15 @@ public void testUpdateDownsampleRound() throws Exception {
269
254
)
270
255
)
271
256
.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
+ )
280
266
)
281
267
);
282
268
@@ -285,7 +271,7 @@ public void testUpdateDownsampleRound() throws Exception {
285
271
assertBusy (() -> {
286
272
assertThat (indexExists (tenSecondsDownsampleIndex ), is (false ));
287
273
288
- List <String > dsBackingIndices = getBackingIndices ( client (), dataStreamName );
274
+ List <String > dsBackingIndices = getDataStreamBackingIndexNames ( dataStreamName );
289
275
assertThat (dsBackingIndices .size (), is (2 ));
290
276
String writeIndex = dsBackingIndices .get (1 );
291
277
assertThat (writeIndex , backingIndexEqualTo (dataStreamName , 2 ));
0 commit comments