Skip to content

Commit

Permalink
Refactored backwards compatibility tests to point to the OpenSearch 1…
Browse files Browse the repository at this point in the history
….1.0.0 zip following deprecation of ODFE. (opensearch-project#510)

Signed-off-by: AWSHurneyt <hurneyt@amazon.com>
  • Loading branch information
AWSHurneyt committed Aug 4, 2022
1 parent 3b8bfe7 commit fea6b4a
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 38 deletions.
12 changes: 6 additions & 6 deletions alerting/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ testClusters.integTest {
}

testClusters.integTest.nodes.each { node ->
node.setting("opendistro.destination.host.deny_list", "[\"10.0.0.0/8\", \"127.0.0.1\"]")
node.setting("plugins.destination.host.deny_list", "[\"10.0.0.0/8\", \"127.0.0.1\"]")
}

integTest {
Expand Down Expand Up @@ -247,17 +247,17 @@ task integTestRemote(type: RestIntegTestTask) {
}
integTestRemote.enabled = System.getProperty("tests.rest.cluster") != null

String bwcVersion = "1.13.1.0"
String bwcVersion = "1.1.0.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
String bwcOpenSearchPlugin = "opensearch-alerting-" + bwcVersion + ".zip"
String bwcRemoteFile = 'https://ci.opensearch.org/ci/dbc/bundle-build/1.1.0/20210930/linux/x64/builds/opensearch/plugins/' + bwcOpenSearchPlugin

2.times {i ->
testClusters {
"${baseName}$i" {
testDistribution = "ARCHIVE"
versions = ["7.10.2","2.1.0-SNAPSHOT"]
versions = ["1.1.0", "2.1.0-SNAPSHOT"]
numberOfNodes = 3
plugin(provider(new Callable<RegularFile>(){
@Override
Expand All @@ -270,7 +270,7 @@ String bwcRemoteFile = 'https://d3g5vo6xdbdb9a.cloudfront.net/downloads/elastics
if (!dir.exists()) {
dir.mkdirs()
}
File f = new File(dir, bwcOpenDistroPlugin)
File f = new File(dir, bwcOpenSearchPlugin)
if (!f.exists()) {
new URL(bwcRemoteFile).withInputStream{ ins -> f.withOutputStream{ it << ins }}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import org.apache.http.entity.ContentType.APPLICATION_JSON
import org.apache.http.entity.StringEntity
import org.opensearch.alerting.ALERTING_BASE_URI
import org.opensearch.alerting.AlertingRestTestCase
import org.opensearch.alerting.LEGACY_OPENDISTRO_ALERTING_BASE_URI
import org.opensearch.alerting.makeRequest
import org.opensearch.alerting.model.Monitor
import org.opensearch.common.settings.Settings
Expand Down Expand Up @@ -53,15 +52,15 @@ class AlertingBackwardsCompatibilityIT : AlertingRestTestCase() {
val pluginNames = plugins.map { plugin -> plugin["name"] }.toSet()
when (CLUSTER_TYPE) {
ClusterType.OLD -> {
assertTrue(pluginNames.contains("opendistro-alerting"))
assertTrue(pluginNames.contains("opensearch-alerting"))
createBasicMonitor()
}
ClusterType.MIXED -> {
assertTrue(pluginNames.contains("opensearch-alerting"))
verifyMonitorExists(LEGACY_OPENDISTRO_ALERTING_BASE_URI)
verifyMonitorExists(ALERTING_BASE_URI)
// TODO: Need to move the base URI being used here into a constant and rename ALERTING_BASE_URI to
// MONITOR_BASE_URI
verifyMonitorStats("/_opendistro/_alerting")
verifyMonitorStats("/_plugins/_alerting")
}
ClusterType.UPGRADED -> {
assertTrue(pluginNames.contains("opensearch-alerting"))
Expand Down Expand Up @@ -112,7 +111,7 @@ class AlertingBackwardsCompatibilityIT : AlertingRestTestCase() {
@Throws(Exception::class)
private fun createBasicMonitor() {
val indexName = "test_bwc_index"
val legacyMonitorString = """
val bwcMonitorString = """
{
"type": "monitor",
"name": "test_bwc_monitor",
Expand All @@ -123,51 +122,46 @@ class AlertingBackwardsCompatibilityIT : AlertingRestTestCase() {
"unit": "MINUTES"
}
},
"inputs": [
{
"search": {
"indices": [
"$indexName"
],
"inputs": [{
"search": {
"indices": ["$indexName"],
"query": {
"size": 0,
"aggregations": {},
"query": {
"size": 0,
"query": {
"match_all": {}
}
"match_all": {}
}
}
}
],
"triggers": [
{
"name": "abc",
"severity": "1",
"condition": {
"script": {
"source": "ctx.results[0].hits.total.value > 100000",
"lang": "painless"
}
},
"actions": []
}
]
}],
"triggers": [{
"name": "abc",
"severity": "1",
"condition": {
"script": {
"source": "ctx.results[0].hits.total.value > 100000",
"lang": "painless"
}
},
"actions": []
}]
}
""".trimIndent()
createIndex(indexName, Settings.EMPTY)

val createResponse = client().makeRequest(
method = "POST",
endpoint = "$LEGACY_OPENDISTRO_ALERTING_BASE_URI?refresh=true",
endpoint = "$ALERTING_BASE_URI?refresh=true",
params = emptyMap(),
entity = StringEntity(legacyMonitorString, APPLICATION_JSON)
entity = StringEntity(bwcMonitorString, APPLICATION_JSON)
)

assertEquals("Create monitor failed", RestStatus.CREATED, createResponse.restStatus())
val responseBody = createResponse.asMap()
val createdId = responseBody["_id"] as String
val createdVersion = responseBody["_version"] as Int
assertNotEquals("Create monitor response is missing id", Monitor.NO_ID, createdId)
assertTrue("Create monitor reponse has incorrect version", createdVersion > 0)
assertTrue("Create monitor response has incorrect version", createdVersion > 0)
}

@Throws(Exception::class)
Expand Down

0 comments on commit fea6b4a

Please sign in to comment.