godep: update clockwork dependency

This commit is contained in:
Jonathan Boulle 2014-10-16 20:23:07 -07:00
parent ec18e46641
commit e0801360d3
10 changed files with 30 additions and 30 deletions

2
Godeps/Godeps.json generated
View File

@ -16,7 +16,7 @@
},
{
"ImportPath": "github.com/jonboulle/clockwork",
"Rev": "46fde511e4fda2f685792de1700f20e1c45bfe41"
"Rev": "72f9bd7c4e0c2a40055ab3d0f09654f730cce982"
},
{
"ImportPath": "github.com/stretchr/testify/assert",

View File

@ -39,8 +39,8 @@ func TestMyFunc(t *testing.T) {
assert_state()
// Tick the FakeClock forward in time
c.Tick(3)
// Advance the FakeClock forward in time
c.Advance(3)
assert_state()
}

View File

@ -14,12 +14,12 @@ type Clock interface {
}
// FakeClock provides an interface for a clock which can be
// manually ticked through time
// manually advanced through time
type FakeClock interface {
Clock
// Tick advances the FakeClock to a new point in time, ensuring any existing
// Advance advances the FakeClock to a new point in time, ensuring any existing
// sleepers are notified appropriately before returning
Tick(d time.Duration)
Advance(d time.Duration)
// BlockUntil will block until the FakeClock has the given number of
// sleepers (callers of Sleep or After)
BlockUntil(n int)
@ -32,7 +32,7 @@ func NewRealClock() Clock {
}
// NewFakeClock returns a FakeClock implementation which can be
// manually ticked through time for testing.
// manually advanced through time for testing.
func NewFakeClock() FakeClock {
return &fakeClock{
l: sync.RWMutex{},
@ -122,10 +122,11 @@ func (fc *fakeClock) Now() time.Time {
return fc.time
}
// Tick advances fakeClock to a new point in time, ensuring channels from any
// Advance advances fakeClock to a new point in time, ensuring channels from any
// previous invocations of After are notified appropriately before returning
func (fc *fakeClock) Tick(d time.Duration) {
func (fc *fakeClock) Advance(d time.Duration) {
fc.l.Lock()
defer fc.l.Unlock()
end := fc.time.Add(d)
var newSleepers []*sleeper
for _, s := range fc.sleepers {
@ -138,7 +139,6 @@ func (fc *fakeClock) Tick(d time.Duration) {
fc.sleepers = newSleepers
fc.blockers = notifyBlockers(fc.blockers, len(fc.sleepers))
fc.time = end
fc.l.Unlock()
}
// BlockUntil will block until the fakeClock has the given number of sleepers

View File

@ -18,7 +18,7 @@ func TestFakeClockAfter(t *testing.T) {
two := fc.After(2)
six := fc.After(6)
ten := fc.After(10)
fc.Tick(1)
fc.Advance(1)
select {
case <-one:
default:
@ -33,7 +33,7 @@ func TestFakeClockAfter(t *testing.T) {
t.Errorf("ten returned prematurely!")
default:
}
fc.Tick(1)
fc.Advance(1)
select {
case <-two:
default:
@ -46,7 +46,7 @@ func TestFakeClockAfter(t *testing.T) {
t.Errorf("ten returned prematurely!")
default:
}
fc.Tick(1)
fc.Advance(1)
select {
case <-six:
t.Errorf("six returned prematurely!")
@ -54,7 +54,7 @@ func TestFakeClockAfter(t *testing.T) {
t.Errorf("ten returned prematurely!")
default:
}
fc.Tick(3)
fc.Advance(3)
select {
case <-six:
default:
@ -65,7 +65,7 @@ func TestFakeClockAfter(t *testing.T) {
t.Errorf("ten returned prematurely!")
default:
}
fc.Tick(100)
fc.Advance(100)
select {
case <-ten:
default:

View File

@ -38,8 +38,8 @@ func TestMyFunc(t *testing.T) {
// Assert the initial state
assert_state(t, i, 0)
// Now tick the clock forward in time
c.Tick(1 * time.Hour)
// Now advance the clock forward in time
c.Advance(1 * time.Hour)
// Wait until the function completes
wg.Wait()

View File

@ -13,8 +13,8 @@ import (
"strings"
"time"
"github.com/coreos/etcd/client"
"github.com/coreos/etcd/Godeps/_workspace/src/github.com/jonboulle/clockwork"
"github.com/coreos/etcd/client"
)
var (

View File

@ -12,8 +12,8 @@ import (
"testing"
"time"
"github.com/coreos/etcd/client"
"github.com/coreos/etcd/Godeps/_workspace/src/github.com/jonboulle/clockwork"
"github.com/coreos/etcd/client"
)
func TestProxyFuncFromEnvUnset(t *testing.T) {
@ -175,7 +175,7 @@ func TestCheckCluster(t *testing.T) {
go func() {
for i := uint(1); i <= nRetries; i++ {
fc.BlockUntil(1)
fc.Tick(time.Second * (0x1 << i))
fc.Advance(time.Second * (0x1 << i))
}
}()
ns, size, err := d.checkCluster()
@ -263,7 +263,7 @@ func TestWaitNodes(t *testing.T) {
go func() {
for i := uint(1); i <= nRetries; i++ {
fc.BlockUntil(1)
fc.Tick(time.Second * (0x1 << i))
fc.Advance(time.Second * (0x1 << i))
}
}()
g, err := d.waitNodes(tt.nodes, 3)
@ -363,7 +363,7 @@ func TestRetryFailure(t *testing.T) {
go func() {
for i := uint(1); i <= nRetries; i++ {
fc.BlockUntil(1)
fc.Tick(time.Second * (0x1 << i))
fc.Advance(time.Second * (0x1 << i))
}
}()
if _, _, err := d.checkCluster(); err != ErrTooManyRetries {

View File

@ -217,7 +217,7 @@ func TestBadParseRequest(t *testing.T) {
func TestGoodParseRequest(t *testing.T) {
fc := clockwork.NewFakeClock()
fc.Tick(1111)
fc.Advance(1111)
tests := []struct {
in *http.Request
w etcdserverpb.Request

View File

@ -93,7 +93,7 @@ func TestStoreStatsExpireCount(t *testing.T) {
s.Create("/foo", false, "bar", false, fc.Now().Add(500*time.Millisecond))
assert.Equal(t, uint64(0), s.Stats.ExpireCount, "")
fc.Tick(600 * time.Millisecond)
fc.Advance(600 * time.Millisecond)
s.DeleteExpiredKeys(fc.Now())
assert.Equal(t, uint64(1), s.Stats.ExpireCount, "")
}

View File

@ -323,7 +323,7 @@ func TestStoreUpdateValueTTL(t *testing.T) {
e, _ := s.Get("/foo", false, false)
assert.Equal(t, *e.Node.Value, "baz", "")
assert.Equal(t, e.EtcdIndex, eidx, "")
fc.Tick(600 * time.Millisecond)
fc.Advance(600 * time.Millisecond)
s.DeleteExpiredKeys(fc.Now())
e, err = s.Get("/foo", false, false)
assert.Nil(t, e, "")
@ -346,7 +346,7 @@ func TestStoreUpdateDirTTL(t *testing.T) {
assert.Equal(t, *e.Node.Value, "baz", "")
assert.Equal(t, e.EtcdIndex, eidx, "")
fc.Tick(600 * time.Millisecond)
fc.Advance(600 * time.Millisecond)
s.DeleteExpiredKeys(fc.Now())
e, err = s.Get("/foo/bar", false, false)
assert.Nil(t, e, "")
@ -715,7 +715,7 @@ func TestStoreWatchExpire(t *testing.T) {
c := w.EventChan()
e := nbselect(c)
assert.Nil(t, e, "")
fc.Tick(600 * time.Millisecond)
fc.Advance(600 * time.Millisecond)
s.DeleteExpiredKeys(fc.Now())
eidx = 3
e = nbselect(c)
@ -800,7 +800,7 @@ func TestStoreRecoverWithExpiration(t *testing.T) {
s2.Recovery(b)
fc.Tick(600 * time.Millisecond)
fc.Advance(600 * time.Millisecond)
s.DeleteExpiredKeys(fc.Now())
e, err := s.Get("/foo/x", false, false)
@ -904,11 +904,11 @@ func TestStoreWatchExpireWithHiddenKey(t *testing.T) {
c := w.EventChan()
e := nbselect(c)
assert.Nil(t, e, "")
fc.Tick(600 * time.Millisecond)
fc.Advance(600 * time.Millisecond)
s.DeleteExpiredKeys(fc.Now())
e = nbselect(c)
assert.Nil(t, e, "")
fc.Tick(600 * time.Millisecond)
fc.Advance(600 * time.Millisecond)
s.DeleteExpiredKeys(fc.Now())
e = nbselect(c)
assert.Equal(t, e.Action, "expire", "")