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