|
|
@@ -201,6 +201,8 @@ func TestPoolTimeout(t *testing.T) {
|
|
|
c.Close()
|
|
|
|
|
|
d.check("2", p, 2, 1)
|
|
|
+
|
|
|
+ p.Close()
|
|
|
}
|
|
|
|
|
|
func TestBorrowCheck(t *testing.T) {
|
|
|
@@ -217,6 +219,7 @@ func TestBorrowCheck(t *testing.T) {
|
|
|
c.Close()
|
|
|
}
|
|
|
d.check("1", p, 10, 1)
|
|
|
+ p.Close()
|
|
|
}
|
|
|
|
|
|
func TestMaxActive(t *testing.T) {
|
|
|
@@ -250,6 +253,7 @@ func TestMaxActive(t *testing.T) {
|
|
|
c3.Close()
|
|
|
|
|
|
d.check("4", p, 2, 2)
|
|
|
+ p.Close()
|
|
|
}
|
|
|
|
|
|
func TestMonitorCleanup(t *testing.T) {
|
|
|
@@ -264,6 +268,7 @@ func TestMonitorCleanup(t *testing.T) {
|
|
|
c.Close()
|
|
|
|
|
|
d.check("", p, 1, 0)
|
|
|
+ p.Close()
|
|
|
}
|
|
|
|
|
|
func TestPubSubCleanup(t *testing.T) {
|
|
|
@@ -293,6 +298,8 @@ func TestPubSubCleanup(t *testing.T) {
|
|
|
t.Errorf("got commands %v, want %v", d.commands, want)
|
|
|
}
|
|
|
d.commands = nil
|
|
|
+
|
|
|
+ p.Close()
|
|
|
}
|
|
|
|
|
|
func TestTransactionCleanup(t *testing.T) {
|
|
|
@@ -363,4 +370,60 @@ func TestTransactionCleanup(t *testing.T) {
|
|
|
t.Errorf("got commands %v, want %v", d.commands, want)
|
|
|
}
|
|
|
d.commands = nil
|
|
|
+
|
|
|
+ p.Close()
|
|
|
+}
|
|
|
+
|
|
|
+func BenchmarkPoolGet(b *testing.B) {
|
|
|
+ b.StopTimer()
|
|
|
+ p := Pool{Dial: DialTestDB, MaxIdle: 2}
|
|
|
+ c := p.Get()
|
|
|
+ if err := c.Err(); err != nil {
|
|
|
+ b.Fatal(err)
|
|
|
+ }
|
|
|
+ c.Close()
|
|
|
+ defer p.Close()
|
|
|
+ b.StartTimer()
|
|
|
+ for i := 0; i < b.N; i++ {
|
|
|
+ c = p.Get()
|
|
|
+ c.Close()
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+func BenchmarkPoolGetErr(b *testing.B) {
|
|
|
+ b.StopTimer()
|
|
|
+ p := Pool{Dial: DialTestDB, MaxIdle: 2}
|
|
|
+ c := p.Get()
|
|
|
+ if err := c.Err(); err != nil {
|
|
|
+ b.Fatal(err)
|
|
|
+ }
|
|
|
+ c.Close()
|
|
|
+ defer p.Close()
|
|
|
+ b.StartTimer()
|
|
|
+ for i := 0; i < b.N; i++ {
|
|
|
+ c = p.Get()
|
|
|
+ if err := c.Err(); err != nil {
|
|
|
+ b.Fatal(err)
|
|
|
+ }
|
|
|
+ c.Close()
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+func BenchmarkPoolGetPing(b *testing.B) {
|
|
|
+ b.StopTimer()
|
|
|
+ p := Pool{Dial: DialTestDB, MaxIdle: 2}
|
|
|
+ c := p.Get()
|
|
|
+ if err := c.Err(); err != nil {
|
|
|
+ b.Fatal(err)
|
|
|
+ }
|
|
|
+ c.Close()
|
|
|
+ defer p.Close()
|
|
|
+ b.StartTimer()
|
|
|
+ for i := 0; i < b.N; i++ {
|
|
|
+ c = p.Get()
|
|
|
+ if _, err := c.Do("PING"); err != nil {
|
|
|
+ b.Fatal(err)
|
|
|
+ }
|
|
|
+ c.Close()
|
|
|
+ }
|
|
|
}
|