Skip to content

Commit

Permalink
add for test-cluster
Browse files Browse the repository at this point in the history
Signed-off-by: Mingshi Liu <[email protected]>
  • Loading branch information
mingshl committed Apr 19, 2024
1 parent a179c2c commit 02f81b1
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@
import com.google.gson.JsonArray;

public abstract class MLCommonsRestTestCase extends OpenSearchRestTestCase {
protected Gson gson = new Gson();
protected static Gson gson = new Gson();
public static long CUSTOM_MODEL_TIMEOUT = 20_000; // 20 seconds

protected boolean isHttps() {
Expand Down Expand Up @@ -600,7 +600,7 @@ public void getModel(RestClient client, String modelId, Consumer<Map<String, Obj
verifyResponse(function, response);
}

public void getTask(RestClient client, String taskId, Consumer<Map<String, Object>> function) throws IOException {
public static void getTask(RestClient client, String taskId, Consumer<Map<String, Object>> function) throws IOException {
Response response = TestHelper.makeRequest(client, "GET", "/_plugins/_ml/tasks/" + taskId, null, "", null);
verifyResponse(function, response);
}
Expand Down Expand Up @@ -635,7 +635,7 @@ public void searchTasks(RestClient client, String query, Consumer<Map<String, Ob
verifyResponse(function, response);
}

private void verifyResponse(Consumer<Map<String, Object>> verificationConsumer, Response response) throws IOException {
private static void verifyResponse(Consumer<Map<String, Object>> verificationConsumer, Response response) throws IOException {
Map<String, Object> map = parseResponseToMap(response);
if (verificationConsumer != null) {
verificationConsumer.accept(map);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ protected boolean checkThrottlingOpenAI(Map responseMap) {
return message.equals("You exceeded your current quota, please check your plan and billing details.");
}

protected Map parseResponseToMap(Response response) throws IOException {
public static Map parseResponseToMap(Response response) throws IOException {
HttpEntity entity = response.getEntity();
assertNotNull(response);
String entityString = TestHelper.httpEntityToString(entity);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
import java.util.List;
import java.util.Map;

import org.apache.hc.core5.http.HttpHeaders;
import org.apache.hc.core5.http.message.BasicHeader;
import org.apache.http.HttpHeaders;
import org.apache.http.message.BasicHeader;
import org.junit.Before;
import org.opensearch.client.Request;
import org.opensearch.client.Response;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
import java.util.function.Consumer;

import org.apache.commons.lang3.exception.ExceptionUtils;
import org.apache.http.HttpEntity;
import org.apache.http.HttpHeaders;
import org.apache.http.message.BasicHeader;
import org.junit.Before;
Expand Down Expand Up @@ -805,14 +804,6 @@ protected boolean checkThrottlingOpenAI(Map responseMap) {
return message.equals("You exceeded your current quota, please check your plan and billing details.");
}

protected Map parseResponseToMap(Response response) throws IOException {
HttpEntity entity = response.getEntity();
assertNotNull(response);
String entityString = TestHelper.httpEntityToString(entity);
return gson.fromJson(entityString, Map.class);
}

protected void disableClusterConnectorAccessControl() throws IOException {
public static void disableClusterConnectorAccessControl() throws IOException {
Response response = TestHelper
.makeRequest(
Expand Down
Binary file not shown.

0 comments on commit 02f81b1

Please sign in to comment.