Skip to content

Commit

Permalink
[Backport 2.5] Update default setting for integ tests (#106)
Browse files Browse the repository at this point in the history
Updates defaul ml commons setting
"plugins.ml_commons.only_run_on_ml_node" to false. This prevents
integration tests from failing when an ml node is not explicitly added.

Also, make circuit breaker 100 for tests

Signed-off-by: John Mazanec <jmazane@amazon.com>
  • Loading branch information
jmazanec15 committed Jan 17, 2023
1 parent a85c2f7 commit e498cba
Showing 1 changed file with 27 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import org.apache.http.entity.StringEntity;
import org.apache.http.message.BasicHeader;
import org.apache.http.util.EntityUtils;
import org.junit.Before;
import org.opensearch.client.Request;
import org.opensearch.client.RequestOptions;
import org.opensearch.client.Response;
Expand Down Expand Up @@ -58,6 +59,32 @@ public abstract class BaseNeuralSearchIT extends OpenSearchSecureRestTestCase {

protected final ClassLoader classLoader = this.getClass().getClassLoader();

@Before
public void setupSettings() {
updateClusterSettings("plugins.ml_commons.only_run_on_ml_node", false);
updateClusterSettings("plugins.ml_commons.native_memory_threshold", 100);
}

@SneakyThrows
protected void updateClusterSettings(String settingKey, Object value) {
XContentBuilder builder = XContentFactory.jsonBuilder()
.startObject()
.startObject("persistent")
.field(settingKey, value)
.endObject()
.endObject();
Response response = makeRequest(
client(),
"PUT",
"_cluster/settings",
null,
toHttpEntity(Strings.toString(builder)),
ImmutableList.of(new BasicHeader(HttpHeaders.USER_AGENT, ""))
);

assertEquals(RestStatus.OK, RestStatus.fromCode(response.getStatusLine().getStatusCode()));
}

protected String uploadModel(String requestBody) throws Exception {
Response uploadResponse = makeRequest(
client(),
Expand Down

0 comments on commit e498cba

Please sign in to comment.