[TEST] pre check download service working

Seen during CI tests, it could appears that the download service is not available for any reason.

This fix in test will check before each test which requires an internet access (annotated with @Network) that the download service we are testing is still working.

It won't fail the test but will mark the test as `Ignored` in case of failure.
This commit is contained in:
David Pilato 2014-03-14 13:17:04 +01:00
parent eef71da650
commit 2aaf81f8ef
1 changed files with 37 additions and 7 deletions

View File

@ -244,23 +244,53 @@ public class PluginManagerTests extends ElasticsearchIntegrationTest {
/**
* We are ignoring by default these tests as they require to have an internet access
* To activate the test, use -Dtests.network=true
* We test regular form: username/reponame/version
* It should find it in download.elasticsearch.org service
*/
@Test
@Network
public void testInstallPluginWithInternet() throws IOException {
// We test regular form: username/reponame/version
// It should find it in download.elasticsearch.org service
public void testInstallPluginWithElasticsearchDownloadService() throws IOException {
assumeTrue(isDownloadServiceWorking("http://download.elasticsearch.org/"));
singlePluginInstallAndRemove("elasticsearch/elasticsearch-transport-thrift/1.5.0", null);
}
// We test regular form: groupId/artifactId/version
// It should find it in maven central service
/**
* We are ignoring by default these tests as they require to have an internet access
* To activate the test, use -Dtests.network=true
* We test regular form: groupId/artifactId/version
* It should find it in maven central service
*/
@Test
@Network
public void testInstallPluginWithMavenCentral() throws IOException {
assumeTrue(isDownloadServiceWorking("http://search.maven.org/"));
singlePluginInstallAndRemove("org.elasticsearch/elasticsearch-transport-thrift/1.5.0", null);
}
// We test site plugins from github: userName/repoName
// It should find it on github
/**
* We are ignoring by default these tests as they require to have an internet access
* To activate the test, use -Dtests.network=true
* We test site plugins from github: userName/repoName
* It should find it on github
*/
@Test
@Network
public void testInstallPluginWithGithub() throws IOException {
assumeTrue(isDownloadServiceWorking("https://github.com/"));
singlePluginInstallAndRemove("elasticsearch/kibana", null);
}
private boolean isDownloadServiceWorking(String url) {
HttpClient client = new HttpClient(url);
try {
client.request("/");
return true;
} catch (Throwable t) {
logger.warn("[{}] download service is not working. Disabling current test.", url);
}
return false;
}
private void deletePluginsFolder() {
FileSystemUtils.deleteRecursively(new File(PLUGIN_DIR));
}