Skip to content

Commit

Permalink
Fix IT
Browse files Browse the repository at this point in the history
Signed-off-by: Louis Chu <clingzhi@amazon.com>
  • Loading branch information
noCharger committed Jul 18, 2024
1 parent c61ccfa commit f984cac
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public class OpenSearchAsyncQuerySchedulerTest {

private static final String TEST_SCHEDULER_INDEX_NAME = "testQS";

private static final String TEST_JOB_ID = "testJobId";
private static final String TEST_JOB_ID = "testJob";

@Mock(answer = Answers.RETURNS_DEEP_STUBS)
private Client client;
Expand Down Expand Up @@ -192,7 +192,7 @@ public void testRemoveJob() {
verify(client).delete(captor.capture());

DeleteRequest capturedRequest = captor.getValue();
assertEquals(jobId, capturedRequest.id());
assertEquals(TEST_JOB_ID, capturedRequest.id());
assertEquals(WriteRequest.RefreshPolicy.IMMEDIATE, capturedRequest.getRefreshPolicy());
}

Expand Down
42 changes: 42 additions & 0 deletions integ-test/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,23 @@ ext {
return repo + "opensearch-security-${securitySnapshotVersion}.zip"
}

getJobSchedulerPluginDownloadLink = { ->
var repo = "https://aws.oss.sonatype.org/content/repositories/snapshots/org/opensearch/plugin/" +
"opensearch-job-scheduler/$opensearch_build_snapshot/"
var metadataFile = Paths.get(projectDir.toString(), "build", "job-scheduler-maven-metadata.xml").toAbsolutePath().toFile()
download.run {
src repo + "maven-metadata.xml"
dest metadataFile
}
def metadata = new XmlParser().parse(metadataFile)
def jobSchedulerSnapshotVersion = metadata.versioning.snapshotVersions[0].snapshotVersion[0].value[0].text()

return repo + "opensearch-job-scheduler-${jobSchedulerSnapshotVersion}.zip"
}

var projectAbsPath = projectDir.getAbsolutePath()
File downloadedSecurityPlugin = Paths.get(projectAbsPath, 'bin', 'opensearch-security-snapshot.zip').toFile()
File downloadedJobSchedulerPlugin = Paths.get(projectAbsPath, 'bin', 'opensearch-job-scheduler-snapshot.zip').toFile()

configureSecurityPlugin = { OpenSearchCluster cluster ->

Expand Down Expand Up @@ -138,6 +153,21 @@ ext {

cluster.plugin provider((Callable<RegularFile>) (() -> (RegularFile) (() -> downloadedSecurityPlugin)))
}

configureJobSchedulerPlugin = { OpenSearchCluster cluster ->

// add a check to avoid re-downloading multiple times during single test run
if (!downloadedJobSchedulerPlugin.exists()) {
download.run {
src getJobSchedulerPluginDownloadLink()
dest downloadedJobSchedulerPlugin
}
} else {
println "Job Scheduler Plugin File Already Exists"
}

cluster.plugin provider((Callable<RegularFile>) (() -> (RegularFile) (() -> downloadedJobSchedulerPlugin)))
}
}

tasks.withType(licenseHeaders.class) {
Expand Down Expand Up @@ -191,6 +221,7 @@ dependencies {
testCompileOnly 'org.apiguardian:apiguardian-api:1.1.2'

// Needed for BWC tests
zipArchive group: 'org.opensearch.plugin', name:'opensearch-job-scheduler', version: "${opensearch_build}"
zipArchive group: 'org.opensearch.plugin', name:'opensearch-sql-plugin', version: "${bwcVersion}-SNAPSHOT"
}

Expand Down Expand Up @@ -231,6 +262,16 @@ testClusters {
}
integTestWithSecurity {
testDistribution = 'archive'
plugin(provider({
new RegularFile() {
@Override
File getAsFile() {
return configurations.zipArchive.asFileTree.matching {
include '**/opensearch-job-scheduler*'
}.singleFile
}
}
}))
plugin ":opensearch-sql-plugin"
}
remoteIntegTestWithSecurity {
Expand Down Expand Up @@ -323,6 +364,7 @@ task integTestWithSecurity(type: RestIntegTestTask) {
getClusters().stream().map(cluster -> cluster.getName()).collect(Collectors.joining(","))

getClusters().forEach { cluster ->
configureJobSchedulerPlugin(cluster)
configureSecurityPlugin(cluster)
}

Expand Down

0 comments on commit f984cac

Please sign in to comment.