|
@@ -18,7 +18,7 @@ import (
|
|
|
"testing"
|
|
"testing"
|
|
|
"time"
|
|
"time"
|
|
|
|
|
|
|
|
- "github.com/stretchr/testify/assert"
|
|
|
|
|
|
|
+ "github.com/coreos/etcd/pkg/testutil"
|
|
|
)
|
|
)
|
|
|
|
|
|
|
|
// Ensure that a successful Get is recorded in the stats.
|
|
// Ensure that a successful Get is recorded in the stats.
|
|
@@ -26,7 +26,7 @@ func TestStoreStatsGetSuccess(t *testing.T) {
|
|
|
s := newStore()
|
|
s := newStore()
|
|
|
s.Create("/foo", false, "bar", false, TTLOptionSet{ExpireTime: Permanent})
|
|
s.Create("/foo", false, "bar", false, TTLOptionSet{ExpireTime: Permanent})
|
|
|
s.Get("/foo", false, false)
|
|
s.Get("/foo", false, false)
|
|
|
- assert.Equal(t, uint64(1), s.Stats.GetSuccess, "")
|
|
|
|
|
|
|
+ testutil.AssertEqual(t, uint64(1), s.Stats.GetSuccess, "")
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// Ensure that a failed Get is recorded in the stats.
|
|
// Ensure that a failed Get is recorded in the stats.
|
|
@@ -34,14 +34,14 @@ func TestStoreStatsGetFail(t *testing.T) {
|
|
|
s := newStore()
|
|
s := newStore()
|
|
|
s.Create("/foo", false, "bar", false, TTLOptionSet{ExpireTime: Permanent})
|
|
s.Create("/foo", false, "bar", false, TTLOptionSet{ExpireTime: Permanent})
|
|
|
s.Get("/no_such_key", false, false)
|
|
s.Get("/no_such_key", false, false)
|
|
|
- assert.Equal(t, uint64(1), s.Stats.GetFail, "")
|
|
|
|
|
|
|
+ testutil.AssertEqual(t, uint64(1), s.Stats.GetFail, "")
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// Ensure that a successful Create is recorded in the stats.
|
|
// Ensure that a successful Create is recorded in the stats.
|
|
|
func TestStoreStatsCreateSuccess(t *testing.T) {
|
|
func TestStoreStatsCreateSuccess(t *testing.T) {
|
|
|
s := newStore()
|
|
s := newStore()
|
|
|
s.Create("/foo", false, "bar", false, TTLOptionSet{ExpireTime: Permanent})
|
|
s.Create("/foo", false, "bar", false, TTLOptionSet{ExpireTime: Permanent})
|
|
|
- assert.Equal(t, uint64(1), s.Stats.CreateSuccess, "")
|
|
|
|
|
|
|
+ testutil.AssertEqual(t, uint64(1), s.Stats.CreateSuccess, "")
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// Ensure that a failed Create is recorded in the stats.
|
|
// Ensure that a failed Create is recorded in the stats.
|
|
@@ -49,7 +49,7 @@ func TestStoreStatsCreateFail(t *testing.T) {
|
|
|
s := newStore()
|
|
s := newStore()
|
|
|
s.Create("/foo", true, "", false, TTLOptionSet{ExpireTime: Permanent})
|
|
s.Create("/foo", true, "", false, TTLOptionSet{ExpireTime: Permanent})
|
|
|
s.Create("/foo", false, "bar", false, TTLOptionSet{ExpireTime: Permanent})
|
|
s.Create("/foo", false, "bar", false, TTLOptionSet{ExpireTime: Permanent})
|
|
|
- assert.Equal(t, uint64(1), s.Stats.CreateFail, "")
|
|
|
|
|
|
|
+ testutil.AssertEqual(t, uint64(1), s.Stats.CreateFail, "")
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// Ensure that a successful Update is recorded in the stats.
|
|
// Ensure that a successful Update is recorded in the stats.
|
|
@@ -57,14 +57,14 @@ func TestStoreStatsUpdateSuccess(t *testing.T) {
|
|
|
s := newStore()
|
|
s := newStore()
|
|
|
s.Create("/foo", false, "bar", false, TTLOptionSet{ExpireTime: Permanent})
|
|
s.Create("/foo", false, "bar", false, TTLOptionSet{ExpireTime: Permanent})
|
|
|
s.Update("/foo", "baz", TTLOptionSet{ExpireTime: Permanent})
|
|
s.Update("/foo", "baz", TTLOptionSet{ExpireTime: Permanent})
|
|
|
- assert.Equal(t, uint64(1), s.Stats.UpdateSuccess, "")
|
|
|
|
|
|
|
+ testutil.AssertEqual(t, uint64(1), s.Stats.UpdateSuccess, "")
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// Ensure that a failed Update is recorded in the stats.
|
|
// Ensure that a failed Update is recorded in the stats.
|
|
|
func TestStoreStatsUpdateFail(t *testing.T) {
|
|
func TestStoreStatsUpdateFail(t *testing.T) {
|
|
|
s := newStore()
|
|
s := newStore()
|
|
|
s.Update("/foo", "bar", TTLOptionSet{ExpireTime: Permanent})
|
|
s.Update("/foo", "bar", TTLOptionSet{ExpireTime: Permanent})
|
|
|
- assert.Equal(t, uint64(1), s.Stats.UpdateFail, "")
|
|
|
|
|
|
|
+ testutil.AssertEqual(t, uint64(1), s.Stats.UpdateFail, "")
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// Ensure that a successful CAS is recorded in the stats.
|
|
// Ensure that a successful CAS is recorded in the stats.
|
|
@@ -72,7 +72,7 @@ func TestStoreStatsCompareAndSwapSuccess(t *testing.T) {
|
|
|
s := newStore()
|
|
s := newStore()
|
|
|
s.Create("/foo", false, "bar", false, TTLOptionSet{ExpireTime: Permanent})
|
|
s.Create("/foo", false, "bar", false, TTLOptionSet{ExpireTime: Permanent})
|
|
|
s.CompareAndSwap("/foo", "bar", 0, "baz", TTLOptionSet{ExpireTime: Permanent})
|
|
s.CompareAndSwap("/foo", "bar", 0, "baz", TTLOptionSet{ExpireTime: Permanent})
|
|
|
- assert.Equal(t, uint64(1), s.Stats.CompareAndSwapSuccess, "")
|
|
|
|
|
|
|
+ testutil.AssertEqual(t, uint64(1), s.Stats.CompareAndSwapSuccess, "")
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// Ensure that a failed CAS is recorded in the stats.
|
|
// Ensure that a failed CAS is recorded in the stats.
|
|
@@ -80,7 +80,7 @@ func TestStoreStatsCompareAndSwapFail(t *testing.T) {
|
|
|
s := newStore()
|
|
s := newStore()
|
|
|
s.Create("/foo", false, "bar", false, TTLOptionSet{ExpireTime: Permanent})
|
|
s.Create("/foo", false, "bar", false, TTLOptionSet{ExpireTime: Permanent})
|
|
|
s.CompareAndSwap("/foo", "wrong_value", 0, "baz", TTLOptionSet{ExpireTime: Permanent})
|
|
s.CompareAndSwap("/foo", "wrong_value", 0, "baz", TTLOptionSet{ExpireTime: Permanent})
|
|
|
- assert.Equal(t, uint64(1), s.Stats.CompareAndSwapFail, "")
|
|
|
|
|
|
|
+ testutil.AssertEqual(t, uint64(1), s.Stats.CompareAndSwapFail, "")
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// Ensure that a successful Delete is recorded in the stats.
|
|
// Ensure that a successful Delete is recorded in the stats.
|
|
@@ -88,14 +88,14 @@ func TestStoreStatsDeleteSuccess(t *testing.T) {
|
|
|
s := newStore()
|
|
s := newStore()
|
|
|
s.Create("/foo", false, "bar", false, TTLOptionSet{ExpireTime: Permanent})
|
|
s.Create("/foo", false, "bar", false, TTLOptionSet{ExpireTime: Permanent})
|
|
|
s.Delete("/foo", false, false)
|
|
s.Delete("/foo", false, false)
|
|
|
- assert.Equal(t, uint64(1), s.Stats.DeleteSuccess, "")
|
|
|
|
|
|
|
+ testutil.AssertEqual(t, uint64(1), s.Stats.DeleteSuccess, "")
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// Ensure that a failed Delete is recorded in the stats.
|
|
// Ensure that a failed Delete is recorded in the stats.
|
|
|
func TestStoreStatsDeleteFail(t *testing.T) {
|
|
func TestStoreStatsDeleteFail(t *testing.T) {
|
|
|
s := newStore()
|
|
s := newStore()
|
|
|
s.Delete("/foo", false, false)
|
|
s.Delete("/foo", false, false)
|
|
|
- assert.Equal(t, uint64(1), s.Stats.DeleteFail, "")
|
|
|
|
|
|
|
+ testutil.AssertEqual(t, uint64(1), s.Stats.DeleteFail, "")
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
//Ensure that the number of expirations is recorded in the stats.
|
|
//Ensure that the number of expirations is recorded in the stats.
|
|
@@ -105,8 +105,8 @@ func TestStoreStatsExpireCount(t *testing.T) {
|
|
|
s.clock = fc
|
|
s.clock = fc
|
|
|
|
|
|
|
|
s.Create("/foo", false, "bar", false, TTLOptionSet{ExpireTime: fc.Now().Add(500 * time.Millisecond)})
|
|
s.Create("/foo", false, "bar", false, TTLOptionSet{ExpireTime: fc.Now().Add(500 * time.Millisecond)})
|
|
|
- assert.Equal(t, uint64(0), s.Stats.ExpireCount, "")
|
|
|
|
|
|
|
+ testutil.AssertEqual(t, uint64(0), s.Stats.ExpireCount, "")
|
|
|
fc.Advance(600 * time.Millisecond)
|
|
fc.Advance(600 * time.Millisecond)
|
|
|
s.DeleteExpiredKeys(fc.Now())
|
|
s.DeleteExpiredKeys(fc.Now())
|
|
|
- assert.Equal(t, uint64(1), s.Stats.ExpireCount, "")
|
|
|
|
|
|
|
+ testutil.AssertEqual(t, uint64(1), s.Stats.ExpireCount, "")
|
|
|
}
|
|
}
|