From 65e3fbc021d6a2013527a4240855bf8b362c3b64 Mon Sep 17 00:00:00 2001 From: Trial97 Date: Tue, 4 Dec 2018 17:55:13 +0200 Subject: [PATCH] Fix asActiveSession --- agents/radagent_it_test.go | 1 - sessions/sessions.go | 16 ++++++++++------ sessions/smg_it_test.go | 3 ++- sessions/smgbirpc_it_test.go | 2 +- 4 files changed, 13 insertions(+), 9 deletions(-) diff --git a/agents/radagent_it_test.go b/agents/radagent_it_test.go index c13dce52b..2e4a8a67f 100644 --- a/agents/radagent_it_test.go +++ b/agents/radagent_it_test.go @@ -189,7 +189,6 @@ func TestRAitAcctStart(t *testing.T) { if len(reply.AVPs) != 0 { // we don't expect AVPs to be populated t.Errorf("Received AVPs: %+v", reply.AVPs) } - time.Sleep(500 * time.Millisecond) // Wait so session is made // Make sure the sessin is managed by SMG var aSessions []*sessions.ActiveSession if err := raRPC.Call(utils.SessionSv1GetActiveSessions, diff --git a/sessions/sessions.go b/sessions/sessions.go index a2271ee83..c914c24f5 100644 --- a/sessions/sessions.go +++ b/sessions/sessions.go @@ -95,7 +95,8 @@ func NewSMGeneric(cgrCfg *config.CGRConfig, rals, resS, thdS, if chargerS != nil && reflect.ValueOf(chargerS).IsNil() { chargerS = nil } - return &SMGeneric{cgrCfg: cgrCfg, + return &SMGeneric{ + cgrCfg: cgrCfg, chargerS: chargerS, rals: rals, resS: resS, @@ -427,6 +428,9 @@ func (smg *SMGeneric) getSessionIDsMatchingIndexes(fltrs map[string]string, runID := fltrs[utils.RunID] checkNr := 0 for fltrName, fltrVal := range fltrs { + if fltrName == utils.RunID { + continue + } checkNr += 1 if _, hasFldName := ssIndx[fltrName]; !hasFldName { continue @@ -447,11 +451,11 @@ func (smg *SMGeneric) getSessionIDsMatchingIndexes(fltrs map[string]string, continue } // Higher run, takes out non matching indexes - for cgrID := range ssIndx[fltrName][fltrVal] { - if _, hasCGRID := matchingSessions[cgrID]; !hasCGRID { - delete(matchingSessions, cgrID) - } - } + // for cgrID := range ssIndx[fltrName][fltrVal] /*[runID]*/ { + // if _, hasCGRID := matchingSessions[cgrID]; !hasCGRID { + // delete(matchingSessions, cgrID) + // } + // } } return matchingSessions.Clone(), matchedIndexes } diff --git a/sessions/smg_it_test.go b/sessions/smg_it_test.go index 43a7ee3bf..a46941212 100644 --- a/sessions/smg_it_test.go +++ b/sessions/smg_it_test.go @@ -673,6 +673,7 @@ func TestSMGVoiceSessionTTL(t *testing.T) { } else if acnt.BalanceMap[utils.MONETARY].GetTotalValue() != eAcntVal { t.Errorf("Expected: %f, received: %f", eAcntVal, acnt.BalanceMap[utils.MONETARY].GetTotalValue()) } + time.Sleep(time.Duration(100 * time.Millisecond)) var cdrs []*engine.ExternalCDR req := utils.RPCCDRsFilter{RunIDs: []string{utils.META_DEFAULT}, DestinationPrefixes: []string{"1008"}} if err := smgRPC.Call("ApierV2.GetCdrs", req, &cdrs); err != nil { @@ -966,7 +967,7 @@ func TestSMGVoiceRelocateWithOriginIDPrefix(t *testing.T) { } else if reply != utils.OK { t.Errorf("Received reply: %s", reply) } - time.Sleep(time.Duration(20) * time.Millisecond) + time.Sleep(100 * time.Millisecond) var cdrs []*engine.ExternalCDR req := utils.RPCCDRsFilter{RunIDs: []string{utils.META_DEFAULT}, DestinationPrefixes: []string{smgEv.GetStringIgnoreErrors(utils.Destination)}} diff --git a/sessions/smgbirpc_it_test.go b/sessions/smgbirpc_it_test.go index 4717b9890..82b117afa 100644 --- a/sessions/smgbirpc_it_test.go +++ b/sessions/smgbirpc_it_test.go @@ -180,7 +180,7 @@ func TestSMGBiRPCSessionAutomaticDisconnects(t *testing.T) { } else if reply != utils.OK { t.Errorf("Received reply: %s", reply) } - time.Sleep(time.Duration(20) * time.Millisecond) + time.Sleep(100 * time.Millisecond) var cdrs []*engine.ExternalCDR req := utils.RPCCDRsFilter{RunIDs: []string{utils.META_DEFAULT}, DestinationPrefixes: []string{smgEv.GetStringIgnoreErrors(utils.Destination)}}