Abacn commented on code in PR #34974:
URL: https://github.com/apache/beam/pull/34974#discussion_r2094242672
##########
runners/spark/src/test/java/org/apache/beam/runners/spark/translation/streaming/StreamingTransformTranslatorTest.java:
##########
@@ -276,29 +277,19 @@ public void testFlattenPCollResumeFromCheckpoint() {
"BoundedAssert",
DistributionResult.create(45, 10, 0L, 9L))));
- // Verify Flattened results show accumulated values from both runs
- // We use anyOf matcher because the unbounded source may emit either 2 or
3 elements during the
- // test window:
- // Case 1 (3 elements): sum=78 (45 from bounded + 33 from unbounded),
count=13 (10 bounded + 3
- // unbounded)
- // Case 2 (2 elements): sum=66 (45 from bounded + 21 from unbounded),
count=12 (10 bounded + 2
- // unbounded)
- // This variation occurs because the unbounded source's withRate(3,
Duration.standardSeconds(1))
- // timing may be affected by test environment conditions
- assertThat(
- res.metrics().queryMetrics(metricsFilter).getDistributions(),
- hasItem(
- anyOf(
- attemptedMetricsResult(
- PAssertFn.class.getName(),
- "distribution",
- "FlattenedAssert",
- DistributionResult.create(78, 13, 0, 12)),
- attemptedMetricsResult(
- PAssertFn.class.getName(),
- "distribution",
- "FlattenedAssert",
- DistributionResult.create(66, 12, 0, 11)))));
+ long secondMax = 0;
+ long secondSum = 0;
+ for (MetricResult<DistributionResult> dists :
+ res.metrics().queryMetrics(metricsFilter).getDistributions()) {
+ long currentMax = dists.getAttempted().getMax();
+ if (currentMax > secondMax) {
+ secondMax = currentMax;
+ secondSum = dists.getAttempted().getSum();
+ }
+ }
+
+ assertTrue(secondMax > firstMax);
Review Comment:
May still need to change to secondMax > 10 for a looser assertion. Combine
with the assertion below, if should be sufficient to check metrics are emitted
in arithmetic sequence
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]