|
|
@@ -25,11 +25,13 @@ import org.elasticsearch.common.logging.LoggerMessageFormat;
|
|
|
import org.elasticsearch.common.settings.Setting;
|
|
|
import org.elasticsearch.common.settings.Settings;
|
|
|
import org.elasticsearch.core.RestApiVersion;
|
|
|
+import org.elasticsearch.test.cluster.ElasticsearchCluster;
|
|
|
import org.elasticsearch.test.rest.ESRestTestCase;
|
|
|
import org.elasticsearch.xcontent.XContentBuilder;
|
|
|
import org.elasticsearch.xcontent.json.JsonXContent;
|
|
|
import org.hamcrest.Matcher;
|
|
|
import org.junit.Before;
|
|
|
+import org.junit.ClassRule;
|
|
|
import org.junit.Rule;
|
|
|
import org.junit.rules.TestName;
|
|
|
|
|
|
@@ -44,9 +46,13 @@ import java.util.stream.Collectors;
|
|
|
|
|
|
import static org.elasticsearch.common.logging.DeprecatedMessage.KEY_FIELD_NAME;
|
|
|
import static org.elasticsearch.common.logging.DeprecatedMessage.X_OPAQUE_ID_FIELD_NAME;
|
|
|
-import static org.elasticsearch.xpack.deprecation.TestDeprecationHeaderRestAction.TEST_DEPRECATED_SETTING_TRUE1;
|
|
|
-import static org.elasticsearch.xpack.deprecation.TestDeprecationHeaderRestAction.TEST_DEPRECATED_SETTING_TRUE2;
|
|
|
-import static org.elasticsearch.xpack.deprecation.TestDeprecationHeaderRestAction.TEST_NOT_DEPRECATED_SETTING;
|
|
|
+import static org.elasticsearch.xpack.deprecation.DeprecationSettings.COMPATIBLE_API_USAGE;
|
|
|
+import static org.elasticsearch.xpack.deprecation.DeprecationSettings.DEPRECATED_ENDPOINT;
|
|
|
+import static org.elasticsearch.xpack.deprecation.DeprecationSettings.DEPRECATED_USAGE;
|
|
|
+import static org.elasticsearch.xpack.deprecation.DeprecationSettings.TEST_DEPRECATED_SETTING_TRUE1;
|
|
|
+import static org.elasticsearch.xpack.deprecation.DeprecationSettings.TEST_DEPRECATED_SETTING_TRUE2;
|
|
|
+import static org.elasticsearch.xpack.deprecation.DeprecationSettings.TEST_DEPRECATED_SETTING_TRUE3;
|
|
|
+import static org.elasticsearch.xpack.deprecation.DeprecationSettings.TEST_NOT_DEPRECATED_SETTING;
|
|
|
import static org.hamcrest.Matchers.allOf;
|
|
|
import static org.hamcrest.Matchers.containsInAnyOrder;
|
|
|
import static org.hamcrest.Matchers.containsString;
|
|
|
@@ -62,6 +68,25 @@ import static org.hamcrest.Matchers.matchesRegex;
|
|
|
*/
|
|
|
public class DeprecationHttpIT extends ESRestTestCase {
|
|
|
|
|
|
+ @ClassRule
|
|
|
+ public static ElasticsearchCluster cluster = ElasticsearchCluster.local()
|
|
|
+ .module("deprecation-plugin")
|
|
|
+ .module("x-pack-deprecation")
|
|
|
+ .module("x-pack-stack")
|
|
|
+ .module("x-pack-ilm")
|
|
|
+ .module("ingest-common")
|
|
|
+ .module("constant-keyword")
|
|
|
+ .setting("cluster.deprecation_indexing.enabled", "true")
|
|
|
+ .setting("cluster.deprecation_indexing.flush_interval", "100ms")
|
|
|
+ .setting("xpack.security.enabled", "false")
|
|
|
+ .setting("xpack.license.self_generated.type", "trial")
|
|
|
+ .build();
|
|
|
+
|
|
|
+ @Override
|
|
|
+ protected String getTestRestCluster() {
|
|
|
+ return cluster.getHttpAddresses();
|
|
|
+ }
|
|
|
+
|
|
|
@Rule
|
|
|
public TestName testName = new TestName();
|
|
|
|
|
|
@@ -233,9 +258,9 @@ public class DeprecationHttpIT extends ESRestTestCase {
|
|
|
final List<String> deprecatedWarnings = getWarningHeaders(response.getHeaders());
|
|
|
final List<Matcher<? super String>> headerMatchers = new ArrayList<>(4);
|
|
|
|
|
|
- headerMatchers.add(equalTo(TestDeprecationHeaderRestAction.DEPRECATED_ENDPOINT));
|
|
|
+ headerMatchers.add(equalTo(DEPRECATED_ENDPOINT));
|
|
|
if (useDeprecatedField) {
|
|
|
- headerMatchers.add(equalTo(TestDeprecationHeaderRestAction.DEPRECATED_USAGE));
|
|
|
+ headerMatchers.add(equalTo(DEPRECATED_USAGE));
|
|
|
}
|
|
|
|
|
|
assertThat(deprecatedWarnings, everyItem(matchesRegex(HeaderWarning.WARNING_HEADER_PATTERN)));
|
|
|
@@ -379,12 +404,7 @@ public class DeprecationHttpIT extends ESRestTestCase {
|
|
|
*/
|
|
|
public void testDeprecationCriticalWarnMessagesCanBeIndexed() throws Exception {
|
|
|
final Request request = new Request("GET", "/_test_cluster/only_deprecated_setting");
|
|
|
- request.setEntity(
|
|
|
- buildSettingsRequest(
|
|
|
- Collections.singletonList(TestDeprecationHeaderRestAction.TEST_DEPRECATED_SETTING_TRUE3),
|
|
|
- "deprecation_critical"
|
|
|
- )
|
|
|
- );
|
|
|
+ request.setEntity(buildSettingsRequest(Collections.singletonList(TEST_DEPRECATED_SETTING_TRUE3), "deprecation_critical"));
|
|
|
performScopedRequest(request);
|
|
|
|
|
|
assertBusy(() -> {
|
|
|
@@ -601,7 +621,7 @@ public class DeprecationHttpIT extends ESRestTestCase {
|
|
|
final List<String> deprecatedWarnings = getWarningHeaders(deprecatedApiResponse.getHeaders());
|
|
|
assertThat(
|
|
|
extractWarningValuesFromWarningHeaders(deprecatedWarnings),
|
|
|
- containsInAnyOrder(TestDeprecationHeaderRestAction.DEPRECATED_ENDPOINT, TestDeprecationHeaderRestAction.COMPATIBLE_API_USAGE)
|
|
|
+ containsInAnyOrder(DEPRECATED_ENDPOINT, COMPATIBLE_API_USAGE)
|
|
|
);
|
|
|
|
|
|
assertBusy(() -> {
|