Test: Extended malformed test to also check if the strict alert mapping in the template is active.
Original commit: elastic/x-pack-elasticsearch@dfcad46f94
This commit is contained in:
parent
4d581876bd
commit
e0741997d0
|
@ -86,7 +86,7 @@ public class BasicAlertingTest extends AbstractAlertingTests {
|
|||
assertFalse(deleteAlertResponse.deleteResponse().isFound());
|
||||
}
|
||||
|
||||
@Test(expected = ElasticsearchIllegalArgumentException.class)
|
||||
@Test
|
||||
public void testMalformedAlert() throws Exception {
|
||||
AlertsClientInterface alertsClient = alertClient();
|
||||
createIndex("my-index");
|
||||
|
@ -98,8 +98,21 @@ public class BasicAlertingTest extends AbstractAlertingTests {
|
|||
.field("enable", true)
|
||||
.field("malformed_field", "x")
|
||||
.endObject().bytes();
|
||||
try {
|
||||
alertsClient.prepareIndexAlert("my-first-alert")
|
||||
.setAlertSource(alertSource)
|
||||
.get();
|
||||
fail();
|
||||
} catch (ElasticsearchIllegalArgumentException e) {
|
||||
// In AlertStore we fail parsing if an alert contains undefined fields.
|
||||
}
|
||||
try {
|
||||
client().prepareIndex(AlertsStore.ALERT_INDEX, AlertsStore.ALERT_TYPE, "my-first-alert")
|
||||
.setSource(alertSource)
|
||||
.get();
|
||||
fail();
|
||||
} catch (Exception e) {
|
||||
// The alert index template the mapping is defined as strict
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue