@@ -37,6 +37,10 @@ def elasticsearch_version
3737 end
3838 end
3939
40+ def elasticsearch_miscellaneous_content_type?
41+ Gem ::Version . create ( Elasticsearch ::VERSION ) >= Gem ::Version . new ( "9.0.0" )
42+ end
43+
4044 def ilm_existence_endpoint ( policy_id )
4145 if Gem ::Version . new ( Elasticsearch ::VERSION ) >= Gem ::Version . new ( "8.0.0" )
4246 "_ilm/policy/#{ policy_id } "
@@ -90,10 +94,20 @@ def test_ilm_policy_exists
9094 def test_create_ilm_policy
9195 stub_request ( :get , "http://localhost:9200/#{ ilm_creation_endpoint ( "fluent-policy" ) } " ) .
9296 to_return ( :status => 404 , :body => "" , :headers => { 'x-elastic-product' => 'Elasticsearch' } )
93- stub_request ( :put , "http://localhost:9200/#{ ilm_creation_endpoint ( "fluent-policy" ) } " ) .
94- with ( :body => "{\" policy\" :{\" phases\" :{\" hot\" :{\" actions\" :{\" rollover\" :{\" max_size\" :\" 50gb\" ,\" max_age\" :\" 30d\" }}}}}}" ,
95- :headers => { 'Content-Type' => 'application/json' } ) .
96- to_return ( :status => 200 , :body => "" , :headers => { 'x-elastic-product' => 'Elasticsearch' } )
97+ if elasticsearch_miscellaneous_content_type?
98+ stub_request ( :put , "http://localhost:9200/#{ ilm_creation_endpoint ( "fluent-policy" ) } " ) .
99+ with (
100+ body : "{\" policy\" :{\" phases\" :{\" hot\" :{\" actions\" :{\" rollover\" :{\" max_size\" :\" 50gb\" ,\" max_age\" :\" 30d\" }}}}}}" ,
101+ headers : {
102+ 'Content-Type' => 'application/vnd.elasticsearch+json; compatible-with=9' ,
103+ } ) .
104+ to_return ( :status => 200 , :body => "" , :headers => { 'x-elastic-product' => 'Elasticsearch' } )
105+ else
106+ stub_request ( :put , "http://localhost:9200/#{ ilm_creation_endpoint ( "fluent-policy" ) } " ) .
107+ with ( :body => "{\" policy\" :{\" phases\" :{\" hot\" :{\" actions\" :{\" rollover\" :{\" max_size\" :\" 50gb\" ,\" max_age\" :\" 30d\" }}}}}}" ,
108+ :headers => { 'Content-Type' => 'application/json' } ) .
109+ to_return ( :status => 200 , :body => "" , :headers => { 'x-elastic-product' => 'Elasticsearch' } )
110+ end
97111 stub_elastic_info
98112 create_ilm_policy ( "fluent-policy" )
99113
0 commit comments