@@ -9,7 +9,6 @@ import org.apache.http.entity.ContentType.APPLICATION_JSON
9
9
import org.apache.http.entity.StringEntity
10
10
import org.opensearch.alerting.ALERTING_BASE_URI
11
11
import org.opensearch.alerting.AlertingRestTestCase
12
- import org.opensearch.alerting.LEGACY_OPENDISTRO_ALERTING_BASE_URI
13
12
import org.opensearch.alerting.makeRequest
14
13
import org.opensearch.alerting.model.Monitor
15
14
import org.opensearch.common.settings.Settings
@@ -53,15 +52,15 @@ class AlertingBackwardsCompatibilityIT : AlertingRestTestCase() {
53
52
val pluginNames = plugins.map { plugin -> plugin[" name" ] }.toSet()
54
53
when (CLUSTER_TYPE ) {
55
54
ClusterType .OLD -> {
56
- assertTrue(pluginNames.contains(" opendistro -alerting" ))
55
+ assertTrue(pluginNames.contains(" opensearch -alerting" ))
57
56
createBasicMonitor()
58
57
}
59
58
ClusterType .MIXED -> {
60
59
assertTrue(pluginNames.contains(" opensearch-alerting" ))
61
- verifyMonitorExists(LEGACY_OPENDISTRO_ALERTING_BASE_URI )
60
+ verifyMonitorExists(ALERTING_BASE_URI )
62
61
// TODO: Need to move the base URI being used here into a constant and rename ALERTING_BASE_URI to
63
62
// MONITOR_BASE_URI
64
- verifyMonitorStats(" /_opendistro /_alerting" )
63
+ verifyMonitorStats(" /_plugins /_alerting" )
65
64
}
66
65
ClusterType .UPGRADED -> {
67
66
assertTrue(pluginNames.contains(" opensearch-alerting" ))
@@ -112,7 +111,7 @@ class AlertingBackwardsCompatibilityIT : AlertingRestTestCase() {
112
111
@Throws(Exception ::class )
113
112
private fun createBasicMonitor () {
114
113
val indexName = " test_bwc_index"
115
- val legacyMonitorString = """
114
+ val bwcMonitorString = """
116
115
{
117
116
"type": "monitor",
118
117
"name": "test_bwc_monitor",
@@ -123,51 +122,46 @@ class AlertingBackwardsCompatibilityIT : AlertingRestTestCase() {
123
122
"unit": "MINUTES"
124
123
}
125
124
},
126
- "inputs": [
127
- {
128
- "search ": {
129
- "indices ": [
130
- " $indexName "
131
- ] ,
125
+ "inputs": [{
126
+ "search": {
127
+ "indices ": [" $indexName "],
128
+ "query ": {
129
+ "size": 0,
130
+ "aggregations": {} ,
132
131
"query": {
133
- "size": 0,
134
- "query": {
135
- "match_all": {}
136
- }
132
+ "match_all": {}
137
133
}
138
134
}
139
135
}
140
- ],
141
- "triggers": [
142
- {
143
- "name": "abc",
144
- "severity": "1",
145
- "condition": {
146
- "script": {
147
- "source": "ctx.results[0].hits.total.value > 100000",
148
- "lang": "painless"
149
- }
150
- },
151
- "actions": []
152
- }
153
- ]
136
+ }],
137
+ "triggers": [{
138
+ "name": "abc",
139
+ "severity": "1",
140
+ "condition": {
141
+ "script": {
142
+ "source": "ctx.results[0].hits.total.value > 100000",
143
+ "lang": "painless"
144
+ }
145
+ },
146
+ "actions": []
147
+ }]
154
148
}
155
149
""" .trimIndent()
156
150
createIndex(indexName, Settings .EMPTY )
157
151
158
152
val createResponse = client().makeRequest(
159
153
method = " POST" ,
160
- endpoint = " $LEGACY_OPENDISTRO_ALERTING_BASE_URI ?refresh=true" ,
154
+ endpoint = " $ALERTING_BASE_URI ?refresh=true" ,
161
155
params = emptyMap(),
162
- entity = StringEntity (legacyMonitorString , APPLICATION_JSON )
156
+ entity = StringEntity (bwcMonitorString , APPLICATION_JSON )
163
157
)
164
158
165
159
assertEquals(" Create monitor failed" , RestStatus .CREATED , createResponse.restStatus())
166
160
val responseBody = createResponse.asMap()
167
161
val createdId = responseBody[" _id" ] as String
168
162
val createdVersion = responseBody[" _version" ] as Int
169
163
assertNotEquals(" Create monitor response is missing id" , Monitor .NO_ID , createdId)
170
- assertTrue(" Create monitor reponse has incorrect version" , createdVersion > 0 )
164
+ assertTrue(" Create monitor response has incorrect version" , createdVersion > 0 )
171
165
}
172
166
173
167
@Throws(Exception ::class )
0 commit comments