Merge pull request #8194 from gyuho/lease

lease: fix racey access to 'leaseRevokeRate'
This commit is contained in:
Gyu-Ho Lee 2017-06-30 11:18:21 -07:00 committed by GitHub
commit 673c6f0650

View File

@ -42,6 +42,7 @@ func TestLessorGrant(t *testing.T) {
defer be.Close()
le := newLessor(be, minLeaseTTL)
defer le.Stop()
le.Promote(0)
l, err := le.Grant(1, 1)
@ -87,6 +88,7 @@ func TestLeaseConcurrentKeys(t *testing.T) {
defer be.Close()
le := newLessor(be, minLeaseTTL)
defer le.Stop()
le.SetRangeDeleter(func() TxnDelete { return newFakeDeleter(be) })
// grant a lease with long term (100 seconds) to
@ -134,6 +136,7 @@ func TestLessorRevoke(t *testing.T) {
defer be.Close()
le := newLessor(be, minLeaseTTL)
defer le.Stop()
var fd *fakeDeleter
le.SetRangeDeleter(func() TxnDelete {
fd = newFakeDeleter(be)
@ -185,6 +188,7 @@ func TestLessorRenew(t *testing.T) {
defer os.RemoveAll(dir)
le := newLessor(be, minLeaseTTL)
defer le.Stop()
le.Promote(0)
l, err := le.Grant(1, minLeaseTTL)
@ -240,6 +244,7 @@ func TestLessorRenewExtendPileup(t *testing.T) {
be = backend.New(bcfg)
defer be.Close()
le = newLessor(be, minLeaseTTL)
defer le.Stop()
// extend after recovery should extend expiration on lease pile-up
le.Promote(0)
@ -268,6 +273,7 @@ func TestLessorDetach(t *testing.T) {
defer be.Close()
le := newLessor(be, minLeaseTTL)
defer le.Stop()
le.SetRangeDeleter(func() TxnDelete { return newFakeDeleter(be) })
// grant a lease with long term (100 seconds) to
@ -307,6 +313,7 @@ func TestLessorRecover(t *testing.T) {
defer be.Close()
le := newLessor(be, minLeaseTTL)
defer le.Stop()
l1, err1 := le.Grant(1, 10)
l2, err2 := le.Grant(2, 20)
if err1 != nil || err2 != nil {
@ -315,6 +322,7 @@ func TestLessorRecover(t *testing.T) {
// Create a new lessor with the same backend
nle := newLessor(be, minLeaseTTL)
defer nle.Stop()
nl1 := nle.Lookup(l1.ID)
if nl1 == nil || nl1.ttl != l1.ttl {
t.Errorf("nl1 = %v, want nl1.ttl= %d", nl1.ttl, l1.ttl)