TxnPrunerSuite.TestPrunes intermittent test failure
Bug #1571831 reported by
Casey Marshall
This bug affects 1 person
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Canonical Juju |
Fix Released
|
Medium
|
Unassigned |
Bug Description
time.Now() dependent test should use clock mocking, just noticed a CI fail like this:
-------
FAIL: txnpruner_
[LOG] 0:00.000 INFO juju.network setting prefer-ipv6 to false
txnpruner_
c.Assert(td >= interval, jc.IsTrue, gc.Commentf(
... obtained bool = false
... td=9.999546ms
OOPS: 1 passed, 1 FAILED
--- FAIL: TestPackage (0.09s)
FAIL
FAIL github.
Changed in juju-core: | |
status: | New → In Progress |
assignee: | nobody → Casey Marshall (cmars) |
Changed in juju-core: | |
status: | New → Triaged |
importance: | Undecided → Medium |
tags: | added: intermittent-failure tech-debt |
Changed in juju-core: | |
assignee: | Casey Marshall (cmars) → nobody |
Changed in juju-core: | |
milestone: | none → 2.0.0 |
affects: | juju-core → juju |
Changed in juju: | |
milestone: | 2.0.0 → none |
milestone: | none → 2.0.0 |
Changed in juju: | |
status: | Triaged → Invalid |
Changed in juju: | |
milestone: | 2.0.0 → none |
status: | Invalid → Fix Released |
To post a comment you must log in.
Actually, mocking the clock here is kind of hard because the test is checking whether a channel is receiving on an interval determined by time.Timer. Mocking time seems pointless to me as you might as well test time.Timer at that point.
My hypothesis is that scheduling can cause the measured time in the test to vary slightly depending on whether code executes in the time.Timer or the test receive -- but the interval should be close to the expected interval.
A quick fix that improves reliability is to test that the expected - actual interval is 0 +/- 1ms.
Another option is to redesign this test, or remove it entirely.