From 85afa27a5edcd286b91352529a09c26dca5cc525 Mon Sep 17 00:00:00 2001 From: Tripon Alexandru-Ionut Date: Thu, 20 Jun 2019 17:14:13 +0300 Subject: [PATCH] Renamed sessions.ActiveSession to sessions.ExternalSession --- agents/radagent_it_test.go | 4 ++-- apier/v1/dispatcher.go | 4 ++-- apier/v1/dispatcher_interface.go | 4 ++-- apier/v1/sessions.go | 4 ++-- apier/v1/sessionsbirpc.go | 4 ++-- apier/v1/sessionsv1_it_test.go | 20 ++++++++++---------- console/active_sessions.go | 2 +- console/passive_sessions.go | 2 +- dispatchers/sessions.go | 4 ++-- dispatchers/sessions_it_test.go | 6 +++--- engine/account_test.go | 12 +++++++++--- general_tests/rpcclient_it_test.go | 2 +- general_tests/session_it_test.go | 2 +- general_tests/sessionrefund_it_test.go | 4 ++-- general_tests/tutorial_calls_test.go | 6 +++--- sessions/session.go | 12 ++++++------ sessions/session_test.go | 22 +++++++++++----------- sessions/sessions.go | 10 +++++----- sessions/sessions_data_it_test.go | 12 ++++++------ sessions/sessions_it_test.go | 2 +- sessions/sessions_rpl_it_test.go | 14 +++++++------- sessions/sessions_voice_it_test.go | 6 +++--- 22 files changed, 82 insertions(+), 76 deletions(-) diff --git a/agents/radagent_it_test.go b/agents/radagent_it_test.go index ab3360803..49e07f826 100644 --- a/agents/radagent_it_test.go +++ b/agents/radagent_it_test.go @@ -276,7 +276,7 @@ func testRAitAcctStart(t *testing.T) { if isDispatcherActive { // no debit interval set on dispatched session expUsage = 3 * time.Hour } - var aSessions []*sessions.ActiveSession + var aSessions []*sessions.ExternalSession if err := raRPC.Call(utils.SessionSv1GetActiveSessions, map[string]string{utils.RunID: utils.META_DEFAULT, utils.OriginID: "e4921177ab0e3586c37f6a185864b71a@0:0:0:0:0:0:0:0-51585361-75c2f57b"}, @@ -344,7 +344,7 @@ func testRAitAcctStop(t *testing.T) { t.Errorf("Received AVPs: %+v", reply.AVPs) } // Make sure the sessin was disconnected from SMG - var aSessions []*sessions.ActiveSession + var aSessions []*sessions.ExternalSession if err := raRPC.Call(utils.SessionSv1GetActiveSessions, map[string]string{utils.RunID: utils.META_DEFAULT, utils.OriginID: "e4921177ab0e3586c37f6a185864b71a@0:0:0:0:0:0:0:0-51585361-75c2f57b"}, &aSessions); err == nil || err.Error() != utils.ErrNotFound.Error() { diff --git a/apier/v1/dispatcher.go b/apier/v1/dispatcher.go index a1fa6b946..f799e5706 100755 --- a/apier/v1/dispatcher.go +++ b/apier/v1/dispatcher.go @@ -458,7 +458,7 @@ func (dS *DispatcherSessionSv1) UpdateSession(args *sessions.V1UpdateSessionArgs } func (dS *DispatcherSessionSv1) GetActiveSessions(args *utils.SessionFilter, - reply *[]*sessions.ActiveSession) (err error) { + reply *[]*sessions.ExternalSession) (err error) { return dS.dS.SessionSv1GetActiveSessions(args, reply) } @@ -473,7 +473,7 @@ func (dS *DispatcherSessionSv1) ForceDisconnect(args *utils.SessionFilter, } func (dS *DispatcherSessionSv1) GetPassiveSessions(args *utils.SessionFilter, - reply *[]*sessions.ActiveSession) (err error) { + reply *[]*sessions.ExternalSession) (err error) { return dS.dS.SessionSv1GetPassiveSessions(args, reply) } diff --git a/apier/v1/dispatcher_interface.go b/apier/v1/dispatcher_interface.go index 57f9c50ca..fbab2f48a 100644 --- a/apier/v1/dispatcher_interface.go +++ b/apier/v1/dispatcher_interface.go @@ -81,10 +81,10 @@ type SessionSv1Interface interface { TerminateSession(args *sessions.V1TerminateSessionArgs, rply *string) error ProcessCDR(cgrEv *utils.CGREventWithArgDispatcher, rply *string) error ProcessEvent(args *sessions.V1ProcessEventArgs, rply *sessions.V1ProcessEventReply) error - GetActiveSessions(args *utils.SessionFilter, rply *[]*sessions.ActiveSession) error + GetActiveSessions(args *utils.SessionFilter, rply *[]*sessions.ExternalSession) error GetActiveSessionsCount(args *utils.SessionFilter, rply *int) error ForceDisconnect(args *utils.SessionFilter, rply *string) error - GetPassiveSessions(args *utils.SessionFilter, rply *[]*sessions.ActiveSession) error + GetPassiveSessions(args *utils.SessionFilter, rply *[]*sessions.ExternalSession) error GetPassiveSessionsCount(args *utils.SessionFilter, rply *int) error Ping(ign *utils.CGREventWithArgDispatcher, reply *string) error ReplicateSessions(args dispatchers.ArgsReplicateSessionsWithApiKey, rply *string) error diff --git a/apier/v1/sessions.go b/apier/v1/sessions.go index 87f962609..50ccd95a7 100644 --- a/apier/v1/sessions.go +++ b/apier/v1/sessions.go @@ -78,7 +78,7 @@ func (ssv1 *SessionSv1) ProcessEvent(args *sessions.V1ProcessEventArgs, } func (ssv1 *SessionSv1) GetActiveSessions(args *utils.SessionFilter, - rply *[]*sessions.ActiveSession) error { + rply *[]*sessions.ExternalSession) error { return ssv1.Ss.BiRPCv1GetActiveSessions(nil, args, rply) } @@ -93,7 +93,7 @@ func (ssv1 *SessionSv1) ForceDisconnect(args *utils.SessionFilter, } func (ssv1 *SessionSv1) GetPassiveSessions(args *utils.SessionFilter, - rply *[]*sessions.ActiveSession) error { + rply *[]*sessions.ExternalSession) error { return ssv1.Ss.BiRPCv1GetPassiveSessions(nil, args, rply) } diff --git a/apier/v1/sessionsbirpc.go b/apier/v1/sessionsbirpc.go index 52c1853be..c493c37dd 100644 --- a/apier/v1/sessionsbirpc.go +++ b/apier/v1/sessionsbirpc.go @@ -96,7 +96,7 @@ func (ssv1 *SessionSv1) BiRPCv1ProcessEvent(clnt *rpc2.Client, args *sessions.V1 } func (ssv1 *SessionSv1) BiRPCv1GetActiveSessions(clnt *rpc2.Client, args *utils.SessionFilter, - rply *[]*sessions.ActiveSession) error { + rply *[]*sessions.ExternalSession) error { return ssv1.Ss.BiRPCv1GetActiveSessions(clnt, args, rply) } @@ -106,7 +106,7 @@ func (ssv1 *SessionSv1) BiRPCv1GetActiveSessionsCount(clnt *rpc2.Client, args *u } func (ssv1 *SessionSv1) BiRPCv1GetPassiveSessions(clnt *rpc2.Client, args *utils.SessionFilter, - rply *[]*sessions.ActiveSession) error { + rply *[]*sessions.ExternalSession) error { return ssv1.Ss.BiRPCv1GetPassiveSessions(clnt, args, rply) } diff --git a/apier/v1/sessionsv1_it_test.go b/apier/v1/sessionsv1_it_test.go index 6a5af0a44..23ab6285e 100644 --- a/apier/v1/sessionsv1_it_test.go +++ b/apier/v1/sessionsv1_it_test.go @@ -313,7 +313,7 @@ func TestSSv1ItInitiateSession(t *testing.T) { t.Errorf("expecting: %+v, received: %+v", utils.ToJSON(eAttrs), utils.ToJSON(rply.Attributes)) } - aSessions := make([]*sessions.ActiveSession, 0) + aSessions := make([]*sessions.ExternalSession, 0) if err := sSv1BiRpc.Call(utils.SessionSv1GetActiveSessions, &utils.SessionFilter{}, &aSessions); err != nil { t.Error(err) } else if len(aSessions) != 2 { @@ -360,7 +360,7 @@ func TestSSv1ItInitiateSessionWithDigest(t *testing.T) { t.Errorf("expecting: %+v, received: %+v", utils.ToJSON(eAttrs), utils.ToJSON(rply.AttributesDigest)) } - aSessions := make([]*sessions.ActiveSession, 0) + aSessions := make([]*sessions.ExternalSession, 0) if err := sSv1BiRpc.Call(utils.SessionSv1GetActiveSessions, nil, &aSessions); err != nil { t.Error(err) } else if len(aSessions) != 2 { @@ -424,7 +424,7 @@ func TestSSv1ItUpdateSession(t *testing.T) { if *rply.MaxUsage != reqUsage { t.Errorf("Unexpected MaxUsage: %v", rply.MaxUsage) } - aSessions := make([]*sessions.ActiveSession, 0) + aSessions := make([]*sessions.ExternalSession, 0) if err := sSv1BiRpc.Call(utils.SessionSv1GetActiveSessions, nil, &aSessions); err != nil { t.Error(err) } else if len(aSessions) != 2 { @@ -461,7 +461,7 @@ func TestSSv1ItTerminateSession(t *testing.T) { if rply != utils.OK { t.Errorf("Unexpected reply: %s", rply) } - aSessions := make([]*sessions.ActiveSession, 0) + aSessions := make([]*sessions.ExternalSession, 0) if err := sSv1BiRpc.Call(utils.SessionSv1GetActiveSessions, nil, &aSessions); err == nil || err.Error() != utils.ErrNotFound.Error() { t.Error(err) @@ -557,7 +557,7 @@ func TestSSv1ItProcessEvent(t *testing.T) { t.Errorf("expecting: %+v, received: %+v", utils.ToJSON(eAttrs), utils.ToJSON(rply.Attributes)) } - aSessions := make([]*sessions.ActiveSession, 0) + aSessions := make([]*sessions.ExternalSession, 0) if err := sSv1BiRpc.Call(utils.SessionSv1GetActiveSessions, nil, &aSessions); err == nil || err.Error() != utils.ErrNotFound.Error() { t.Error(err) @@ -640,7 +640,7 @@ func TestSSv1ItCDRsGetCdrs(t *testing.T) { } func TestSSv1ItForceUpdateSession(t *testing.T) { - aSessions := make([]*sessions.ActiveSession, 0) + aSessions := make([]*sessions.ExternalSession, 0) if err := sSv1BiRpc.Call(utils.SessionSv1GetActiveSessions, nil, &aSessions); err == nil || err.Error() != utils.ErrNotFound.Error() { t.Errorf("Error: %v with len(asessions)=%v", err, len(aSessions)) } @@ -710,7 +710,7 @@ func TestSSv1ItForceUpdateSession(t *testing.T) { if *rply.MaxUsage != reqUsage { t.Errorf("Unexpected MaxUsage: %v", rply.MaxUsage) } - aSessions = make([]*sessions.ActiveSession, 0) + aSessions = make([]*sessions.ExternalSession, 0) if err := sSv1BiRpc.Call(utils.SessionSv1GetActiveSessions, nil, &aSessions); err != nil { t.Error(err) } else if len(aSessions) != 2 { @@ -730,7 +730,7 @@ func TestSSv1ItForceUpdateSession(t *testing.T) { } else if rplyt != utils.OK { t.Errorf("Unexpected reply: %s", rplyt) } - aSessions = make([]*sessions.ActiveSession, 0) + aSessions = make([]*sessions.ExternalSession, 0) if err := sSv1BiRpc.Call(utils.SessionSv1GetActiveSessions, nil, &aSessions); err == nil || err.Error() != utils.ErrNotFound.Error() { t.Error(err) @@ -823,7 +823,7 @@ func TestSSv1ItDynamicDebit(t *testing.T) { t.Errorf("Unexpected MaxUsage: %v", rply1.MaxUsage) } - aSessions := make([]*sessions.ActiveSession, 0) + aSessions := make([]*sessions.ExternalSession, 0) if err := sSv1BiRpc.Call(utils.SessionSv1GetActiveSessions, nil, &aSessions); err != nil { t.Error(err) } else if len(aSessions) != 2 { @@ -870,7 +870,7 @@ func TestSSv1ItDynamicDebit(t *testing.T) { time.Sleep(50 * time.Millisecond) - aSessions = make([]*sessions.ActiveSession, 0) + aSessions = make([]*sessions.ExternalSession, 0) if err := sSv1BiRpc.Call(utils.SessionSv1GetActiveSessions, nil, &aSessions); err == nil || err.Error() != utils.ErrNotFound.Error() { t.Error(err) diff --git a/console/active_sessions.go b/console/active_sessions.go index 1824cb838..f1de5bb53 100644 --- a/console/active_sessions.go +++ b/console/active_sessions.go @@ -63,7 +63,7 @@ func (self *CmdActiveSessions) PostprocessRpcParams() error { } func (self *CmdActiveSessions) RpcResult() interface{} { - var sessions *[]*sessions.ActiveSession + var sessions *[]*sessions.ExternalSession return &sessions } diff --git a/console/passive_sessions.go b/console/passive_sessions.go index 67dd6995e..2f92a940d 100644 --- a/console/passive_sessions.go +++ b/console/passive_sessions.go @@ -62,7 +62,7 @@ func (self *CmdPassiveSessions) PostprocessRpcParams() error { } func (self *CmdPassiveSessions) RpcResult() interface{} { - var sessions *[]*sessions.ActiveSession + var sessions *[]*sessions.ExternalSession return &sessions } diff --git a/dispatchers/sessions.go b/dispatchers/sessions.go index 63aa769b6..f5e648cd8 100755 --- a/dispatchers/sessions.go +++ b/dispatchers/sessions.go @@ -226,7 +226,7 @@ func (dS *DispatcherService) SessionSv1ProcessEvent(args *sessions.V1ProcessEven } func (dS *DispatcherService) SessionSv1GetActiveSessions(args *utils.SessionFilter, - reply *[]*sessions.ActiveSession) (err error) { + reply *[]*sessions.ExternalSession) (err error) { if dS.attrS != nil { if args.ArgDispatcher == nil { return utils.NewErrMandatoryIeMissing(utils.ArgDispatcherField) @@ -283,7 +283,7 @@ func (dS *DispatcherService) SessionSv1ForceDisconnect(args *utils.SessionFilter } func (dS *DispatcherService) SessionSv1GetPassiveSessions(args *utils.SessionFilter, - reply *[]*sessions.ActiveSession) (err error) { + reply *[]*sessions.ExternalSession) (err error) { if dS.attrS != nil { if args.ArgDispatcher == nil { return utils.NewErrMandatoryIeMissing(utils.ArgDispatcherField) diff --git a/dispatchers/sessions_it_test.go b/dispatchers/sessions_it_test.go index 89ce1d56a..91c78ec43 100755 --- a/dispatchers/sessions_it_test.go +++ b/dispatchers/sessions_it_test.go @@ -300,7 +300,7 @@ func testDspGetSessions(t *testing.T) { } else if reply != 2 { t.Errorf("Expected 2 active sessions recived %v", reply) } - var rply []*sessions.ActiveSession + var rply []*sessions.ExternalSession if err := dispEngine.RCP.Call(utils.SessionSv1GetActiveSessions, &filtr, &rply); err != nil { t.Fatal(err) @@ -717,7 +717,7 @@ func testDspSessionPassive(t *testing.T) { t.Errorf("Expected 1 active sessions recived %v", repl) } - var rply []*sessions.ActiveSession + var rply []*sessions.ExternalSession if err := dispEngine.RCP.Call(utils.SessionSv1GetActiveSessions, &filtr, &rply); err != nil { t.Fatal(err) @@ -819,7 +819,7 @@ func testDspSessionForceDisconect(t *testing.T) { t.Errorf("Expected 1 active sessions recived %v", repl) } - var rply []*sessions.ActiveSession + var rply []*sessions.ExternalSession if err := dispEngine.RCP.Call(utils.SessionSv1GetActiveSessions, &filtr, &rply); err != nil { t.Fatal(err) diff --git a/engine/account_test.go b/engine/account_test.go index c5ec77587..34f20f21a 100644 --- a/engine/account_test.go +++ b/engine/account_test.go @@ -1650,9 +1650,15 @@ func TestDebitGeneric(t *testing.T) { RateInterval: &RateInterval{ Rating: &RIRate{ Rates: RateGroups{ - &Rate{GroupIntervalStart: 0, Value: 100, - RateIncrement: 1, - RateUnit: time.Nanosecond}}}}, + &Rate{ + GroupIntervalStart: 0, + Value: 100, + RateIncrement: 1, + RateUnit: time.Nanosecond, + }, + }, + }, + }, }, }, TOR: utils.GENERIC, diff --git a/general_tests/rpcclient_it_test.go b/general_tests/rpcclient_it_test.go index 917ae080d..1804e35a4 100644 --- a/general_tests/rpcclient_it_test.go +++ b/general_tests/rpcclient_it_test.go @@ -171,7 +171,7 @@ func TestRPCITLclStatusFirstFailback(t *testing.T) { // Make sure it executes on the first node supporting the command func TestRPCITLclTDirectedRPC(t *testing.T) { - var sessions []*sessions.ActiveSession + var sessions []*sessions.ExternalSession if err := rpcPoolFirst.Call(utils.SessionSv1GetActiveSessions, map[string]string{}, &sessions); err == nil || err.Error() != utils.ErrNotFound.Error() { t.Error(err) } diff --git a/general_tests/session_it_test.go b/general_tests/session_it_test.go index 4c88091b0..e92d97630 100644 --- a/general_tests/session_it_test.go +++ b/general_tests/session_it_test.go @@ -176,7 +176,7 @@ func TestSesItTerminateSession(t *testing.T) { if rply != utils.OK { t.Errorf("Unexpected reply: %s", rply) } - aSessions := make([]*sessions.ActiveSession, 0) + aSessions := make([]*sessions.ExternalSession, 0) if err := sesRPC.Call(utils.SessionSv1GetActiveSessions, nil, &aSessions); err == nil || err.Error() != utils.ErrNotFound.Error() { t.Error(err) diff --git a/general_tests/sessionrefund_it_test.go b/general_tests/sessionrefund_it_test.go index bcba2b5ec..669c019c0 100644 --- a/general_tests/sessionrefund_it_test.go +++ b/general_tests/sessionrefund_it_test.go @@ -175,7 +175,7 @@ func TestSrItTerminateSession(t *testing.T) { if rply != utils.OK { t.Errorf("Unexpected reply: %s", rply) } - aSessions := make([]*sessions.ActiveSession, 0) + aSessions := make([]*sessions.ExternalSession, 0) if err := srrpc.Call(utils.SessionSv1GetActiveSessions, nil, &aSessions); err == nil || err.Error() != utils.ErrNotFound.Error() { t.Error(err) @@ -262,7 +262,7 @@ func TestSrItTerminateSession2(t *testing.T) { if rply != utils.OK { t.Errorf("Unexpected reply: %s", rply) } - aSessions := make([]*sessions.ActiveSession, 0) + aSessions := make([]*sessions.ExternalSession, 0) if err := srrpc.Call(utils.SessionSv1GetActiveSessions, nil, &aSessions); err == nil || err.Error() != utils.ErrNotFound.Error() { t.Error(err) diff --git a/general_tests/tutorial_calls_test.go b/general_tests/tutorial_calls_test.go index 03a19ee9a..480ed9c43 100755 --- a/general_tests/tutorial_calls_test.go +++ b/general_tests/tutorial_calls_test.go @@ -382,8 +382,8 @@ func testCallCall1001To1002(t *testing.T) { // GetActiveSessions func testCallGetActiveSessions(t *testing.T) { - var reply *[]*sessions.ActiveSession - expected := &[]*sessions.ActiveSession{ + var reply *[]*sessions.ExternalSession + expected := &[]*sessions.ExternalSession{ { RequestType: "*prepaid", Tenant: "cgrates.org", @@ -685,7 +685,7 @@ func testCallCheckThreshold1002After(t *testing.T) { } func testCallSyncSessions(t *testing.T) { - var reply *[]*sessions.ActiveSession + var reply *[]*sessions.ExternalSession // activeSessions shouldn't be active if err := tutorialCallsRpc.Call(utils.SessionSv1GetActiveSessions, &map[string]string{}, &reply); err == nil || err.Error() != utils.ErrNotFound.Error() { diff --git a/sessions/session.go b/sessions/session.go index 60dec892c..3b55c3b44 100644 --- a/sessions/session.go +++ b/sessions/session.go @@ -36,7 +36,7 @@ func (s *SessionID) CGRID() string { } // Will be used when displaying active sessions via RPC -type ActiveSession struct { +type ExternalSession struct { CGRID string RunID string ToR string // type of record, meta-field, should map to one of the TORs hardcoded inside the server <*voice|*data|*sms|*generic> @@ -114,11 +114,11 @@ func (s Session) Clone() (cln *Session) { return } -func (s *Session) AsActiveSessions(tmz, nodeID string) (aSs []*ActiveSession) { +func (s *Session) AsExternalSessions(tmz, nodeID string) (aSs []*ExternalSession) { s.RLock() - aSs = make([]*ActiveSession, len(s.SRuns)) + aSs = make([]*ExternalSession, len(s.SRuns)) for i, sr := range s.SRuns { - aSs[i] = &ActiveSession{ + aSs[i] = &ExternalSession{ CGRID: s.CGRID, RunID: sr.Event.GetStringIgnoreErrors(utils.RunID), ToR: sr.Event.GetStringIgnoreErrors(utils.ToR), @@ -150,9 +150,9 @@ func (s *Session) AsActiveSessions(tmz, nodeID string) (aSs []*ActiveSession) { s.RUnlock() return } -func (s *Session) asActiveSessions(sr *SRun, tmz, nodeID string) (aS *ActiveSession) { +func (s *Session) AsExternalSession(sr *SRun, tmz, nodeID string) (aS *ExternalSession) { s.RLock() - aS = &ActiveSession{ + aS = &ExternalSession{ CGRID: s.CGRID, RunID: sr.Event.GetStringIgnoreErrors(utils.RunID), ToR: sr.Event.GetStringIgnoreErrors(utils.ToR), diff --git a/sessions/session_test.go b/sessions/session_test.go index ec6b8179f..72960420d 100644 --- a/sessions/session_test.go +++ b/sessions/session_test.go @@ -269,7 +269,7 @@ func TestSessionAsCGREvents(t *testing.T) { } } -func TestSessionAsActiveSessions(t *testing.T) { +func TestSessionAsExternalSessions(t *testing.T) { startEv := map[string]interface{}{ utils.EVENT_NAME: "TEST_EVENT", utils.ToR: utils.VOICE, @@ -313,8 +313,8 @@ func TestSessionAsActiveSessions(t *testing.T) { }, }, } - exp := []*ActiveSession{ - &ActiveSession{ + exp := []*ExternalSession{ + &ExternalSession{ CGRID: "RandomCGRID", RunID: utils.MetaDefault, ToR: utils.VOICE, @@ -343,14 +343,14 @@ func TestSessionAsActiveSessions(t *testing.T) { }, } //check for some fields if populated correct - rply := s.AsActiveSessions("", "ALL") + rply := s.AsExternalSessions("", "ALL") if !reflect.DeepEqual(exp, rply) { t.Errorf("Expecting: %s, received: %s", utils.ToJSON(exp), utils.ToJSON(rply)) } } -func TestSessionAsActiveSessions2(t *testing.T) { +func TestSessionAsExternalSessions2(t *testing.T) { startEv := map[string]interface{}{ utils.EVENT_NAME: "TEST_EVENT", utils.ToR: utils.VOICE, @@ -401,8 +401,8 @@ func TestSessionAsActiveSessions2(t *testing.T) { }, }, } - exp := []*ActiveSession{ - &ActiveSession{ + exp := []*ExternalSession{ + &ExternalSession{ CGRID: "RandomCGRID", RunID: utils.MetaDefault, ToR: utils.VOICE, @@ -431,14 +431,14 @@ func TestSessionAsActiveSessions2(t *testing.T) { }, } //check for some fields if populated correct - rply := s.AsActiveSessions("", "ALL") + rply := s.AsExternalSessions("", "ALL") if !reflect.DeepEqual(exp, rply) { t.Errorf("Expecting: %s, received: %s", utils.ToJSON(exp), utils.ToJSON(rply)) } } -func TestSessionAsActiveSessions3(t *testing.T) { +func TestSessionAsExternalSessions3(t *testing.T) { startEv := map[string]interface{}{ utils.EVENT_NAME: "TEST_EVENT", utils.ToR: utils.VOICE, @@ -489,7 +489,7 @@ func TestSessionAsActiveSessions3(t *testing.T) { }, }, } - exp := &ActiveSession{ + exp := &ExternalSession{ CGRID: "RandomCGRID", RunID: utils.MetaDefault, ToR: utils.VOICE, @@ -517,7 +517,7 @@ func TestSessionAsActiveSessions3(t *testing.T) { MaxCostSoFar: 20, } //check for some fields if populated correct - rply := s.asActiveSessions(s.SRuns[0], "", "ALL") + rply := s.AsExternalSession(s.SRuns[0], "", "ALL") if !reflect.DeepEqual(exp, rply) { t.Errorf("Expecting: %s, received: %s", utils.ToJSON(exp), utils.ToJSON(rply)) } diff --git a/sessions/sessions.go b/sessions/sessions.go index f83e5a60d..1cfa1bb1a 100644 --- a/sessions/sessions.go +++ b/sessions/sessions.go @@ -947,12 +947,12 @@ func (sS *SessionS) getSessionIDsMatchingIndexes(fltrs map[string][]string, return cgrIDs, matchingSessions } -func (sS *SessionS) filterSessions(sf *utils.SessionFilter, psv bool) (aSs []*ActiveSession) { +func (sS *SessionS) filterSessions(sf *utils.SessionFilter, psv bool) (aSs []*ExternalSession) { if len(sf.Filters) == 0 { ss := sS.getSessions(utils.EmptyString, psv) for _, s := range ss { aSs = append(aSs, - s.AsActiveSessions(sS.cgrCfg.GeneralCfg().DefaultTimezone, + s.AsExternalSessions(sS.cgrCfg.GeneralCfg().DefaultTimezone, sS.cgrCfg.GeneralCfg().NodeID)...) // Expensive for large number of sessions if sf.Limit != nil && *sf.Limit > 0 && *sf.Limit < len(aSs) { return aSs[:*sf.Limit] @@ -989,7 +989,7 @@ func (sS *SessionS) filterSessions(sf *utils.SessionFilter, psv bool) (aSs []*Ac } if pass(unindx, sr.Event) { aSs = append(aSs, - s.asActiveSessions(sr, sS.cgrCfg.GeneralCfg().DefaultTimezone, + s.AsExternalSession(sr, sS.cgrCfg.GeneralCfg().DefaultTimezone, sS.cgrCfg.GeneralCfg().NodeID)) // Expensive for large number of sessions if sf.Limit != nil && *sf.Limit > 0 && *sf.Limit < len(aSs) { s.RUnlock() @@ -1554,7 +1554,7 @@ func (sS *SessionS) CallBiRPC(clnt rpcclient.RpcClientConnection, // BiRPCv1GetActiveSessions returns the list of active sessions based on filter func (sS *SessionS) BiRPCv1GetActiveSessions(clnt rpcclient.RpcClientConnection, - args *utils.SessionFilter, reply *[]*ActiveSession) (err error) { + args *utils.SessionFilter, reply *[]*ExternalSession) (err error) { if args == nil { //protection in case on nil args = &utils.SessionFilter{} } @@ -1584,7 +1584,7 @@ func (sS *SessionS) BiRPCv1GetActiveSessionsCount(clnt rpcclient.RpcClientConnec // BiRPCv1GetPassiveSessions returns the passive sessions handled by SessionS func (sS *SessionS) BiRPCv1GetPassiveSessions(clnt rpcclient.RpcClientConnection, - args *utils.SessionFilter, reply *[]*ActiveSession) error { + args *utils.SessionFilter, reply *[]*ExternalSession) error { if args == nil { //protection in case on nil args = &utils.SessionFilter{} } diff --git a/sessions/sessions_data_it_test.go b/sessions/sessions_data_it_test.go index d8ca6238f..a04d1b7e5 100644 --- a/sessions/sessions_data_it_test.go +++ b/sessions/sessions_data_it_test.go @@ -288,7 +288,7 @@ func TestSessionsDataLastUsedMultipleUpdates(t *testing.T) { } else if totalVal := acnt.BalanceMap[utils.DATA].GetTotalValue(); totalVal != eAcntVal { t.Errorf("Expected: %f, received: %f", eAcntVal, totalVal) } - aSessions := make([]*ActiveSession, 0) + aSessions := make([]*ExternalSession, 0) if err := sDataRPC.Call(utils.SessionSv1GetActiveSessions, nil, &aSessions); err != nil { t.Error(err) } else if len(aSessions) != 1 || @@ -620,7 +620,7 @@ func TestSessionsDataTTLExpMultiUpdates(t *testing.T) { } else if dataVal := acnt.BalanceMap[utils.DATA].GetTotalValue(); dataVal != eAcntVal { t.Errorf("Expected: %f, received: %f", eAcntVal, dataVal) } - aSessions := make([]*ActiveSession, 0) + aSessions := make([]*ExternalSession, 0) if err := sDataRPC.Call(utils.SessionSv1GetActiveSessions, nil, &aSessions); err != nil { t.Error(err) } else if len(aSessions) != 1 || @@ -742,7 +742,7 @@ func TestSessionsDataMultipleDataNoUsage(t *testing.T) { } else if dataVal := acnt.BalanceMap[utils.DATA].GetTotalValue(); dataVal != eAcntVal { t.Errorf("Expected: %f, received: %f", eAcntVal, dataVal) } - aSessions := make([]*ActiveSession, 0) + aSessions := make([]*ExternalSession, 0) if err := sDataRPC.Call(utils.SessionSv1GetActiveSessions, nil, &aSessions); err != nil { t.Error(err) } else if len(aSessions) != 1 || @@ -789,7 +789,7 @@ func TestSessionsDataMultipleDataNoUsage(t *testing.T) { } else if dataVal := acnt.BalanceMap[utils.DATA].GetTotalValue(); dataVal != eAcntVal { t.Errorf("Expected: %f, received: %f", eAcntVal, dataVal) } - aSessions = make([]*ActiveSession, 0) + aSessions = make([]*ExternalSession, 0) if err := sDataRPC.Call(utils.SessionSv1GetActiveSessions, nil, &aSessions); err != nil { t.Error(err) } else if len(aSessions) != 1 || @@ -835,7 +835,7 @@ func TestSessionsDataMultipleDataNoUsage(t *testing.T) { } else if dataVal := acnt.BalanceMap[utils.DATA].GetTotalValue(); dataVal != eAcntVal { t.Errorf("Expected: %f, received: %f", eAcntVal, dataVal) } - aSessions = make([]*ActiveSession, 0) + aSessions = make([]*ExternalSession, 0) if err := sDataRPC.Call(utils.SessionSv1GetActiveSessions, nil, &aSessions); err != nil { t.Error(err) } else if len(aSessions) != 1 || @@ -947,7 +947,7 @@ func TestSessionsDataTTLUsageProtection(t *testing.T) { } else if dataVal := acnt.BalanceMap[utils.DATA].GetTotalValue(); dataVal != eAcntVal { t.Errorf("Expected: %f, received: %f", eAcntVal, dataVal) } - aSessions := make([]*ActiveSession, 0) + aSessions := make([]*ExternalSession, 0) if err := sDataRPC.Call(utils.SessionSv1GetActiveSessions, nil, &aSessions); err != nil { t.Error(err) } else if len(aSessions) != 1 || diff --git a/sessions/sessions_it_test.go b/sessions/sessions_it_test.go index e79a51d14..544b34369 100644 --- a/sessions/sessions_it_test.go +++ b/sessions/sessions_it_test.go @@ -274,7 +274,7 @@ func TestSessionsItTerminatePassive(t *testing.T) { } else if rply != utils.OK { t.Errorf("Expecting : %+v, received: %+v", utils.OK, rply) } - var pSessions []*ActiveSession + var pSessions []*ExternalSession //check if the passive session was created if err := sItRPC.Call(utils.SessionSv1GetPassiveSessions, map[string]string{utils.OriginID: "123789"}, &pSessions); err != nil { diff --git a/sessions/sessions_rpl_it_test.go b/sessions/sessions_rpl_it_test.go index 8b35ee634..dce7e7937 100644 --- a/sessions/sessions_rpl_it_test.go +++ b/sessions/sessions_rpl_it_test.go @@ -89,7 +89,7 @@ func TestSessionSRplTPFromFolder(t *testing.T) { } func TestSessionSRplInitiate(t *testing.T) { - var aSessions []*ActiveSession + var aSessions []*ExternalSession //make sure we don't have active sessions on master and passive on slave if err := smgRplcMstrRPC.Call(utils.SessionSv1GetActiveSessions, nil, &aSessions); err == nil || err.Error() != utils.ErrNotFound.Error() { @@ -145,7 +145,7 @@ func TestSessionSRplInitiate(t *testing.T) { } //check if the session was created as passive session on slave - var pSessions []*ActiveSession + var pSessions []*ExternalSession if err := smgRplcSlvRPC.Call(utils.SessionSv1GetPassiveSessions, map[string]string{utils.OriginID: "123451"}, &pSessions); err != nil { t.Error(err) @@ -190,7 +190,7 @@ func TestSessionSRplUpdate(t *testing.T) { } time.Sleep(time.Duration(*waitRater) * time.Millisecond) // Wait for the sessions to be populated - var aSessions []*ActiveSession + var aSessions []*ExternalSession if err := smgRplcSlvRPC.Call(utils.SessionSv1GetActiveSessions, map[string]string{utils.OriginID: "123451"}, &aSessions); err != nil { t.Error(err) @@ -200,7 +200,7 @@ func TestSessionSRplUpdate(t *testing.T) { t.Errorf("Expecting : %+v, received: %+v", time.Duration(150)*time.Second, aSessions[0].Usage) } - var pSessions []*ActiveSession + var pSessions []*ExternalSession // Make sure we don't have passive session on active host if err := smgRplcSlvRPC.Call(utils.SessionSv1GetPassiveSessions, nil, &pSessions); err == nil || err.Error() != utils.ErrNotFound.Error() { @@ -255,7 +255,7 @@ func TestSessionSRplTerminate(t *testing.T) { t.Error(err) } time.Sleep(time.Duration(*waitRater) * time.Millisecond) // Wait for the sessions to be populated - var aSessions []*ActiveSession + var aSessions []*ExternalSession //check if the session was terminated on master if err := smgRplcMstrRPC.Call(utils.SessionSv1GetActiveSessions, map[string]string{utils.OriginID: "123451"}, &aSessions); err == nil || @@ -268,7 +268,7 @@ func TestSessionSRplTerminate(t *testing.T) { t.Errorf("Error: %v with len(aSessions)=%v , session : %+v", err, len(aSessions), utils.ToIJSON(aSessions)) } // check to don't have passive session on master and slave - var pSessions []*ActiveSession + var pSessions []*ExternalSession if err := smgRplcSlvRPC.Call(utils.SessionSv1GetPassiveSessions, nil, &pSessions); err == nil || err.Error() != utils.ErrNotFound.Error() { t.Errorf("Error: %v with len(pSessions)=%v , session : %+v", err, len(pSessions), utils.ToIJSON(pSessions)) @@ -342,7 +342,7 @@ func TestSessionSRplManualReplicate(t *testing.T) { } } //verify if the sessions was created on master and are active - var aSessions []*ActiveSession + var aSessions []*ExternalSession if err := smgRplcMstrRPC.Call(utils.SessionSv1GetActiveSessions, nil, &aSessions); err != nil { t.Error(err) } else if len(aSessions) != 2 { diff --git a/sessions/sessions_voice_it_test.go b/sessions/sessions_voice_it_test.go index bb55b280c..656c72bff 100644 --- a/sessions/sessions_voice_it_test.go +++ b/sessions/sessions_voice_it_test.go @@ -791,7 +791,7 @@ func TestSessionsVoiceSessionTTL(t *testing.T) { t.Errorf("Expected: %+v, received: %+v", usage, *initRpl.MaxUsage) } - var aSessions []*ActiveSession + var aSessions []*ExternalSession if err := sessionsRPC.Call(utils.SessionSv1GetActiveSessions, map[string]string{utils.RunID: utils.META_DEFAULT, utils.OriginID: "12360"}, &aSessions); err != nil { @@ -941,7 +941,7 @@ func TestSessionsVoiceSessionTTLWithRelocate(t *testing.T) { t.Errorf("Expected: %+v, received: %+v", usage, *initRpl.MaxUsage) } - var aSessions []*ActiveSession + var aSessions []*ExternalSession if err := sessionsRPC.Call(utils.SessionSv1GetActiveSessions, map[string]string{utils.RunID: utils.META_DEFAULT, utils.OriginID: "12361"}, @@ -1102,7 +1102,7 @@ func TestSessionsVoiceRelocateWithOriginIDPrefix(t *testing.T) { } time.Sleep(time.Duration(20) * time.Millisecond) - var aSessions []*ActiveSession + var aSessions []*ExternalSession if err := sessionsRPC.Call(utils.SessionSv1GetActiveSessions, map[string]string{utils.RunID: utils.META_DEFAULT, utils.OriginID: "12371"},