Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

apiserver: Use WaitAdvance in listenerSuite.TestPause #7596

Merged
merged 1 commit into from Jul 5, 2017

Conversation

babbageclunk
Copy link
Contributor

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 Use testclock.WaitAdvance in TestPause apiserver: Use WaitAdvance in listenerSuite.TestPause Jul 4, 2017
@@ -157,14 +158,17 @@ func (s *listenerSuite) TestPause(c *gc.C) {
}()

start <- true
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call - removed.

}
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):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@@ -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)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

select {
case <-done:
c.Fatal("pause returned too soon")
case <-time.After(50 * time.Millisecond):
case <-minPauseTimeGone:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should be coretesting.ShortWait too

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.
Copy link
Contributor

@axw axw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks!

@babbageclunk
Copy link
Contributor Author

$$merge$$

@jujubot
Copy link
Collaborator

jujubot commented Jul 5, 2017

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

@jujubot
Copy link
Collaborator

jujubot commented Jul 5, 2017

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

@babbageclunk
Copy link
Contributor Author

Merge job died. :(

$$merge$$

@jujubot
Copy link
Collaborator

jujubot commented Jul 5, 2017

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

@jujubot
Copy link
Collaborator

jujubot commented Jul 5, 2017

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

@jujubot
Copy link
Collaborator

jujubot commented Jul 5, 2017

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

@babbageclunk
Copy link
Contributor Author

$$merge$$

@jujubot
Copy link
Collaborator

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants