[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:
parent
0805c01984
commit
8dfdc6f647
|
@ -47,7 +47,7 @@ import java.io.IOException;
|
|||
import java.net.URL;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.*;
|
||||
import static org.hamcrest.CoreMatchers.is;
|
||||
import static org.hamcrest.Matchers.equalTo;
|
||||
import static org.hamcrest.Matchers.notNullValue;
|
||||
|
||||
|
@ -250,7 +250,7 @@ public class PluginManagerTests extends ElasticsearchIntegrationTest {
|
|||
@Test
|
||||
@Network
|
||||
public void testInstallPluginWithElasticsearchDownloadService() throws IOException {
|
||||
assumeTrue(isDownloadServiceWorking("http://download.elasticsearch.org/"));
|
||||
assumeTrue(isDownloadServiceWorking("http://download.elasticsearch.org/", "elasticsearch/ci-test.txt"));
|
||||
singlePluginInstallAndRemove("elasticsearch/elasticsearch-transport-thrift/1.5.0", null);
|
||||
}
|
||||
|
||||
|
@ -263,7 +263,7 @@ public class PluginManagerTests extends ElasticsearchIntegrationTest {
|
|||
@Test
|
||||
@Network
|
||||
public void testInstallPluginWithMavenCentral() throws IOException {
|
||||
assumeTrue(isDownloadServiceWorking("http://search.maven.org/"));
|
||||
assumeTrue(isDownloadServiceWorking("http://search.maven.org/", "/"));
|
||||
singlePluginInstallAndRemove("org.elasticsearch/elasticsearch-transport-thrift/1.5.0", null);
|
||||
}
|
||||
|
||||
|
@ -276,17 +276,20 @@ public class PluginManagerTests extends ElasticsearchIntegrationTest {
|
|||
@Test
|
||||
@Network
|
||||
public void testInstallPluginWithGithub() throws IOException {
|
||||
assumeTrue(isDownloadServiceWorking("https://github.com/"));
|
||||
assumeTrue(isDownloadServiceWorking("https://github.com/", "/"));
|
||||
singlePluginInstallAndRemove("elasticsearch/kibana", null);
|
||||
}
|
||||
|
||||
private boolean isDownloadServiceWorking(String url) {
|
||||
private boolean isDownloadServiceWorking(String url, String resource) {
|
||||
HttpClient client = new HttpClient(url);
|
||||
try {
|
||||
client.request("/");
|
||||
if (client.request(resource).errorCode() != 200) {
|
||||
logger.warn("[{}{}] download service is not working. Disabling current test.", url, resource);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
} catch (Throwable t) {
|
||||
logger.warn("[{}] download service is not working. Disabling current test.", url);
|
||||
logger.warn("[{}{}] download service is not working. Disabling current test.", url, resource);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue