Skip to content

Commit

Permalink
Add path.repo for registering snapshot repository in integ tests (ope…
Browse files Browse the repository at this point in the history
…nsearch-project#2461)

Signed-off-by: AnnTian Shao <[email protected]>
Co-authored-by: AnnTian Shao <[email protected]>
  • Loading branch information
anntians and AnnTian Shao authored Jan 29, 2025
1 parent 3885256 commit 168ee3c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 14 deletions.
4 changes: 4 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,7 @@ integTest {
systemProperty 'tests.security.manager', 'false'
systemProperty 'java.io.tmpdir', opensearch_tmp_dir.absolutePath
systemProperty "java.library.path", "$rootDir/jni/release"
systemProperty "tests.path.repo", "${buildDir}/testSnapshotFolder"
// allows integration test classes to access test resource from project root path
systemProperty('project.root', project.rootDir.absolutePath)

Expand Down Expand Up @@ -438,6 +439,9 @@ testClusters.integTest {
}
}
systemProperty("java.library.path", "$rootDir/jni/release")
final testSnapshotFolder = file("${buildDir}/testSnapshotFolder")
testSnapshotFolder.mkdirs()
setting 'path.repo', "${buildDir}/testSnapshotFolder"
}

task integTestRemote(type: RestIntegTestTask) {
Expand Down
15 changes: 1 addition & 14 deletions src/testFixtures/java/org/opensearch/knn/KNNRestTestCase.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
import org.apache.http.client.utils.URIBuilder;
import org.apache.http.util.EntityUtils;
import org.opensearch.Version;
import org.opensearch.common.xcontent.support.XContentMapValues;
import org.opensearch.core.common.bytes.BytesReference;
import org.opensearch.common.xcontent.XContentHelper;
import org.opensearch.core.xcontent.DeprecationHandler;
Expand Down Expand Up @@ -74,8 +73,6 @@
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;

import static org.hamcrest.Matchers.hasSize;
import static org.hamcrest.Matchers.notNullValue;
import static org.opensearch.knn.common.KNNConstants.DIMENSION;
import static org.opensearch.knn.common.KNNConstants.ENCODER_PARAMETER_PQ_CODE_SIZE;
import static org.opensearch.knn.common.KNNConstants.ENCODER_PARAMETER_PQ_M;
Expand Down Expand Up @@ -1986,17 +1983,7 @@ protected static String randomLowerCaseString() {

@SneakyThrows
protected void setupSnapshotRestore(String index, String snapshot, String repository) {
Request clusterSettingsRequest = new Request("GET", "/_cluster/settings");
clusterSettingsRequest.addParameter("include_defaults", "true");
Response clusterSettingsResponse = client().performRequest(clusterSettingsRequest);
Map<String, Object> clusterSettings = entityAsMap(clusterSettingsResponse);

@SuppressWarnings("unchecked")
List<String> pathRepos = (List<String>) XContentMapValues.extractValue("defaults.path.repo", clusterSettings);
assertThat(pathRepos, notNullValue());
assertThat(pathRepos, hasSize(1));

final String pathRepo = pathRepos.get(0);
final String pathRepo = System.getProperty("tests.path.repo");

// create index
createIndex(index, getDefaultIndexSettings());
Expand Down

0 comments on commit 168ee3c

Please sign in to comment.