From 158d209b67248efbef2b7088f02f3c9c75a593a5 Mon Sep 17 00:00:00 2001 From: DanB Date: Thu, 4 Jan 2018 18:16:30 +0100 Subject: [PATCH] Integration test for sessions replication updated with config session_replication_conns --- data/conf/samples/smgreplcslave/cgrates.json | 2 +- sessionmanager/smgbirpc_it_test.go | 4 ++-- sessionmanager/smgreplc_it_test.go | 13 +++++++++---- 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/data/conf/samples/smgreplcslave/cgrates.json b/data/conf/samples/smgreplcslave/cgrates.json index 8ae97df68..b5e1129cf 100644 --- a/data/conf/samples/smgreplcslave/cgrates.json +++ b/data/conf/samples/smgreplcslave/cgrates.json @@ -24,7 +24,7 @@ "sessions": { "enabled": true, // starts SessionManager service: "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"}, ], }, diff --git a/sessionmanager/smgbirpc_it_test.go b/sessionmanager/smgbirpc_it_test.go index 6875c5016..c91ec4875 100644 --- a/sessionmanager/smgbirpc_it_test.go +++ b/sessionmanager/smgbirpc_it_test.go @@ -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) } diff --git a/sessionmanager/smgreplc_it_test.go b/sessionmanager/smgreplc_it_test.go index f595a4965..0432b5ae6 100644 --- a/sessionmanager/smgreplc_it_test.go +++ b/sessionmanager/smgreplc_it_test.go @@ -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)