Skip to content

Commit

Permalink
Replace checked-in ZIP for bwc tests with a dynamic dependency (#411)
Browse files Browse the repository at this point in the history
* Replace checked-in ZIP with a dynamic dependency

Signed-off-by: Subhobrata Dey <sbcd90@gmail.com>

* Replace checked-in ZIP with a dynamic dependency

Signed-off-by: Subhobrata Dey <sbcd90@gmail.com>
  • Loading branch information
sbcd90 authored and AWSHurneyt committed Apr 21, 2022
1 parent f740c9b commit c7a342f
Show file tree
Hide file tree
Showing 5 changed files with 73 additions and 4 deletions.
74 changes: 70 additions & 4 deletions alerting/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,13 @@ integTest.dependsOn(bundle)
integTest.getClusters().forEach{c -> c.plugin(project.getObjects().fileProperty().value(bundle.getArchiveFile()))}

def _numNodes = findProperty('numNodes') as Integer ?: 1

String notificationsFilePath = "src/test/resources/notifications"
String notificationsCoreFilePath = "src/test/resources/notifications-core"
String notificationsPlugin = "opensearch-notifications-" + plugin_no_snapshot + ".zip"
String notificationsCorePlugin = "opensearch-notifications-core-" + plugin_no_snapshot + ".zip"
String notificationsRemoteFile = "https://ci.opensearch.org/ci/dbc/distribution-build-opensearch/" + opensearch_no_snapshot + "/latest/linux/x64/tar/builds/opensearch/plugins/" + notificationsPlugin
String notificationsCoreRemoteFile = "https://ci.opensearch.org/ci/dbc/distribution-build-opensearch/" + opensearch_no_snapshot + "/latest/linux/x64/tar/builds/opensearch/plugins/" + notificationsCorePlugin
testClusters.integTest {
testDistribution = "ARCHIVE"
// Cluster shrink exception thrown if we try to set numberOfNodes to 1, so only apply if > 1
Expand All @@ -115,14 +122,38 @@ testClusters.integTest {
plugin(provider({
new RegularFile() {
@Override
File getAsFile() { fileTree("src/test/resources/notifications-core").getSingleFile() }
File getAsFile() {
File dir = new File(rootDir.path + "/alerting/" + notificationsCoreFilePath)

if (!dir.exists()) {
dir.mkdirs()
}

File f = new File(dir, notificationsCorePlugin)
if (!f.exists()) {
new URL(notificationsCoreRemoteFile).withInputStream{ ins -> f.withOutputStream{ it << ins }}
}
fileTree(notificationsCoreFilePath).getSingleFile()
}
}
}))

plugin(provider({
new RegularFile() {
@Override
File getAsFile() { fileTree("src/test/resources/notifications").getSingleFile() }
File getAsFile() {
File dir = new File(rootDir.path + "/alerting/" + notificationsFilePath)

if (!dir.exists()) {
dir.mkdirs()
}

File f = new File(dir, notificationsPlugin)
if (!f.exists()) {
new URL(notificationsRemoteFile).withInputStream{ ins -> f.withOutputStream{ it << ins }}
}
fileTree(notificationsFilePath).getSingleFile()
}
}
}))
}
Expand Down Expand Up @@ -170,6 +201,8 @@ integTest {
String bwcVersion = "1.13.1.0"
String baseName = "alertingBwcCluster"
String bwcFilePath = "src/test/resources/bwc"
String bwcOpenDistroPlugin = "opendistro-alerting-" + bwcVersion + ".zip"
String bwcRemoteFile = 'https://d3g5vo6xdbdb9a.cloudfront.net/downloads/elasticsearch-plugins/opendistro-alerting/' + bwcOpenDistroPlugin

2.times {i ->
testClusters {
Expand All @@ -183,6 +216,15 @@ String bwcFilePath = "src/test/resources/bwc"
return new RegularFile() {
@Override
File getAsFile() {
File dir = new File(rootDir.path + "/alerting/" + bwcFilePath + "/alerting/" + bwcVersion)

if (!dir.exists()) {
dir.mkdirs()
}
File f = new File(dir, bwcOpenDistroPlugin)
if (!f.exists()) {
new URL(bwcRemoteFile).withInputStream{ ins -> f.withOutputStream{ it << ins }}
}
return fileTree(bwcFilePath + "/alerting/" + bwcVersion).getSingleFile()
}
}
Expand All @@ -205,13 +247,37 @@ task prepareBwcTests {
provider({
new RegularFile() {
@Override
File getAsFile() { fileTree("src/test/resources/notifications-core").getSingleFile() }
File getAsFile() {
File dir = new File(rootDir.path + "/alerting/" + notificationsCoreFilePath)

if (!dir.exists()) {
dir.mkdirs()
}

File f = new File(dir, notificationsCorePlugin)
if (!f.exists()) {
new URL(notificationsCoreRemoteFile).withInputStream{ ins -> f.withOutputStream{ it << ins }}
}
fileTree(notificationsCoreFilePath).getSingleFile()
}
}
}),
provider({
new RegularFile() {
@Override
File getAsFile() { fileTree("src/test/resources/notifications").getSingleFile() }
File getAsFile() {
File dir = new File(rootDir.path + "/alerting/" + notificationsFilePath)

if (!dir.exists()) {
dir.mkdirs()
}

File f = new File(dir, notificationsPlugin)
if (!f.exists()) {
new URL(notificationsRemoteFile).withInputStream{ ins -> f.withOutputStream{ it << ins }}
}
fileTree(notificationsFilePath).getSingleFile()
}
}
})
]
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
3 changes: 3 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,15 @@ buildscript {
// 2.0.0-rc1-SNAPSHOT -> 2.0.0.0-rc1-SNAPSHOT
version_tokens = opensearch_version.tokenize('-')
opensearch_build = version_tokens[0] + '.0'
plugin_no_snapshot = opensearch_build
if (buildVersionQualifier) {
opensearch_build += "-${buildVersionQualifier}"
plugin_no_snapshot += "-${buildVersionQualifier}"
}
if (isSnapshot) {
opensearch_build += "-SNAPSHOT"
}
opensearch_no_snapshot = opensearch_version.replace("-SNAPSHOT","")
common_utils_version = System.getProperty("common_utils.version", opensearch_build)
kotlin_version = '1.6.10'
}
Expand Down

0 comments on commit c7a342f

Please sign in to comment.