Skip to content

Commit dca5161

Browse files
committed
add tests
Signed-off-by: Mohamed Hamza <[email protected]>
1 parent 1a110b6 commit dca5161

File tree

2 files changed

+44
-1
lines changed

2 files changed

+44
-1
lines changed

go/stats/export.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,10 +100,11 @@ func (vg *varGroup) publish(name string, v expvar.Var) {
100100
vg.Lock()
101101
defer vg.Unlock()
102102

103-
// Check if the variable is already registered
103+
// Ignore if the variable is already registered
104104
if v := expvar.Get(name); v != nil {
105105
return
106106
}
107+
107108
expvar.Publish(name, v)
108109
if vg.newVarHook != nil {
109110
vg.newVarHook(name, v)

go/vt/vttablet/tabletserver/connpool/pool_test.go

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,48 @@ func TestConnPoolGet(t *testing.T) {
5050
dbConn.Recycle()
5151
}
5252

53+
func TestReopenPool(t *testing.T) {
54+
db := fakesqldb.New(t)
55+
defer db.Close()
56+
57+
cfg := tabletenv.ConnPoolConfig{
58+
Size: 1,
59+
Timeout: time.Second,
60+
IdleTimeout: 10 * time.Second,
61+
}
62+
env := tabletenv.NewEnv(vtenv.NewTestEnv(), nil, "PoolTest")
63+
params := dbconfigs.New(db.ConnParams())
64+
65+
connPool := NewPool(env, "TestPool", cfg)
66+
connPool.Open(params, params, params)
67+
connPool.Close()
68+
69+
connPool = NewPool(env, "TestPool", cfg)
70+
connPool.Open(params, params, params)
71+
connPool.Close()
72+
}
73+
74+
func TestReopenPoolUnnamedEnv(t *testing.T) {
75+
db := fakesqldb.New(t)
76+
defer db.Close()
77+
78+
cfg := tabletenv.ConnPoolConfig{
79+
Size: 1,
80+
Timeout: time.Second,
81+
IdleTimeout: 10 * time.Second,
82+
}
83+
env := tabletenv.NewEnv(vtenv.NewTestEnv(), nil, "")
84+
params := dbconfigs.New(db.ConnParams())
85+
86+
connPool := NewPool(env, "TestPool", cfg)
87+
connPool.Open(params, params, params)
88+
connPool.Close()
89+
90+
connPool = NewPool(env, "TestPool", cfg)
91+
connPool.Open(params, params, params)
92+
connPool.Close()
93+
}
94+
5395
func TestConnPoolTimeout(t *testing.T) {
5496
db := fakesqldb.New(t)
5597
defer db.Close()

0 commit comments

Comments
 (0)