Skip to content

Commit

Permalink
relax test for trigger count, it might have been incremented but not …
Browse files Browse the repository at this point in the history
…persisted

fixes elastic#52931
  • Loading branch information
Hendrik Muhs committed Dec 2, 2020
1 parent bcea87f commit a52a724
Showing 1 changed file with 4 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,6 @@ public void testUsage() throws Exception {

Request getRequest = new Request("GET", getTransformEndpoint() + "test_usage/_stats");
Map<String, Object> stats = entityAsMap(client().performRequest(getRequest));
// temporary debug logs for https://github.com/elastic/elasticsearch/issues/52931
logger.info("test_usage/_stats response: [{}]", stats);
Map<String, Double> expectedStats = new HashMap<>();
for (String statName : PROVIDED_STATS) {
@SuppressWarnings("unchecked")
Expand All @@ -87,8 +85,6 @@ public void testUsage() throws Exception {

getRequest = new Request("GET", getTransformEndpoint() + "test_usage_continuous/_stats");
stats = entityAsMap(client().performRequest(getRequest));
// temporary debug logs for https://github.com/elastic/elasticsearch/issues/52931
logger.info("test_usage_continuous/_stats response: [{}]", stats);
for (String statName : PROVIDED_STATS) {
@SuppressWarnings("unchecked")
List<Object> specificStatistic = (List<Object>) (XContentMapValues.extractValue("transforms.stats." + statName, stats));
Expand All @@ -107,12 +103,14 @@ public void testUsage() throws Exception {
assertEquals(2, XContentMapValues.extractValue("transform.transforms.stopped", statsMap));
assertEquals(1, XContentMapValues.extractValue("transform.transforms.started", statsMap));
for (String statName : PROVIDED_STATS) {
// the trigger count can be higher if the scheduler kicked before usage has been called, therefore check for gte
// the trigger count can be off: e.g. if the scheduler kicked before usage has been called,
// or if the the scheduler triggered later, but state hasn't been persisted (by design)
// however, we know that as we have 2 transforms, the trigger count must be greater or equal to 2
if (statName.equals(TransformIndexerStats.NUM_INVOCATIONS.getPreferredName())) {
assertThat(
"Incorrect stat " + statName + ", got: " + statsMap.get("transform"),
extractStatsAsDouble(XContentMapValues.extractValue("transform.stats." + statName, statsMap)),
greaterThanOrEqualTo(expectedStats.get(statName).doubleValue())
greaterThanOrEqualTo(2.0)
);
} else {
assertThat(
Expand Down

0 comments on commit a52a724

Please sign in to comment.