diff --git a/agents/radagent_it_test.go b/agents/radagent_it_test.go
index 49e07f826..f8691fb92 100644
--- a/agents/radagent_it_test.go
+++ b/agents/radagent_it_test.go
@@ -21,6 +21,7 @@ along with this program. If not, see
package agents
import (
+ "fmt"
"net/rpc"
"net/rpc/jsonrpc"
"os/exec"
@@ -278,9 +279,12 @@ func testRAitAcctStart(t *testing.T) {
}
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 {
+ utils.SessionFilter{
+ Filters: []string{
+ fmt.Sprintf("*string:~%s:%s", utils.RunID, utils.META_DEFAULT),
+ fmt.Sprintf("*string:~%s:%s", utils.OriginID, "e4921177ab0e3586c37f6a185864b71a@0:0:0:0:0:0:0:0-51585361-75c2f57b"),
+ },
+ }, &aSessions); err != nil {
t.Error(err)
} else if len(aSessions) != 1 {
t.Errorf("Unexpected number of sessions received: %+v", aSessions)
@@ -346,8 +350,12 @@ func testRAitAcctStop(t *testing.T) {
// Make sure the sessin was disconnected from SMG
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() {
+ utils.SessionFilter{
+ Filters: []string{
+ fmt.Sprintf("*string:~%s:%s", utils.RunID, utils.META_DEFAULT),
+ fmt.Sprintf("*string:~%s:%s", utils.OriginID, "e4921177ab0e3586c37f6a185864b71a@0:0:0:0:0:0:0:0-51585361-75c2f57b"),
+ },
+ }, &aSessions); err == nil || err.Error() != utils.ErrNotFound.Error() {
t.Error(err)
}
time.Sleep(150 * time.Millisecond)
diff --git a/dispatchers/sessions_it_test.go b/dispatchers/sessions_it_test.go
index 91c78ec43..a65b370ba 100755
--- a/dispatchers/sessions_it_test.go
+++ b/dispatchers/sessions_it_test.go
@@ -685,7 +685,7 @@ func testDspSessionReplicate(t *testing.T) {
var repl int
time.Sleep(10 * time.Millisecond)
if err := allEngine2.RCP.Call(utils.SessionSv1GetPassiveSessionsCount,
- map[string]string{}, &repl); err != nil {
+ nil, &repl); err != nil {
t.Fatal(err)
} else if repl != 2 {
t.Errorf("Expected 1 sessions recived %v", repl)
diff --git a/engine/safevent_test.go b/engine/safevent_test.go
index 466ea68f1..4dc8a2b68 100644
--- a/engine/safevent_test.go
+++ b/engine/safevent_test.go
@@ -814,19 +814,20 @@ func TestSafEventGetTInt64(t *testing.T) {
}
func TestSafEventGetDurationPtrIgnoreErrors(t *testing.T) {
+ safEv = &SafEvent{Me: NewMapEvent(sMap)}
if rply := safEv.GetDurationPtrIgnoreErrors("test"); rply != nil {
t.Errorf("Expected: %+v, received: %+v", nil, rply)
}
expected := utils.DurationPointer(time.Duration(10 * time.Second))
- if rply := safEv.GetDurationPtrIgnoreErrors("test6"); *rply != *expected {
+ if rply := safEv.GetDurationPtrIgnoreErrors("test6"); rply == nil || *rply != *expected {
t.Errorf("Expected: %+v, received: %+v", expected, rply)
}
expected = utils.DurationPointer(time.Duration(42 * time.Second))
- if rply := safEv.GetDurationPtrIgnoreErrors("test7"); *rply != *expected {
+ if rply := safEv.GetDurationPtrIgnoreErrors("test7"); rply == nil || *rply != *expected {
t.Errorf("Expected: %+v, received: %+v", expected, rply)
}
expected = utils.DurationPointer(time.Duration(42))
- if rply := safEv.GetDurationPtrIgnoreErrors("test2"); *rply != *expected {
+ if rply := safEv.GetDurationPtrIgnoreErrors("test2"); rply == nil || *rply != *expected {
t.Errorf("Expected: %+v, received: %+v", expected, rply)
}
}
diff --git a/general_tests/rpcclient_it_test.go b/general_tests/rpcclient_it_test.go
index 1804e35a4..be669304b 100644
--- a/general_tests/rpcclient_it_test.go
+++ b/general_tests/rpcclient_it_test.go
@@ -172,7 +172,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.ExternalSession
- if err := rpcPoolFirst.Call(utils.SessionSv1GetActiveSessions, map[string]string{}, &sessions); err == nil || err.Error() != utils.ErrNotFound.Error() {
+ if err := rpcPoolFirst.Call(utils.SessionSv1GetActiveSessions, nil, &sessions); 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 480ed9c43..1d55b7552 100755
--- a/general_tests/tutorial_calls_test.go
+++ b/general_tests/tutorial_calls_test.go
@@ -394,7 +394,7 @@ func testCallGetActiveSessions(t *testing.T) {
},
}
if err := tutorialCallsRpc.Call(utils.SessionSv1GetActiveSessions,
- &map[string]string{}, &reply); err != nil {
+ nil, &reply); err != nil {
t.Error("Got error on SessionSv1.GetActiveSessions: ", err.Error())
} else {
// compare some fields (eg. CGRId is generated)
@@ -688,7 +688,7 @@ func testCallSyncSessions(t *testing.T) {
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() {
+ nil, &reply); err == nil || err.Error() != utils.ErrNotFound.Error() {
t.Error("Got error on SessionSv1.GetActiveSessions: ", err)
}
// 1001 call 1002 stop the call after 12 seconds
@@ -706,7 +706,7 @@ func testCallSyncSessions(t *testing.T) {
time.Sleep(1 * time.Second)
// get active sessions
if err := tutorialCallsRpc.Call(utils.SessionSv1GetActiveSessions,
- &map[string]string{}, &reply); err != nil {
+ nil, &reply); err != nil {
t.Error("Got error on SessionSv1.GetActiveSessions: ", err.Error())
} else if len(*reply) != 2 {
t.Errorf("expecting 2 active sessions, received: %+v", utils.ToJSON(reply))
@@ -757,7 +757,7 @@ func testCallSyncSessions(t *testing.T) {
// activeSessions shouldn't be active
if err := tutorialCallsRpc.Call(utils.SessionSv1GetActiveSessions,
- &map[string]string{}, &reply); err == nil || err.Error() != utils.ErrNotFound.Error() {
+ nil, &reply); err == nil || err.Error() != utils.ErrNotFound.Error() {
t.Errorf("Got error on SessionSv1.GetActiveSessions: %v and reply: %s", err, utils.ToJSON(reply))
}
diff --git a/sessions/sessions_it_test.go b/sessions/sessions_it_test.go
index 544b34369..5c8ce05b8 100644
--- a/sessions/sessions_it_test.go
+++ b/sessions/sessions_it_test.go
@@ -20,6 +20,7 @@ along with this program. If not, see
package sessions
import (
+ "fmt"
"net/rpc"
"net/rpc/jsonrpc"
"path"
@@ -277,7 +278,11 @@ func TestSessionsItTerminatePassive(t *testing.T) {
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 {
+ utils.SessionFilter{
+ Filters: []string{
+ fmt.Sprintf("*string:~%s:%s", utils.OriginID, "123789"),
+ },
+ }, &pSessions); err != nil {
t.Error(err)
} else if len(pSessions) != 1 {
t.Errorf("Unexpected number of sessions received: %+v", pSessions)
@@ -315,7 +320,11 @@ func TestSessionsItTerminatePassive(t *testing.T) {
//check if the passive session was terminate
if err := sItRPC.Call(utils.SessionSv1GetPassiveSessions,
- map[string]string{utils.OriginID: "123789"}, &pSessions); err == nil ||
+ utils.SessionFilter{
+ Filters: []string{
+ fmt.Sprintf("*string:~%s:%s", utils.OriginID, "123789"),
+ },
+ }, &pSessions); err == nil ||
err.Error() != utils.ErrNotFound.Error() {
t.Errorf("Error: %v with len(aSessions)=%v , session : %+v", err, len(pSessions), utils.ToJSON(pSessions))
}
diff --git a/sessions/sessions_rpl_it_test.go b/sessions/sessions_rpl_it_test.go
index dce7e7937..1c4544610 100644
--- a/sessions/sessions_rpl_it_test.go
+++ b/sessions/sessions_rpl_it_test.go
@@ -20,6 +20,7 @@ along with this program. If not, see
package sessions
import (
+ "fmt"
"net/rpc"
"net/rpc/jsonrpc"
"path"
@@ -136,7 +137,11 @@ func TestSessionSRplInitiate(t *testing.T) {
//check if the session was createad as active session on master
if err := smgRplcMstrRPC.Call(utils.SessionSv1GetActiveSessions,
- map[string]string{utils.OriginID: "123451"}, &aSessions); err != nil {
+ utils.SessionFilter{
+ Filters: []string{
+ fmt.Sprintf("*string:~%s:%s", utils.OriginID, "123451"),
+ },
+ }, &aSessions); err != nil {
t.Error(err)
} else if len(aSessions) != 1 {
t.Errorf("Unexpected number of sessions received: %+v", utils.ToIJSON(aSessions))
@@ -147,7 +152,11 @@ func TestSessionSRplInitiate(t *testing.T) {
//check if the session was created as passive session on slave
var pSessions []*ExternalSession
if err := smgRplcSlvRPC.Call(utils.SessionSv1GetPassiveSessions,
- map[string]string{utils.OriginID: "123451"}, &pSessions); err != nil {
+ utils.SessionFilter{
+ Filters: []string{
+ fmt.Sprintf("*string:~%s:%s", utils.OriginID, "123451"),
+ },
+ }, &pSessions); err != nil {
t.Error(err)
} else if len(pSessions) != 1 {
t.Errorf("PassiveSessions: %+v", pSessions)
@@ -192,7 +201,11 @@ func TestSessionSRplUpdate(t *testing.T) {
time.Sleep(time.Duration(*waitRater) * time.Millisecond) // Wait for the sessions to be populated
var aSessions []*ExternalSession
if err := smgRplcSlvRPC.Call(utils.SessionSv1GetActiveSessions,
- map[string]string{utils.OriginID: "123451"}, &aSessions); err != nil {
+ utils.SessionFilter{
+ Filters: []string{
+ fmt.Sprintf("*string:~%s:%s", utils.OriginID, "123451"),
+ },
+ }, &aSessions); err != nil {
t.Error(err)
} else if len(aSessions) != 1 {
t.Errorf("Unexpected number of sessions received: %+v", aSessions)
@@ -209,7 +222,11 @@ func TestSessionSRplUpdate(t *testing.T) {
// Master should not longer have activeSession
if err := smgRplcMstrRPC.Call(utils.SessionSv1GetActiveSessions,
- map[string]string{utils.OriginID: "123451"}, &aSessions); err == nil ||
+ utils.SessionFilter{
+ Filters: []string{
+ fmt.Sprintf("*string:~%s:%s", utils.OriginID, "123451"),
+ },
+ }, &aSessions); err == nil ||
err.Error() != utils.ErrNotFound.Error() {
t.Errorf("Error: %v with len(aSessions)=%v , session : %+v", err, len(aSessions), utils.ToJSON(aSessions))
}
@@ -258,7 +275,11 @@ func TestSessionSRplTerminate(t *testing.T) {
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 ||
+ utils.SessionFilter{
+ Filters: []string{
+ fmt.Sprintf("*string:~%s:%s", utils.OriginID, "123451"),
+ },
+ }, &aSessions); err == nil ||
err.Error() != utils.ErrNotFound.Error() {
t.Errorf("Error: %v with len(aSessions)=%v , session : %+v", err, len(aSessions), utils.ToIJSON(aSessions))
}
diff --git a/sessions/sessions_voice_it_test.go b/sessions/sessions_voice_it_test.go
index 656c72bff..107842b23 100644
--- a/sessions/sessions_voice_it_test.go
+++ b/sessions/sessions_voice_it_test.go
@@ -21,6 +21,7 @@ package sessions
import (
"flag"
+ "fmt"
"net/rpc"
"net/rpc/jsonrpc"
"path"
@@ -793,8 +794,12 @@ func TestSessionsVoiceSessionTTL(t *testing.T) {
var aSessions []*ExternalSession
if err := sessionsRPC.Call(utils.SessionSv1GetActiveSessions,
- map[string]string{utils.RunID: utils.META_DEFAULT,
- utils.OriginID: "12360"}, &aSessions); err != nil {
+ utils.SessionFilter{
+ Filters: []string{
+ fmt.Sprintf("*string:~%s:%s", utils.RunID, utils.META_DEFAULT),
+ fmt.Sprintf("*string:~%s:%s", utils.OriginID, "12360"),
+ },
+ }, &aSessions); err != nil {
t.Error(err)
} else if len(aSessions) != 1 {
t.Errorf("Unexpected number of sessions received: %+v", aSessions)
@@ -834,7 +839,7 @@ func TestSessionsVoiceSessionTTL(t *testing.T) {
var updateRpl *V1UpdateSessionReply
if err := sessionsRPC.Call(utils.SessionSv1UpdateSession, updateArgs, &updateRpl); err != nil {
- t.Error(err)
+ t.Fatal(err)
}
time.Sleep(time.Duration(10 * time.Millisecond))
if *updateRpl.MaxUsage != usage {
@@ -842,8 +847,12 @@ func TestSessionsVoiceSessionTTL(t *testing.T) {
}
if err := sessionsRPC.Call(utils.SessionSv1GetActiveSessions,
- map[string]string{utils.RunID: utils.META_DEFAULT, utils.OriginID: "12360"},
- &aSessions); err != nil {
+ utils.SessionFilter{
+ Filters: []string{
+ fmt.Sprintf("*string:~%s:%s", utils.RunID, utils.META_DEFAULT),
+ fmt.Sprintf("*string:~%s:%s", utils.OriginID, "12360"),
+ },
+ }, &aSessions); err != nil {
t.Error(err)
} else if len(aSessions) != 1 {
t.Errorf("Unexpected number of sessions received: %+v", aSessions)
@@ -943,9 +952,12 @@ func TestSessionsVoiceSessionTTLWithRelocate(t *testing.T) {
var aSessions []*ExternalSession
if err := sessionsRPC.Call(utils.SessionSv1GetActiveSessions,
- map[string]string{utils.RunID: utils.META_DEFAULT,
- utils.OriginID: "12361"},
- &aSessions); err != nil {
+ utils.SessionFilter{
+ Filters: []string{
+ fmt.Sprintf("*string:~%s:%s", utils.RunID, utils.META_DEFAULT),
+ fmt.Sprintf("*string:~%s:%s", utils.OriginID, "12361"),
+ },
+ }, &aSessions); err != nil {
t.Error(err)
} else if len(aSessions) != 1 {
t.Errorf("Unexpected number of sessions received: %+v", aSessions)
@@ -997,9 +1009,12 @@ func TestSessionsVoiceSessionTTLWithRelocate(t *testing.T) {
time.Sleep(time.Duration(20) * time.Millisecond)
if err := sessionsRPC.Call(utils.SessionSv1GetActiveSessions,
- map[string]string{utils.RunID: utils.META_DEFAULT,
- utils.OriginID: "12362"},
- &aSessions); err != nil {
+ utils.SessionFilter{
+ Filters: []string{
+ fmt.Sprintf("*string:~%s:%s", utils.RunID, utils.META_DEFAULT),
+ fmt.Sprintf("*string:~%s:%s", utils.OriginID, "12362"),
+ },
+ }, &aSessions); err != nil {
t.Error(err)
} else if len(aSessions) != 1 {
t.Errorf("Unexpected number of sessions received: %+v", aSessions)
@@ -1024,9 +1039,12 @@ func TestSessionsVoiceSessionTTLWithRelocate(t *testing.T) {
eAcntVal, acnt.BalanceMap[utils.VOICE].GetTotalValue())
}
if err := sessionsRPC.Call(utils.SessionSv1GetActiveSessions,
- map[string]string{utils.RunID: utils.META_DEFAULT,
- utils.OriginID: "12362"},
- &aSessions); err == nil || err.Error() != utils.ErrNotFound.Error() {
+ utils.SessionFilter{
+ Filters: []string{
+ fmt.Sprintf("*string:~%s:%s", utils.RunID, utils.META_DEFAULT),
+ fmt.Sprintf("*string:~%s:%s", utils.OriginID, "12362"),
+ },
+ }, &aSessions); err == nil || err.Error() != utils.ErrNotFound.Error() {
t.Error(err, utils.ToJSON(aSessions))
}
time.Sleep(500 * time.Millisecond)
@@ -1104,9 +1122,12 @@ func TestSessionsVoiceRelocateWithOriginIDPrefix(t *testing.T) {
time.Sleep(time.Duration(20) * time.Millisecond)
var aSessions []*ExternalSession
if err := sessionsRPC.Call(utils.SessionSv1GetActiveSessions,
- map[string]string{utils.RunID: utils.META_DEFAULT,
- utils.OriginID: "12371"},
- &aSessions); err != nil {
+ utils.SessionFilter{
+ Filters: []string{
+ fmt.Sprintf("*string:~%s:%s", utils.RunID, utils.META_DEFAULT),
+ fmt.Sprintf("*string:~%s:%s", utils.OriginID, "12371"),
+ },
+ }, &aSessions); err != nil {
t.Error(err)
} else if len(aSessions) != 1 {
t.Errorf("Unexpected number of sessions received: %+v", aSessions)
@@ -1158,8 +1179,12 @@ func TestSessionsVoiceRelocateWithOriginIDPrefix(t *testing.T) {
time.Sleep(time.Duration(20) * time.Millisecond)
if err := sessionsRPC.Call(utils.SessionSv1GetActiveSessions,
- map[string]string{utils.RunID: utils.META_DEFAULT,
- utils.OriginID: "12372-1"}, &aSessions); err != nil {
+ utils.SessionFilter{
+ Filters: []string{
+ fmt.Sprintf("*string:~%s:%s", utils.RunID, utils.META_DEFAULT),
+ fmt.Sprintf("*string:~%s:%s", utils.OriginID, "12372-1"),
+ },
+ }, &aSessions); err != nil {
t.Error(err)
} else if len(aSessions) != 1 {
t.Errorf("Unexpected number of sessions received: %+v", aSessions)
@@ -1204,8 +1229,12 @@ func TestSessionsVoiceRelocateWithOriginIDPrefix(t *testing.T) {
time.Sleep(time.Duration(10) * time.Millisecond)
if err := sessionsRPC.Call(utils.SessionSv1GetActiveSessions,
- map[string]string{utils.RunID: utils.META_DEFAULT,
- utils.OriginID: "12372-1"}, &aSessions); err == nil ||
+ utils.SessionFilter{
+ Filters: []string{
+ fmt.Sprintf("*string:~%s:%s", utils.RunID, utils.META_DEFAULT),
+ fmt.Sprintf("*string:~%s:%s", utils.OriginID, "12372-1"),
+ },
+ }, &aSessions); err == nil ||
err.Error() != utils.ErrNotFound.Error() {
t.Error(err, aSessions)
}
@@ -1283,7 +1312,6 @@ func TestSMGDataDerivedChargingNoCredit(t *testing.T) {
*/
// ToDo: Add test for ChargeEvent with derived charging, one with debit possible and second not so we see refund and error.CreditInsufficient showing up.
-
func TestSessionsVoiceStopCgrEngine(t *testing.T) {
if err := engine.KillEngine(1000); err != nil {
t.Error(err)