Commit e898720
authored
chore: Fix CounterTest created timestamp flake (#2049)
## What changed
Relaxed the `CounterTest.testTotalStrippedFromName` protobuf text
assertion so `created_timestamp` accepts both forms emitted by protobuf
text format:
- `created_timestamp { seconds: ... nanos: ... }`
- `created_timestamp { seconds: ... }`
## Why
This test was flaky when the created timestamp landed exactly on a
whole-second boundary. In that case, protobuf text format omits the
`nanos` field when it is zero, but the test required `nanos` to always
be present.
## Impact
This does not change product behavior. It removes a nondeterministic
test failure in CI by matching the actual protobuf output contract more
accurately.
## Root cause
The assertion encoded a stronger formatting assumption than protobuf
guarantees. `protobuf-java` may omit zero-valued `nanos` in text output.
## Validation
- `./mvnw test -pl prometheus-metrics-core
-Dtest=CounterTest#testTotalStrippedFromName -Dcoverage.skip=true
-Dcheckstyle.skip=true`
- `mise run build`1 parent 9e05c1d commit e898720
1 file changed
Lines changed: 1 addition & 1 deletion
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
123 | 123 | | |
124 | 124 | | |
125 | 125 | | |
126 | | - | |
| 126 | + | |
127 | 127 | | |
128 | 128 | | |
129 | 129 | | |
| |||
0 commit comments