apiserver: Use WaitAdvance in listenerSuite.TestPause #7596

Merged
merged 1 commit into from Jul 5, 2017

Conversation

Projects
None yet
3 participants
Member

babbageclunk commented Jul 4, 2017

Description of change

The test passes fine locally but fails often in CI, and when run under
stress it fails after 1 or 2 runs. It looks like the clock advance is
happening before the throttlingListener manages to wait for it. Change
the Advance calls to WaitAdvance so we know the listener is waiting when
we advance. The time.After threshold needs to be created before the
WaitAdvance call so that the done channel doesn't appear to be ready
early in the case that we needed to wait for the accept goroutine to be
waiting. (Picking the max waits on the WaitAdvance calls was fiddly
because WaitAdvance divides the max wait time into 10 chunks.)

QA steps

The test passes normally and for more than 20 runs under stress.

@babbageclunk babbageclunk changed the title from Use testclock.WaitAdvance in TestPause to apiserver: Use WaitAdvance in listenerSuite.TestPause Jul 4, 2017

apiserver/listener_test.go
@@ -157,14 +158,17 @@ func (s *listenerSuite) TestPause(c *gc.C) {
}()
start <- true
@axw

axw Jul 5, 2017

Member

start seems pointless? it's created just above and sent on here, and the time between those should be negligible

@babbageclunk

babbageclunk Jul 5, 2017

Member

Good call - removed.

apiserver/listener_test.go
@@ -157,14 +158,17 @@ func (s *listenerSuite) TestPause(c *gc.C) {
}()
start <- true
- s.clock.Advance((l.minPause/time.Millisecond - 1) * time.Millisecond)
+ minPauseTimeGone := time.After(50 * time.Millisecond)
+ err := s.clock.WaitAdvance(time.Millisecond, (l.minPause/time.Millisecond-1)*time.Millisecond, 1)
@axw

axw Jul 5, 2017

Member

use coretesting.ShortWait for the 2nd arg here? i.e. the amount of time to when something is expected not to happen

apiserver/listener_test.go
select {
case <-done:
c.Fatal("pause returned too soon")
- case <-time.After(50 * time.Millisecond):
+ case <-minPauseTimeGone:
@axw

axw Jul 5, 2017

Member

I think this should be coretesting.ShortWait too

apiserver/listener_test.go
}
c.Assert(s.listener.count, gc.Equals, 0)
- s.clock.Advance(time.Millisecond)
+ err = s.clock.WaitAdvance(10*time.Millisecond, time.Millisecond, 1)
+ c.Assert(err, jc.ErrorIsNil)
select {
case <-done:
case <-time.After(10 * time.Second):
@axw

axw Jul 5, 2017

Member

use coretesting.LongWait here? i.e. the amount of time to when something is expected to happen

Use testclock.WaitAdvance in TestPause
The test passes fine locally but fails often in CI, and when run under
stress it fails after 1 or 2 runs. It looks like the clock advance is
happening before the throttlingListener manages to wait for it. Change
the Advance calls to WaitAdvance so we know the listener is waiting when
we advance.

Removed start channel - it complicated the test for no real benefit.

axw approved these changes Jul 5, 2017

LGTM, thanks!

Member

babbageclunk commented Jul 5, 2017

$$merge$$

Contributor

jujubot commented Jul 5, 2017

Status: merge request accepted. Url: http://juju-ci.vapour.ws:8080/job/github-merge-juju

Contributor

jujubot commented Jul 5, 2017

Build failed: Tests failed
build url: http://juju-ci.vapour.ws:8080/job/github-merge-juju/11268

Member

babbageclunk commented Jul 5, 2017

Merge job died. :(

$$merge$$

Contributor

jujubot commented Jul 5, 2017

Status: merge request accepted. Url: http://juju-ci.vapour.ws:8080/job/github-merge-juju

Contributor

jujubot commented Jul 5, 2017

Build failed: Tests failed
build url: http://juju-ci.vapour.ws:8080/job/github-merge-juju/11269

Contributor

jujubot commented Jul 5, 2017

Build failed: Tests failed
build url: http://juju-ci.vapour.ws:8080/job/github-merge-juju/11270

Member

babbageclunk commented Jul 5, 2017

$$merge$$

Contributor

jujubot commented Jul 5, 2017

Status: merge request accepted. Url: http://juju-ci.vapour.ws:8080/job/github-merge-juju

@jujubot jujubot merged commit 2d5a2e9 into juju:2.2 Jul 5, 2017

1 check failed

github-check-merge-juju Ran tests against PR. Use !!.*!! to request another build. IE, !!build!!, !!retry!!
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment