worker/txnpruner: sporadic test failure
Bug #1618560 reported by
Roger Peppe
This bug affects 1 person
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Canonical Juju |
New
|
Undecided
|
Unassigned |
Bug Description
It seems this timing-related test can occasionally fail:
http://
To post a comment you must log in.
The reason for the failure is that the test relies on the scheduler.
There are two goroutines in play here.
When the test works, this happens:
txnpruner: receives on timer channe action, which sends on the test channel action, which sends on the test channel
txnpruner: calls MaybePruneTrans
test: receives on test channel
test: set t0
txnpruner: reset timer to 10ms
txnpruner: receives on timer channel at t0+10ms+something small
txnpruner: calls MaybePruneTrans
test: receives on test channel
test: set t1
test: t1 >= t0 + 10ms, all ok
But this can happen instead:
txnpruner: receives on timer channe action, which sends on the test channel action, which sends on the test channel
txnpruner: calls MaybePruneTrans
test: receives on test channel
txnpruner: reset timer to 10ms
test: set t0
txnpruner: receives on timer channel at t0+10ms+something small
txnpruner: calls MaybePruneTrans
test: receives on test channel
test: set t1
test: t1 < t0 + 10ms, fail
That is, there's nothing stopping the timer from resetting before the
test has decided on what time the previous event was set.
To fix this, the time should be set deterministically before the
code can continue running (for example by using a reply channel
or changing the test mock to send the time on the channel)