mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-11 18:16:24 +05:00
Connection pool update, allowed errors per connection if at least one connection up, updated tests and glide.lock
This commit is contained in:
@@ -135,7 +135,7 @@ func startSmGeneric(internalSMGChan chan rpcclient.RpcClientConnection, internal
|
||||
ralsConns, err = engine.NewRPCPool(rpcclient.POOL_FIRST, cfg.ConnectAttempts, cfg.Reconnects, utils.GOB,
|
||||
cfg.SmGenericConfig.RALsConns, internalRaterChan, cfg.InternalTtl)
|
||||
if err != nil {
|
||||
utils.Logger.Crit(fmt.Sprintf("<SMGeneric> Could not connect to RAL: %s", err.Error()))
|
||||
utils.Logger.Crit(fmt.Sprintf("<SMGeneric> Could not connect to RALs: %s", err.Error()))
|
||||
exitChan <- true
|
||||
return
|
||||
}
|
||||
@@ -144,7 +144,7 @@ func startSmGeneric(internalSMGChan chan rpcclient.RpcClientConnection, internal
|
||||
cdrsConn, err = engine.NewRPCPool(rpcclient.POOL_FIRST, cfg.ConnectAttempts, cfg.Reconnects, utils.GOB,
|
||||
cfg.SmGenericConfig.CDRsConns, internalCDRSChan, cfg.InternalTtl)
|
||||
if err != nil {
|
||||
utils.Logger.Crit(fmt.Sprintf("<SMGeneric> Could not connect to RAL: %s", err.Error()))
|
||||
utils.Logger.Crit(fmt.Sprintf("<SMGeneric> Could not connect to RALs: %s", err.Error()))
|
||||
exitChan <- true
|
||||
return
|
||||
}
|
||||
|
||||
@@ -32,6 +32,7 @@ func NewRPCPool(dispatchStrategy string, connAttempts, reconnects int, codec str
|
||||
var rpcClient *rpcclient.RpcClient
|
||||
var err error
|
||||
rpcPool := rpcclient.NewRpcClientPool(dispatchStrategy)
|
||||
atLestOneConnected := false // If one connected we don't longer return errors
|
||||
for _, rpcConnCfg := range rpcConnCfgs {
|
||||
if rpcConnCfg.Address == utils.MetaInternal {
|
||||
var internalConn rpcclient.RpcClientConnection
|
||||
@@ -45,13 +46,16 @@ func NewRPCPool(dispatchStrategy string, connAttempts, reconnects int, codec str
|
||||
} else {
|
||||
rpcClient, err = rpcclient.NewRpcClient("tcp", rpcConnCfg.Address, connAttempts, reconnects, codec, nil)
|
||||
}
|
||||
if err != nil {
|
||||
break
|
||||
//if err != nil { // Commented so we pass the last error instead of first
|
||||
// break
|
||||
//}
|
||||
if err == nil {
|
||||
atLestOneConnected = true
|
||||
}
|
||||
rpcPool.AddClient(rpcClient)
|
||||
}
|
||||
if err != nil {
|
||||
return nil, err
|
||||
if atLestOneConnected {
|
||||
err = nil
|
||||
}
|
||||
return rpcPool, nil
|
||||
return rpcPool, err
|
||||
}
|
||||
|
||||
@@ -55,14 +55,11 @@ func TestRPCITInitCfg(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestRPCITStartEngine(t *testing.T) {
|
||||
func TestRPCITStartSecondEngine(t *testing.T) {
|
||||
if !*testIntegration {
|
||||
return
|
||||
}
|
||||
if ral1, err = engine.StopStartEngine(rpcITCfgPath1, *waitRater); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if ral2, err = engine.StartEngine(rpcITCfgPath2, *waitRater); err != nil {
|
||||
if ral2, err = engine.StopStartEngine(rpcITCfgPath2, *waitRater); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
@@ -74,8 +71,8 @@ func TestRPCITRpcConnPool(t *testing.T) {
|
||||
}
|
||||
rpcPoolFirst = rpcclient.NewRpcClientPool(rpcclient.POOL_FIRST)
|
||||
rpcRAL1, err = rpcclient.NewRpcClient("tcp", rpcITCfg1.RPCJSONListen, 3, 1, rpcclient.JSON_RPC, nil)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
if err == nil {
|
||||
t.Fatal("Should receive cannot connect error here")
|
||||
}
|
||||
rpcPoolFirst.AddClient(rpcRAL1)
|
||||
rpcRAL2, err = rpcclient.NewRpcClient("tcp", rpcITCfg2.RPCJSONListen, 3, 1, rpcclient.JSON_RPC, nil)
|
||||
@@ -85,6 +82,36 @@ func TestRPCITRpcConnPool(t *testing.T) {
|
||||
rpcPoolFirst.AddClient(rpcRAL2)
|
||||
}
|
||||
|
||||
// Connect rpc client to rater
|
||||
func TestRPCITStatusSecondEngine(t *testing.T) {
|
||||
if !*testIntegration {
|
||||
return
|
||||
}
|
||||
var status map[string]interface{}
|
||||
if err := rpcPoolFirst.Call("Responder.Status", "", &status); err != nil {
|
||||
t.Error(err)
|
||||
} else if status[utils.InstanceID].(string) == "" {
|
||||
t.Error("Empty InstanceID received")
|
||||
} else {
|
||||
ral2ID = status[utils.InstanceID].(string)
|
||||
}
|
||||
if err := rpcPoolFirst.Call("Responder.Status", "", &status); err != nil { // Make sure second time we land on the same instance
|
||||
t.Error(err)
|
||||
} else if status[utils.InstanceID].(string) != ral2ID {
|
||||
t.Errorf("Expecting: %s, received: %s", ral2ID, status[utils.InstanceID].(string))
|
||||
}
|
||||
}
|
||||
|
||||
// Start first engine
|
||||
func TestRPCITStartFirstEngine(t *testing.T) {
|
||||
if !*testIntegration {
|
||||
return
|
||||
}
|
||||
if ral1, err = engine.StartEngine(rpcITCfgPath1, *waitRater); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
// Connect rpc client to rater
|
||||
func TestRPCITStatusFirstInitial(t *testing.T) {
|
||||
if !*testIntegration {
|
||||
@@ -95,6 +122,8 @@ func TestRPCITStatusFirstInitial(t *testing.T) {
|
||||
t.Error(err)
|
||||
} else if status[utils.InstanceID].(string) == "" {
|
||||
t.Error("Empty InstanceID received")
|
||||
} else if status[utils.InstanceID].(string) == ral2ID {
|
||||
t.Fatalf("Should receive ralID different than second one, got: %s", status[utils.InstanceID].(string))
|
||||
} else {
|
||||
ral1ID = status[utils.InstanceID].(string)
|
||||
}
|
||||
@@ -119,15 +148,15 @@ func TestRPCITStatusFirstFailover(t *testing.T) {
|
||||
t.Error(err)
|
||||
} else if status[utils.InstanceID].(string) == "" {
|
||||
t.Error("Empty InstanceID received")
|
||||
} else if status[utils.InstanceID].(string) == ral1ID {
|
||||
t.Fatalf("Should receive ralID different than first one, got: %s", status[utils.InstanceID].(string))
|
||||
} else {
|
||||
ral1ID = status[utils.InstanceID].(string)
|
||||
ral2ID = status[utils.InstanceID].(string)
|
||||
}
|
||||
if err := rpcPoolFirst.Call("Responder.Status", "", &status); err != nil { // Make sure second time we land on the same instance
|
||||
t.Error(err)
|
||||
} else if status[utils.InstanceID].(string) != ral1ID {
|
||||
t.Errorf("Expecting: %s, received: %s", ral1ID, status[utils.InstanceID].(string))
|
||||
} else {
|
||||
ral2ID = status[utils.InstanceID].(string)
|
||||
} else if status[utils.InstanceID].(string) != ral2ID {
|
||||
t.Errorf("Expecting: %s, received: %s", ral2ID, status[utils.InstanceID].(string))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
30
glide.lock
generated
30
glide.lock
generated
@@ -1,8 +1,8 @@
|
||||
hash: 3140edeb6e77689465bafe5508a04afb78246b5f126488aa6db99f4984c4bbed
|
||||
updated: 2016-05-06T13:17:47.39427346+02:00
|
||||
updated: 2016-05-15T20:52:24.065638286+02:00
|
||||
imports:
|
||||
- name: camlistore.org
|
||||
version: 99a3dac0a862e43cbd8aa6c34a4969432815ce3d
|
||||
version: 86f480aa69fd4ae3e904b61f4ad33b1bc9c92a19
|
||||
subpackages:
|
||||
- pkg/googlestorage
|
||||
- pkg/blob
|
||||
@@ -27,22 +27,20 @@ imports:
|
||||
- internal/execxp
|
||||
- internal/parser
|
||||
- tree
|
||||
- xtypes
|
||||
- tree/xmltree
|
||||
- internal/lexer
|
||||
- internal/parser/findutil
|
||||
- internal/parser/intfns
|
||||
- internal/parser/pathexpr
|
||||
- literals/numlit
|
||||
- literals/strlit
|
||||
- xconst
|
||||
- xfn
|
||||
- xsort
|
||||
- literals/boollit
|
||||
- tree/xmltree/xmlbuilder
|
||||
- tree/xmltree/xmlele
|
||||
- tree/xmltree/xmlnode
|
||||
- name: github.com/denisenkom/go-mssqldb
|
||||
version: 8d4984e8baccbf5bfadd7f7e366fd61b7ccac38b
|
||||
version: 2a223b1644106bc7ca456c12cde55a80185813ef
|
||||
- name: github.com/DisposaBoy/JsonConfigReader
|
||||
version: 33a99fdf1d5ee1f79b5077e9c06f955ad356d5f4
|
||||
- name: github.com/fiorix/go-diameter
|
||||
@@ -73,18 +71,18 @@ imports:
|
||||
- name: github.com/gorhill/cronexpr
|
||||
version: f0984319b44273e83de132089ae42b1810f4933b
|
||||
- name: github.com/jinzhu/gorm
|
||||
version: bf413d67d3a25d4eeddb28541283fa6434d1cdb5
|
||||
version: 57c72125b3087e1ed02c16f23a1f381cde3aaf2c
|
||||
- name: github.com/jinzhu/inflection
|
||||
version: 3272df6c21d04180007eb3349844c89a3856bc25
|
||||
- name: github.com/kr/pty
|
||||
version: f7ee69f31298ecbe5d2b349c711e2547a617d398
|
||||
- name: github.com/lib/pq
|
||||
version: dd3290b2f71a8b30bee8e4e75a337a825263d26f
|
||||
version: ee1442bda7bd1b6a84e913bdb421cb1874ec629d
|
||||
subpackages:
|
||||
- hstore
|
||||
- oid
|
||||
- name: github.com/mattn/go-sqlite3
|
||||
version: 7204887cf3a42df1cfaa5505dc3a3427f6dded8b
|
||||
version: 38ee283dabf11c9cbdb968eebd79b1fa7acbabe6
|
||||
- name: github.com/mediocregopher/radix.v2
|
||||
version: 74e50e64194d2d2f4836212451c28b127f9d7fa1
|
||||
subpackages:
|
||||
@@ -102,12 +100,12 @@ imports:
|
||||
- syncutil/singleflight
|
||||
- readerutil
|
||||
- name: golang.org/x/crypto
|
||||
version: 019870fc9d457ee8abd13a2e93e3f2a3b55b7119
|
||||
version: b6789ab629056511030d652d851e7dc10c9e9c9e
|
||||
subpackages:
|
||||
- ssh/terminal
|
||||
- md4
|
||||
- name: golang.org/x/net
|
||||
version: 7e42c0e1329bb108f7376a7618a2871ab90f1c4d
|
||||
version: ef00b378c73f107bf44d5c9b69875255ce89b79a
|
||||
subpackages:
|
||||
- websocket
|
||||
- context
|
||||
@@ -125,11 +123,11 @@ imports:
|
||||
- jws
|
||||
- jwt
|
||||
- name: golang.org/x/sys
|
||||
version: b776ec39b3e54652e09028aaaaac9757f4f8211a
|
||||
version: 33267e036fd93fcd26ea95b7bdaf2d8306cb743c
|
||||
subpackages:
|
||||
- unix
|
||||
- name: golang.org/x/text
|
||||
version: bd1c9905f55d983c0cd0b15cf0c3e2fe860c8902
|
||||
version: f773ec03ce334298742df7f3108fc0d402646d22
|
||||
subpackages:
|
||||
- encoding
|
||||
- encoding/charmap
|
||||
@@ -147,7 +145,7 @@ imports:
|
||||
- runes
|
||||
- internal/tag
|
||||
- name: google.golang.org/api
|
||||
version: f9a4669e07732c84854dce1f5c451c22427228fb
|
||||
version: 4300f6b0c8a7f09e521dd0af2cee27e28846e037
|
||||
subpackages:
|
||||
- compute/v1
|
||||
- storage/v1
|
||||
@@ -179,7 +177,7 @@ imports:
|
||||
- internal/log
|
||||
- internal/remote_api
|
||||
- name: google.golang.org/cloud
|
||||
version: 200292f09e3aaa34878d801ab71fe823b1f7d36a
|
||||
version: ed0cb07e5fc4f6936e6e9d523568808f93228351
|
||||
subpackages:
|
||||
- compute/metadata
|
||||
- internal
|
||||
@@ -195,7 +193,7 @@ imports:
|
||||
- pubsub
|
||||
- storage
|
||||
- name: google.golang.org/grpc
|
||||
version: 8eb8dd0298f7a44728405d92c7ed710f65f7ad17
|
||||
version: 4c4ed377c72e199edd16a87011f13a56fd519119
|
||||
subpackages:
|
||||
- credentials
|
||||
- credentials/oauth
|
||||
|
||||
Reference in New Issue
Block a user