From cda1b5a7e5c658a6d291650241fe9f214e271959 Mon Sep 17 00:00:00 2001 From: zane-neo Date: Wed, 16 Oct 2024 15:49:27 +0800 Subject: [PATCH 1/2] Add logs to response to locate failure of ITs. Signed-off-by: zane-neo --- .../java/org/opensearch/integTest/BaseAgentToolsIT.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/test/java/org/opensearch/integTest/BaseAgentToolsIT.java b/src/test/java/org/opensearch/integTest/BaseAgentToolsIT.java index fa73d4fe..4128572a 100644 --- a/src/test/java/org/opensearch/integTest/BaseAgentToolsIT.java +++ b/src/test/java/org/opensearch/integTest/BaseAgentToolsIT.java @@ -16,6 +16,7 @@ import java.util.function.Predicate; import java.util.stream.Collectors; +import lombok.extern.log4j.Log4j2; import org.apache.commons.lang3.StringUtils; import org.apache.hc.core5.http.ContentType; import org.apache.hc.core5.http.Header; @@ -49,6 +50,7 @@ import lombok.SneakyThrows; +@Log4j2 public abstract class BaseAgentToolsIT extends OpenSearchSecureRestTestCase { public static final Gson gson = new Gson(); private static final int MAX_TASK_RESULT_QUERY_TIME_IN_SECOND = 60 * 5; @@ -90,9 +92,10 @@ protected void updateClusterSettings(String settingKey, Object value) { @SneakyThrows private Map parseResponseToMap(Response response) { - Map responseInMap = XContentHelper - .convertToMap(XContentType.JSON.xContent(), EntityUtils.toString(response.getEntity()), false); - return responseInMap; + String responseBody = EntityUtils.toString(response.getEntity()); + log.info("raw response is: {}", responseBody); + return XContentHelper + .convertToMap(XContentType.JSON.xContent(), responseBody, false); } @SneakyThrows From 38eb7d358adf82bb6706758d86fe7a1faf18fcda Mon Sep 17 00:00:00 2001 From: zane-neo Date: Thu, 17 Oct 2024 16:29:15 +0800 Subject: [PATCH 2/2] format code Signed-off-by: zane-neo --- src/test/java/org/opensearch/integTest/BaseAgentToolsIT.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/test/java/org/opensearch/integTest/BaseAgentToolsIT.java b/src/test/java/org/opensearch/integTest/BaseAgentToolsIT.java index 4128572a..6a9698db 100644 --- a/src/test/java/org/opensearch/integTest/BaseAgentToolsIT.java +++ b/src/test/java/org/opensearch/integTest/BaseAgentToolsIT.java @@ -16,7 +16,6 @@ import java.util.function.Predicate; import java.util.stream.Collectors; -import lombok.extern.log4j.Log4j2; import org.apache.commons.lang3.StringUtils; import org.apache.hc.core5.http.ContentType; import org.apache.hc.core5.http.Header; @@ -49,6 +48,7 @@ import com.google.gson.Gson; import lombok.SneakyThrows; +import lombok.extern.log4j.Log4j2; @Log4j2 public abstract class BaseAgentToolsIT extends OpenSearchSecureRestTestCase { @@ -94,8 +94,7 @@ protected void updateClusterSettings(String settingKey, Object value) { private Map parseResponseToMap(Response response) { String responseBody = EntityUtils.toString(response.getEntity()); log.info("raw response is: {}", responseBody); - return XContentHelper - .convertToMap(XContentType.JSON.xContent(), responseBody, false); + return XContentHelper.convertToMap(XContentType.JSON.xContent(), responseBody, false); } @SneakyThrows