No-Issue: TestExecutor enhancements
- add ability to pass an http context to http executions
- update cluster state wait from exact match to regex
Change-Id: Ib3a33c9f5bda8211d404c6d2155b2c1d2ea078b9
Reviewed-on: https://asterix-gerrit.ics.uci.edu/1884
Sonar-Qube: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Tested-by: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
BAD: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Integration-Tests: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Reviewed-by: Till Westmann <tillw@apache.org>
diff --git a/asterixdb/asterix-app/src/test/java/org/apache/asterix/test/common/TestExecutor.java b/asterixdb/asterix-app/src/test/java/org/apache/asterix/test/common/TestExecutor.java
index 8791756..8442162 100644
--- a/asterixdb/asterix-app/src/test/java/org/apache/asterix/test/common/TestExecutor.java
+++ b/asterixdb/asterix-app/src/test/java/org/apache/asterix/test/common/TestExecutor.java
@@ -81,6 +81,7 @@
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.impl.client.StandardHttpRequestRetryHandler;
+import org.apache.http.protocol.HttpContext;
import org.apache.http.util.EntityUtils;
import org.apache.hyracks.util.StorageUtil;
import org.junit.Assert;
@@ -445,7 +446,7 @@
protected HttpResponse executeHttpRequest(HttpUriRequest method) throws Exception {
HttpClient client = HttpClients.custom().setRetryHandler(StandardHttpRequestRetryHandler.INSTANCE).build();
try {
- return client.execute(method);
+ return client.execute(method, getHttpContext());
} catch (Exception e) {
GlobalConfig.ASTERIX_LOGGER.log(Level.SEVERE, e.getMessage(), e);
e.printStackTrace();
@@ -453,6 +454,10 @@
}
}
+ protected HttpContext getHttpContext() {
+ return null;
+ }
+
protected HttpResponse checkResponse(HttpResponse httpResponse, Predicate<Integer> responseCodeValidator)
throws Exception {
if (!responseCodeValidator.test(httpResponse.getStatusLine().getStatusCode())) {
@@ -1441,9 +1446,8 @@
while (true) {
try {
final HttpClient client = HttpClients.createDefault();
-
final HttpGet get = new HttpGet(getEndpoint(Servlets.CLUSTER_STATE));
- final HttpResponse httpResponse = client.execute(get);
+ final HttpResponse httpResponse = client.execute(get, getHttpContext());
final int statusCode = httpResponse.getStatusLine().getStatusCode();
final String response = EntityUtils.toString(httpResponse.getEntity());
if (statusCode != HttpStatus.SC_OK) {
@@ -1451,7 +1455,7 @@
}
ObjectMapper om = new ObjectMapper();
ObjectNode result = (ObjectNode) om.readTree(response);
- if (desiredState.equals(result.get("state").asText())) {
+ if (result.get("state").asText().matches(desiredState)) {
break;
}
} catch (Exception e) {