|
@@ -100,8 +100,11 @@ public class HttpExporterTests extends ESTestCase {
|
|
|
private void runTestEmptyHostList(final boolean useDefault) {
|
|
|
final String prefix = "xpack.monitoring.exporters.example";
|
|
|
final Settings.Builder builder = Settings.builder().put(prefix + ".type", "http");
|
|
|
+ List<String> expectedWarnings = new ArrayList<>();
|
|
|
if (useDefault == false) {
|
|
|
builder.putList(prefix + ".host", Collections.emptyList());
|
|
|
+ expectedWarnings.add("[xpack.monitoring.exporters.example.host] setting was deprecated in Elasticsearch and will be removed " +
|
|
|
+ "in a future release! See the breaking changes documentation for the next major version.");
|
|
|
}
|
|
|
final Settings settings = builder.build();
|
|
|
final IllegalArgumentException e = expectThrows(
|
|
@@ -110,6 +113,9 @@ public class HttpExporterTests extends ESTestCase {
|
|
|
assertThat(e, hasToString(containsString("Failed to parse value [[]] for setting [" + prefix + ".host]")));
|
|
|
assertThat(e.getCause(), instanceOf(SettingsException.class));
|
|
|
assertThat(e.getCause(), hasToString(containsString("host list for [" + prefix + ".host] is empty")));
|
|
|
+ expectedWarnings.add("[xpack.monitoring.exporters.example.type] setting was deprecated in Elasticsearch and will be removed " +
|
|
|
+ "in a future release! See the breaking changes documentation for the next major version.");
|
|
|
+ assertWarnings(expectedWarnings.toArray(new String[0]));
|
|
|
}
|
|
|
|
|
|
public void testEmptyHostListOkayIfTypeNotSetDefault() {
|
|
@@ -129,6 +135,8 @@ public class HttpExporterTests extends ESTestCase {
|
|
|
builder.putList(prefix + ".host", Collections.emptyList());
|
|
|
final Settings settings = builder.build();
|
|
|
HttpExporter.HOST_SETTING.getConcreteSetting(prefix + ".host").get(settings);
|
|
|
+ assertWarnings("[xpack.monitoring.exporters.example.host] setting was deprecated in Elasticsearch and will be removed in a " +
|
|
|
+ "future release! See the breaking changes documentation for the next major version.");
|
|
|
}
|
|
|
|
|
|
public void testHostListIsRejectedIfTypeIsNotHttp() {
|
|
@@ -139,6 +147,12 @@ public class HttpExporterTests extends ESTestCase {
|
|
|
final ClusterSettings clusterSettings = new ClusterSettings(settings, Set.of(HttpExporter.HOST_SETTING, Exporter.TYPE_SETTING));
|
|
|
final SettingsException e = expectThrows(SettingsException.class, () -> clusterSettings.validate(settings, true));
|
|
|
assertThat(e, hasToString(containsString("[" + prefix + ".host] is set but type is [local]")));
|
|
|
+ assertWarnings(
|
|
|
+ "[xpack.monitoring.exporters.example.type] setting was deprecated in Elasticsearch and will be removed in a future release! " +
|
|
|
+ "See the breaking changes documentation for the next major version.",
|
|
|
+ "[xpack.monitoring.exporters.example.host] setting was deprecated in Elasticsearch and will be removed in a future release! " +
|
|
|
+ "See the breaking changes documentation for the next major version."
|
|
|
+ );
|
|
|
}
|
|
|
|
|
|
public void testSecurePasswordIsRejectedIfTypeIsNotHttp() {
|
|
@@ -157,6 +171,12 @@ public class HttpExporterTests extends ESTestCase {
|
|
|
new ClusterSettings(settings, Set.of(HttpExporter.AUTH_SECURE_PASSWORD_SETTING, Exporter.TYPE_SETTING));
|
|
|
final SettingsException e = expectThrows(SettingsException.class, () -> clusterSettings.validate(settings, true));
|
|
|
assertThat(e, hasToString(containsString("[" + prefix + settingName + "] is set but type is [local]")));
|
|
|
+ assertWarnings(
|
|
|
+ "[xpack.monitoring.exporters.example.type] setting was deprecated in Elasticsearch and will be removed in a future release! " +
|
|
|
+ "See the breaking changes documentation for the next major version.",
|
|
|
+ "[xpack.monitoring.exporters.example.auth.secure_password] setting was deprecated in Elasticsearch and will be removed in a " +
|
|
|
+ "future release! See the breaking changes documentation for the next major version."
|
|
|
+ );
|
|
|
}
|
|
|
|
|
|
public void testInvalidHost() {
|
|
@@ -176,6 +196,12 @@ public class HttpExporterTests extends ESTestCase {
|
|
|
assertThat(e.getCause(), hasToString(containsString("[" + prefix + ".host] invalid host: [" + host + "]")));
|
|
|
assertThat(e.getCause().getCause(), instanceOf(IllegalArgumentException.class));
|
|
|
assertThat(e.getCause().getCause(), hasToString(containsString("HttpHosts do not use paths [/].")));
|
|
|
+ assertWarnings(
|
|
|
+ "[xpack.monitoring.exporters.example.host] setting was deprecated in Elasticsearch and will be removed in a future release! " +
|
|
|
+ "See the breaking changes documentation for the next major version.",
|
|
|
+ "[xpack.monitoring.exporters.example.type] setting was deprecated in Elasticsearch and will be removed in a future release! " +
|
|
|
+ "See the breaking changes documentation for the next major version."
|
|
|
+ );
|
|
|
}
|
|
|
|
|
|
public void testMixedSchemes() {
|
|
@@ -195,6 +221,12 @@ public class HttpExporterTests extends ESTestCase {
|
|
|
"Failed to parse value [[\"" + httpHost + "\",\"" + httpsHost + "\"]] for setting [" + prefix + ".host]")));
|
|
|
assertThat(e.getCause(), instanceOf(SettingsException.class));
|
|
|
assertThat(e.getCause(), hasToString(containsString("[" + prefix + ".host] must use a consistent scheme: http or https")));
|
|
|
+ assertWarnings(
|
|
|
+ "[xpack.monitoring.exporters.example.host] setting was deprecated in Elasticsearch and will be removed in a future release! " +
|
|
|
+ "See the breaking changes documentation for the next major version.",
|
|
|
+ "[xpack.monitoring.exporters.example.type] setting was deprecated in Elasticsearch and will be removed in a future release! " +
|
|
|
+ "See the breaking changes documentation for the next major version."
|
|
|
+ );
|
|
|
}
|
|
|
|
|
|
public void testExporterWithBlacklistedHeaders() {
|
|
@@ -217,6 +249,13 @@ public class HttpExporterTests extends ESTestCase {
|
|
|
expectThrows(SettingsException.class, () -> new HttpExporter(config, sslService, threadContext, coordinator));
|
|
|
|
|
|
assertThat(exception.getMessage(), equalTo(expected));
|
|
|
+
|
|
|
+ assertWarnings(
|
|
|
+ "[xpack.monitoring.exporters._http.host] setting was deprecated in Elasticsearch and will be removed in a " +
|
|
|
+ "future release! See the breaking changes documentation for the next major version.",
|
|
|
+ "[xpack.monitoring.exporters._http.type] setting was deprecated in Elasticsearch and will be removed in a future release! " +
|
|
|
+ "See the breaking changes documentation for the next major version."
|
|
|
+ );
|
|
|
}
|
|
|
|
|
|
public void testExporterWithEmptyHeaders() {
|
|
@@ -238,6 +277,12 @@ public class HttpExporterTests extends ESTestCase {
|
|
|
expectThrows(SettingsException.class, () -> new HttpExporter(config, sslService, threadContext, coordinator));
|
|
|
|
|
|
assertThat(exception.getMessage(), equalTo(expected));
|
|
|
+ assertWarnings(
|
|
|
+ "[xpack.monitoring.exporters._http.host] setting was deprecated in Elasticsearch and will be removed in a future release! " +
|
|
|
+ "See the breaking changes documentation for the next major version.",
|
|
|
+ "[xpack.monitoring.exporters._http.type] setting was deprecated in Elasticsearch and will be removed in a future release! " +
|
|
|
+ "See the breaking changes documentation for the next major version."
|
|
|
+ );
|
|
|
}
|
|
|
|
|
|
public void testExporterWithUnknownBlacklistedClusterAlerts() {
|
|
@@ -267,6 +312,8 @@ public class HttpExporterTests extends ESTestCase {
|
|
|
assertThat(exception.getMessage(),
|
|
|
equalTo("[xpack.monitoring.exporters._http.cluster_alerts.management.blacklist] contains unrecognized Cluster " +
|
|
|
"Alert IDs [does_not_exist]"));
|
|
|
+ assertWarnings("[xpack.monitoring.exporters._http.cluster_alerts.management.blacklist] setting was deprecated in Elasticsearch" +
|
|
|
+ " and will be removed in a future release! See the breaking changes documentation for the next major version.");
|
|
|
}
|
|
|
|
|
|
public void testExporterWithHostOnly() throws Exception {
|
|
@@ -281,6 +328,12 @@ public class HttpExporterTests extends ESTestCase {
|
|
|
final MonitoringMigrationCoordinator coordinator = new MonitoringMigrationCoordinator();
|
|
|
|
|
|
new HttpExporter(config, sslService, threadContext, coordinator).close();
|
|
|
+ assertWarnings(
|
|
|
+ "[xpack.monitoring.exporters._http.host] setting was deprecated in Elasticsearch and will be removed in a future release! " +
|
|
|
+ "See the breaking changes documentation for the next major version.",
|
|
|
+ "[xpack.monitoring.exporters._http.type] setting was deprecated in Elasticsearch and will be removed in a future release! " +
|
|
|
+ "See the breaking changes documentation for the next major version."
|
|
|
+ );
|
|
|
}
|
|
|
|
|
|
public void testExporterWithInvalidProxyBasePath() throws Exception {
|
|
@@ -304,16 +357,23 @@ public class HttpExporterTests extends ESTestCase {
|
|
|
|
|
|
assertThat(e.getCause(), instanceOf(SettingsException.class));
|
|
|
assertThat(e.getCause(), hasToString(containsString(expected)));
|
|
|
+ assertWarnings("[xpack.monitoring.exporters._http.proxy.base_path] setting was deprecated in Elasticsearch and will be removed " +
|
|
|
+ "in a future release! See the breaking changes documentation for the next major version.");
|
|
|
}
|
|
|
|
|
|
public void testCreateRestClient() throws IOException {
|
|
|
final SSLIOSessionStrategy sslStrategy = mock(SSLIOSessionStrategy.class);
|
|
|
|
|
|
when(sslService.sslIOSessionStrategy(any(Settings.class))).thenReturn(sslStrategy);
|
|
|
+ List<String> expectedWarnings = new ArrayList<>();
|
|
|
|
|
|
final Settings.Builder builder = Settings.builder()
|
|
|
.put("xpack.monitoring.exporters._http.type", "http")
|
|
|
.put("xpack.monitoring.exporters._http.host", "http://localhost:9200");
|
|
|
+ expectedWarnings.add("[xpack.monitoring.exporters._http.host] setting was deprecated in Elasticsearch and will be removed in " +
|
|
|
+ "a future release! See the breaking changes documentation for the next major version.");
|
|
|
+ expectedWarnings.add("[xpack.monitoring.exporters._http.type] setting was deprecated in Elasticsearch and will be removed in " +
|
|
|
+ "a future release! See the breaking changes documentation for the next major version.");
|
|
|
|
|
|
// use basic auth
|
|
|
final boolean useBasicAuth = randomBoolean();
|
|
@@ -322,6 +382,8 @@ public class HttpExporterTests extends ESTestCase {
|
|
|
MockSecureSettings mockSecureSettings = new MockSecureSettings();
|
|
|
mockSecureSettings.setString("xpack.monitoring.exporters._http.auth.secure_password", "securePassword");
|
|
|
builder.setSecureSettings(mockSecureSettings);
|
|
|
+ expectedWarnings.add("[xpack.monitoring.exporters._http.auth.username] setting was deprecated in Elasticsearch and will be " +
|
|
|
+ "removed in a future release! See the breaking changes documentation for the next major version.");
|
|
|
}
|
|
|
|
|
|
// use headers
|
|
@@ -334,6 +396,10 @@ public class HttpExporterTests extends ESTestCase {
|
|
|
|
|
|
// doesn't explode
|
|
|
HttpExporter.createRestClient(config, sslService, listener).close();
|
|
|
+
|
|
|
+ if (expectedWarnings.size() > 0) {
|
|
|
+ assertWarnings(expectedWarnings.toArray(new String[0]));
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
public void testCreateCredentialsProviderWithoutSecurity() {
|
|
@@ -345,6 +411,9 @@ public class HttpExporterTests extends ESTestCase {
|
|
|
CredentialsProvider provider = HttpExporter.createCredentialsProvider(config);
|
|
|
|
|
|
assertNull(provider);
|
|
|
+
|
|
|
+ assertWarnings("[xpack.monitoring.exporters._http.type] setting was deprecated in Elasticsearch and will be removed in a " +
|
|
|
+ "future release! See the breaking changes documentation for the next major version.");
|
|
|
}
|
|
|
|
|
|
public void testCreateSnifferDisabledByDefault() {
|
|
@@ -383,6 +452,15 @@ public class HttpExporterTests extends ESTestCase {
|
|
|
verify(client, atMost(1)).performRequest(any(Request.class));
|
|
|
|
|
|
verifyNoMoreInteractions(client, listener);
|
|
|
+
|
|
|
+ assertWarnings(
|
|
|
+ "[xpack.monitoring.exporters._http.sniff.enabled] setting was deprecated in Elasticsearch and will be removed " +
|
|
|
+ "in a future release! See the breaking changes documentation for the next major version.",
|
|
|
+ "[xpack.monitoring.exporters._http.host] setting was deprecated in Elasticsearch and will be removed in a future release!" +
|
|
|
+ " See the breaking changes documentation for the next major version.",
|
|
|
+ "[xpack.monitoring.exporters._http.type] setting was deprecated in Elasticsearch and will be removed in a future release!" +
|
|
|
+ " See the breaking changes documentation for the next major version."
|
|
|
+ );
|
|
|
}
|
|
|
|
|
|
public void testCreateResources() {
|
|
@@ -391,13 +469,20 @@ public class HttpExporterTests extends ESTestCase {
|
|
|
|
|
|
final Settings.Builder builder = Settings.builder()
|
|
|
.put("xpack.monitoring.exporters._http.type", "http");
|
|
|
+ List<String> warningsExpected = new ArrayList<>();
|
|
|
|
|
|
if (clusterAlertManagement == false) {
|
|
|
builder.put("xpack.monitoring.exporters._http.cluster_alerts.management.enabled", false);
|
|
|
+ warningsExpected.add("[xpack.monitoring.exporters._http.cluster_alerts.management.enabled] setting was deprecated in " +
|
|
|
+ "Elasticsearch and will be removed in a future release! See the breaking changes documentation for the next major " +
|
|
|
+ "version.");
|
|
|
}
|
|
|
|
|
|
if (templateTimeout != null) {
|
|
|
builder.put("xpack.monitoring.exporters._http.index.template.master_timeout", templateTimeout.getStringRep());
|
|
|
+ warningsExpected.add("[xpack.monitoring.exporters._http.index.template.master_timeout] setting was deprecated in " +
|
|
|
+ "Elasticsearch and will be removed in a future release! See the breaking changes documentation for the next major " +
|
|
|
+ "version.");
|
|
|
}
|
|
|
|
|
|
final Config config = createConfig(builder.build());
|
|
@@ -441,6 +526,9 @@ public class HttpExporterTests extends ESTestCase {
|
|
|
|
|
|
assertThat(uniqueOwners, hasSize(1));
|
|
|
assertThat(uniqueOwners.get(0), equalTo("xpack.monitoring.exporters._http"));
|
|
|
+ if (warningsExpected.size() > 0) {
|
|
|
+ assertWarnings(warningsExpected.toArray(new String[0]));
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
public void testCreateDefaultParams() {
|
|
@@ -461,6 +549,8 @@ public class HttpExporterTests extends ESTestCase {
|
|
|
|
|
|
if (bulkTimeout != null) {
|
|
|
assertThat(parameters.remove("timeout"), equalTo(bulkTimeout.toString()));
|
|
|
+ assertWarnings("[xpack.monitoring.exporters._http.bulk.timeout] setting was deprecated in Elasticsearch and will be removed " +
|
|
|
+ "in a future release! See the breaking changes documentation for the next major version.");
|
|
|
} else {
|
|
|
assertNull(parameters.remove("timeout"));
|
|
|
}
|