10
10
11
11
import com .carrotsearch .randomizedtesting .annotations .Name ;
12
12
13
- import org .elasticsearch .Version ;
14
13
import org .elasticsearch .client .Request ;
15
14
import org .elasticsearch .client .Response ;
16
15
import org .elasticsearch .client .ResponseException ;
17
16
import org .elasticsearch .common .settings .Settings ;
18
17
import org .elasticsearch .common .xcontent .support .XContentMapValues ;
19
18
import org .elasticsearch .core .Strings ;
19
+ import org .elasticsearch .test .rest .RestTestLegacyFeatures ;
20
20
21
21
import java .io .IOException ;
22
22
import java .util .Map ;
@@ -42,23 +42,23 @@ public void testOldIndexSettings() throws Exception {
42
42
Request createTestIndex = new Request ("PUT" , "/" + INDEX_NAME );
43
43
createTestIndex .setJsonEntity ("{\" settings\" : {\" index.indexing.slowlog.level\" : \" WARN\" }}" );
44
44
createTestIndex .setOptions (expectWarnings (EXPECTED_WARNING ));
45
- if (getOldClusterVersion ().before (Version .V_8_0_0 )) {
46
- // create index with settings no longer valid in 8.0
47
- client ().performRequest (createTestIndex );
48
- } else {
45
+ if (oldClusterHasFeature (RestTestLegacyFeatures .INDEXING_SLOWLOG_LEVEL_SETTING_REMOVED )) {
49
46
assertTrue (
50
47
expectThrows (ResponseException .class , () -> client ().performRequest (createTestIndex )).getMessage ()
51
48
.contains ("unknown setting [index.indexing.slowlog.level]" )
52
49
);
53
50
54
51
Request createTestIndex1 = new Request ("PUT" , "/" + INDEX_NAME );
55
52
client ().performRequest (createTestIndex1 );
53
+ } else {
54
+ // create index with settings no longer valid in 8.0
55
+ client ().performRequest (createTestIndex );
56
56
}
57
57
58
58
// add some data
59
59
Request bulk = new Request ("POST" , "/_bulk" );
60
60
bulk .addParameter ("refresh" , "true" );
61
- if (getOldClusterVersion (). before ( Version . V_8_0_0 ) ) {
61
+ if (oldClusterHasFeature ( RestTestLegacyFeatures . INDEXING_SLOWLOG_LEVEL_SETTING_REMOVED ) == false ) {
62
62
bulk .setOptions (expectWarnings (EXPECTED_WARNING ));
63
63
}
64
64
bulk .setJsonEntity (Strings .format ("""
@@ -70,7 +70,7 @@ public void testOldIndexSettings() throws Exception {
70
70
// add some more data
71
71
Request bulk = new Request ("POST" , "/_bulk" );
72
72
bulk .addParameter ("refresh" , "true" );
73
- if (getOldClusterVersion (). before ( Version . V_8_0_0 ) ) {
73
+ if (oldClusterHasFeature ( RestTestLegacyFeatures . INDEXING_SLOWLOG_LEVEL_SETTING_REMOVED ) == false ) {
74
74
bulk .setOptions (expectWarnings (EXPECTED_WARNING ));
75
75
}
76
76
bulk .setJsonEntity (Strings .format ("""
@@ -79,7 +79,7 @@ public void testOldIndexSettings() throws Exception {
79
79
""" , INDEX_NAME ));
80
80
client ().performRequest (bulk );
81
81
} else {
82
- if (getOldClusterVersion (). before ( Version . V_8_0_0 ) ) {
82
+ if (oldClusterHasFeature ( RestTestLegacyFeatures . INDEXING_SLOWLOG_LEVEL_SETTING_REMOVED ) == false ) {
83
83
Request createTestIndex = new Request ("PUT" , "/" + INDEX_NAME + "/_settings" );
84
84
// update index settings should work
85
85
createTestIndex .setJsonEntity ("{\" index.indexing.slowlog.level\" : \" INFO\" }" );
@@ -117,7 +117,7 @@ private void assertCount(String index, int countAtLeast) throws IOException {
117
117
public static void updateIndexSettingsPermittingSlowlogDeprecationWarning (String index , Settings .Builder settings ) throws IOException {
118
118
Request request = new Request ("PUT" , "/" + index + "/_settings" );
119
119
request .setJsonEntity (org .elasticsearch .common .Strings .toString (settings .build ()));
120
- if (getOldClusterVersion (). before ( Version . V_7_17_9 ) ) {
120
+ if (oldClusterHasFeature ( RestTestLegacyFeatures . DEPRECATION_WARNINGS_LEAK_FIXED ) == false ) {
121
121
// There is a bug (fixed in 7.17.9 and 8.7.0 where deprecation warnings could leak into ClusterApplierService#applyChanges)
122
122
// Below warnings are set (and leaking) from an index in this test case
123
123
request .setOptions (expectVersionSpecificWarnings (v -> {
0 commit comments