diff --git a/x-pack/plugin/transform/qa/single-node-tests/src/test/java/org/elasticsearch/xpack/transform/integration/TransformUsageIT.java b/x-pack/plugin/transform/qa/single-node-tests/src/test/java/org/elasticsearch/xpack/transform/integration/TransformUsageIT.java index 805f9ed24362a..765feca863262 100644 --- a/x-pack/plugin/transform/qa/single-node-tests/src/test/java/org/elasticsearch/xpack/transform/integration/TransformUsageIT.java +++ b/x-pack/plugin/transform/qa/single-node-tests/src/test/java/org/elasticsearch/xpack/transform/integration/TransformUsageIT.java @@ -22,6 +22,8 @@ import static org.elasticsearch.xpack.core.transform.TransformField.INDEX_DOC_TYPE; import static org.elasticsearch.xpack.transform.TransformInfoTransportAction.PROVIDED_STATS; +import static org.hamcrest.Matchers.equalTo; +import static org.hamcrest.Matchers.greaterThanOrEqualTo; public class TransformUsageIT extends TransformRestTestCase { @@ -102,12 +104,21 @@ public void testUsage() throws Exception { || statName.equals(TransformIndexerStats.SEARCH_TIME_IN_MS.getPreferredName())) { continue; } - assertEquals( - "Incorrect stat " + statName, - expectedStats.get(statName).doubleValue(), - extractStatsAsDouble(XContentMapValues.extractValue("transform.stats." + statName, statsMap)), - 0.0001 - ); + + // the trigger count can be higher if the scheduler kicked before usage has been called, therefore check for gte + if (statName.equals(TransformIndexerStats.NUM_INVOCATIONS.getPreferredName())) { + assertThat( + "Incorrect stat " + statName, + extractStatsAsDouble(XContentMapValues.extractValue("transform.stats." + statName, statsMap)), + greaterThanOrEqualTo(expectedStats.get(statName).doubleValue()) + ); + } else { + assertThat( + "Incorrect stat " + statName, + extractStatsAsDouble(XContentMapValues.extractValue("transform.stats." + statName, statsMap)), + equalTo(expectedStats.get(statName).doubleValue()) + ); + } } // Refresh the index so that statistics are searchable refreshIndex(TransformInternalIndexConstants.LATEST_INDEX_VERSIONED_NAME);