|
@@ -1,4 +1,4 @@
|
|
|
-package client_test
|
|
|
+package odbclient_test
|
|
|
|
|
|
import (
|
|
|
"fmt"
|
|
@@ -11,35 +11,18 @@ import (
|
|
|
ccfg "git.wecise.com/wecise/common/matrix/cfg"
|
|
|
clog "git.wecise.com/wecise/common/matrix/logger"
|
|
|
"git.wecise.com/wecise/odb-go/odb"
|
|
|
+ "git.wecise.com/wecise/odbtest/odbclient"
|
|
|
)
|
|
|
|
|
|
var cfg = ccfg.MConfig()
|
|
|
var log = clog.New().WithConfig(cfg, "log")
|
|
|
|
|
|
-var config = &odb.Config{
|
|
|
- // Hosts: []string{"47.92.151.165:11001"},
|
|
|
- Hosts: []string{"127.0.0.1:11001"},
|
|
|
- Keyspace: "oktest",
|
|
|
- // Keyspace: "icbctest",
|
|
|
- User: fmt.Sprint("测试客户端", cfg.GetString("N")),
|
|
|
- Pass: "********",
|
|
|
- PoolSize: 2,
|
|
|
-}
|
|
|
-
|
|
|
-func getClient() (c odb.Client, err error) {
|
|
|
- client, err := odb.NewClient(config)
|
|
|
- if err != nil {
|
|
|
- return nil, err
|
|
|
- }
|
|
|
- return client, nil
|
|
|
-}
|
|
|
-
|
|
|
func TestConcurrent(t *testing.T) {
|
|
|
var n, reqcount, okcount, confirmcount, errcount int32
|
|
|
odb.QueryDoAsync = true
|
|
|
fmt.Println("QueryDoAsync =", odb.QueryDoAsync)
|
|
|
- fmt.Println("开始测试连接到", config.Hosts)
|
|
|
- client, err := odb.NewClient(config)
|
|
|
+ fmt.Println("开始测试连接到", odbclient.Config().Hosts)
|
|
|
+ client, err := odbclient.NewClient()
|
|
|
if err != nil {
|
|
|
println(fmt.Sprint("connection error:", err, atomic.AddInt32(&errcount, 1)))
|
|
|
return
|
|
@@ -213,7 +196,7 @@ func TestConcurrent(t *testing.T) {
|
|
|
}
|
|
|
}
|
|
|
}()
|
|
|
- for i := 0; i < config.PoolSize*1000; i++ {
|
|
|
+ for i := 0; i < odbclient.Config().PoolSize*1000; i++ {
|
|
|
go func(i int) {
|
|
|
for {
|
|
|
identifier := fmt.Sprint("222.129.134.178.1.3.6.1.4.1.2011.5.25.219.2.5.665.25.219.2.5.6.", i, ".", atomic.AddInt32(&n, 1))
|