mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-11 18:16:24 +05:00
Renamed sessions.ActiveSession to sessions.ExternalSession
This commit is contained in:
committed by
Dan Christian Bogos
parent
42ceafb815
commit
85afa27a5e
@@ -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() {
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -63,7 +63,7 @@ func (self *CmdActiveSessions) PostprocessRpcParams() error {
|
||||
}
|
||||
|
||||
func (self *CmdActiveSessions) RpcResult() interface{} {
|
||||
var sessions *[]*sessions.ActiveSession
|
||||
var sessions *[]*sessions.ExternalSession
|
||||
return &sessions
|
||||
}
|
||||
|
||||
|
||||
@@ -62,7 +62,7 @@ func (self *CmdPassiveSessions) PostprocessRpcParams() error {
|
||||
}
|
||||
|
||||
func (self *CmdPassiveSessions) RpcResult() interface{} {
|
||||
var sessions *[]*sessions.ActiveSession
|
||||
var sessions *[]*sessions.ExternalSession
|
||||
return &sessions
|
||||
}
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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() {
|
||||
|
||||
@@ -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),
|
||||
|
||||
@@ -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))
|
||||
}
|
||||
|
||||
@@ -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{}
|
||||
}
|
||||
|
||||
@@ -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 ||
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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"},
|
||||
|
||||
Reference in New Issue
Block a user