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:
Brian Murphy 2014-11-19 09:33:16 +00:00
parent 90a214f9ab
commit 84680f84b3
4 changed files with 7 additions and 4 deletions

View File

@ -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);

View File

@ -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);
}

View File

@ -1,5 +1,5 @@
{
"template": "alerthistory",
"template": ".alert_history",
"order": 0,
"settings": {
"number_of_shards": 1,

View File

@ -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));
}
}