Marvel: Clean HttpESExporterTests and AgentUtilsTests classes

Original commit: elastic/x-pack-elasticsearch@9cd271333e
This commit is contained in:
Tanguy Leroux 2015-07-23 10:50:38 +02:00
parent 6a479a6dc8
commit e1c4285482
2 changed files with 31 additions and 31 deletions

View File

@ -110,19 +110,6 @@ public class AgentUtilsTests extends ElasticsearchTestCase {
verifyUrl(url, "http", "server-dash", 9200, "/_bulk");
}
void verifyUrl(URL url, String protocol, String host, int port, String path) throws URISyntaxException {
assertThat(url.getProtocol(), equalTo(protocol));
assertThat(url.getHost(), equalTo(host));
assertThat(url.getPort(), equalTo(port));
assertThat(url.toURI().getPath(), equalTo(path));
}
void verifyUrl(URL url, String protocol, String host, int port, String path, String userInfo) throws URISyntaxException {
verifyUrl(url, protocol, host, port, path);
assertThat(url.getUserInfo(), equalTo(userInfo));
}
@Test
public void sanitizeUrlPadTest() throws UnsupportedEncodingException {
String pwd = URLEncoder.encode(randomRealisticUnicodeOfCodepointLengthBetween(3, 20), "UTF-8");
@ -165,4 +152,17 @@ public class AgentUtilsTests extends ElasticsearchTestCase {
assertThat(sanitized, not(containsString(pwd)));
}
}
void verifyUrl(URL url, String protocol, String host, int port, String path) throws URISyntaxException {
assertThat(url.getProtocol(), equalTo(protocol));
assertThat(url.getHost(), equalTo(host));
assertThat(url.getPort(), equalTo(port));
assertThat(url.toURI().getPath(), equalTo(path));
}
void verifyUrl(URL url, String protocol, String host, int port, String path, String userInfo) throws URISyntaxException {
verifyUrl(url, protocol, host, port, path);
assertThat(url.getUserInfo(), equalTo(userInfo));
}
}

View File

@ -34,6 +34,8 @@ import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcke
@ClusterScope(transportClientRatio = 0.0, scope = ElasticsearchIntegrationTest.Scope.TEST, numDataNodes = 0, numClientNodes = 0)
public class HttpESExporterTests extends ElasticsearchIntegrationTest {
final static AtomicLong timeStampGenerator = new AtomicLong();
@Override
protected Settings nodeSettings(int nodeOrdinal) {
return Settings.settingsBuilder()
@ -52,6 +54,7 @@ public class HttpESExporterTests extends ElasticsearchIntegrationTest {
logger.info("trying exporting despite of no target");
httpEsExporter.export(ImmutableList.of(newRandomMarvelDoc()));
}
/*
@Test
public void testLargeClusterStateSerialization() throws InterruptedException {
@ -107,22 +110,6 @@ public class HttpESExporterTests extends ElasticsearchIntegrationTest {
assertMarvelTemplate();
}
private void assertMarvelTemplate() {
boolean found;
found = findMarvelTemplate();
assertTrue("failed to find a template named `marvel`", found);
}
private boolean findMarvelTemplate() {
for (IndexTemplateMetaData template : client().admin().indices().prepareGetTemplates("marvel").get().getIndexTemplates()) {
if (template.getName().equals("marvel")) {
return true;
}
}
return false;
}
@Test
public void testDynamicHostChange() {
// disable exporting to be able to use non valid hosts
@ -232,10 +219,23 @@ public class HttpESExporterTests extends ElasticsearchIntegrationTest {
return (HttpESExporter) service.getExporters().iterator().next();
}
final static AtomicLong timeStampGenerator = new AtomicLong();
private MarvelDoc newRandomMarvelDoc() {
return IndexStatsMarvelDoc.createMarvelDoc(internalCluster().getClusterName(), "test_marvelDoc", timeStampGenerator.incrementAndGet(),
"test_index", randomInt(), randomLong(), randomLong(), randomLong());
}
private void assertMarvelTemplate() {
boolean found;
found = findMarvelTemplate();
assertTrue("failed to find a template named `marvel`", found);
}
private boolean findMarvelTemplate() {
for (IndexTemplateMetaData template : client().admin().indices().prepareGetTemplates("marvel").get().getIndexTemplates()) {
if (template.getName().equals("marvel")) {
return true;
}
}
return false;
}
}