Skip to content

Commit

Permalink
[Transform] fix sporadic race condition in TransformUsageIT (#52946)
Browse files Browse the repository at this point in the history
relax the test for trigger count

fixes #52931
  • Loading branch information
Hendrik Muhs authored Mar 3, 2020
1 parent 6c86b60 commit 9b262dc
Showing 1 changed file with 17 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 9b262dc

Please sign in to comment.