SEPURI-SAI-KRISHNA opened a new issue, #13777:
URL: https://github.com/apache/seatunnel/issues/13777

   ### Search before asking
   
   - [X] I had searched in the 
[issues](https://github.com/apache/seatunnel/issues?q=is%3Aissue+label%3A%22bug%22)
 and found no similar issues.
   
   
   ### What happened
   
   `SeaTunnelClientTest.testGetMultiTableJobMetrics` fails from time to time at 
line 703 with `expected: <true> but was: <false>`, on code that does not touch 
metrics:
   
   - dev Build run 46114535713 (2026-11-28), job 140885969770, unit-test (17, 
ubuntu-latest)
   - fork runs on 2026-11-06 (job 128016535188, JDK 11) and 2026-11-07 (job 
128487335481, JDK 17)
   
   All three fail at `:703`, which is the `SinkWriteQPS` check in each of those 
commits. Reruns of the two fork runs passed.
   
   **Why.** The test compares each rate metric with the sum of its per-table 
metrics, within 2%:
   
   ```java
   Math.abs(totalCount.get(SINK_WRITE_QPS) - <sum of SinkWriteQPS#table values>)
           < totalCount.get(SINK_WRITE_QPS) * 0.02
   ```
   
   Both sides are sums of `value.get("value").asLong()`, so every rate is 
truncated to a whole number first. The rates are doubles from 
`ThreadSafeQPSMeter.getRate()` (`count * 1000 / (now - creation time)`), and 
each meter has its own creation time, so a table's rate and its part of the 
total differ a little. The job writes 50 rows, so the total is about 20 and 2% 
of it is 0.4. When the two values lie on either side of a whole number, 
truncation turns that small gap into 1, and the check fails.
   
   **Measured.** Five local runs of the unchanged test (JDK 17), values from 
its own `jobMetrics` log line:
   
   | run | SinkWriteQPS total entries | SinkWriteQPS per table | gap |
   |---|---|---|---|
   | 1 | 8.0645, 12.1704 | 8.0645, 12.1803 | 0.0099 |
   | 2 | 12.1951, 7.7489 | 12.1951, 7.7549 | 0.0060 |
   | 3 | 12.3711, 8.2136 | 12.3813, 8.2136 | 0.0102 |
   | 4 | 12.2499, 8.0808 | 12.2649, 8.0775 | 0.0118 |
   | 5 | 12.3762, 8.2034 | 12.3865, 8.2034 | 0.0102 |
   
   All five passed. Taking run 2's metrics and moving only one pair across a 
whole number with the same 0.006 gap (7.9995 total, 8.0055 table), the check as 
written gives `|19 - 20| < 0.38`, false, while the same check on the unrounded 
values gives `|20.1946 - 20.2006| < 0.4039`, true. The `SourceReceivedQPS` 
pairs were equal in three of the five runs, which fits all three CI failures 
being on the sink line.
   
   **Fix.** Add up the rates as doubles before the 2% comparison. I have a 
patch and can open a PR.
   
   ### SeaTunnel Version
   
   dev (954136a0c6)
   
   ### SeaTunnel Config
   
   ```conf
   # 
seatunnel-engine/seatunnel-engine-client/src/test/resources/batch_fake_multi_table_to_console.conf
   # FakeSource with fake.table1 (row.num = 20) and fake.public.table2 (row.num 
= 30), parallelism 1, to Console
   ```
   
   ### Running Command
   
   ```shell
   ./mvnw -pl seatunnel-engine/seatunnel-engine-client test 
-Dtest='SeaTunnelClientTest#testGetMultiTableJobMetrics'
   ```
   
   ### Error Exception
   
   ```log
   [ERROR]   SeaTunnelClientTest.testGetMultiTableJobMetrics:703 expected: 
<true> but was: <false>
   ```
   
   ### Zeta or Flink or Spark Version
   
   Zeta (test of seatunnel-engine-client)
   
   ### Java or Scala Version
   
   JDK 11 and JDK 17 (both seen in CI)
   
   ### Screenshots
   
   _No response_
   
   ### Are you willing to submit PR?
   
   - [X] Yes I am willing to submit a PR!
   
   ### Code of Conduct
   
   - [X] I agree to follow this project's [Code of 
Conduct](https://www.apache.org/foundation/policies/conduct)
   


-- 
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]

Reply via email to