[Transform] fix sporadic race condition in TransformUsageIT (#52946)

relax the test for trigger count

fixes #52931
This commit is contained in:
Hendrik Muhs 2020-03-03 10:01:04 +01:00
parent a154f9c657
commit d9258e210e
1 changed files with 17 additions and 6 deletions

View File

@ -22,6 +22,8 @@ import java.util.concurrent.TimeUnit;
import static org.elasticsearch.xpack.core.transform.TransformField.INDEX_DOC_TYPE;
import static org.elasticsearch.xpack.transform.TransformFeatureSet.PROVIDED_STATS;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.greaterThanOrEqualTo;
public class TransformUsageIT extends TransformRestTestCase {
@ -102,12 +104,21 @@ public class TransformUsageIT extends TransformRestTestCase {
|| 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);