Skip to content

Commit

Permalink
Add path.repo for registering snapshot repository in integ tests (#2461)
Browse files Browse the repository at this point in the history
Signed-off-by: AnnTian Shao <anntians@amazon.com>
Co-authored-by: AnnTian Shao <anntians@amazon.com>
(cherry picked from commit 168ee3c)
  • Loading branch information
anntians authored and AnnTian Shao committed Jan 29, 2025
1 parent d142366 commit 2dc6738
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
4 changes: 4 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,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 @@ -448,6 +449,9 @@ testClusters.integTest {
}
}
systemProperty("java.library.path", "$rootDir/jni/release")
final testSnapshotFolder = file("${buildDir}/testSnapshotFolder")
testSnapshotFolder.mkdirs()
setting 'path.repo', "${buildDir}/testSnapshotFolder"
systemProperty propertyKeys.breaker.useRealMemory, getBreakerSetting()
}

Expand Down
15 changes: 15 additions & 0 deletions src/testFixtures/java/org/opensearch/knn/KNNRestTestCase.java
Original file line number Diff line number Diff line change
Expand Up @@ -1980,4 +1980,19 @@ protected boolean isApproximateThresholdSupported(final Optional<String> bwcVers
protected static String randomLowerCaseString() {
return randomAlphaOfLengthBetween(MIN_CODE_UNITS, MAX_CODE_UNITS).toLowerCase(Locale.ROOT);
}

@SneakyThrows
protected void setupSnapshotRestore(String index, String snapshot, String repository) {
final String pathRepo = System.getProperty("tests.path.repo");

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

// create repo
Settings repoSettings = Settings.builder().put("compress", randomBoolean()).put("location", pathRepo).build();
registerRepository(repository, "fs", true, repoSettings);

// create snapshot
createSnapshot(repository, snapshot, true);
}
}

0 comments on commit 2dc6738

Please sign in to comment.