@@ -44,6 +44,7 @@ const (
44
44
dependenciesTemplateName = "jaeger-dependencies"
45
45
primaryNamespace = "es"
46
46
archiveNamespace = "es-archive"
47
+ ilmPolicy = "jaeger-ilm-policy"
47
48
)
48
49
49
50
type ESStorageIntegration struct {
@@ -110,7 +111,7 @@ func (*ESStorageIntegration) initializeESFactory(t *testing.T, allTagsAsFields b
110
111
fmt .Sprintf ("--es.num-shards=%v" , 5 ),
111
112
fmt .Sprintf ("--es.num-replicas=%v" , 1 ),
112
113
fmt .Sprintf ("--es.index-prefix=%v" , indexPrefix ),
113
- fmt .Sprintf ("--es.use-ilm=%v" , false ),
114
+ fmt .Sprintf ("--es.use-ilm=%v" , true ),
114
115
fmt .Sprintf ("--es.service-cache-ttl=%v" , 1 * time .Second ),
115
116
fmt .Sprintf ("--es.tags-as-fields.all=%v" , allTagsAsFields ),
116
117
fmt .Sprintf ("--es.bulk.actions=%v" , 1 ),
@@ -245,3 +246,37 @@ func (s *ESStorageIntegration) cleanESIndexTemplates(t *testing.T, prefix string
245
246
}
246
247
return nil
247
248
}
249
+
250
+ func TestElasticsearchStorage_ILMPolicy (t * testing.T ) {
251
+ SkipUnlessEnv (t , "elasticsearch" , "opensearch" )
252
+ t .Cleanup (func () {
253
+ testutils .VerifyGoLeaksOnceForES (t )
254
+ })
255
+ c := getESHttpClient (t )
256
+ require .NoError (t , healthCheck (c ))
257
+ s := & ESStorageIntegration {}
258
+ s .initializeES (t , c , true )
259
+ esVersion , err := s .getVersion ()
260
+ require .NoError (t , err )
261
+ if esVersion == 8 {
262
+ request := s .v8Client .ILM .GetLifecycle .WithPolicy (ilmPolicy )
263
+ ilmPolicyExistsResponse , err := s .v8Client .ILM .GetLifecycle (request )
264
+ require .NoError (t , err )
265
+ assert .Equal (t , 200 , ilmPolicyExistsResponse .StatusCode )
266
+ } else {
267
+ // nothing
268
+ }
269
+ s .cleanEsILMPolicy (t , ilmPolicy )
270
+ }
271
+
272
+ func (s * ESStorageIntegration ) cleanEsILMPolicy (t * testing.T , policy string ) error {
273
+ version , err := s .getVersion ()
274
+ require .NoError (t , err )
275
+ if version == 8 {
276
+ _ , err := s .v8Client .ILM .RemovePolicy (ilmPolicy )
277
+ require .NoError (t , err )
278
+ } else {
279
+ // nothing
280
+ }
281
+ return nil
282
+ }
0 commit comments