- Notifications
You must be signed in to change notification settings - Fork1.1k
Commit645da33
authored
test: fix TestDescCacheTimestampUpdate flake (#20975)
## Problem`TestDescCacheTimestampUpdate` was flaky on Windows CI because`time.Now()` has ~15.6ms resolution, causing consecutive calls to returnidentical timestamps.## SolutionInject `quartz.Clock` into `MetricsAggregator` using an options pattern,making the test deterministic by using a mock clock with explicit timeadvancement.### Changes- Add `clock quartz.Clock` field to `MetricsAggregator` struct- Add `WithClock()` option for dependency injection- Replace all `time.Now()` calls with `ma.clock.Now()`- Update test to use mock clock with `mClock.Advance(time.Second)`---This PR was fully generated by [`mux`](https://github.com/coder/mux)using Claude Opus 4.5, and reviewed by me.Closescoder/internal#11461 parentab4366f commit645da33
File tree
2 files changed
+30
-9
lines changed- coderd/prometheusmetrics
2 files changed
+30
-9
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
| 19 | + | |
| 20 | + | |
19 | 21 | | |
20 | 22 | | |
21 | 23 | | |
| |||
47 | 49 | | |
48 | 50 | | |
49 | 51 | | |
| 52 | + | |
50 | 53 | | |
51 | 54 | | |
52 | 55 | | |
| |||
151 | 154 | | |
152 | 155 | | |
153 | 156 | | |
154 | | - | |
| 157 | + | |
155 | 158 | | |
156 | 159 | | |
157 | 160 | | |
| |||
192 | 195 | | |
193 | 196 | | |
194 | 197 | | |
195 | | - | |
| 198 | + | |
196 | 199 | | |
197 | 200 | | |
| 201 | + | |
198 | 202 | | |
199 | 203 | | |
200 | 204 | | |
| |||
206 | 210 | | |
207 | 211 | | |
208 | 212 | | |
209 | | - | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
210 | 226 | | |
211 | 227 | | |
212 | 228 | | |
| |||
349 | 365 | | |
350 | 366 | | |
351 | 367 | | |
352 | | - | |
| 368 | + | |
353 | 369 | | |
354 | 370 | | |
355 | 371 | | |
| |||
407 | 423 | | |
408 | 424 | | |
409 | 425 | | |
410 | | - | |
| 426 | + | |
411 | 427 | | |
412 | 428 | | |
413 | 429 | | |
| |||
419 | 435 | | |
420 | 436 | | |
421 | 437 | | |
422 | | - | |
| 438 | + | |
423 | 439 | | |
424 | 440 | | |
425 | 441 | | |
| |||
497 | 513 | | |
498 | 514 | | |
499 | 515 | | |
500 | | - | |
| 516 | + | |
501 | 517 | | |
502 | 518 | | |
503 | 519 | | |
| |||
508 | 524 | | |
509 | 525 | | |
510 | 526 | | |
511 | | - | |
| 527 | + | |
512 | 528 | | |
513 | 529 | | |
514 | 530 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
| 14 | + | |
14 | 15 | | |
15 | 16 | | |
16 | 17 | | |
| |||
62 | 63 | | |
63 | 64 | | |
64 | 65 | | |
| 66 | + | |
65 | 67 | | |
66 | | - | |
| 68 | + | |
67 | 69 | | |
68 | 70 | | |
69 | 71 | | |
| |||
78 | 80 | | |
79 | 81 | | |
80 | 82 | | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
81 | 86 | | |
82 | 87 | | |
83 | 88 | | |
| |||
0 commit comments
Comments
(0)