Update tests for sessions after simplified locking

This commit is contained in:
TeoV
2019-10-08 08:52:08 -04:00
committed by DanB
parent 5dbaee2d33
commit 2184121c02
11 changed files with 72 additions and 78 deletions

View File

@@ -972,7 +972,7 @@ variable_rtp_audio_rtcp_octet_count: 0`
timezone := config.CgrConfig().GeneralCfg().DefaultTimezone
fsCdrCfg, _ = config.NewDefaultCGRConfig()
fsCdr, _ := engine.NewFSCdr(body, fsCdrCfg)
smGev := engine.NewSafEvent(NewFSEvent(hangUp).AsMapStringInterface(timezone))
smGev := engine.NewMapEvent(NewFSEvent(hangUp).AsMapStringInterface(timezone))
sessions.GetSetCGRID(smGev)
smCDR, err := smGev.AsCDR(fsCdrCfg, utils.EmptyString, timezone)
if err != nil {

View File

@@ -701,13 +701,14 @@ func TestMapEventGetDurationPtrIgnoreErrors(t *testing.T) {
}
func TestMapEventGetDurationPtrOrDefault(t *testing.T) {
dflt := &time.Duration(1)
if rcv, err := mapEv.GetDurationPtrOrDefault("test7", &dflt); !reflect.DeepEqual(rcv, dflt) {
t.Error("received: ", ptr)
mapEv := NewMapEvent(nil)
dflt := time.Duration(1)
if ptr, _ := mapEv.GetDurationPtrOrDefault("test7", &dflt); dflt.String()!=ptr.String() {
t.Errorf("Expected: %+v, received: %+v", dflt, ptr)
}
newVal := time.Duration(2)
mapEv["test7"] = newVal
if ptr, err := mapEv.GetDurationPtrOrDefault("test7", &dflt); !reflect.DeepEqual(rcv, newVal) {
t.Error("received: ", ptr)
if ptr, _ := mapEv.GetDurationPtrOrDefault("test7", &dflt);newVal.String()!=ptr.String() {
t.Errorf("Expected: %+v, received: %+v", newVal, ptr)
}
}

View File

@@ -54,7 +54,7 @@ type SessionSClient interface {
// getSessionTTL retrieves SessionTTL setting out of ev
// if SessionTTLMaxDelay is present in ev, the return is randomized
func getSessionTTL(ev *engine.SafEvent, cfgSessionTTL time.Duration,
func getSessionTTL(ev *engine.MapEvent, cfgSessionTTL time.Duration,
cfgSessionTTLMaxDelay *time.Duration) (ttl time.Duration, err error) {
if ttl, err = ev.GetDuration(utils.SessionTTL); err != nil {
if err != utils.ErrNotFound {

View File

@@ -27,7 +27,7 @@ import (
)
func TestLibSessionSGetSetCGRID(t *testing.T) {
sEv := engine.NewSafEvent(map[string]interface{}{
sEv := engine.NewMapEvent(map[string]interface{}{
utils.EVENT_NAME: "TEST_EVENT",
utils.ToR: "*voice",
utils.OriginID: "12345",
@@ -52,7 +52,7 @@ func TestLibSessionSGetSetCGRID(t *testing.T) {
t.Errorf("Unexpected cgrID: %+v", cgrID)
}
//populate CGRID in event
sEv.Set(utils.CGRID, "someRandomVal")
sEv[utils.CGRID] = "someRandomVal"
cgrID = GetSetCGRID(sEv)
if cgrID != "someRandomVal" {
t.Errorf("Expecting: someRandomVal, received: %+v", cgrID)
@@ -60,7 +60,7 @@ func TestLibSessionSGetSetCGRID(t *testing.T) {
}
func TestLibSessionSgetSessionTTL(t *testing.T) {
sEv := engine.NewSafEvent(map[string]interface{}{
sEv := engine.NewMapEvent(map[string]interface{}{
utils.EVENT_NAME: "TEST_EVENT",
utils.ToR: "*voice",
utils.OriginID: "12345",
@@ -82,15 +82,15 @@ func TestLibSessionSgetSessionTTL(t *testing.T) {
})
//ttl is taken from event
if ttl, err := getSessionTTL(sEv, time.Duration(0), nil); err != nil {
if ttl, err := getSessionTTL(&sEv, time.Duration(0), nil); err != nil {
t.Error(err)
} else if ttl != time.Duration(2*time.Second) {
t.Errorf("Expecting: %+v, received: %+v",
time.Duration(2*time.Second), ttl)
}
//remove ttl from event
sEv.Remove(utils.SessionTTL)
if ttl, err := getSessionTTL(sEv, time.Duration(4*time.Second), nil); err != nil {
delete(sEv, utils.SessionTTL)
if ttl, err := getSessionTTL(&sEv, time.Duration(4*time.Second), nil); err != nil {
t.Error(err)
} else if ttl != time.Duration(4*time.Second) {
t.Errorf("Expecting: %+v, received: %+v",
@@ -98,16 +98,16 @@ func TestLibSessionSgetSessionTTL(t *testing.T) {
}
//add sessionTTLMaxDelay in event
sEv.Set(utils.SessionTTLMaxDelay, "1s")
if ttl, err := getSessionTTL(sEv, time.Duration(4*time.Second), nil); err != nil {
sEv[utils.SessionTTLMaxDelay] = "1s"
if ttl, err := getSessionTTL(&sEv, time.Duration(4*time.Second), nil); err != nil {
t.Error(err)
} else if ttl <= time.Duration(4*time.Second) {
t.Errorf("Unexpected ttl : %+v", ttl)
}
//remove sessionTTLMaxDelay from event
sEv.Remove(utils.SessionTTLMaxDelay)
if ttl, err := getSessionTTL(sEv, time.Duration(7*time.Second),
delete(sEv, utils.SessionTTLMaxDelay)
if ttl, err := getSessionTTL(&sEv, time.Duration(7*time.Second),
utils.DurationPointer(time.Duration(2*time.Second))); err != nil {
t.Error(err)
} else if ttl <= time.Duration(7*time.Second) {

View File

@@ -78,19 +78,16 @@ type Session struct {
*utils.ArgDispatcher
}
// CGRid is a thread-safe method to return the CGRID of a session
func (s *Session) CGRid() (cgrID string) {
s.RLock()
// cgrID is method to return the CGRID of a session
// not thread safe
func (s *Session) cgrID() (cgrID string) {
cgrID = s.CGRID
s.RUnlock()
return
}
// DebitStopChan reads the debit stop
func (s *Session) DebitStopChan() (dbtStop chan struct{}) {
s.RLock()
dbtStop = s.debitStop
s.RUnlock()
return
}
@@ -182,17 +179,16 @@ func (s *Session) AsExternalSession(sr *SRun, tmz, nodeID string) (aS *ExternalS
return
}
// TotalUsage returns the first session run total usage
func (s *Session) TotalUsage() (tDur time.Duration) {
// totalUsage returns the first session run total usage
// not thread save
func (s *Session) totalUsage() (tDur time.Duration) {
if len(s.SRuns) == 0 {
return
}
s.RLock()
for _, sr := range s.SRuns {
tDur = sr.TotalUsage
break // only first
}
s.RUnlock()
return
}

View File

@@ -195,7 +195,7 @@ func TestSessionAsCGREventsRawEvent(t *testing.T) {
s := &Session{
CGRID: "RandomCGRID",
Tenant: "cgrates.org",
EventStart: engine.NewSafEvent(ev),
EventStart: engine.NewMapEvent(ev),
}
if cgrEvs, _ := s.asCGREvents(); len(cgrEvs) != 1 {
t.Errorf("Expecting: 1, received: %+v", len(cgrEvs))
@@ -242,7 +242,7 @@ func TestSessionAsCGREvents(t *testing.T) {
s := &Session{
CGRID: "RandomCGRID",
Tenant: "cgrates.org",
EventStart: engine.NewSafEvent(startEv),
EventStart: engine.NewMapEvent(startEv),
SRuns: []*SRun{
&SRun{
Event: engine.NewMapEvent(ev),
@@ -304,7 +304,7 @@ func TestSessionAsExternalSessions(t *testing.T) {
s := &Session{
CGRID: "RandomCGRID",
Tenant: "cgrates.org",
EventStart: engine.NewSafEvent(startEv),
EventStart: engine.NewMapEvent(startEv),
DebitInterval: time.Second,
SRuns: []*SRun{
&SRun{
@@ -385,7 +385,7 @@ func TestSessionAsExternalSessions2(t *testing.T) {
s := &Session{
CGRID: "RandomCGRID",
Tenant: "cgrates.org",
EventStart: engine.NewSafEvent(startEv),
EventStart: engine.NewMapEvent(startEv),
DebitInterval: time.Second,
SRuns: []*SRun{
&SRun{
@@ -473,7 +473,7 @@ func TestSessionAsExternalSessions3(t *testing.T) {
s := &Session{
CGRID: "RandomCGRID",
Tenant: "cgrates.org",
EventStart: engine.NewSafEvent(startEv),
EventStart: engine.NewMapEvent(startEv),
DebitInterval: time.Second,
SRuns: []*SRun{
&SRun{

View File

@@ -300,7 +300,10 @@ func (sS *SessionS) setSTerminator(s *Session) {
utils.SessionS, utils.SessionTTLMaxDelay, s.EventStart.String(), err.Error()))
return
}
maxDelay = *sS.cgrCfg.SessionSCfg().SessionTTLMaxDelay
err = nil
if sS.cgrCfg.SessionSCfg().SessionTTLMaxDelay != nil {
maxDelay = *sS.cgrCfg.SessionSCfg().SessionTTLMaxDelay
}
}
if maxDelay != 0 {
rand.Seed(time.Now().Unix())
@@ -374,7 +377,7 @@ func (sS *SessionS) forceSTerminate(s *Session, extraDebit time.Duration, lastUs
utils.Logger.Warning(
fmt.Sprintf(
"<%s> failed debitting cgrID %s, sRunIdx: %d, err: %s",
utils.SessionS, s.CGRid(), i, err.Error()))
utils.SessionS, s.cgrID(), i, err.Error()))
}
}
}
@@ -383,7 +386,7 @@ func (sS *SessionS) forceSTerminate(s *Session, extraDebit time.Duration, lastUs
utils.Logger.Warning(
fmt.Sprintf(
"<%s> failed force terminating session with ID <%s>, err: <%s>",
utils.SessionS, s.CGRid(), err.Error()))
utils.SessionS, s.cgrID(), err.Error()))
}
// post the CDRs
if sS.cdrS != nil {
@@ -529,7 +532,7 @@ func (sS *SessionS) debitLoopSession(s *Session, sRunIdx int,
if maxDebit, err = sS.debitSession(s, sRunIdx, dbtIvl, nil); err != nil {
utils.Logger.Warning(
fmt.Sprintf("<%s> could not complete debit operation on session: <%s>, error: <%s>",
utils.SessionS, s.CGRid(), err.Error()))
utils.SessionS, s.cgrID(), err.Error()))
dscReason := utils.ErrServerError.Error()
if err.Error() == utils.ErrUnauthorizedDestination.Error() {
dscReason = err.Error()
@@ -542,10 +545,10 @@ func (sS *SessionS) debitLoopSession(s *Session, sRunIdx int,
}
utils.Logger.Warning(
fmt.Sprintf("<%s> could not disconnect session: %s, error: %s",
utils.SessionS, s.CGRid(), err.Error()))
utils.SessionS, s.cgrID(), err.Error()))
}
if err = sS.forceSTerminate(s, 0, nil); err != nil {
utils.Logger.Warning(fmt.Sprintf("<%s> failed force-terminating session: <%s>, err: <%s>", utils.SessionS, s.CGRid(), err))
utils.Logger.Warning(fmt.Sprintf("<%s> failed force-terminating session: <%s>, err: <%s>", utils.SessionS, s.cgrID(), err))
}
s.Unlock()
return
@@ -567,10 +570,10 @@ func (sS *SessionS) debitLoopSession(s *Session, sRunIdx int,
}
utils.Logger.Warning(
fmt.Sprintf("<%s> could not disconnect session: <%s>, error: <%s>",
utils.SessionS, s.CGRid(), err.Error()))
utils.SessionS, s.cgrID(), err.Error()))
if err = sS.forceSTerminate(s, 0, nil); err != nil {
utils.Logger.Warning(fmt.Sprintf("<%s> failed force-terminating session: <%s>, err: <%s>",
utils.SessionS, s.CGRid(), err))
utils.SessionS, s.cgrID(), err))
}
}
return
@@ -695,7 +698,7 @@ func (sS *SessionS) disconnectSession(s *Session, rsn string) (err error) {
return fmt.Errorf("calling %s requires bidirectional JSON connection, connID: <%s>",
utils.SessionSv1DisconnectSession, s.ClientConnID)
}
s.EventStart[utils.Usage] = s.TotalUsage() // Set the usage to total one debitted
s.EventStart[utils.Usage] = s.totalUsage() // Set the usage to total one debitted
servMethod := utils.SessionSv1DisconnectSession
if clnt.proto == 0 { // compatibility with OpenSIPS 2.3
servMethod = "SMGClientV1.DisconnectSession"
@@ -2470,7 +2473,6 @@ func (sS *SessionS) BiRPCv1TerminateSession(clnt rpcclient.RpcClientConnection,
if args.CGREvent.ID == "" {
args.CGREvent.ID = utils.GenUUID()
}
// RPC caching
if sS.cgrCfg.CacheCfg()[utils.CacheRPCResponses].Limit != 0 {
cacheKey := utils.ConcatenatedKey(utils.SessionSv1TerminateSession, args.CGREvent.ID)
@@ -2490,7 +2492,6 @@ func (sS *SessionS) BiRPCv1TerminateSession(clnt rpcclient.RpcClientConnection,
nil, true, utils.NonTransactional)
}
// end of RPC caching
if !args.TerminateSession && !args.ReleaseResources {
return utils.NewErrMandatoryIeMissing("subsystems")
}
@@ -3251,7 +3252,7 @@ func (sS *SessionS) BiRPCv1ForceDisconnect(clnt rpcclient.RpcClientConnection,
utils.Logger.Warning(
fmt.Sprintf(
"<%s> failed force-terminating session with id: <%s>, err: <%s>",
utils.SessionS, ss[0].CGRid(), errTerm.Error()))
utils.SessionS, ss[0].cgrID(), errTerm.Error()))
err = utils.ErrPartiallyExecuted
}
}

View File

@@ -36,7 +36,7 @@ var (
sessionsBiRPCCfgPath string
sessionsBiRPCCfg *config.CGRConfig
sessionsBiRPC *rpc2.Client
disconnectEvChan = make(chan *utils.AttrDisconnectSession)
disconnectEvChan = make(chan *utils.AttrDisconnectSession, 1)
err error
)
@@ -163,7 +163,6 @@ func TestSessionsBiRPCSessionAutomaticDisconnects(t *testing.T) {
if *initRpl.MaxUsage != expMaxUsage {
t.Errorf("Expecting : %+v, received: %+v", expMaxUsage, *initRpl.MaxUsage)
}
// Make sure we are receiving a disconnect event
select {
case <-time.After(time.Duration(100 * time.Millisecond)):
@@ -174,7 +173,6 @@ func TestSessionsBiRPCSessionAutomaticDisconnects(t *testing.T) {
}
initArgs.CGREvent.Event[utils.Usage] = disconnectEv.EventStart[utils.Usage]
}
termArgs := &V1TerminateSessionArgs{
TerminateSession: true,
CGREvent: &utils.CGREvent{
@@ -202,20 +200,17 @@ func TestSessionsBiRPCSessionAutomaticDisconnects(t *testing.T) {
if err := sessionsBiRPC.Call(utils.SessionSv1TerminateSession, termArgs, &rpl); err != nil || rpl != utils.OK {
t.Error(err)
}
time.Sleep(time.Duration(100 * time.Millisecond)) // Give time for debits to occur
if err := sessionsRPC.Call("ApierV2.GetAccount", attrGetAcnt, &acnt); err != nil {
t.Error(err)
} else if acnt.BalanceMap[utils.VOICE].GetTotalValue() != 0 {
t.Errorf("Balance should be empty, have: %f", acnt.BalanceMap[utils.VOICE].GetTotalValue())
}
if err := sessionsBiRPC.Call(utils.SessionSv1ProcessCDR, termArgs.CGREvent, &reply); err != nil {
t.Error(err)
} else if reply != utils.OK {
t.Errorf("Received reply: %s", reply)
}
time.Sleep(100 * time.Millisecond)
var cdrs []*engine.ExternalCDR
req := utils.RPCCDRsFilter{RunIDs: []string{utils.META_DEFAULT},

View File

@@ -239,7 +239,7 @@ func TestSessionsItUpdateUnexist(t *testing.T) {
func TestSessionsItTerminatePassive(t *testing.T) {
//create the event for session
sEv := engine.NewSafEvent(map[string]interface{}{
sEv := engine.NewMapEvent(map[string]interface{}{
utils.EVENT_NAME: "UpdateEvent",
utils.ToR: utils.VOICE,
utils.OriginID: "123789",
@@ -260,7 +260,7 @@ func TestSessionsItTerminatePassive(t *testing.T) {
EventStart: sEv,
SRuns: []*SRun{
&SRun{
Event: engine.NewMapEvent(sEv.AsMapInterface()),
Event: sEv,
TotalUsage: time.Minute,
CD: &engine.CallDescriptor{},
},

View File

@@ -231,7 +231,7 @@ func TestSessionSRplUpdate(t *testing.T) {
t.Errorf("Error: %v with len(aSessions)=%v , session : %+v", err, len(aSessions), utils.ToJSON(aSessions))
}
cgrID := GetSetCGRID(engine.NewSafEvent(argsUpdate.Event))
cgrID := GetSetCGRID(engine.NewMapEvent(argsUpdate.Event))
// Make sure session was replicated
if err := smgRplcMstrRPC.Call(utils.SessionSv1GetPassiveSessions,
nil, &pSessions); err != nil {

View File

@@ -60,7 +60,7 @@ func TestSessionSIndexAndUnindexSessions(t *testing.T) {
"Extra4": true,
}
sS := NewSessionS(sSCfg, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, "UTC")
sEv := engine.NewSafEvent(map[string]interface{}{
sEv := engine.NewMapEvent(map[string]interface{}{
utils.EVENT_NAME: "TEST_EVENT",
utils.ToR: "*voice",
utils.OriginID: "12345",
@@ -89,7 +89,7 @@ func TestSessionSIndexAndUnindexSessions(t *testing.T) {
EventStart: sEv,
SRuns: []*SRun{
&SRun{
Event: sEv.AsMapInterface(),
Event: sEv,
CD: &engine.CallDescriptor{
RunID: utils.DEFAULT_RUNID,
},
@@ -143,7 +143,7 @@ func TestSessionSIndexAndUnindexSessions(t *testing.T) {
t.Errorf("Expecting: %+v, received: %+v", eRIdxes, sS.aSessionsRIdx)
}
// Index second session
sSEv2 := engine.NewSafEvent(map[string]interface{}{
sSEv2 := engine.NewMapEvent(map[string]interface{}{
utils.EVENT_NAME: "TEST_EVENT2",
utils.OriginID: "12346",
utils.Direction: "*out",
@@ -159,7 +159,7 @@ func TestSessionSIndexAndUnindexSessions(t *testing.T) {
EventStart: sSEv2,
SRuns: []*SRun{
&SRun{
Event: sSEv2.AsMapInterface(),
Event: sSEv2,
CD: &engine.CallDescriptor{
RunID: utils.DEFAULT_RUNID,
},
@@ -167,7 +167,7 @@ func TestSessionSIndexAndUnindexSessions(t *testing.T) {
},
}
sS.indexSession(session2, false)
sSEv3 := engine.NewSafEvent(map[string]interface{}{
sSEv3 := engine.NewMapEvent(map[string]interface{}{
utils.EVENT_NAME: "TEST_EVENT3",
utils.Tenant: "cgrates.org",
utils.OriginID: "12347",
@@ -180,7 +180,7 @@ func TestSessionSIndexAndUnindexSessions(t *testing.T) {
EventStart: sSEv3,
SRuns: []*SRun{
&SRun{
Event: sSEv3.AsMapInterface(),
Event: sSEv3,
CD: &engine.CallDescriptor{
RunID: utils.DEFAULT_RUNID,
},
@@ -382,7 +382,7 @@ func TestSessionSIndexAndUnindexSessions(t *testing.T) {
func TestSessionSRegisterAndUnregisterASessions(t *testing.T) {
sSCfg, _ := config.NewDefaultCGRConfig()
sS := NewSessionS(sSCfg, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, "UTC")
sSEv := engine.NewSafEvent(map[string]interface{}{
sSEv := engine.NewMapEvent(map[string]interface{}{
utils.EVENT_NAME: "TEST_EVENT",
utils.ToR: "*voice",
utils.OriginID: "111",
@@ -406,7 +406,7 @@ func TestSessionSRegisterAndUnregisterASessions(t *testing.T) {
EventStart: sSEv,
SRuns: []*SRun{
&SRun{
Event: sSEv.AsMapInterface(),
Event: sSEv,
CD: &engine.CallDescriptor{
RunID: utils.DEFAULT_RUNID,
},
@@ -443,7 +443,7 @@ func TestSessionSRegisterAndUnregisterASessions(t *testing.T) {
t.Errorf("Expecting: %+v, received: %+v", eRIdxes, sS.aSessionsRIdx)
}
sSEv2 := engine.NewSafEvent(map[string]interface{}{
sSEv2 := engine.NewMapEvent(map[string]interface{}{
utils.EVENT_NAME: "TEST_EVENT",
utils.ToR: "*voice",
utils.OriginID: "222",
@@ -465,7 +465,7 @@ func TestSessionSRegisterAndUnregisterASessions(t *testing.T) {
EventStart: sSEv2,
SRuns: []*SRun{
&SRun{
Event: sSEv2.AsMapInterface(),
Event: sSEv2,
CD: &engine.CallDescriptor{
RunID: utils.DEFAULT_RUNID,
},
@@ -510,7 +510,7 @@ func TestSessionSRegisterAndUnregisterASessions(t *testing.T) {
t.Errorf("Expecting: %+v, received: %+v", eRIdxes, sS.aSessionsRIdx)
}
sSEv3 := engine.NewSafEvent(map[string]interface{}{
sSEv3 := engine.NewMapEvent(map[string]interface{}{
utils.EVENT_NAME: "TEST_EVENT",
utils.ToR: "*voice",
utils.OriginID: "111",
@@ -533,7 +533,7 @@ func TestSessionSRegisterAndUnregisterASessions(t *testing.T) {
EventStart: sSEv3,
SRuns: []*SRun{
&SRun{
Event: sSEv3.AsMapInterface(),
Event: sSEv3,
CD: &engine.CallDescriptor{
RunID: utils.DEFAULT_RUNID,
},
@@ -598,7 +598,7 @@ func TestSessionSRegisterAndUnregisterASessions(t *testing.T) {
func TestSessionSRegisterAndUnregisterPSessions(t *testing.T) {
sSCfg, _ := config.NewDefaultCGRConfig()
sS := NewSessionS(sSCfg, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, "UTC")
sSEv := engine.NewSafEvent(map[string]interface{}{
sSEv := engine.NewMapEvent(map[string]interface{}{
utils.EVENT_NAME: "TEST_EVENT",
utils.ToR: "*voice",
utils.OriginID: "111",
@@ -622,7 +622,7 @@ func TestSessionSRegisterAndUnregisterPSessions(t *testing.T) {
EventStart: sSEv,
SRuns: []*SRun{
&SRun{
Event: sSEv.AsMapInterface(),
Event: sSEv,
CD: &engine.CallDescriptor{
RunID: utils.DEFAULT_RUNID,
},
@@ -662,7 +662,7 @@ func TestSessionSRegisterAndUnregisterPSessions(t *testing.T) {
t.Errorf("Expecting: %+v, received: %+v", eRIdxes, sS.pSessionsRIdx)
}
sSEv2 := engine.NewSafEvent(map[string]interface{}{
sSEv2 := engine.NewMapEvent(map[string]interface{}{
utils.EVENT_NAME: "TEST_EVENT",
utils.ToR: "*voice",
utils.OriginID: "222",
@@ -684,7 +684,7 @@ func TestSessionSRegisterAndUnregisterPSessions(t *testing.T) {
EventStart: sSEv2,
SRuns: []*SRun{
&SRun{
Event: sSEv2.AsMapInterface(),
Event: sSEv2,
CD: &engine.CallDescriptor{
RunID: utils.DEFAULT_RUNID,
},
@@ -729,7 +729,7 @@ func TestSessionSRegisterAndUnregisterPSessions(t *testing.T) {
t.Errorf("Expecting: %+v, received: %+v", eRIdxes, sS.pSessionsRIdx)
}
sSEv3 := engine.NewSafEvent(map[string]interface{}{
sSEv3 := engine.NewMapEvent(map[string]interface{}{
utils.EVENT_NAME: "TEST_EVENT",
utils.ToR: "*voice",
utils.OriginID: "111",
@@ -752,7 +752,7 @@ func TestSessionSRegisterAndUnregisterPSessions(t *testing.T) {
EventStart: sSEv3,
SRuns: []*SRun{
&SRun{
Event: sSEv3.AsMapInterface(),
Event: sSEv3,
CD: &engine.CallDescriptor{},
},
},
@@ -1123,7 +1123,7 @@ func TestSessionSV1ProcessMessageReplyAsNavigableMap(t *testing.T) {
func TestSessionStransitSState(t *testing.T) {
sSCfg, _ := config.NewDefaultCGRConfig()
sS := NewSessionS(sSCfg, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, "UTC")
sSEv := engine.NewSafEvent(map[string]interface{}{
sSEv := engine.NewMapEvent(map[string]interface{}{
utils.EVENT_NAME: "TEST_EVENT",
utils.ToR: "*voice",
utils.OriginID: "111",
@@ -1169,8 +1169,9 @@ func TestSessionStransitSState(t *testing.T) {
func TestSessionSregisterSessionWithTerminator(t *testing.T) {
sSCfg, _ := config.NewDefaultCGRConfig()
config.SetCgrConfig(sSCfg)
sS := NewSessionS(sSCfg, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, "UTC")
sSEv := engine.NewSafEvent(map[string]interface{}{
sSEv := engine.NewMapEvent(map[string]interface{}{
utils.EVENT_NAME: "TEST_EVENT",
utils.ToR: "*voice",
utils.OriginID: "111",
@@ -1209,7 +1210,7 @@ func TestSessionSregisterSessionWithTerminator(t *testing.T) {
func TestSessionSrelocateSessionS(t *testing.T) {
sSCfg, _ := config.NewDefaultCGRConfig()
sS := NewSessionS(sSCfg, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, "UTC")
sSEv := engine.NewSafEvent(map[string]interface{}{
sSEv := engine.NewMapEvent(map[string]interface{}{
utils.EVENT_NAME: "TEST_EVENT",
utils.ToR: "*voice",
utils.OriginID: "111",
@@ -1241,13 +1242,13 @@ func TestSessionSrelocateSessionS(t *testing.T) {
t.Errorf("Expecting %+v, received: %+v", s, rcvS[0])
}
//relocate the session
sS.relocateSessions("111", "222", "127.0.0.1")
sS.relocateSession("111", "222", "127.0.0.1")
//check if the session exist with old CGRID
rcvS = sS.getSessions(initialCGRID, false)
if len(rcvS) != 0 {
t.Errorf("Expecting 0, received: %+v", len(rcvS))
}
ev := engine.NewSafEvent(map[string]interface{}{
ev := engine.NewMapEvent(map[string]interface{}{
utils.OriginID: "222",
utils.OriginHost: "127.0.0.1"})
cgrID := GetSetCGRID(ev)
@@ -1385,7 +1386,7 @@ func TestSessionSgetSessionIDsMatchingIndexes(t *testing.T) {
"ToR": true,
}
sS := NewSessionS(sSCfg, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, "UTC")
sEv := engine.NewSafEvent(map[string]interface{}{
sEv := engine.NewMapEvent(map[string]interface{}{
utils.EVENT_NAME: "TEST_EVENT",
utils.ToR: "*voice",
utils.OriginID: "12345",
@@ -1414,7 +1415,7 @@ func TestSessionSgetSessionIDsMatchingIndexes(t *testing.T) {
EventStart: sEv,
SRuns: []*SRun{
&SRun{
Event: sEv.AsMapInterface(),
Event: sEv,
CD: &engine.CallDescriptor{
RunID: "RunID",
},