Skip to content

Commit cb1c999

Browse files
committed
Use plugin provider instead of manual download
1 parent fe21979 commit cb1c999

File tree

1 file changed

+41
-22
lines changed

1 file changed

+41
-22
lines changed

integ-test/build.gradle

Lines changed: 41 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ apply plugin: 'com.wiredforcode.spawn'
4848

4949

5050
repositories {
51+
mavenLocal()
5152
mavenCentral()
5253
maven { url 'https://jitpack.io' }
5354

@@ -62,22 +63,22 @@ ext {
6263
licenseFile = rootProject.file('LICENSE.TXT')
6364
noticeFile = rootProject.file('NOTICE')
6465

65-
getSecurityPluginDownloadLink = { ->
66-
var repo = "https://aws.oss.sonatype.org/content/repositories/snapshots/org/opensearch/plugin/" +
67-
"opensearch-security/$opensearch_build_snapshot/"
68-
var metadataFile = Paths.get(projectDir.toString(), "build", "maven-metadata.xml").toAbsolutePath().toFile()
69-
download.run {
70-
src repo + "maven-metadata.xml"
71-
dest metadataFile
72-
}
73-
def metadata = new XmlParser().parse(metadataFile)
74-
def securitySnapshotVersion = metadata.versioning.snapshotVersions[0].snapshotVersion[0].value[0].text()
66+
// getSecurityPluginDownloadLink = { ->
67+
// var repo = "https://aws.oss.sonatype.org/content/repositories/snapshots/org/opensearch/plugin/" +
68+
// "opensearch-security/$opensearch_build_snapshot/"
69+
// var metadataFile = Paths.get(projectDir.toString(), "build", "maven-metadata.xml").toAbsolutePath().toFile()
70+
// download.run {
71+
// src repo + "maven-metadata.xml"
72+
// dest metadataFile
73+
// }
74+
// def metadata = new XmlParser().parse(metadataFile)
75+
// def securitySnapshotVersion = metadata.versioning.snapshotVersions[0].snapshotVersion[0].value[0].text()
7576

76-
return repo + "opensearch-security-${securitySnapshotVersion}.zip"
77-
}
77+
// return repo + "opensearch-security-${securitySnapshotVersion}.zip"
78+
// }
7879

7980
var projectAbsPath = projectDir.getAbsolutePath()
80-
File downloadedSecurityPlugin = Paths.get(projectAbsPath, 'bin', 'opensearch-security-snapshot.zip').toFile()
81+
// File downloadedSecurityPlugin = Paths.get(projectAbsPath, 'bin', 'opensearch-security-snapshot.zip').toFile()
8182
configureSecurityPlugin = { OpenSearchCluster cluster ->
8283

8384
cluster.getNodes().forEach { node ->
@@ -90,14 +91,14 @@ ext {
9091
}
9192

9293
// add a check to avoid re-downloading multiple times during single test run
93-
if (!downloadedSecurityPlugin.exists()) {
94-
download.run {
95-
src getSecurityPluginDownloadLink()
96-
dest downloadedSecurityPlugin
97-
}
98-
} else {
99-
println "Security Plugin File Already Exists"
100-
}
94+
// if (!downloadedSecurityPlugin.exists()) {
95+
// download.run {
96+
// src getSecurityPluginDownloadLink()
97+
// dest downloadedSecurityPlugin
98+
// }
99+
// } else {
100+
// println "Security Plugin File Already Exists"
101+
// }
101102

102103
// Config below including files are copied from security demo configuration
103104
['esnode.pem', 'esnode-key.pem', 'root-ca.pem'].forEach { file ->
@@ -133,7 +134,7 @@ ext {
133134
cluster.setting name, value
134135
}
135136

136-
cluster.plugin provider((Callable<RegularFile>) (() -> (RegularFile) (() -> downloadedSecurityPlugin)))
137+
// cluster.plugin provider((Callable<RegularFile>) (() -> (RegularFile) (() -> downloadedSecurityPlugin)))
137138
}
138139

139140
bwcFilePath = "src/test/resources/bwc/"
@@ -227,6 +228,22 @@ def getJobSchedulerPlugin() {
227228
})
228229
}
229230

231+
def getSecurityPlugin() {
232+
provider(new Callable<RegularFile>() {
233+
@Override
234+
RegularFile call() throws Exception {
235+
return new RegularFile() {
236+
@Override
237+
File getAsFile() {
238+
return configurations.zipArchive.asFileTree.matching {
239+
include '**/opensearch-security*'
240+
}.singleFile
241+
}
242+
}
243+
}
244+
})
245+
}
246+
230247
testClusters {
231248
integTest {
232249
testDistribution = 'archive'
@@ -242,11 +259,13 @@ testClusters {
242259
integTestWithSecurity {
243260
testDistribution = 'archive'
244261
plugin(getJobSchedulerPlugin())
262+
plugin(getSecurityPlugin())
245263
plugin ":opensearch-sql-plugin"
246264
}
247265
remoteIntegTestWithSecurity {
248266
testDistribution = 'archive'
249267
plugin(getJobSchedulerPlugin())
268+
plugin(getSecurityPlugin())
250269
plugin ":opensearch-sql-plugin"
251270
}
252271
}

0 commit comments

Comments
 (0)