diff --git a/async-query/src/test/java/org/opensearch/sql/spark/scheduler/OpenSearchAsyncQuerySchedulerTest.java b/async-query/src/test/java/org/opensearch/sql/spark/scheduler/OpenSearchAsyncQuerySchedulerTest.java index 4e90d02239..689d1f808e 100644 --- a/async-query/src/test/java/org/opensearch/sql/spark/scheduler/OpenSearchAsyncQuerySchedulerTest.java +++ b/async-query/src/test/java/org/opensearch/sql/spark/scheduler/OpenSearchAsyncQuerySchedulerTest.java @@ -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; @@ -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()); } diff --git a/integ-test/build.gradle b/integ-test/build.gradle index 22b6d24005..c2312797bc 100644 --- a/integ-test/build.gradle +++ b/integ-test/build.gradle @@ -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 -> @@ -138,6 +153,21 @@ ext { cluster.plugin provider((Callable) (() -> (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) (() -> downloadedJobSchedulerPlugin))) + } } tasks.withType(licenseHeaders.class) { @@ -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" } @@ -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 { @@ -323,6 +364,7 @@ task integTestWithSecurity(type: RestIntegTestTask) { getClusters().stream().map(cluster -> cluster.getName()).collect(Collectors.joining(",")) getClusters().forEach { cluster -> + configureJobSchedulerPlugin(cluster) configureSecurityPlugin(cluster) }