mirror of
https://github.com/honeymoose/OpenSearch.git
synced 2025-02-06 13:08:29 +00:00
TESTS : Fix the alert stats test failure and some cleanup and docs.
This test fixes the alert stats test failures due the the scope being suite scope which meant that the pass/fail was dependent on execution order for the clean start test. Also add asciidoc for alert stats. Original commit: elastic/x-pack-elasticsearch@be3ff86359
This commit is contained in:
parent
90a214f9ab
commit
84680f84b3
@ -160,6 +160,7 @@ public class AlertActionManager extends AbstractComponent {
|
||||
|
||||
public void loadQueue() {
|
||||
client.admin().indices().refresh(new RefreshRequest(ALERT_HISTORY_INDEX)).actionGet();
|
||||
|
||||
SearchResponse response = client.prepareSearch()
|
||||
.setQuery(QueryBuilders.termQuery(AlertActionState.FIELD_NAME, AlertActionState.SEARCH_NEEDED.toString()))
|
||||
.setSearchType(SearchType.SCAN)
|
||||
@ -181,6 +182,7 @@ public class AlertActionManager extends AbstractComponent {
|
||||
client.prepareClearScroll().addScrollId(response.getScrollId()).get();
|
||||
}
|
||||
logger.info("Loaded [{}] actions from the alert history index into actions queue", actionsToBeProcessed.size());
|
||||
largestQueueSize.set(actionsToBeProcessed.size());
|
||||
}
|
||||
|
||||
AlertActionEntry parseHistory(String historyId, BytesReference source, long version, AlertActionRegistry actionRegistry) {
|
||||
@ -258,6 +260,7 @@ public class AlertActionManager extends AbstractComponent {
|
||||
.setSource(XContentFactory.jsonBuilder().value(entry))
|
||||
.setOpType(IndexRequest.OpType.CREATE)
|
||||
.get();
|
||||
logger.info("Adding alert action for alert [{}]", alert.alertName() );
|
||||
entry.setVersion(response.getVersion());
|
||||
long currentSize = actionsToBeProcessed.size() + 1;
|
||||
actionsToBeProcessed.add(entry);
|
||||
|
@ -43,7 +43,8 @@ public class RestAlertsStatsAction extends BaseRestHandler {
|
||||
.field("alert_manager_started", alertsStatsResponse.isAlertManagerStarted())
|
||||
.field("alert_action_manager_started", alertsStatsResponse.isAlertActionManagerStarted())
|
||||
.field("alert_action_queue_size", alertsStatsResponse.getAlertActionManagerQueueSize())
|
||||
.field("number_of_alerts", alertsStatsResponse.getNumberOfRegisteredAlerts());
|
||||
.field("number_of_alerts", alertsStatsResponse.getNumberOfRegisteredAlerts())
|
||||
.field("alert_action_queue_max_size", alertsStatsResponse.getAlertActionManagerLargestQueueSize());
|
||||
return new BytesRestResponse(OK, builder);
|
||||
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
{
|
||||
"template": "alerthistory",
|
||||
"template": ".alert_history",
|
||||
"order": 0,
|
||||
"settings": {
|
||||
"number_of_shards": 1,
|
||||
|
@ -24,7 +24,7 @@ import static org.hamcrest.core.IsEqual.equalTo;
|
||||
|
||||
/**
|
||||
*/
|
||||
@ElasticsearchIntegrationTest.ClusterScope(scope = ElasticsearchIntegrationTest.Scope.SUITE, numClientNodes = 0, transportClientRatio = 0)
|
||||
@ElasticsearchIntegrationTest.ClusterScope(scope = ElasticsearchIntegrationTest.Scope.TEST, numClientNodes = 0, transportClientRatio = 0)
|
||||
public class AlertStatsTests extends AbstractAlertingTests {
|
||||
|
||||
@Test
|
||||
@ -65,6 +65,5 @@ public class AlertStatsTests extends AbstractAlertingTests {
|
||||
assertTrue(response.isAlertManagerStarted());
|
||||
assertThat(response.getNumberOfRegisteredAlerts(), equalTo(1L));
|
||||
//assertThat(response.getAlertActionManagerLargestQueueSize(), greaterThan(0L));
|
||||
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user