Integration test for sessions replication updated with config session_replication_conns

This commit is contained in:
DanB
2018-01-04 18:16:30 +01:00
parent 58da425ac0
commit 158d209b67
3 changed files with 12 additions and 7 deletions

View File

@@ -24,7 +24,7 @@
"sessions": {
"enabled": true, // starts SessionManager service: <true|false>
"listen_bijson": "127.0.0.1:22014", // address where to listen for bidirectional JSON-RPC requests
"sessions_replication_conns": [
"session_replication_conns": [
{"address": "127.0.0.1:2012", "transport": "*json"},
],
},

View File

@@ -82,11 +82,11 @@ func TestSMGBiRPCStartEngine(t *testing.T) {
func TestSMGBiRPCApierRpcConn(t *testing.T) {
time.Sleep(time.Duration(1 * time.Second))
clntHandlers := map[string]interface{}{"SMGClientV1.DisconnectSession": handleDisconnectSession}
if _, err = utils.NewBiJSONrpcClient(smgBiRPCCfg.SMGConfig.ListenBijson,
if _, err = utils.NewBiJSONrpcClient(smgBiRPCCfg.SessionSCfg().ListenBijson,
clntHandlers); err != nil { // First attempt is to make sure multiple clients are supported
t.Fatal(err)
}
if smgBiRPC, err = utils.NewBiJSONrpcClient(smgBiRPCCfg.SMGConfig.ListenBijson,
if smgBiRPC, err = utils.NewBiJSONrpcClient(smgBiRPCCfg.SessionSCfg().ListenBijson,
clntHandlers); err != nil {
t.Fatal(err)
}

View File

@@ -160,7 +160,8 @@ func TestSMGRplcUpdate(t *testing.T) {
}
time.Sleep(time.Duration(*waitRater) * time.Millisecond) // Wait for the sessions to be populated
var aSessions []*ActiveSession
if err := smgRplcSlvRPC.Call("SMGenericV1.GetActiveSessions", map[string]string{utils.OriginID: "123451"}, &aSessions); err != nil {
if err := smgRplcSlvRPC.Call("SMGenericV1.GetActiveSessions",
map[string]string{utils.OriginID: "123451"}, &aSessions); err != nil {
t.Error(err)
} else if len(aSessions) != 1 {
t.Errorf("Unexpected number of sessions received: %+v", aSessions)
@@ -169,16 +170,20 @@ func TestSMGRplcUpdate(t *testing.T) {
}
var pSessions []*ActiveSession
// Make sure we don't have passive session on active host
if err := smgRplcSlvRPC.Call("SMGenericV1.GetPassiveSessions", nil, &pSessions); err == nil || err.Error() != utils.ErrNotFound.Error() {
if err := smgRplcSlvRPC.Call("SMGenericV1.GetPassiveSessions", nil,
&pSessions); err == nil || err.Error() != utils.ErrNotFound.Error() {
t.Error(err)
}
// Master should not longer have activeSession
if err := smgRplcMstrRPC.Call("SMGenericV1.GetActiveSessions", map[string]string{utils.OriginID: "123451"}, &aSessions); err == nil || err.Error() != utils.ErrNotFound.Error() {
if err := smgRplcMstrRPC.Call("SMGenericV1.GetActiveSessions",
map[string]string{utils.OriginID: "123451"}, &aSessions); err == nil ||
err.Error() != utils.ErrNotFound.Error() {
t.Error(err)
}
cgrID := smgEv.GetCGRID(utils.META_DEFAULT)
// Make sure session was replicated
if err := smgRplcMstrRPC.Call("SMGenericV1.GetPassiveSessions", nil, &pSessions); err != nil {
if err := smgRplcMstrRPC.Call("SMGenericV1.GetPassiveSessions",
nil, &pSessions); err != nil {
t.Error(err)
} else if len(pSessions) != 1 {
t.Errorf("PassiveSessions: %+v", pSessions)