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

Use an artificial timebase for raft tests #255

Merged
merged 2 commits into from
Apr 7, 2016

Commits on Apr 6, 2016

  1. Use an artificial timebase for raft tests

    Instead of running the raft tick on a real time clock and using sleeps
    to wait for time to elapse, use github.com/pivotal-golang/clock to fake
    a timebase that we can advance at will.
    
    When we want to advance the raft state machine's view of time, call the
    Increment function to fake it.
    
    When we want to wait for something async to happen, use polling so we
    can catch it quickly without a fixed sleep.
    
    Before: ok  	github.com/docker/swarm-v2/manager/state	20.064s
    After:  ok       github.com/docker/swarm-v2/manager/state        1.257s
    
    This should also hopefully make the tests more deterministic.
    
    Fixes #182
    
    Signed-off-by: Aaron Lehmann <[email protected]>
    aaronlehmann committed Apr 6, 2016
    Configuration menu
    Copy the full SHA
    2b62941 View commit details
    Browse the repository at this point in the history
  2. Some fixes for raft and raft tests

    - Add locking around shutdown process to prevent asynchronous RPCs from
      crashing. Fixes #148.
    
    - Close open GRPC connections when shutting down a raft member. Avoids
      leaking those connections in the tests.
    
    - Make waitForCluster wait until all all members have applied the
      same portion of the log to their state machine.
    
    - TestRaftFollowerLeave needs to call Leave on a member other than the
      one that is leaving the cluster. Otherwise, this call can hang
      forever, because the machine can be removed from the cluster before it
      gets confirmation that it has left.
    
    - Fix deregisterNode not to check the error from Close. This can return
      an error when the connection was not yet open to begin with.
    
    Signed-off-by: Aaron Lehmann <[email protected]>
    aaronlehmann committed Apr 6, 2016
    Configuration menu
    Copy the full SHA
    547188b View commit details
    Browse the repository at this point in the history