Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Backport 2.5] Update default setting for integ tests #106

Merged
merged 2 commits into from
Jan 17, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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