예제 #1
0
func TestGet(t *testing.T) {
	p := createPool(t)

	index, err := selector.SelectServer(servers, key)
	if err != nil {
		t.Error("get index error")
	}

	t.Logf("pool len = %d", len(p.Pools[index]))

	_, err = p.Get(key)
	if err != nil {
		t.Error("get gonn error")
	}

	t.Logf("pool len = %d", len(p.Pools[index]))
}
예제 #2
0
func TestRelease(t *testing.T) {
	p := createPool(t)

	index, err := selector.SelectServer(servers, key)
	if err != nil {
		t.Error("get index error")
	}

	conn, _ := p.Get(key)
	conn1, _ := p.Get(key)

	t.Logf("pool len = %d", len(p.Pools[index]))

	p.Release(key, conn)
	t.Logf("pool len = %d", len(p.Pools[index]))

	p.Release(key, conn1)
	t.Logf("pool len = %d", len(p.Pools[index]))
}