Updated dispatcher integration tests

This commit is contained in:
Trial97
2019-12-04 09:51:10 +02:00
parent e548ebc073
commit b3887584b5
22 changed files with 300 additions and 219 deletions

View File

@@ -0,0 +1,22 @@
#Tenant,ID,Contexts,FilterIDs,ActivationInterval,AttributeFilterIDs,FieldName,Type,Value,Blocker,Weight
cgrates.org,ATTR_1001_SIMPLEAUTH,*any,*string:~*req.Account:1001,,,Password,*constant,CGRateS.org,false,20
cgrates.org,ATTR_1001_SIMPLEAUTH,*any,,,,EventName,*constant,*none,false,20
cgrates.org,ATTR_1003_SIMPLEAUTH,*any,*string:~*req.Account:1003,,,Password,*constant,CGRateS.com,false,20
cgrates.org,ATTR_API_ATTR_FAKE_AUTH,*auth,*string:~*req.APIKey:12345,,,APIMethods,*constant,,false,20
cgrates.org,ATTR_API_ATTR_AUTH,*auth,*string:~*req.APIKey:attr12345,,,APIMethods,*constant,AttributeSv1.Ping&AttributeSv1.GetAttributeForEvent&AttributeSv1.ProcessEvent,false,20
cgrates.org,ATTR_API_CHRG_AUTH,*auth,*string:~*req.APIKey:chrg12345,,,APIMethods,*constant,ChargerSv1.Ping&ChargerSv1.GetChargersForEvent&ChargerSv1.ProcessEvent,false,20
cgrates.org,ATTR_API_THR_AUTH,*auth,*string:~*req.APIKey:thr12345,,,APIMethods,*constant,ThresholdSv1.Ping&ThresholdSv1.GetThresholdsForEvent&ThresholdSv1.ProcessEvent&ThresholdSv1.GetThreshold&ThresholdSv1.GetThresholdIDs,false,20
cgrates.org,ATTR_API_SUP_AUTH,*auth,*string:~*req.APIKey:sup12345,,,APIMethods,*constant,SupplierSv1.Ping&SupplierSv1.GetSuppliers&SupplierSv1.GetSupplierProfilesForEvent,false,20
cgrates.org,ATTR_API_STAT_AUTH,*auth,*string:~*req.APIKey:stat12345,,,APIMethods,*constant,StatSv1.Ping&StatSv1.GetStatQueuesForEvent&StatSv1.GetQueueStringMetrics&StatSv1.ProcessEvent&StatSv1.GetQueueIDs&StatSv1.GetQueueFloatMetrics,false,20
cgrates.org,ATTR_API_RES_AUTH,*auth,*string:~*req.APIKey:res12345,,,APIMethods,*constant,ResourceSv1.Ping&ResourceSv1.GetResourcesForEvent&ResourceSv1.AuthorizeResources&ResourceSv1.AllocateResources&ResourceSv1.ReleaseResources,false,20
cgrates.org,ATTR_API_SES_AUTH,*auth,*string:~*req.APIKey:ses12345,,,APIMethods,*constant,SessionSv1.Ping&SessionSv1.AuthorizeEvent&SessionSv1.AuthorizeEventWithDigest&SessionSv1.InitiateSession&SessionSv1.InitiateSessionWithDigest&SessionSv1.UpdateSession&SessionSv1.SyncSessions&SessionSv1.TerminateSession&SessionSv1.ProcessCDR&SessionSv1.ProcessMessage&SessionSv1.GetActiveSessions&SessionSv1.GetActiveSessionsCount&SessionSv1.ForceDisconnect&SessionSv1.GetPassiveSessions&SessionSv1.GetPassiveSessionsCount&SessionSv1.ReplicateSessions&SessionSv1.SetPassiveSession&SessionSv1.ProcessEvent,false,20
cgrates.org,ATTR_API_RSP_AUTH,*auth,*string:~*req.APIKey:rsp12345,,,APIMethods,*constant,CoreSv1.Status&CoreSv1.Ping&Responder.GetTimeout&Responder.Shutdown&Responder.Ping,false,20
cgrates.org,ATTR_API_CHC_AUTH,*auth,*string:~*req.APIKey:chc12345,,,APIMethods,*constant,CacheSv1.Ping&CacheSv1.GetCacheStats&CacheSv1.LoadCache&CacheSv1.PrecacheStatus&CacheSv1.GetItemIDs&CacheSv1.HasItem&CacheSv1.GetItemExpiryTime&CacheSv1.ReloadCache&CacheSv1.RemoveItem&CacheSv1.FlushCache&CacheSv1.Clear,false,20
cgrates.org,ATTR_API_GRD_AUTH,*auth,*string:~*req.APIKey:grd12345,,,APIMethods,*constant,GuardianSv1.Ping&GuardianSv1.RemoteLock&GuardianSv1.RemoteUnlock,false,20
cgrates.org,ATTR_API_SCHD_AUTH,*auth,*string:~*req.APIKey:sched12345,,,APIMethods,*constant,SchedulerSv1.Ping,false,20
cgrates.org,ATTR_API_CDRS_AUTH,*auth,*string:~*req.APIKey:cdrs12345,,,APIMethods,*constant,CDRsV1.Ping&CDRsV1.ProcessEvent&CDRsV1.GetCDRs&CDRsV1.CountCDRs&CDRsV1.ProcessCDR&CDRsV1.ProcessExternalCDR,false,20
cgrates.org,ATTR_API_DSP_AUTH,*auth,*string:~*req.APIKey:dsp12345,,,APIMethods,*constant,DispatcherSv1.Ping&DispatcherSv1.GetProfileForEvent,false,20
cgrates.org,ATTR_API_PSE_AUTH,*auth,*string:~*req.APIKey:pse12345,,,APIMethods,*constant,SessionSv1.Ping&SessionSv1.AuthorizeEvent&SessionSv1.AuthorizeEventWithDigest&SessionSv1.InitiateSession&SessionSv1.InitiateSessionWithDigest&SessionSv1.UpdateSession&SessionSv1.SyncSessions&SessionSv1.TerminateSession&SessionSv1.ProcessCDR&SessionSv1.ProcessMessage&SessionSv1.GetActiveSessions&SessionSv1.GetActiveSessionsCount&SessionSv1.ForceDisconnect&SessionSv1.GetPassiveSessions&SessionSv1.GetPassiveSessionsCount&SessionSv1.ReplicateSessions&SessionSv1.SetPassiveSession&AttributeSv1.ProcessEvent&Responder.Debit&ResourceSv1.AllocateResources&ChargerSv1.ProcessEvent&Responder.MaxDebit,false,20
cgrates.org,ATTR_API_CFG_AUTH,*auth,*string:~*req.APIKey:cfg12345,,,APIMethods,*constant,ConfigSv1.GetJSONSection&ConfigSv1.ReloadConfig,false,20
cgrates.org,ATTR_API_APIER_AUTH,*auth,*string:~*req.APIKey:apier12345,,,APIMethods,*constant,ApierV1.GetAttributeProfile&ApierV1.SetAttributeProfile,false,20
cgrates.org,ATTR_API_RALS_AUTH,*auth,*string:~*req.APIKey:rals12345,,,APIMethods,*constant,RALsV1.Ping&RALsV1.GetRatingPlansCost,false,20
1 #Tenant ID Contexts FilterIDs ActivationInterval AttributeFilterIDs FieldName Type Value Blocker Weight
2 cgrates.org ATTR_1001_SIMPLEAUTH *any *string:~*req.Account:1001 Password *constant CGRateS.org false 20
3 cgrates.org ATTR_1001_SIMPLEAUTH *any EventName *constant *none false 20
4 cgrates.org ATTR_1003_SIMPLEAUTH *any *string:~*req.Account:1003 Password *constant CGRateS.com false 20
5 cgrates.org ATTR_API_ATTR_FAKE_AUTH *auth *string:~*req.APIKey:12345 APIMethods *constant false 20
6 cgrates.org ATTR_API_ATTR_AUTH *auth *string:~*req.APIKey:attr12345 APIMethods *constant AttributeSv1.Ping&AttributeSv1.GetAttributeForEvent&AttributeSv1.ProcessEvent false 20
7 cgrates.org ATTR_API_CHRG_AUTH *auth *string:~*req.APIKey:chrg12345 APIMethods *constant ChargerSv1.Ping&ChargerSv1.GetChargersForEvent&ChargerSv1.ProcessEvent false 20
8 cgrates.org ATTR_API_THR_AUTH *auth *string:~*req.APIKey:thr12345 APIMethods *constant ThresholdSv1.Ping&ThresholdSv1.GetThresholdsForEvent&ThresholdSv1.ProcessEvent&ThresholdSv1.GetThreshold&ThresholdSv1.GetThresholdIDs false 20
9 cgrates.org ATTR_API_SUP_AUTH *auth *string:~*req.APIKey:sup12345 APIMethods *constant SupplierSv1.Ping&SupplierSv1.GetSuppliers&SupplierSv1.GetSupplierProfilesForEvent false 20
10 cgrates.org ATTR_API_STAT_AUTH *auth *string:~*req.APIKey:stat12345 APIMethods *constant StatSv1.Ping&StatSv1.GetStatQueuesForEvent&StatSv1.GetQueueStringMetrics&StatSv1.ProcessEvent&StatSv1.GetQueueIDs&StatSv1.GetQueueFloatMetrics false 20
11 cgrates.org ATTR_API_RES_AUTH *auth *string:~*req.APIKey:res12345 APIMethods *constant ResourceSv1.Ping&ResourceSv1.GetResourcesForEvent&ResourceSv1.AuthorizeResources&ResourceSv1.AllocateResources&ResourceSv1.ReleaseResources false 20
12 cgrates.org ATTR_API_SES_AUTH *auth *string:~*req.APIKey:ses12345 APIMethods *constant SessionSv1.Ping&SessionSv1.AuthorizeEvent&SessionSv1.AuthorizeEventWithDigest&SessionSv1.InitiateSession&SessionSv1.InitiateSessionWithDigest&SessionSv1.UpdateSession&SessionSv1.SyncSessions&SessionSv1.TerminateSession&SessionSv1.ProcessCDR&SessionSv1.ProcessMessage&SessionSv1.GetActiveSessions&SessionSv1.GetActiveSessionsCount&SessionSv1.ForceDisconnect&SessionSv1.GetPassiveSessions&SessionSv1.GetPassiveSessionsCount&SessionSv1.ReplicateSessions&SessionSv1.SetPassiveSession&SessionSv1.ProcessEvent false 20
13 cgrates.org ATTR_API_RSP_AUTH *auth *string:~*req.APIKey:rsp12345 APIMethods *constant CoreSv1.Status&CoreSv1.Ping&Responder.GetTimeout&Responder.Shutdown&Responder.Ping false 20
14 cgrates.org ATTR_API_CHC_AUTH *auth *string:~*req.APIKey:chc12345 APIMethods *constant CacheSv1.Ping&CacheSv1.GetCacheStats&CacheSv1.LoadCache&CacheSv1.PrecacheStatus&CacheSv1.GetItemIDs&CacheSv1.HasItem&CacheSv1.GetItemExpiryTime&CacheSv1.ReloadCache&CacheSv1.RemoveItem&CacheSv1.FlushCache&CacheSv1.Clear false 20
15 cgrates.org ATTR_API_GRD_AUTH *auth *string:~*req.APIKey:grd12345 APIMethods *constant GuardianSv1.Ping&GuardianSv1.RemoteLock&GuardianSv1.RemoteUnlock false 20
16 cgrates.org ATTR_API_SCHD_AUTH *auth *string:~*req.APIKey:sched12345 APIMethods *constant SchedulerSv1.Ping false 20
17 cgrates.org ATTR_API_CDRS_AUTH *auth *string:~*req.APIKey:cdrs12345 APIMethods *constant CDRsV1.Ping&CDRsV1.ProcessEvent&CDRsV1.GetCDRs&CDRsV1.CountCDRs&CDRsV1.ProcessCDR&CDRsV1.ProcessExternalCDR false 20
18 cgrates.org ATTR_API_DSP_AUTH *auth *string:~*req.APIKey:dsp12345 APIMethods *constant DispatcherSv1.Ping&DispatcherSv1.GetProfileForEvent false 20
19 cgrates.org ATTR_API_PSE_AUTH *auth *string:~*req.APIKey:pse12345 APIMethods *constant SessionSv1.Ping&SessionSv1.AuthorizeEvent&SessionSv1.AuthorizeEventWithDigest&SessionSv1.InitiateSession&SessionSv1.InitiateSessionWithDigest&SessionSv1.UpdateSession&SessionSv1.SyncSessions&SessionSv1.TerminateSession&SessionSv1.ProcessCDR&SessionSv1.ProcessMessage&SessionSv1.GetActiveSessions&SessionSv1.GetActiveSessionsCount&SessionSv1.ForceDisconnect&SessionSv1.GetPassiveSessions&SessionSv1.GetPassiveSessionsCount&SessionSv1.ReplicateSessions&SessionSv1.SetPassiveSession&AttributeSv1.ProcessEvent&Responder.Debit&ResourceSv1.AllocateResources&ChargerSv1.ProcessEvent&Responder.MaxDebit false 20
20 cgrates.org ATTR_API_CFG_AUTH *auth *string:~*req.APIKey:cfg12345 APIMethods *constant ConfigSv1.GetJSONSection&ConfigSv1.ReloadConfig false 20
21 cgrates.org ATTR_API_APIER_AUTH *auth *string:~*req.APIKey:apier12345 APIMethods *constant ApierV1.GetAttributeProfile&ApierV1.SetAttributeProfile false 20
22 cgrates.org ATTR_API_RALS_AUTH *auth *string:~*req.APIKey:rals12345 APIMethods *constant RALsV1.Ping&RALsV1.GetRatingPlansCost false 20

View File

@@ -0,0 +1,4 @@
#Tenant[0],ID[1],Address[2],Transport[3],TLS[4]
cgrates.org,SELF,*internal,,
cgrates.org,ALL,127.0.0.1:6013,*gob,false
cgrates.org,ALL2,127.0.0.1:7013,*gob,false
1 #Tenant[0] ID[1] Address[2] Transport[3] TLS[4]
2 cgrates.org SELF *internal
3 cgrates.org ALL 127.0.0.1:6013 *gob false
4 cgrates.org ALL2 127.0.0.1:7013 *gob false

View File

@@ -0,0 +1,12 @@
#Tenant,ID,Subsystems,FilterIDs,ActivationInterval,Strategy,StrategyParameters,ConnID,ConnFilterIDs,ConnWeight,ConnBlocker,ConnParameters,Weight
cgrates.org,PING1,*any,,,*weight,,ALL,,20,false,,10
cgrates.org,PING1,,,,,,ALL2,,10,,,
cgrates.org,EVENT1,*any,*string:~*req.EventName:Event1,,*weight,,ALL2,,20,false,,30
cgrates.org,EVENT1,,,,,,ALL,,10,,,
cgrates.org,EVENT2,*any,*string:~*req.EventName:RoundRobin,,*round_robin,,ALL2,,20,false,,20
cgrates.org,EVENT2,,,,,,ALL,,10,,,
cgrates.org,EVENT3,*any,*string:~*req.EventName:Random,,*random,,ALL2,,20,false,,20
cgrates.org,EVENT3,,,,,,ALL,,10,,,
cgrates.org,EVENT4,*any,*string:~*req.EventName:Broadcast,,*broadcast,,ALL2,,20,false,,20
cgrates.org,EVENT4,,,,,,ALL,,10,,,
cgrates.org,EVENT5,*any,*string:~*req.EventName:Internal,,*weight,,SELF,,20,false,,20
1 #Tenant ID Subsystems FilterIDs ActivationInterval Strategy StrategyParameters ConnID ConnFilterIDs ConnWeight ConnBlocker ConnParameters Weight
2 cgrates.org PING1 *any *weight ALL 20 false 10
3 cgrates.org PING1 ALL2 10
4 cgrates.org EVENT1 *any *string:~*req.EventName:Event1 *weight ALL2 20 false 30
5 cgrates.org EVENT1 ALL 10
6 cgrates.org EVENT2 *any *string:~*req.EventName:RoundRobin *round_robin ALL2 20 false 20
7 cgrates.org EVENT2 ALL 10
8 cgrates.org EVENT3 *any *string:~*req.EventName:Random *random ALL2 20 false 20
9 cgrates.org EVENT3 ALL 10
10 cgrates.org EVENT4 *any *string:~*req.EventName:Broadcast *broadcast ALL2 20 false 20
11 cgrates.org EVENT4 ALL 10
12 cgrates.org EVENT5 *any *string:~*req.EventName:Internal *weight SELF 20 false 20

View File

@@ -47,11 +47,19 @@ var sTestsDspAttr = []func(t *testing.T){
//Test start here
func TestDspAttributeSTMySQL(t *testing.T) {
testDsp(t, sTestsDspAttr, "TestDspAttributeS", "all", "all2", "dispatchers", "tutorial", "oldtutorial", "dispatchers")
if *encoding == utils.MetaGOB {
testDsp(t, sTestsDspAttr, "TestDspAttributeS", "all", "all2", "dispatchers", "tutorial", "oldtutorial", "dispatchers_gob")
} else {
testDsp(t, sTestsDspAttr, "TestDspAttributeS", "all", "all2", "dispatchers", "tutorial", "oldtutorial", "dispatchers")
}
}
func TestDspAttributeSMongo(t *testing.T) {
testDsp(t, sTestsDspAttr, "TestDspAttributeS", "all", "all2", "dispatchers_mongo", "tutorial", "oldtutorial", "dispatchers")
if *encoding == utils.MetaGOB {
testDsp(t, sTestsDspAttr, "TestDspAttributeS", "all", "all2", "dispatchers_mongo", "tutorial", "oldtutorial", "dispatchers_gob")
} else {
testDsp(t, sTestsDspAttr, "TestDspAttributeS", "all", "all2", "dispatchers_mongo", "tutorial", "oldtutorial", "dispatchers")
}
}
func TestDspAttributeSNoConn(t *testing.T) {
@@ -64,13 +72,13 @@ func TestDspAttributeSNoConn(t *testing.T) {
func testDspAttrPingFailover(t *testing.T) {
var reply string
if err := allEngine.RCP.Call(utils.AttributeSv1Ping, new(utils.CGREvent), &reply); err != nil {
if err := allEngine.RPC.Call(utils.AttributeSv1Ping, new(utils.CGREvent), &reply); err != nil {
t.Error(err)
} else if reply != utils.Pong {
t.Errorf("Received: %s", reply)
}
reply = ""
if err := allEngine2.RCP.Call(utils.AttributeSv1Ping, new(utils.CGREvent), &reply); err != nil {
if err := allEngine2.RPC.Call(utils.AttributeSv1Ping, new(utils.CGREvent), &reply); err != nil {
t.Error(err)
} else if reply != utils.Pong {
t.Errorf("Received: %s", reply)
@@ -84,27 +92,27 @@ func testDspAttrPingFailover(t *testing.T) {
APIKey: utils.StringPointer("attr12345"),
},
}
if err := dispEngine.RCP.Call(utils.AttributeSv1Ping, &ev, &reply); err != nil {
if err := dispEngine.RPC.Call(utils.AttributeSv1Ping, &ev, &reply); err != nil {
t.Error(err)
} else if reply != utils.Pong {
t.Errorf("Received: %s", reply)
}
allEngine.stopEngine(t)
reply = ""
if err := dispEngine.RCP.Call(utils.AttributeSv1Ping, &ev, &reply); err != nil {
if err := dispEngine.RPC.Call(utils.AttributeSv1Ping, &ev, &reply); err != nil {
t.Error(err)
} else if reply != utils.Pong {
t.Errorf("Received: %s", reply)
}
allEngine2.stopEngine(t)
reply = ""
if err := dispEngine.RCP.Call(utils.AttributeSv1Ping, &ev, &reply); err == nil {
if err := dispEngine.RPC.Call(utils.AttributeSv1Ping, &ev, &reply); err == nil {
t.Errorf("Expected error but recived %v and reply %v\n", err, reply)
}
allEngine.startEngine(t)
allEngine2.startEngine(t)
reply = ""
if err := dispEngine.RCP.Call(utils.AttributeSv1Ping, &ev, &reply); err != nil {
if err := dispEngine.RPC.Call(utils.AttributeSv1Ping, &ev, &reply); err != nil {
t.Error(err)
} else if reply != utils.Pong {
t.Errorf("Received: %s", reply)
@@ -142,6 +150,9 @@ func testDspAttrGetAttrFailover(t *testing.T) {
Weight: 20.0,
}
eAttrPrf.Compile()
if *encoding == utils.MetaGOB {
eAttrPrf.Attributes[0].FilterIDs = nil // empty slice are nil in gob
}
eRply := &engine.AttrSProcessEventReply{
MatchedProfiles: []string{"ATTR_1002_SIMPLEAUTH"},
@@ -159,12 +170,12 @@ func testDspAttrGetAttrFailover(t *testing.T) {
var attrReply *engine.AttributeProfile
var rplyEv engine.AttrSProcessEventReply
if err := dispEngine.RCP.Call(utils.AttributeSv1GetAttributeForEvent,
if err := dispEngine.RPC.Call(utils.AttributeSv1GetAttributeForEvent,
args, &attrReply); err == nil || err.Error() != utils.ErrNotFound.Error() {
t.Error(err)
}
if err := dispEngine.RCP.Call(utils.AttributeSv1ProcessEvent,
if err := dispEngine.RPC.Call(utils.AttributeSv1ProcessEvent,
args, &rplyEv); err == nil || err.Error() != utils.ErrNotFound.Error() {
t.Error(err)
} else if reflect.DeepEqual(eRply, &rplyEv) {
@@ -174,7 +185,7 @@ func testDspAttrGetAttrFailover(t *testing.T) {
allEngine2.stopEngine(t)
if err := dispEngine.RCP.Call(utils.AttributeSv1GetAttributeForEvent,
if err := dispEngine.RPC.Call(utils.AttributeSv1GetAttributeForEvent,
args, &attrReply); err != nil {
t.Error(err)
}
@@ -185,7 +196,7 @@ func testDspAttrGetAttrFailover(t *testing.T) {
t.Errorf("Expecting: %s, received: %s", utils.ToJSON(eAttrPrf), utils.ToJSON(attrReply))
}
if err := dispEngine.RCP.Call(utils.AttributeSv1ProcessEvent,
if err := dispEngine.RPC.Call(utils.AttributeSv1ProcessEvent,
args, &rplyEv); err != nil {
t.Error(err)
} else if !reflect.DeepEqual(eRply, &rplyEv) {
@@ -198,15 +209,15 @@ func testDspAttrGetAttrFailover(t *testing.T) {
func testDspAttrPing(t *testing.T) {
var reply string
if err := allEngine.RCP.Call(utils.AttributeSv1Ping, new(utils.CGREvent), &reply); err != nil {
if err := allEngine.RPC.Call(utils.AttributeSv1Ping, new(utils.CGREvent), &reply); err != nil {
t.Error(err)
} else if reply != utils.Pong {
t.Errorf("Received: %s", reply)
}
if dispEngine.RCP == nil {
t.Fatal(dispEngine.RCP)
if dispEngine.RPC == nil {
t.Fatal(dispEngine.RPC)
}
if err := dispEngine.RCP.Call(utils.AttributeSv1Ping, &utils.CGREventWithArgDispatcher{
if err := dispEngine.RPC.Call(utils.AttributeSv1Ping, &utils.CGREventWithArgDispatcher{
CGREvent: &utils.CGREvent{
Tenant: "cgrates.org",
},
@@ -232,7 +243,7 @@ func testDspAttrTestMissingArgDispatcher(t *testing.T) {
},
}
var attrReply *engine.AttributeProfile
if err := dispEngine.RCP.Call(utils.AttributeSv1GetAttributeForEvent,
if err := dispEngine.RPC.Call(utils.AttributeSv1GetAttributeForEvent,
args, &attrReply); err == nil || err.Error() != utils.NewErrMandatoryIeMissing(utils.ArgDispatcherField).Error() {
t.Errorf("Error:%v rply=%s", err, utils.ToJSON(attrReply))
}
@@ -251,7 +262,7 @@ func testDspAttrTestMissingApiKey(t *testing.T) {
ArgDispatcher: &utils.ArgDispatcher{},
}
var attrReply *engine.AttributeProfile
if err := dispEngine.RCP.Call(utils.AttributeSv1GetAttributeForEvent,
if err := dispEngine.RPC.Call(utils.AttributeSv1GetAttributeForEvent,
args, &attrReply); err == nil || err.Error() != utils.NewErrMandatoryIeMissing(utils.APIKey).Error() {
t.Errorf("Error:%v rply=%s", err, utils.ToJSON(attrReply))
}
@@ -272,7 +283,7 @@ func testDspAttrTestUnknownApiKey(t *testing.T) {
},
}
var attrReply *engine.AttributeProfile
if err := dispEngine.RCP.Call(utils.AttributeSv1GetAttributeForEvent,
if err := dispEngine.RPC.Call(utils.AttributeSv1GetAttributeForEvent,
args, &attrReply); err == nil || err.Error() != utils.ErrUnknownApiKey.Error() {
t.Error(err)
}
@@ -293,7 +304,7 @@ func testDspAttrTestAuthKey(t *testing.T) {
},
}
var attrReply *engine.AttributeProfile
if err := dispEngine.RCP.Call(utils.AttributeSv1GetAttributeForEvent,
if err := dispEngine.RPC.Call(utils.AttributeSv1GetAttributeForEvent,
args, &attrReply); err == nil || err.Error() != utils.ErrUnauthorizedApi.Error() {
t.Error(err)
}
@@ -329,8 +340,11 @@ func testDspAttrTestAuthKey2(t *testing.T) {
Weight: 20.0,
}
eAttrPrf.Compile()
if *encoding == utils.MetaGOB {
eAttrPrf.Attributes[0].FilterIDs = nil // empty slice are nil in gob
}
var attrReply *engine.AttributeProfile
if err := dispEngine.RCP.Call(utils.AttributeSv1GetAttributeForEvent,
if err := dispEngine.RPC.Call(utils.AttributeSv1GetAttributeForEvent,
args, &attrReply); err != nil {
t.Error(err)
}
@@ -355,7 +369,7 @@ func testDspAttrTestAuthKey2(t *testing.T) {
}
var rplyEv engine.AttrSProcessEventReply
if err := dispEngine.RCP.Call(utils.AttributeSv1ProcessEvent,
if err := dispEngine.RPC.Call(utils.AttributeSv1ProcessEvent,
args, &rplyEv); err != nil {
t.Error(err)
} else if !reflect.DeepEqual(eRply, &rplyEv) {
@@ -380,7 +394,7 @@ func testDspAttrTestAuthKey3(t *testing.T) {
},
}
var attrReply *engine.AttributeProfile
if err := dispEngine.RCP.Call(utils.AttributeSv1GetAttributeForEvent,
if err := dispEngine.RPC.Call(utils.AttributeSv1GetAttributeForEvent,
args, &attrReply); err == nil || err.Error() != utils.ErrNotFound.Error() {
t.Error(err)
}
@@ -417,6 +431,9 @@ func testDspAttrGetAttrRoundRobin(t *testing.T) {
Weight: 20.0,
}
eAttrPrf.Compile()
if *encoding == utils.MetaGOB {
eAttrPrf.Attributes[0].FilterIDs = nil // empty slice are nil in gob
}
eRply := &engine.AttrSProcessEventReply{
MatchedProfiles: []string{"ATTR_1002_SIMPLEAUTH"},
@@ -435,13 +452,13 @@ func testDspAttrGetAttrRoundRobin(t *testing.T) {
var attrReply *engine.AttributeProfile
var rplyEv engine.AttrSProcessEventReply
// To ALL2
if err := dispEngine.RCP.Call(utils.AttributeSv1GetAttributeForEvent,
if err := dispEngine.RPC.Call(utils.AttributeSv1GetAttributeForEvent,
args, &attrReply); err == nil || err.Error() != utils.ErrNotFound.Error() {
t.Error(err)
}
// To ALL
if err := dispEngine.RCP.Call(utils.AttributeSv1GetAttributeForEvent,
if err := dispEngine.RPC.Call(utils.AttributeSv1GetAttributeForEvent,
args, &attrReply); err != nil {
t.Error(err)
}
@@ -453,7 +470,7 @@ func testDspAttrGetAttrRoundRobin(t *testing.T) {
}
// To ALL2
if err := dispEngine.RCP.Call(utils.AttributeSv1ProcessEvent,
if err := dispEngine.RPC.Call(utils.AttributeSv1ProcessEvent,
args, &rplyEv); err == nil || err.Error() != utils.ErrNotFound.Error() {
t.Error(err)
} else if reflect.DeepEqual(eRply, &rplyEv) {
@@ -462,7 +479,7 @@ func testDspAttrGetAttrRoundRobin(t *testing.T) {
}
// To ALL
if err := dispEngine.RCP.Call(utils.AttributeSv1ProcessEvent,
if err := dispEngine.RPC.Call(utils.AttributeSv1ProcessEvent,
args, &rplyEv); err != nil {
t.Error(err)
} else if !reflect.DeepEqual(eRply, &rplyEv) {
@@ -502,7 +519,7 @@ func testDspAttrGetAttrInternal(t *testing.T) {
}
var rplyEv engine.AttrSProcessEventReply
if err := dispEngine.RCP.Call(utils.AttributeSv1ProcessEvent,
if err := dispEngine.RPC.Call(utils.AttributeSv1ProcessEvent,
args, &rplyEv); err != nil {
t.Error(err)
} else if !reflect.DeepEqual(eRply, &rplyEv) {
@@ -513,15 +530,15 @@ func testDspAttrGetAttrInternal(t *testing.T) {
func testDspAttrPingNoArgDispatcher(t *testing.T) {
var reply string
if err := allEngine.RCP.Call(utils.AttributeSv1Ping, new(utils.CGREvent), &reply); err != nil {
if err := allEngine.RPC.Call(utils.AttributeSv1Ping, new(utils.CGREvent), &reply); err != nil {
t.Error(err)
} else if reply != utils.Pong {
t.Errorf("Received: %s", reply)
}
if dispEngine.RCP == nil {
t.Fatal(dispEngine.RCP)
if dispEngine.RPC == nil {
t.Fatal(dispEngine.RPC)
}
if err := dispEngine.RCP.Call(utils.AttributeSv1Ping, &utils.CGREventWithArgDispatcher{
if err := dispEngine.RPC.Call(utils.AttributeSv1Ping, &utils.CGREventWithArgDispatcher{
CGREvent: &utils.CGREvent{Tenant: "cgrates.org"},
}, &reply); err != nil {
t.Error(err)

View File

@@ -213,7 +213,7 @@ func (dS *DispatcherService) CacheSv1GetCacheStats(args *utils.AttrCacheIDsWithA
routeID = args.ArgDispatcher.RouteID
}
return dS.Dispatch(&utils.CGREvent{Tenant: tnt}, utils.MetaCaches, routeID,
utils.CacheSv1GetCacheStats, args.CacheIDs, reply)
utils.CacheSv1GetCacheStats, args, reply)
}
// PrecacheStatus checks status of active precache processes

View File

@@ -45,24 +45,32 @@ var sTestsDspChc = []func(t *testing.T){
//Test start here
func TestDspCacheSv1TMySQL(t *testing.T) {
testDsp(t, sTestsDspChc, "TestDspCacheSv1", "all", "all2", "dispatchers", "tutorial", "oldtutorial", "dispatchers")
if *encoding == utils.MetaGOB {
testDsp(t, sTestsDspChc, "TestDspCacheSv1", "all", "all2", "dispatchers", "tutorial", "oldtutorial", "dispatchers_gob")
} else {
testDsp(t, sTestsDspChc, "TestDspCacheSv1", "all", "all2", "dispatchers", "tutorial", "oldtutorial", "dispatchers")
}
}
func TestDspCacheSv1Mongo(t *testing.T) {
testDsp(t, sTestsDspChc, "TestDspCacheSv1", "all", "all2", "dispatchers_mongo", "tutorial", "oldtutorial", "dispatchers")
if *encoding == utils.MetaGOB {
testDsp(t, sTestsDspChc, "TestDspCacheSv1", "all", "all2", "dispatchers_mongo", "tutorial", "oldtutorial", "dispatchers_gob")
} else {
testDsp(t, sTestsDspChc, "TestDspCacheSv1", "all", "all2", "dispatchers_mongo", "tutorial", "oldtutorial", "dispatchers")
}
}
func testDspChcPing(t *testing.T) {
var reply string
if err := allEngine.RCP.Call(utils.CacheSv1Ping, new(utils.CGREvent), &reply); err != nil {
if err := allEngine.RPC.Call(utils.CacheSv1Ping, new(utils.CGREvent), &reply); err != nil {
t.Error(err)
} else if reply != utils.Pong {
t.Errorf("Received: %s", reply)
}
if dispEngine.RCP == nil {
t.Fatal(dispEngine.RCP)
if dispEngine.RPC == nil {
t.Fatal(dispEngine.RPC)
}
if err := dispEngine.RCP.Call(utils.CacheSv1Ping, &utils.CGREventWithArgDispatcher{
if err := dispEngine.RPC.Call(utils.CacheSv1Ping, &utils.CGREventWithArgDispatcher{
CGREvent: &utils.CGREvent{
Tenant: "cgrates.org",
},
@@ -92,14 +100,14 @@ func testDspChcLoadAfterFolder(t *testing.T) {
Tenant: "cgrates.org",
},
}
if err := dispEngine.RCP.Call(utils.CacheSv1GetCacheStats, args, &rcvStats); err != nil {
if err := dispEngine.RPC.Call(utils.CacheSv1GetCacheStats, args, &rcvStats); err != nil {
t.Error(err)
} else if !reflect.DeepEqual(expStats, rcvStats) {
t.Errorf("Expecting: %+v, \n received: %+v", utils.ToJSON(expStats), utils.ToJSON(rcvStats))
}
reply := ""
// Simple test that command is executed without errors
if err := dispEngine.RCP.Call(utils.CacheSv1LoadCache, utils.AttrReloadCacheWithArgDispatcher{
if err := dispEngine.RPC.Call(utils.CacheSv1LoadCache, utils.AttrReloadCacheWithArgDispatcher{
ArgDispatcher: &utils.ArgDispatcher{
APIKey: utils.StringPointer("chc12345"),
},
@@ -126,7 +134,7 @@ func testDspChcLoadAfterFolder(t *testing.T) {
expStats[utils.CacheThresholdProfiles].Items = 2
expStats[utils.CacheThresholds].Items = 2
expStats[utils.CacheLoadIDs].Items = 20
if err := dispEngine.RCP.Call(utils.CacheSv1GetCacheStats, &args, &rcvStats); err != nil {
if err := dispEngine.RPC.Call(utils.CacheSv1GetCacheStats, &args, &rcvStats); err != nil {
t.Error(err)
} else if !reflect.DeepEqual(expStats, rcvStats) {
t.Errorf("Expecting: %+v, \n received: %+v", utils.ToJSON(expStats), utils.ToJSON(rcvStats))
@@ -169,7 +177,7 @@ func testDspChcPrecacheStatus(t *testing.T) {
utils.CacheLoadIDs: utils.MetaReady,
}
if err := dispEngine.RCP.Call(utils.CacheSv1PrecacheStatus, utils.AttrCacheIDsWithArgDispatcher{
if err := dispEngine.RPC.Call(utils.CacheSv1PrecacheStatus, utils.AttrCacheIDsWithArgDispatcher{
ArgDispatcher: &utils.ArgDispatcher{
APIKey: utils.StringPointer("chc12345"),
},
@@ -197,7 +205,7 @@ func testDspChcGetItemIDs(t *testing.T) {
Tenant: "cgrates.org",
},
}
if err := dispEngine.RCP.Call(utils.CacheSv1GetItemIDs, argsAPI, &rcvKeys); err != nil {
if err := dispEngine.RPC.Call(utils.CacheSv1GetItemIDs, argsAPI, &rcvKeys); err != nil {
t.Fatalf("Got error on ApierV1.GetCacheStats: %s ", err.Error())
}
if !reflect.DeepEqual(expKeys, rcvKeys) {
@@ -220,7 +228,7 @@ func testDspChcHasItem(t *testing.T) {
Tenant: "cgrates.org",
},
}
if err := dispEngine.RCP.Call(utils.CacheSv1HasItem, argsAPI, &reply); err != nil {
if err := dispEngine.RPC.Call(utils.CacheSv1HasItem, argsAPI, &reply); err != nil {
t.Error(err)
} else if !reply {
t.Errorf("Expected: %v , received:%v", expected, reply)
@@ -242,7 +250,7 @@ func testDspChcGetItemExpiryTime(t *testing.T) {
Tenant: "cgrates.org",
},
}
if err := dispEngine.RCP.Call(utils.CacheSv1GetItemExpiryTime, argsAPI, &reply); err != nil {
if err := dispEngine.RPC.Call(utils.CacheSv1GetItemExpiryTime, argsAPI, &reply); err != nil {
t.Error(err)
} else if !reflect.DeepEqual(expected, reply) {
t.Errorf("Expected: %v , received:%v", expected, reply)
@@ -251,7 +259,7 @@ func testDspChcGetItemExpiryTime(t *testing.T) {
func testDspChcReloadCache(t *testing.T) {
reply := ""
if err := dispEngine.RCP.Call(utils.CacheSv1ReloadCache, utils.AttrReloadCacheWithArgDispatcher{
if err := dispEngine.RPC.Call(utils.CacheSv1ReloadCache, utils.AttrReloadCacheWithArgDispatcher{
ArgDispatcher: &utils.ArgDispatcher{
APIKey: utils.StringPointer("chc12345"),
},
@@ -279,18 +287,18 @@ func testDspChcRemoveItem(t *testing.T) {
Tenant: "cgrates.org",
},
}
if err := dispEngine.RCP.Call(utils.CacheSv1HasItem, argsAPI, &reply); err != nil {
if err := dispEngine.RPC.Call(utils.CacheSv1HasItem, argsAPI, &reply); err != nil {
t.Error(err)
} else if !reply {
t.Errorf("Expected: %v , received:%v", true, reply)
}
var remReply string
if err := dispEngine.RCP.Call(utils.CacheSv1RemoveItem, argsAPI, &remReply); err != nil {
if err := dispEngine.RPC.Call(utils.CacheSv1RemoveItem, argsAPI, &remReply); err != nil {
t.Error(err)
} else if remReply != utils.OK {
t.Errorf("Expected: %v , received:%v", utils.OK, remReply)
}
if err := dispEngine.RCP.Call(utils.CacheSv1HasItem, argsAPI, &reply); err != nil {
if err := dispEngine.RPC.Call(utils.CacheSv1HasItem, argsAPI, &reply); err != nil {
t.Error(err)
} else if reply {
t.Errorf("Expected: %v , received:%v", false, reply)
@@ -299,7 +307,7 @@ func testDspChcRemoveItem(t *testing.T) {
func testDspChcClear(t *testing.T) {
reply := ""
if err := dispEngine.RCP.Call(utils.CacheSv1Clear, utils.AttrCacheIDsWithArgDispatcher{
if err := dispEngine.RPC.Call(utils.CacheSv1Clear, utils.AttrCacheIDsWithArgDispatcher{
ArgDispatcher: &utils.ArgDispatcher{
APIKey: utils.StringPointer("chc12345"),
},
@@ -313,7 +321,7 @@ func testDspChcClear(t *testing.T) {
}
var rcvStats map[string]*ltcache.CacheStats
expStats := engine.GetDefaultEmptyCacheStats()
if err := dispEngine.RCP.Call(utils.CacheSv1GetCacheStats, utils.AttrCacheIDsWithArgDispatcher{
if err := dispEngine.RPC.Call(utils.CacheSv1GetCacheStats, utils.AttrCacheIDsWithArgDispatcher{
ArgDispatcher: &utils.ArgDispatcher{
APIKey: utils.StringPointer("chc12345"),
},
@@ -329,7 +337,7 @@ func testDspChcClear(t *testing.T) {
func testDspChcFlush(t *testing.T) {
reply := ""
if err := dispEngine.RCP.Call(utils.CacheSv1FlushCache, utils.AttrReloadCacheWithArgDispatcher{
if err := dispEngine.RPC.Call(utils.CacheSv1FlushCache, utils.AttrReloadCacheWithArgDispatcher{
ArgDispatcher: &utils.ArgDispatcher{
APIKey: utils.StringPointer("chc12345"),
},
@@ -346,7 +354,7 @@ func testDspChcFlush(t *testing.T) {
}
var rcvStats map[string]*ltcache.CacheStats
expStats := engine.GetDefaultEmptyCacheStats()
if err := dispEngine.RCP.Call(utils.CacheSv1GetCacheStats, utils.AttrCacheIDsWithArgDispatcher{
if err := dispEngine.RPC.Call(utils.CacheSv1GetCacheStats, utils.AttrCacheIDsWithArgDispatcher{
ArgDispatcher: &utils.ArgDispatcher{
APIKey: utils.StringPointer("chc12345"),
},

View File

@@ -67,12 +67,12 @@ func TestDspCDRsITMongo(t *testing.T) {
func testDspCDRsPing(t *testing.T) {
var reply string
if err := allEngine.RCP.Call(utils.CDRsV1Ping, new(utils.CGREvent), &reply); err != nil {
if err := allEngine.RPC.Call(utils.CDRsV1Ping, new(utils.CGREvent), &reply); err != nil {
t.Error(err)
} else if reply != utils.Pong {
t.Errorf("Received: %s", reply)
}
if err := dispEngine.RCP.Call(utils.CDRsV1Ping, &utils.CGREventWithArgDispatcher{
if err := dispEngine.RPC.Call(utils.CDRsV1Ping, &utils.CGREventWithArgDispatcher{
CGREvent: &utils.CGREvent{
Tenant: "cgrates.org",
},
@@ -110,7 +110,7 @@ func testDspCDRsProcessEvent(t *testing.T) {
},
}
if err := dispEngine.RCP.Call(utils.CDRsV1ProcessEvent, args, &reply); err != nil {
if err := dispEngine.RPC.Call(utils.CDRsV1ProcessEvent, args, &reply); err != nil {
t.Error(err)
} else if reply != utils.OK {
t.Errorf("Received: %s", reply)
@@ -133,7 +133,7 @@ func testDspCDRsCountCDR(t *testing.T) {
},
}
if err := dispEngine.RCP.Call(utils.CDRsV1CountCDRs, args, &reply); err != nil {
if err := dispEngine.RPC.Call(utils.CDRsV1CountCDRs, args, &reply); err != nil {
t.Error(err)
} else if reply != 1 {
t.Errorf("Received: %+v", reply)
@@ -155,7 +155,7 @@ func testDspCDRsGetCDR(t *testing.T) {
},
}
if err := dispEngine.RCP.Call(utils.CDRsV1GetCDRs, args, &reply); err != nil {
if err := dispEngine.RPC.Call(utils.CDRsV1GetCDRs, args, &reply); err != nil {
t.Error(err)
} else if len(reply) != 1 {
t.Errorf("Received: %+v", reply)
@@ -176,7 +176,7 @@ func testDspCDRsGetCDRWithoutTenant(t *testing.T) {
},
}
if err := dispEngine.RCP.Call(utils.CDRsV1GetCDRs, args, &reply); err != nil {
if err := dispEngine.RPC.Call(utils.CDRsV1GetCDRs, args, &reply); err != nil {
t.Error(err)
} else if len(reply) != 1 {
t.Errorf("Received: %+v", reply)
@@ -204,7 +204,7 @@ func testDspCDRsProcessCDR(t *testing.T) {
APIKey: utils.StringPointer("cdrs12345"),
},
}
if err := dispEngine.RCP.Call(utils.CDRsV1ProcessCDR, args, &reply); err != nil {
if err := dispEngine.RPC.Call(utils.CDRsV1ProcessCDR, args, &reply); err != nil {
t.Error(err)
} else if reply != utils.OK {
t.Errorf("Received: %s", reply)
@@ -228,7 +228,7 @@ func testDspCDRsGetCDR2(t *testing.T) {
},
}
if err := dispEngine.RCP.Call(utils.CDRsV1GetCDRs, args, &reply); err != nil {
if err := dispEngine.RPC.Call(utils.CDRsV1GetCDRs, args, &reply); err != nil {
t.Error(err)
} else if len(reply) != 1 {
t.Errorf("Received: %+v", reply)
@@ -260,7 +260,7 @@ func testDspCDRsProcessExternalCDR(t *testing.T) {
APIKey: utils.StringPointer("cdrs12345"),
},
}
if err := dispEngine.RCP.Call(utils.CDRsV1ProcessExternalCDR, args, &reply); err != nil {
if err := dispEngine.RPC.Call(utils.CDRsV1ProcessExternalCDR, args, &reply); err != nil {
t.Error(err)
} else if reply != utils.OK {
t.Errorf("Received: %s", reply)
@@ -284,7 +284,7 @@ func testDspCDRsGetCDR3(t *testing.T) {
},
}
if err := dispEngine.RCP.Call(utils.CDRsV1GetCDRs, args, &reply); err != nil {
if err := dispEngine.RPC.Call(utils.CDRsV1GetCDRs, args, &reply); err != nil {
t.Error(err)
} else if len(reply) != 1 {
t.Errorf("Received: %+v", reply)
@@ -295,12 +295,12 @@ func testDspCDRsGetCDR3(t *testing.T) {
func testDspCDRsPingNoAuth(t *testing.T) {
var reply string
if err := allEngine.RCP.Call(utils.CDRsV1Ping, new(utils.CGREvent), &reply); err != nil {
if err := allEngine.RPC.Call(utils.CDRsV1Ping, new(utils.CGREvent), &reply); err != nil {
t.Error(err)
} else if reply != utils.Pong {
t.Errorf("Received: %s", reply)
}
if err := dispEngine.RCP.Call(utils.CDRsV1Ping, &utils.CGREventWithArgDispatcher{
if err := dispEngine.RPC.Call(utils.CDRsV1Ping, &utils.CGREventWithArgDispatcher{
CGREvent: &utils.CGREvent{
Tenant: "cgrates.org",
},
@@ -332,7 +332,7 @@ func testDspCDRsProcessEventNoAuth(t *testing.T) {
},
}
if err := dispEngine.RCP.Call(utils.CDRsV1ProcessEvent, args, &reply); err != nil {
if err := dispEngine.RPC.Call(utils.CDRsV1ProcessEvent, args, &reply); err != nil {
t.Error(err)
} else if reply != utils.OK {
t.Errorf("Received: %s", reply)
@@ -352,7 +352,7 @@ func testDspCDRsCountCDRNoAuth(t *testing.T) {
},
}
if err := dispEngine.RCP.Call(utils.CDRsV1CountCDRs, args, &reply); err != nil {
if err := dispEngine.RPC.Call(utils.CDRsV1CountCDRs, args, &reply); err != nil {
t.Error(err)
} else if reply != 1 {
t.Errorf("Received: %+v", reply)
@@ -371,7 +371,7 @@ func testDspCDRsGetCDRNoAuth(t *testing.T) {
},
}
if err := dispEngine.RCP.Call(utils.CDRsV1GetCDRs, args, &reply); err != nil {
if err := dispEngine.RPC.Call(utils.CDRsV1GetCDRs, args, &reply); err != nil {
t.Error(err)
} else if len(reply) != 1 {
t.Errorf("Received: %+v", reply)
@@ -389,7 +389,7 @@ func testDspCDRsGetCDRNoAuthWithoutTenant(t *testing.T) {
},
}
if err := dispEngine.RCP.Call(utils.CDRsV1GetCDRs, args, &reply); err != nil {
if err := dispEngine.RPC.Call(utils.CDRsV1GetCDRs, args, &reply); err != nil {
t.Error(err)
} else if len(reply) != 1 {
t.Errorf("Received: %+v", reply)
@@ -414,7 +414,7 @@ func testDspCDRsProcessCDRNoAuth(t *testing.T) {
Usage: time.Duration(2) * time.Minute,
},
}
if err := dispEngine.RCP.Call(utils.CDRsV1ProcessCDR, args, &reply); err != nil {
if err := dispEngine.RPC.Call(utils.CDRsV1ProcessCDR, args, &reply); err != nil {
t.Error(err)
} else if reply != utils.OK {
t.Errorf("Received: %s", reply)
@@ -435,7 +435,7 @@ func testDspCDRsGetCDR2NoAuth(t *testing.T) {
},
}
if err := dispEngine.RCP.Call(utils.CDRsV1GetCDRs, args, &reply); err != nil {
if err := dispEngine.RPC.Call(utils.CDRsV1GetCDRs, args, &reply); err != nil {
t.Error(err)
} else if len(reply) != 1 {
t.Errorf("Received: %+v", reply)
@@ -464,7 +464,7 @@ func testDspCDRsProcessExternalCDRNoAuth(t *testing.T) {
ExtraFields: map[string]string{"field_extr1": "val_extr1", "fieldextr2": "valextr2"},
},
}
if err := dispEngine.RCP.Call(utils.CDRsV1ProcessExternalCDR, args, &reply); err != nil {
if err := dispEngine.RPC.Call(utils.CDRsV1ProcessExternalCDR, args, &reply); err != nil {
t.Error(err)
} else if reply != utils.OK {
t.Errorf("Received: %s", reply)
@@ -485,7 +485,7 @@ func testDspCDRsGetCDR3NoAuth(t *testing.T) {
},
}
if err := dispEngine.RCP.Call(utils.CDRsV1GetCDRs, args, &reply); err != nil {
if err := dispEngine.RPC.Call(utils.CDRsV1GetCDRs, args, &reply); err != nil {
t.Error(err)
} else if len(reply) != 1 {
t.Errorf("Received: %+v", reply)

View File

@@ -49,7 +49,7 @@ func TestDspChargerSMongo(t *testing.T) {
func testDspCppPingFailover(t *testing.T) {
var reply string
if err := allEngine.RCP.Call(utils.ChargerSv1Ping, new(utils.CGREvent), &reply); err != nil {
if err := allEngine.RPC.Call(utils.ChargerSv1Ping, new(utils.CGREvent), &reply); err != nil {
t.Error(err)
} else if reply != utils.Pong {
t.Errorf("Received: %s", reply)
@@ -62,19 +62,19 @@ func testDspCppPingFailover(t *testing.T) {
APIKey: utils.StringPointer("chrg12345"),
},
}
if err := dispEngine.RCP.Call(utils.ChargerSv1Ping, &ev, &reply); err != nil {
if err := dispEngine.RPC.Call(utils.ChargerSv1Ping, &ev, &reply); err != nil {
t.Error(err)
} else if reply != utils.Pong {
t.Errorf("Received: %s", reply)
}
allEngine.stopEngine(t)
if err := dispEngine.RCP.Call(utils.ChargerSv1Ping, &ev, &reply); err != nil {
if err := dispEngine.RPC.Call(utils.ChargerSv1Ping, &ev, &reply); err != nil {
t.Error(err)
} else if reply != utils.Pong {
t.Errorf("Received: %s", reply)
}
allEngine2.stopEngine(t)
if err := dispEngine.RCP.Call(utils.ChargerSv1Ping, &ev, &reply); err == nil {
if err := dispEngine.RPC.Call(utils.ChargerSv1Ping, &ev, &reply); err == nil {
t.Errorf("Expected error but recived %v and reply %v\n", err, reply)
}
allEngine.startEngine(t)
@@ -106,7 +106,7 @@ func testDspCppGetChtgFailover(t *testing.T) {
},
}
var reply *engine.ChargerProfiles
if err := dispEngine.RCP.Call(utils.ChargerSv1GetChargersForEvent,
if err := dispEngine.RPC.Call(utils.ChargerSv1GetChargersForEvent,
args, &reply); err != nil {
t.Error(err)
} else if !reflect.DeepEqual(eChargers, reply) {
@@ -115,7 +115,7 @@ func testDspCppGetChtgFailover(t *testing.T) {
allEngine2.stopEngine(t)
if err := dispEngine.RCP.Call(utils.ChargerSv1GetChargersForEvent,
if err := dispEngine.RPC.Call(utils.ChargerSv1GetChargersForEvent,
args, &reply); err != nil {
t.Error(err)
} else if !reflect.DeepEqual(eChargers, reply) {
@@ -127,12 +127,12 @@ func testDspCppGetChtgFailover(t *testing.T) {
func testDspCppPing(t *testing.T) {
var reply string
if err := allEngine.RCP.Call(utils.ChargerSv1Ping, new(utils.CGREvent), &reply); err != nil {
if err := allEngine.RPC.Call(utils.ChargerSv1Ping, new(utils.CGREvent), &reply); err != nil {
t.Error(err)
} else if reply != utils.Pong {
t.Errorf("Received: %s", reply)
}
if err := dispEngine.RCP.Call(utils.ChargerSv1Ping, &utils.CGREventWithArgDispatcher{
if err := dispEngine.RPC.Call(utils.ChargerSv1Ping, &utils.CGREventWithArgDispatcher{
CGREvent: &utils.CGREvent{
Tenant: "cgrates.org",
},
@@ -160,7 +160,7 @@ func testDspCppTestAuthKey(t *testing.T) {
},
}
var reply *engine.ChargerProfiles
if err := dispEngine.RCP.Call(utils.ChargerSv1GetChargersForEvent,
if err := dispEngine.RPC.Call(utils.ChargerSv1GetChargersForEvent,
args, &reply); err == nil || err.Error() != utils.ErrUnauthorizedApi.Error() {
t.Error(err)
}
@@ -190,7 +190,7 @@ func testDspCppTestAuthKey2(t *testing.T) {
},
}
var reply *engine.ChargerProfiles
if err := dispEngine.RCP.Call(utils.ChargerSv1GetChargersForEvent,
if err := dispEngine.RPC.Call(utils.ChargerSv1GetChargersForEvent,
args, &reply); err != nil {
t.Error(err)
} else if !reflect.DeepEqual(eChargers, reply) {
@@ -224,14 +224,14 @@ func testDspCppGetChtgRoundRobin(t *testing.T) {
}
var reply *engine.ChargerProfiles
// To ALL2
if err := dispEngine.RCP.Call(utils.ChargerSv1GetChargersForEvent,
if err := dispEngine.RPC.Call(utils.ChargerSv1GetChargersForEvent,
args, &reply); err != nil {
t.Error(err)
} else if !reflect.DeepEqual(eChargers, reply) {
t.Errorf("Expecting : %+v, received: %+v", utils.ToJSON(eChargers), utils.ToJSON(reply))
}
// To ALL
if err := dispEngine.RCP.Call(utils.ChargerSv1GetChargersForEvent,
if err := dispEngine.RPC.Call(utils.ChargerSv1GetChargersForEvent,
args, &reply); err != nil {
t.Error(err)
} else if !reflect.DeepEqual(eChargers, reply) {

View File

@@ -47,7 +47,7 @@ func testDspConfigSv1GetJSONSection(t *testing.T) {
"RPCJSONTLSListen": "127.0.0.1:2022",
}
var reply map[string]interface{}
if err := dispEngine.RCP.Call(utils.ConfigSv1GetJSONSection, &config.StringWithArgDispatcher{
if err := dispEngine.RPC.Call(utils.ConfigSv1GetJSONSection, &config.StringWithArgDispatcher{
TenantArg: utils.TenantArg{
Tenant: "cgrates.org",
},

View File

@@ -20,6 +20,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
package dispatchers
// for the moment we dispable Apier through dispatcher
// until we figured out a better sollution in case of gob server
/*
import (
"reflect"
@@ -72,7 +74,7 @@ func testDspApierSetAttributes(t *testing.T) {
utils.APIKey: utils.StringPointer("apier12345"),
}
var result string
if err := dispEngine.RCP.Call(utils.ApierV1SetAttributeProfile, ev, &result); err != nil {
if err := dispEngine.RPC.Call(utils.ApierV1SetAttributeProfile, ev, &result); err != nil {
t.Error(err)
} else if result != utils.OK {
t.Error("Unexpected reply returned", result)
@@ -105,7 +107,7 @@ func testDspApierGetAttributes(t *testing.T) {
Weight: 10,
}
alsPrf.Compile()
if err := dispEngine.RCP.Call(utils.ApierV1GetAttributeProfile,
if err := dispEngine.RPC.Call(utils.ApierV1GetAttributeProfile,
utils.TenantIDWithArgDispatcher{
TenantID: &utils.TenantID{Tenant: "cgrates.org", ID: "ATTR_Dispatcher"},
ArgDispatcher: &utils.ArgDispatcher{APIKey: utils.StringPointer("apier12345")},
@@ -121,7 +123,7 @@ func testDspApierGetAttributes(t *testing.T) {
func testDspApierUnkownAPiKey(t *testing.T) {
var reply *engine.AttributeProfile
if err := dispEngine.RCP.Call(utils.ApierV1GetAttributeProfile,
if err := dispEngine.RPC.Call(utils.ApierV1GetAttributeProfile,
utils.TenantIDWithArgDispatcher{
TenantID: &utils.TenantID{Tenant: "cgrates.org", ID: "ATTR_Dispatcher"},
ArgDispatcher: &utils.ArgDispatcher{APIKey: utils.StringPointer("RandomApiKey")},

View File

@@ -40,17 +40,17 @@ func TestDspGuardianSTMySQL(t *testing.T) {
func testDspGrdPing(t *testing.T) {
var reply string
if err := allEngine.RCP.Call(utils.GuardianSv1Ping, nil, &reply); err != nil {
if err := allEngine.RPC.Call(utils.GuardianSv1Ping, nil, &reply); err != nil {
t.Error(err)
} else if reply != utils.Pong {
t.Errorf("Received: %s", reply)
}
if err := allEngine.RCP.Call(utils.GuardianSv1Ping, new(utils.CGREvent), &reply); err != nil {
if err := allEngine.RPC.Call(utils.GuardianSv1Ping, new(utils.CGREvent), &reply); err != nil {
t.Error(err)
} else if reply != utils.Pong {
t.Errorf("Received: %s", reply)
}
if err := dispEngine.RCP.Call(utils.GuardianSv1Ping, &utils.CGREventWithArgDispatcher{
if err := dispEngine.RPC.Call(utils.GuardianSv1Ping, &utils.CGREventWithArgDispatcher{
CGREvent: &utils.CGREvent{
Tenant: "cgrates.org",
},
@@ -72,7 +72,7 @@ func testDspGrdLock(t *testing.T) {
Timeout: 500 * time.Millisecond,
}
var reply string
if err := dispEngine.RCP.Call(utils.GuardianSv1RemoteLock, &AttrRemoteLockWithApiKey{
if err := dispEngine.RPC.Call(utils.GuardianSv1RemoteLock, &AttrRemoteLockWithApiKey{
AttrRemoteLock: args,
TenantArg: utils.TenantArg{
Tenant: "cgrates.org",
@@ -85,7 +85,7 @@ func testDspGrdLock(t *testing.T) {
}
var unlockReply []string
if err := dispEngine.RCP.Call(utils.GuardianSv1RemoteUnlock, &AttrRemoteUnlockWithApiKey{
if err := dispEngine.RPC.Call(utils.GuardianSv1RemoteUnlock, &AttrRemoteUnlockWithApiKey{
RefID: reply,
TenantArg: utils.TenantArg{
Tenant: "cgrates.org",

View File

@@ -19,6 +19,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
package dispatchers
import (
"errors"
"flag"
"net/rpc"
"net/rpc/jsonrpc"
"os/exec"
@@ -37,11 +39,25 @@ var (
allEngine *testDispatcher
allEngine2 *testDispatcher
)
var (
encoding = flag.String("rpc", utils.MetaJSON, "what encoding whould be uused for rpc comunication")
)
func newRPCClient(cfg *config.ListenCfg) (c *rpc.Client, err error) {
switch *encoding {
case utils.MetaJSON:
return jsonrpc.Dial(utils.TCP, cfg.RPCJSONListen)
case utils.MetaGOB:
return rpc.Dial(utils.TCP, cfg.RPCGOBListen)
default:
return nil, errors.New("UNSUPPORTED_RPC")
}
}
type testDispatcher struct {
CfgParh string
Cfg *config.CGRConfig
RCP *rpc.Client
RPC *rpc.Client
cmd *exec.Cmd
}
@@ -72,7 +88,7 @@ func (d *testDispatcher) startEngine(t *testing.T) {
t.Fatalf("Error at engine start:%v\n", err)
}
if d.RCP, err = jsonrpc.Dial("tcp", d.Cfg.ListenCfg().RPCJSONListen); err != nil {
if d.RPC, err = newRPCClient(d.Cfg.ListenCfg()); err != nil {
t.Fatalf("Error at dialing rcp client:%v\n", err)
}
}
@@ -102,7 +118,7 @@ func (d *testDispatcher) resetStorDb(t *testing.T) {
func (d *testDispatcher) loadData(t *testing.T, path string) {
var reply string
attrs := &utils.AttrLoadTpFromFolder{FolderPath: path}
if err := d.RCP.Call(utils.ApierV1LoadTariffPlanFromFolder, attrs, &reply); err != nil {
if err := d.RPC.Call(utils.ApierV1LoadTariffPlanFromFolder, attrs, &reply); err != nil {
t.Errorf("<%s>Error at loading data from folder :%v", d.CfgParh, err)
}
}

View File

@@ -39,12 +39,12 @@ func TestDspRALsITMySQL(t *testing.T) {
func testDspRALsPing(t *testing.T) {
var reply string
if err := allEngine.RCP.Call(utils.RALsV1Ping, new(utils.CGREvent), &reply); err != nil {
if err := allEngine.RPC.Call(utils.RALsV1Ping, new(utils.CGREvent), &reply); err != nil {
t.Error(err)
} else if reply != utils.Pong {
t.Errorf("Received: %s", reply)
}
if err := dispEngine.RCP.Call(utils.RALsV1Ping, &utils.CGREventWithArgDispatcher{
if err := dispEngine.RPC.Call(utils.RALsV1Ping, &utils.CGREventWithArgDispatcher{
CGREvent: &utils.CGREvent{
Tenant: "cgrates.org",
},
@@ -69,7 +69,7 @@ func testDspRALsGetRatingPlanCost(t *testing.T) {
},
}
var reply RatingPlanCost
if err := dispEngine.RCP.Call(utils.RALsV1GetRatingPlansCost, arg, &reply); err != nil {
if err := dispEngine.RPC.Call(utils.RALsV1GetRatingPlansCost, arg, &reply); err != nil {
t.Error(err)
} else if reply.RatingPlanID != "RP_1001" {
t.Error("Unexpected RatingPlanID: ", reply.RatingPlanID)

View File

@@ -48,7 +48,7 @@ func TestDspResourceSITMongo(t *testing.T) {
func testDspResPingFailover(t *testing.T) {
var reply string
if err := allEngine.RCP.Call(utils.ResourceSv1Ping, new(utils.CGREvent), &reply); err != nil {
if err := allEngine.RPC.Call(utils.ResourceSv1Ping, new(utils.CGREvent), &reply); err != nil {
t.Error(err)
} else if reply != utils.Pong {
t.Errorf("Received: %s", reply)
@@ -61,19 +61,19 @@ func testDspResPingFailover(t *testing.T) {
APIKey: utils.StringPointer("res12345"),
},
}
if err := dispEngine.RCP.Call(utils.ResourceSv1Ping, &ev, &reply); err != nil {
if err := dispEngine.RPC.Call(utils.ResourceSv1Ping, &ev, &reply); err != nil {
t.Error(err)
} else if reply != utils.Pong {
t.Errorf("Received: %s", reply)
}
allEngine.stopEngine(t)
if err := dispEngine.RCP.Call(utils.ResourceSv1Ping, &ev, &reply); err != nil {
if err := dispEngine.RPC.Call(utils.ResourceSv1Ping, &ev, &reply); err != nil {
t.Error(err)
} else if reply != utils.Pong {
t.Errorf("Received: %s", reply)
}
allEngine2.stopEngine(t)
if err := dispEngine.RCP.Call(utils.ResourceSv1Ping, &ev, &reply); err == nil {
if err := dispEngine.RPC.Call(utils.ResourceSv1Ping, &ev, &reply); err == nil {
t.Errorf("Expected error but recived %v and reply %v\n", err, reply)
}
allEngine.startEngine(t)
@@ -82,12 +82,12 @@ func testDspResPingFailover(t *testing.T) {
func testDspResPing(t *testing.T) {
var reply string
if err := allEngine.RCP.Call(utils.ResourceSv1Ping, new(utils.CGREvent), &reply); err != nil {
if err := allEngine.RPC.Call(utils.ResourceSv1Ping, new(utils.CGREvent), &reply); err != nil {
t.Error(err)
} else if reply != utils.Pong {
t.Errorf("Received: %s", reply)
}
if err := dispEngine.RCP.Call(utils.ResourceSv1Ping, &utils.CGREventWithArgDispatcher{
if err := dispEngine.RPC.Call(utils.ResourceSv1Ping, &utils.CGREventWithArgDispatcher{
CGREvent: &utils.CGREvent{
Tenant: "cgrates.org",
},
@@ -118,7 +118,7 @@ func testDspResTestAuthKey(t *testing.T) {
},
}
if err := dispEngine.RCP.Call(utils.ResourceSv1GetResourcesForEvent,
if err := dispEngine.RPC.Call(utils.ResourceSv1GetResourcesForEvent,
args, &rs); err == nil || err.Error() != utils.ErrUnauthorizedApi.Error() {
t.Error(err)
}
@@ -148,7 +148,7 @@ func testDspResTestAuthKey2(t *testing.T) {
},
}
if err := dispEngine.RCP.Call(utils.ResourceSv1GetResourcesForEvent,
if err := dispEngine.RPC.Call(utils.ResourceSv1GetResourcesForEvent,
args, &rs); err != nil {
t.Error(err)
} else if !reflect.DeepEqual(eRs, rs) {
@@ -174,7 +174,7 @@ func testDspResTestAuthKey3(t *testing.T) {
APIKey: utils.StringPointer("res12345"),
},
}
if err := dispEngine.RCP.Call(utils.ResourceSv1AllocateResources,
if err := dispEngine.RPC.Call(utils.ResourceSv1AllocateResources,
argsRU, &reply); err != nil {
t.Error(err)
}
@@ -183,7 +183,7 @@ func testDspResTestAuthKey3(t *testing.T) {
t.Errorf("Expecting: %+v, received: %+v", eAllocationMsg, reply)
}
if err := dispEngine.RCP.Call(utils.ResourceSv1AuthorizeResources, argsRU, &reply); err != nil {
if err := dispEngine.RPC.Call(utils.ResourceSv1AuthorizeResources, argsRU, &reply); err != nil {
t.Error(err)
} else if reply != eAllocationMsg { // already 3 usages active before allow call, we should have now more than allowed
t.Errorf("Expecting: %+v, received: %+v", eAllocationMsg, reply)
@@ -203,7 +203,7 @@ func testDspResTestAuthKey3(t *testing.T) {
APIKey: utils.StringPointer("res12345"),
},
}
if err := dispEngine.RCP.Call(utils.ResourceSv1AuthorizeResources,
if err := dispEngine.RPC.Call(utils.ResourceSv1AuthorizeResources,
argsRU, &reply); err == nil || err.Error() != utils.ErrResourceUnauthorized.Error() {
t.Error(err)
}
@@ -223,7 +223,7 @@ func testDspResTestAuthKey3(t *testing.T) {
APIKey: utils.StringPointer("res12345"),
},
}
if err := dispEngine.RCP.Call(utils.ResourceSv1ReleaseResources,
if err := dispEngine.RPC.Call(utils.ResourceSv1ReleaseResources,
argsRU, &reply); err != nil {
t.Error(err)
}
@@ -244,7 +244,7 @@ func testDspResTestAuthKey3(t *testing.T) {
APIKey: utils.StringPointer("res12345"),
},
}
if err := dispEngine.RCP.Call(utils.ResourceSv1AuthorizeResources, argsRU, &reply); err != nil {
if err := dispEngine.RPC.Call(utils.ResourceSv1AuthorizeResources, argsRU, &reply); err != nil {
t.Error(err)
} else if reply != "ResGroup1" {
t.Error("Unexpected reply returned", reply)
@@ -264,7 +264,7 @@ func testDspResTestAuthKey3(t *testing.T) {
APIKey: utils.StringPointer("res12345"),
},
}
if err := dispEngine.RCP.Call(utils.ResourceSv1GetResourcesForEvent, args, &rs); err != nil {
if err := dispEngine.RPC.Call(utils.ResourceSv1GetResourcesForEvent, args, &rs); err != nil {
t.Error(err)
} else if len(*rs) != 1 {
t.Errorf("Resources: %+v", utils.ToJSON(rs))

View File

@@ -47,7 +47,7 @@ func TestDspResponderMongo(t *testing.T) {
func testDspResponderStatus(t *testing.T) {
var reply map[string]interface{}
if err := allEngine.RCP.Call(utils.CoreSv1Status, utils.TenantWithArgDispatcher{}, &reply); err != nil {
if err := allEngine.RPC.Call(utils.CoreSv1Status, utils.TenantWithArgDispatcher{}, &reply); err != nil {
t.Error(err)
} else if reply[utils.NodeID] != "ALL" {
t.Errorf("Received: %s", reply)
@@ -60,13 +60,13 @@ func testDspResponderStatus(t *testing.T) {
APIKey: utils.StringPointer("rsp12345"),
},
}
if err := dispEngine.RCP.Call(utils.CoreSv1Status, &ev, &reply); err != nil {
if err := dispEngine.RPC.Call(utils.CoreSv1Status, &ev, &reply); err != nil {
t.Error(err)
} else if reply[utils.NodeID] != "ALL" {
t.Errorf("Received: %s", utils.ToJSON(reply))
}
allEngine.stopEngine(t)
if err := dispEngine.RCP.Call(utils.CoreSv1Status, &ev, &reply); err != nil {
if err := dispEngine.RPC.Call(utils.CoreSv1Status, &ev, &reply); err != nil {
t.Error(err)
} else if reply[utils.NodeID] != "ALL2" {
t.Errorf("Received: %s", utils.ToJSON(reply))
@@ -99,12 +99,12 @@ func getNodeWithRoute(route string, t *testing.T) string {
},
}
if err := dispEngine.RCP.Call(utils.CoreSv1Ping, pingEv, &pingReply); err != nil {
if err := dispEngine.RPC.Call(utils.CoreSv1Ping, pingEv, &pingReply); err != nil {
t.Error(err)
} else if pingReply != utils.Pong {
t.Errorf("Received: %s", pingReply)
}
if err := dispEngine.RCP.Call(utils.CoreSv1Status, ev, &reply); err != nil {
if err := dispEngine.RPC.Call(utils.CoreSv1Status, ev, &reply); err != nil {
t.Error(err)
}
if reply[utils.NodeID] == nil {
@@ -134,17 +134,17 @@ func testDspResponderShutdown(t *testing.T) {
APIKey: utils.StringPointer("rsp12345"),
},
}
if err := dispEngine.RCP.Call(utils.ResponderShutdown, ev, &reply); err != nil {
if err := dispEngine.RPC.Call(utils.ResponderShutdown, ev, &reply); err != nil {
t.Error(err)
} else if reply != "Done!" {
t.Errorf("Received: %s", utils.ToJSON(reply))
}
if err := dispEngine.RCP.Call(utils.CoreSv1Status, &ev, &statusReply); err != nil {
if err := dispEngine.RPC.Call(utils.CoreSv1Status, &ev, &statusReply); err != nil {
t.Error(err)
} else if statusReply[utils.NodeID] != "ALL2" {
t.Errorf("Received: %s", utils.ToJSON(statusReply))
}
if err := dispEngine.RCP.Call(utils.ResponderShutdown, &ev, &reply); err != nil {
if err := dispEngine.RPC.Call(utils.ResponderShutdown, &ev, &reply); err != nil {
t.Error(err)
} else if reply != "Done!" {
t.Errorf("Received: %s", utils.ToJSON(reply))
@@ -166,7 +166,7 @@ func testDspResponderBroadcast(t *testing.T) {
APIKey: utils.StringPointer("rsp12345"),
},
}
if err := dispEngine.RCP.Call(utils.ResponderPing, pingEv, &pingReply); err != nil {
if err := dispEngine.RPC.Call(utils.ResponderPing, pingEv, &pingReply); err != nil {
t.Error(err)
} else if pingReply != utils.Pong {
t.Errorf("Received: %s", pingReply)
@@ -174,13 +174,13 @@ func testDspResponderBroadcast(t *testing.T) {
allEngine2.stopEngine(t)
pingReply = ""
if err := dispEngine.RCP.Call(utils.ResponderPing, pingEv, &pingReply); err == nil ||
if err := dispEngine.RPC.Call(utils.ResponderPing, pingEv, &pingReply); err == nil ||
err.Error() != utils.ErrPartiallyExecuted.Error() {
t.Errorf("Expected error: %s received error: %v and reply %q", utils.ErrPartiallyExecuted.Error(), err, pingReply)
}
allEngine.stopEngine(t)
pingReply = ""
if err := dispEngine.RCP.Call(utils.ResponderPing, pingEv, &pingReply); err == nil ||
if err := dispEngine.RPC.Call(utils.ResponderPing, pingEv, &pingReply); err == nil ||
err.Error() != utils.ErrPartiallyExecuted.Error() {
t.Errorf("Expected error: %s received error: %v and reply %q", utils.ErrPartiallyExecuted.Error(), err, pingReply)
}
@@ -213,12 +213,12 @@ func testDspResponderInternal(t *testing.T) {
RouteID: &route,
},
}
if err := dispEngine.RCP.Call(utils.CoreSv1Ping, pingEv, &pingReply); err != nil {
if err := dispEngine.RPC.Call(utils.CoreSv1Ping, pingEv, &pingReply); err != nil {
t.Error(err)
} else if pingReply != utils.Pong {
t.Errorf("Received: %s", pingReply)
}
if err := dispEngine.RCP.Call(utils.CoreSv1Status, &ev, &reply); err != nil {
if err := dispEngine.RPC.Call(utils.CoreSv1Status, &ev, &reply); err != nil {
t.Error(err)
}
if reply[utils.NodeID] == nil {

View File

@@ -37,12 +37,12 @@ func TestDspSchedulerSTMySQL(t *testing.T) {
func testDspSchedPing(t *testing.T) {
var reply string
if err := allEngine.RCP.Call(utils.SchedulerSv1Ping, new(utils.CGREvent), &reply); err != nil {
if err := allEngine.RPC.Call(utils.SchedulerSv1Ping, new(utils.CGREvent), &reply); err != nil {
t.Error(err)
} else if reply != utils.Pong {
t.Errorf("Received: %s", reply)
}
if err := dispEngine.RCP.Call(utils.SchedulerSv1Ping, &utils.CGREventWithArgDispatcher{
if err := dispEngine.RPC.Call(utils.SchedulerSv1Ping, &utils.CGREventWithArgDispatcher{
CGREvent: &utils.CGREvent{
Tenant: "cgrates.org",
},

View File

@@ -79,7 +79,7 @@ func testDspSessionAddBalacne(t *testing.T) {
},
}
var reply string
if err := allEngine.RCP.Call(utils.ApierV2SetBalance, attrSetBalance, &reply); err != nil {
if err := allEngine.RPC.Call(utils.ApierV2SetBalance, attrSetBalance, &reply); err != nil {
t.Error(err)
} else if reply != utils.OK {
t.Errorf("Received: %s", reply)
@@ -90,18 +90,18 @@ func testDspSessionAddBalacne(t *testing.T) {
Account: attrSetBalance.Account,
}
eAcntVal := float64(initUsage)
if err := allEngine.RCP.Call(utils.ApierV2GetAccount, attrs, &acnt); err != nil {
if err := allEngine.RPC.Call(utils.ApierV2GetAccount, attrs, &acnt); err != nil {
t.Error(err)
} else if acnt.BalanceMap[utils.VOICE].GetTotalValue() != eAcntVal {
t.Errorf("Expecting: %v, received: %v",
time.Duration(eAcntVal), time.Duration(acnt.BalanceMap[utils.VOICE].GetTotalValue()))
}
if err := allEngine2.RCP.Call(utils.ApierV2SetBalance, attrSetBalance, &reply); err != nil {
if err := allEngine2.RPC.Call(utils.ApierV2SetBalance, attrSetBalance, &reply); err != nil {
t.Error(err)
} else if reply != utils.OK {
t.Errorf("Received: %s", reply)
}
if err := allEngine2.RCP.Call(utils.ApierV2GetAccount, attrs, &acnt); err != nil {
if err := allEngine2.RPC.Call(utils.ApierV2GetAccount, attrs, &acnt); err != nil {
t.Error(err)
} else if acnt.BalanceMap[utils.VOICE].GetTotalValue() != eAcntVal {
t.Errorf("Expecting: %v, received: %v",
@@ -111,12 +111,12 @@ func testDspSessionAddBalacne(t *testing.T) {
func testDspSessionPing(t *testing.T) {
var reply string
if err := allEngine.RCP.Call(utils.SessionSv1Ping, new(utils.CGREvent), &reply); err != nil {
if err := allEngine.RPC.Call(utils.SessionSv1Ping, new(utils.CGREvent), &reply); err != nil {
t.Error(err)
} else if reply != utils.Pong {
t.Errorf("Received: %s", reply)
}
if err := dispEngine.RCP.Call(utils.SessionSv1Ping, &utils.CGREventWithArgDispatcher{
if err := dispEngine.RPC.Call(utils.SessionSv1Ping, &utils.CGREventWithArgDispatcher{
CGREvent: &utils.CGREvent{
Tenant: "cgrates.org",
},
@@ -132,7 +132,7 @@ func testDspSessionPing(t *testing.T) {
func testDspSessionPingFailover(t *testing.T) {
var reply string
if err := allEngine.RCP.Call(utils.SessionSv1Ping, new(utils.CGREvent), &reply); err != nil {
if err := allEngine.RPC.Call(utils.SessionSv1Ping, new(utils.CGREvent), &reply); err != nil {
t.Error(err)
} else if reply != utils.Pong {
t.Errorf("Received: %s", reply)
@@ -145,19 +145,19 @@ func testDspSessionPingFailover(t *testing.T) {
APIKey: utils.StringPointer("ses12345"),
},
}
if err := dispEngine.RCP.Call(utils.SessionSv1Ping, &ev, &reply); err != nil {
if err := dispEngine.RPC.Call(utils.SessionSv1Ping, &ev, &reply); err != nil {
t.Error(err)
} else if reply != utils.Pong {
t.Errorf("Received: %s", reply)
}
allEngine.stopEngine(t)
if err := dispEngine.RCP.Call(utils.SessionSv1Ping, &ev, &reply); err != nil {
if err := dispEngine.RPC.Call(utils.SessionSv1Ping, &ev, &reply); err != nil {
t.Error(err)
} else if reply != utils.Pong {
t.Errorf("Received: %s", reply)
}
allEngine2.stopEngine(t)
if err := dispEngine.RCP.Call(utils.SessionSv1Ping, &ev, &reply); err == nil {
if err := dispEngine.RPC.Call(utils.SessionSv1Ping, &ev, &reply); err == nil {
t.Errorf("Expected error but recived %v and reply %v\n", err, reply)
}
allEngine.startEngine(t)
@@ -191,7 +191,7 @@ func testDspSessionTestAuthKey(t *testing.T) {
},
}
var rply sessions.V1AuthorizeReplyWithDigest
if err := dispEngine.RCP.Call(utils.SessionSv1AuthorizeEventWithDigest,
if err := dispEngine.RPC.Call(utils.SessionSv1AuthorizeEventWithDigest,
args, &rply); err == nil || err.Error() != utils.ErrUnauthorizedApi.Error() {
t.Error(err)
}
@@ -225,7 +225,7 @@ func testDspSessionAuthorize(t *testing.T) {
},
}
var rply sessions.V1AuthorizeReplyWithDigest
if err := dispEngine.RCP.Call(utils.SessionSv1AuthorizeEventWithDigest,
if err := dispEngine.RPC.Call(utils.SessionSv1AuthorizeEventWithDigest,
argsAuth, &rply); err != nil {
t.Error(err)
return
@@ -277,7 +277,7 @@ func testDspSessionInit(t *testing.T) {
},
}
var rply sessions.V1InitReplyWithDigest
if err := dispEngine.RCP.Call(utils.SessionSv1InitiateSessionWithDigest,
if err := dispEngine.RPC.Call(utils.SessionSv1InitiateSessionWithDigest,
argsInit, &rply); err != nil {
t.Fatal(err)
}
@@ -298,28 +298,28 @@ func testDspGetSessions(t *testing.T) {
Filters: []string{},
}
var reply int
if err := dispEngine.RCP.Call(utils.SessionSv1GetActiveSessionsCount,
if err := dispEngine.RPC.Call(utils.SessionSv1GetActiveSessionsCount,
&filtr, &reply); err != nil {
t.Fatal(err)
} else if reply != 2 {
t.Errorf("Expected 2 active sessions recived %v", reply)
}
var rply []*sessions.ExternalSession
if err := dispEngine.RCP.Call(utils.SessionSv1GetActiveSessions,
if err := dispEngine.RPC.Call(utils.SessionSv1GetActiveSessions,
&filtr, &rply); err != nil {
t.Fatal(err)
} else if len(rply) != 2 {
t.Errorf("Unexpected number of sessions returned %v :%s", len(rply), utils.ToJSON(rply))
}
if err := dispEngine.RCP.Call(utils.SessionSv1GetPassiveSessionsCount,
if err := dispEngine.RPC.Call(utils.SessionSv1GetPassiveSessionsCount,
&filtr, &reply); err != nil {
t.Fatal(err)
} else if reply != 0 {
t.Errorf("Expected no pasive sessions recived %v", reply)
}
rply = nil
if err := dispEngine.RCP.Call(utils.SessionSv1GetPassiveSessions,
if err := dispEngine.RPC.Call(utils.SessionSv1GetPassiveSessions,
&filtr, &rply); err == nil || err.Error() != utils.ErrNotFound.Error() {
t.Fatalf("Expected %v recived %v with reply %s", utils.ErrNotFound, err, utils.ToJSON(rply))
}
@@ -351,7 +351,7 @@ func testDspSessionUpdate(t *testing.T) {
},
}
var rply sessions.V1UpdateSessionReply
if err := dispEngine.RCP.Call(utils.SessionSv1UpdateSession,
if err := dispEngine.RPC.Call(utils.SessionSv1UpdateSession,
argsUpdate, &rply); err != nil {
t.Error(err)
}
@@ -413,7 +413,7 @@ func testDspSessionUpdate2(t *testing.T) {
},
}
var rply sessions.V1UpdateSessionReply
if err := dispEngine.RCP.Call(utils.SessionSv1UpdateSession,
if err := dispEngine.RPC.Call(utils.SessionSv1UpdateSession,
argsUpdate, &rply); err != nil {
t.Fatal(err)
}
@@ -479,7 +479,7 @@ func testDspSessionTerminate(t *testing.T) {
},
}
var rply string
if err := dispEngine.RCP.Call(utils.SessionSv1TerminateSession,
if err := dispEngine.RPC.Call(utils.SessionSv1TerminateSession,
args, &rply); err != nil {
t.Error(err)
}
@@ -512,7 +512,7 @@ func testDspSessionProcessCDR(t *testing.T) {
}
var rply string
if err := dispEngine.RCP.Call(utils.SessionSv1ProcessCDR,
if err := dispEngine.RPC.Call(utils.SessionSv1ProcessCDR,
args, &rply); err != nil {
t.Fatal(err)
}
@@ -549,7 +549,7 @@ func testDspSessionProcessEvent(t *testing.T) {
},
}
var rply sessions.V1ProcessMessageReply
if err := dispEngine.RCP.Call(utils.SessionSv1ProcessMessage,
if err := dispEngine.RPC.Call(utils.SessionSv1ProcessMessage,
args, &rply); err != nil {
t.Fatal(err)
}
@@ -616,7 +616,7 @@ func testDspSessionProcessEvent2(t *testing.T) {
},
}
var rply sessions.V1ProcessMessageReply
if err := dispEngine.RCP.Call(utils.SessionSv1ProcessMessage,
if err := dispEngine.RPC.Call(utils.SessionSv1ProcessMessage,
args, &rply); err != nil {
t.Fatal(err)
}
@@ -663,7 +663,7 @@ func testDspSessionReplicate(t *testing.T) {
testDspSessionInit(t)
var reply string
if err := dispEngine.RCP.Call(utils.SessionSv1ReplicateSessions, ArgsReplicateSessionsWithApiKey{
if err := dispEngine.RPC.Call(utils.SessionSv1ReplicateSessions, ArgsReplicateSessionsWithApiKey{
ArgDispatcher: &utils.ArgDispatcher{
APIKey: utils.StringPointer("ses12345"),
},
@@ -688,7 +688,7 @@ func testDspSessionReplicate(t *testing.T) {
var repl int
time.Sleep(10 * time.Millisecond)
if err := allEngine2.RCP.Call(utils.SessionSv1GetPassiveSessionsCount,
if err := allEngine2.RPC.Call(utils.SessionSv1GetPassiveSessionsCount,
nil, &repl); err != nil {
t.Fatal(err)
} else if repl != 2 {
@@ -708,13 +708,13 @@ func testDspSessionPassive(t *testing.T) {
Filters: []string{},
}
time.Sleep(10 * time.Millisecond)
if err := dispEngine.RCP.Call(utils.SessionSv1GetPassiveSessionsCount,
if err := dispEngine.RPC.Call(utils.SessionSv1GetPassiveSessionsCount,
filtr, &repl); err != nil {
t.Fatal(err)
} else if repl != 0 {
t.Errorf("Expected no passive sessions recived %v", repl)
}
if err := dispEngine.RCP.Call(utils.SessionSv1GetActiveSessionsCount,
if err := dispEngine.RPC.Call(utils.SessionSv1GetActiveSessionsCount,
filtr, &repl); err != nil {
t.Fatal(err)
} else if repl != 2 {
@@ -722,7 +722,7 @@ func testDspSessionPassive(t *testing.T) {
}
var rply []*sessions.ExternalSession
if err := dispEngine.RCP.Call(utils.SessionSv1GetActiveSessions,
if err := dispEngine.RPC.Call(utils.SessionSv1GetActiveSessions,
&filtr, &rply); err != nil {
t.Fatal(err)
} else if len(rply) != 2 {
@@ -730,7 +730,7 @@ func testDspSessionPassive(t *testing.T) {
}
var reply string
if err := dispEngine.RCP.Call(utils.SessionSv1SetPassiveSession, sessions.Session{
if err := dispEngine.RPC.Call(utils.SessionSv1SetPassiveSession, sessions.Session{
CGRID: rply[0].CGRID,
Tenant: rply[0].Tenant,
ResourceID: "TestSSv1It1",
@@ -779,13 +779,13 @@ func testDspSessionPassive(t *testing.T) {
t.Errorf("Unexpected reply %s", reply)
}
time.Sleep(10 * time.Millisecond)
if err := dispEngine.RCP.Call(utils.SessionSv1GetPassiveSessionsCount,
if err := dispEngine.RPC.Call(utils.SessionSv1GetPassiveSessionsCount,
filtr, &repl); err != nil {
t.Fatal(err)
} else if repl != 1 {
t.Errorf("Expected 1 passive sessions recived %v", repl)
}
if err := dispEngine.RCP.Call(utils.SessionSv1GetActiveSessionsCount,
if err := dispEngine.RPC.Call(utils.SessionSv1GetActiveSessionsCount,
filtr, &repl); err != nil {
t.Fatal(err)
} else if repl != 0 {
@@ -810,13 +810,13 @@ func testDspSessionForceDisconect(t *testing.T) {
Filters: []string{},
}
time.Sleep(10 * time.Millisecond)
if err := dispEngine.RCP.Call(utils.SessionSv1GetPassiveSessionsCount,
if err := dispEngine.RPC.Call(utils.SessionSv1GetPassiveSessionsCount,
filtr, &repl); err != nil {
t.Fatal(err)
} else if repl != 0 {
t.Errorf("Expected no passive sessions recived %v", repl)
}
if err := dispEngine.RCP.Call(utils.SessionSv1GetActiveSessionsCount,
if err := dispEngine.RPC.Call(utils.SessionSv1GetActiveSessionsCount,
filtr, &repl); err != nil {
t.Fatal(err)
} else if repl != 2 {
@@ -824,7 +824,7 @@ func testDspSessionForceDisconect(t *testing.T) {
}
var rply []*sessions.ExternalSession
if err := dispEngine.RCP.Call(utils.SessionSv1GetActiveSessions,
if err := dispEngine.RPC.Call(utils.SessionSv1GetActiveSessions,
&filtr, &rply); err != nil {
t.Fatal(err)
} else if len(rply) != 2 {
@@ -832,19 +832,19 @@ func testDspSessionForceDisconect(t *testing.T) {
}
var reply string
if err := dispEngine.RCP.Call(utils.SessionSv1ForceDisconnect, &filtr, &reply); err != nil {
if err := dispEngine.RPC.Call(utils.SessionSv1ForceDisconnect, &filtr, &reply); err != nil {
t.Fatal(err)
} else if reply != utils.OK {
t.Errorf("Unexpected reply %s", reply)
}
time.Sleep(10 * time.Millisecond)
if err := dispEngine.RCP.Call(utils.SessionSv1GetPassiveSessionsCount,
if err := dispEngine.RPC.Call(utils.SessionSv1GetPassiveSessionsCount,
filtr, &repl); err != nil {
t.Fatal(err)
} else if repl != 0 {
t.Errorf("Expected 1 passive sessions recived %v", repl)
}
if err := dispEngine.RCP.Call(utils.SessionSv1GetActiveSessionsCount,
if err := dispEngine.RPC.Call(utils.SessionSv1GetActiveSessionsCount,
filtr, &repl); err != nil {
t.Fatal(err)
} else if repl != 0 {
@@ -876,13 +876,13 @@ func testDspSessionProcessEvent3(t *testing.T) {
},
}
var rply sessions.V1ProcessEventReply
if err := dispEngine.RCP.Call(utils.SessionSv1ProcessEvent,
if err := dispEngine.RPC.Call(utils.SessionSv1ProcessEvent,
args, &rply); err != nil {
t.Error(err)
}
var repl int
if err := dispEngine.RCP.Call(utils.SessionSv1GetActiveSessionsCount,
if err := dispEngine.RPC.Call(utils.SessionSv1GetActiveSessionsCount,
utils.SessionFilter{
ArgDispatcher: &utils.ArgDispatcher{
APIKey: utils.StringPointer("ses12345"),

View File

@@ -51,7 +51,7 @@ func TestDspStatSMongo(t *testing.T) {
func testDspStsPingFailover(t *testing.T) {
var reply string
if err := allEngine.RCP.Call(utils.StatSv1Ping, new(utils.CGREvent), &reply); err != nil {
if err := allEngine.RPC.Call(utils.StatSv1Ping, new(utils.CGREvent), &reply); err != nil {
t.Error(err)
} else if reply != utils.Pong {
t.Errorf("Received: %s", reply)
@@ -64,19 +64,19 @@ func testDspStsPingFailover(t *testing.T) {
APIKey: utils.StringPointer("stat12345"),
},
}
if err := dispEngine.RCP.Call(utils.StatSv1Ping, &ev, &reply); err != nil {
if err := dispEngine.RPC.Call(utils.StatSv1Ping, &ev, &reply); err != nil {
t.Error(err)
} else if reply != utils.Pong {
t.Errorf("Received: %s", reply)
}
allEngine.stopEngine(t)
if err := dispEngine.RCP.Call(utils.StatSv1Ping, &ev, &reply); err != nil {
if err := dispEngine.RPC.Call(utils.StatSv1Ping, &ev, &reply); err != nil {
t.Error(err)
} else if reply != utils.Pong {
t.Errorf("Received: %s", reply)
}
allEngine2.stopEngine(t)
if err := dispEngine.RCP.Call(utils.StatSv1Ping, &ev, &reply); err == nil {
if err := dispEngine.RPC.Call(utils.StatSv1Ping, &ev, &reply); err == nil {
t.Errorf("Expected error but recived %v and reply %v\n", err, reply)
}
allEngine.startEngine(t)
@@ -104,7 +104,7 @@ func testDspStsGetStatFailover(t *testing.T) {
APIKey: utils.StringPointer("stat12345"),
},
}
if err := dispEngine.RCP.Call(utils.StatSv1ProcessEvent, args, &reply); err != nil {
if err := dispEngine.RPC.Call(utils.StatSv1ProcessEvent, args, &reply); err != nil {
t.Error(err)
} else if !reflect.DeepEqual(reply, expected) {
t.Errorf("Expecting: %+v, received: %+v", expected, reply)
@@ -120,7 +120,7 @@ func testDspStsGetStatFailover(t *testing.T) {
},
}
allEngine.stopEngine(t)
if err := dispEngine.RCP.Call(utils.StatSv1GetQueueStringMetrics,
if err := dispEngine.RPC.Call(utils.StatSv1GetQueueStringMetrics,
args2, &metrics); err != nil {
t.Error(err)
}
@@ -128,7 +128,7 @@ func testDspStsGetStatFailover(t *testing.T) {
allEngine.startEngine(t)
allEngine2.stopEngine(t)
if err := dispEngine.RCP.Call(utils.StatSv1GetQueueStringMetrics,
if err := dispEngine.RPC.Call(utils.StatSv1GetQueueStringMetrics,
args2, &metrics); err == nil || err.Error() != utils.ErrNotFound.Error() {
t.Errorf("Expected error NOT_FOUND but recived %v and reply %v\n", err, reply)
}
@@ -137,12 +137,12 @@ func testDspStsGetStatFailover(t *testing.T) {
func testDspStsPing(t *testing.T) {
var reply string
if err := allEngine.RCP.Call(utils.StatSv1Ping, new(utils.CGREvent), &reply); err != nil {
if err := allEngine.RPC.Call(utils.StatSv1Ping, new(utils.CGREvent), &reply); err != nil {
t.Error(err)
} else if reply != utils.Pong {
t.Errorf("Received: %s", reply)
}
if err := dispEngine.RCP.Call(utils.StatSv1Ping, &utils.CGREventWithArgDispatcher{
if err := dispEngine.RPC.Call(utils.StatSv1Ping, &utils.CGREventWithArgDispatcher{
CGREvent: &utils.CGREvent{
Tenant: "cgrates.org",
},
@@ -173,7 +173,7 @@ func testDspStsTestAuthKey(t *testing.T) {
APIKey: utils.StringPointer("12345"),
},
}
if err := dispEngine.RCP.Call(utils.StatSv1ProcessEvent,
if err := dispEngine.RPC.Call(utils.StatSv1ProcessEvent,
args, &reply); err == nil || err.Error() != utils.ErrUnauthorizedApi.Error() {
t.Error(err)
}
@@ -189,7 +189,7 @@ func testDspStsTestAuthKey(t *testing.T) {
}
var metrics map[string]string
if err := dispEngine.RCP.Call(utils.StatSv1GetQueueStringMetrics,
if err := dispEngine.RPC.Call(utils.StatSv1GetQueueStringMetrics,
args2, &metrics); err == nil || err.Error() != utils.ErrUnauthorizedApi.Error() {
t.Error(err)
}
@@ -215,7 +215,7 @@ func testDspStsTestAuthKey2(t *testing.T) {
APIKey: utils.StringPointer("stat12345"),
},
}
if err := dispEngine.RCP.Call(utils.StatSv1ProcessEvent, args, &reply); err != nil {
if err := dispEngine.RPC.Call(utils.StatSv1ProcessEvent, args, &reply); err != nil {
t.Error(err)
} else if !reflect.DeepEqual(reply, expected) {
t.Errorf("Expecting: %+v, received: %+v", expected, reply)
@@ -235,7 +235,7 @@ func testDspStsTestAuthKey2(t *testing.T) {
utils.MetaTCD: "2m15s",
}
if err := dispEngine.RCP.Call(utils.StatSv1GetQueueStringMetrics,
if err := dispEngine.RPC.Call(utils.StatSv1GetQueueStringMetrics,
args2, &metrics); err != nil {
t.Error(err)
} else if !reflect.DeepEqual(expectedMetrics, metrics) {
@@ -259,7 +259,7 @@ func testDspStsTestAuthKey2(t *testing.T) {
APIKey: utils.StringPointer("stat12345"),
},
}
if err := dispEngine.RCP.Call(utils.StatSv1ProcessEvent, args, &reply); err != nil {
if err := dispEngine.RPC.Call(utils.StatSv1ProcessEvent, args, &reply); err != nil {
t.Error(err)
} else if !reflect.DeepEqual(reply, expected) {
t.Errorf("Expecting: %+v, received: %+v", expected, reply)
@@ -269,7 +269,7 @@ func testDspStsTestAuthKey2(t *testing.T) {
utils.MetaTCC: "133",
utils.MetaTCD: "3m0s",
}
if err := dispEngine.RCP.Call(utils.StatSv1GetQueueStringMetrics,
if err := dispEngine.RPC.Call(utils.StatSv1GetQueueStringMetrics,
args2, &metrics); err != nil {
t.Error(err)
} else if !reflect.DeepEqual(expectedMetrics, metrics) {
@@ -295,7 +295,7 @@ func testDspStsTestAuthKey3(t *testing.T) {
utils.MetaTCD: 180,
}
if err := dispEngine.RCP.Call(utils.StatSv1GetQueueFloatMetrics,
if err := dispEngine.RPC.Call(utils.StatSv1GetQueueFloatMetrics,
args2, &metrics); err != nil {
t.Error(err)
} else if !reflect.DeepEqual(expectedMetrics, metrics) {
@@ -303,7 +303,7 @@ func testDspStsTestAuthKey3(t *testing.T) {
}
estats := []string{"Stats2", "Stats2_1"}
if err := dispEngine.RCP.Call(utils.StatSv1GetQueueIDs,
if err := dispEngine.RPC.Call(utils.StatSv1GetQueueIDs,
&utils.TenantWithArgDispatcher{
TenantArg: &utils.TenantArg{
Tenant: "cgrates.org",
@@ -321,7 +321,7 @@ func testDspStsTestAuthKey3(t *testing.T) {
}
estats = []string{"Stats2"}
if err := dispEngine.RCP.Call(utils.StatSv1GetStatQueuesForEvent,
if err := dispEngine.RPC.Call(utils.StatSv1GetStatQueuesForEvent,
&engine.StatsArgsProcessEvent{
CGREvent: &utils.CGREvent{
Tenant: "cgrates.org",

View File

@@ -52,12 +52,12 @@ func TestDspSupplierSMongo(t *testing.T) {
func testDspSupPing(t *testing.T) {
var reply string
if err := allEngine.RCP.Call(utils.SupplierSv1Ping, new(utils.CGREvent), &reply); err != nil {
if err := allEngine.RPC.Call(utils.SupplierSv1Ping, new(utils.CGREvent), &reply); err != nil {
t.Error(err)
} else if reply != utils.Pong {
t.Errorf("Received: %s", reply)
}
if err := dispEngine.RCP.Call(utils.SupplierSv1Ping, &utils.CGREventWithArgDispatcher{
if err := dispEngine.RPC.Call(utils.SupplierSv1Ping, &utils.CGREventWithArgDispatcher{
CGREvent: &utils.CGREvent{
Tenant: "cgrates.org",
},
@@ -73,7 +73,7 @@ func testDspSupPing(t *testing.T) {
func testDspSupPingFailover(t *testing.T) {
var reply string
if err := allEngine.RCP.Call(utils.SupplierSv1Ping, new(utils.CGREvent), &reply); err != nil {
if err := allEngine.RPC.Call(utils.SupplierSv1Ping, new(utils.CGREvent), &reply); err != nil {
t.Error(err)
} else if reply != utils.Pong {
t.Errorf("Received: %s", reply)
@@ -86,19 +86,19 @@ func testDspSupPingFailover(t *testing.T) {
APIKey: utils.StringPointer("sup12345"),
},
}
if err := dispEngine.RCP.Call(utils.SupplierSv1Ping, &ev, &reply); err != nil {
if err := dispEngine.RPC.Call(utils.SupplierSv1Ping, &ev, &reply); err != nil {
t.Error(err)
} else if reply != utils.Pong {
t.Errorf("Received: %s", reply)
}
allEngine.stopEngine(t)
if err := dispEngine.RCP.Call(utils.SupplierSv1Ping, &ev, &reply); err != nil {
if err := dispEngine.RPC.Call(utils.SupplierSv1Ping, &ev, &reply); err != nil {
t.Error(err)
} else if reply != utils.Pong {
t.Errorf("Received: %s", reply)
}
allEngine2.stopEngine(t)
if err := dispEngine.RCP.Call(utils.SupplierSv1Ping, &ev, &reply); err == nil {
if err := dispEngine.RPC.Call(utils.SupplierSv1Ping, &ev, &reply); err == nil {
t.Errorf("Expected error but recived %v and reply %v\n", err, reply)
}
allEngine.startEngine(t)
@@ -164,14 +164,14 @@ func testDspSupGetSupFailover(t *testing.T) {
APIKey: utils.StringPointer("sup12345"),
},
}
if err := dispEngine.RCP.Call(utils.SupplierSv1GetSuppliers,
if err := dispEngine.RPC.Call(utils.SupplierSv1GetSuppliers,
args, &rpl); err != nil {
t.Error(err)
} else if !reflect.DeepEqual(eRpl1, rpl) {
t.Errorf("Expecting : %+v, received: %+v", utils.ToJSON(eRpl1), utils.ToJSON(rpl))
}
allEngine2.stopEngine(t)
if err := dispEngine.RCP.Call(utils.SupplierSv1GetSuppliers,
if err := dispEngine.RPC.Call(utils.SupplierSv1GetSuppliers,
args, &rpl); err != nil {
t.Error(err)
} else if !reflect.DeepEqual(eRpl, rpl) {
@@ -198,7 +198,7 @@ func testDspSupTestAuthKey(t *testing.T) {
APIKey: utils.StringPointer("12345"),
},
}
if err := dispEngine.RCP.Call(utils.SupplierSv1GetSuppliers,
if err := dispEngine.RPC.Call(utils.SupplierSv1GetSuppliers,
args, &rpl); err == nil || err.Error() != utils.ErrUnauthorizedApi.Error() {
t.Error(err)
}
@@ -248,7 +248,7 @@ func testDspSupTestAuthKey2(t *testing.T) {
APIKey: utils.StringPointer("sup12345"),
},
}
if err := dispEngine.RCP.Call(utils.SupplierSv1GetSuppliers,
if err := dispEngine.RPC.Call(utils.SupplierSv1GetSuppliers,
args, &rpl); err != nil {
t.Error(err)
} else if !reflect.DeepEqual(eRpl, rpl) {
@@ -315,13 +315,13 @@ func testDspSupGetSupRoundRobin(t *testing.T) {
APIKey: utils.StringPointer("sup12345"),
},
}
if err := dispEngine.RCP.Call(utils.SupplierSv1GetSuppliers,
if err := dispEngine.RPC.Call(utils.SupplierSv1GetSuppliers,
args, &rpl); err != nil {
t.Error(err)
} else if !reflect.DeepEqual(eRpl1, rpl) {
t.Errorf("Expecting : %+v, received: %+v", utils.ToJSON(eRpl1), utils.ToJSON(rpl))
}
if err := dispEngine.RCP.Call(utils.SupplierSv1GetSuppliers,
if err := dispEngine.RPC.Call(utils.SupplierSv1GetSuppliers,
args, &rpl); err != nil {
t.Error(err)
} else if !reflect.DeepEqual(eRpl, rpl) {
@@ -382,7 +382,7 @@ func testDspSupGetSupplierForEvent(t *testing.T) {
Weight: 10,
}
var supProf []*engine.SupplierProfile
if err := dispEngine.RCP.Call(utils.SupplierSv1GetSupplierProfilesForEvent,
if err := dispEngine.RPC.Call(utils.SupplierSv1GetSupplierProfilesForEvent,
ev, &supProf); err != nil {
t.Fatal(err)
}

View File

@@ -51,7 +51,7 @@ func TestDspThresholdSMongo(t *testing.T) {
func testDspThPingFailover(t *testing.T) {
var reply string
if err := allEngine.RCP.Call(utils.ThresholdSv1Ping, new(utils.CGREvent), &reply); err != nil {
if err := allEngine.RPC.Call(utils.ThresholdSv1Ping, new(utils.CGREvent), &reply); err != nil {
t.Error(err)
} else if reply != utils.Pong {
t.Errorf("Received: %s", reply)
@@ -64,19 +64,19 @@ func testDspThPingFailover(t *testing.T) {
APIKey: utils.StringPointer("thr12345"),
},
}
if err := dispEngine.RCP.Call(utils.ThresholdSv1Ping, &ev, &reply); err != nil {
if err := dispEngine.RPC.Call(utils.ThresholdSv1Ping, &ev, &reply); err != nil {
t.Error(err)
} else if reply != utils.Pong {
t.Errorf("Received: %s", reply)
}
allEngine.stopEngine(t)
if err := dispEngine.RCP.Call(utils.ThresholdSv1Ping, &ev, &reply); err != nil {
if err := dispEngine.RPC.Call(utils.ThresholdSv1Ping, &ev, &reply); err != nil {
t.Error(err)
} else if reply != utils.Pong {
t.Errorf("Received: %s", reply)
}
allEngine2.stopEngine(t)
if err := dispEngine.RCP.Call(utils.ThresholdSv1Ping, &ev, &reply); err == nil {
if err := dispEngine.RPC.Call(utils.ThresholdSv1Ping, &ev, &reply); err == nil {
t.Errorf("Expected error but recived %v and reply %v\n", err, reply)
}
allEngine.startEngine(t)
@@ -101,12 +101,12 @@ func testDspThProcessEventFailover(t *testing.T) {
},
}
if err := dispEngine.RCP.Call(utils.ThresholdSv1ProcessEvent, args,
if err := dispEngine.RPC.Call(utils.ThresholdSv1ProcessEvent, args,
&ids); err == nil || err.Error() != utils.ErrNotFound.Error() {
t.Errorf("Expected error NOT_FOUND but recived %v and reply %v\n", err, ids)
}
allEngine2.stopEngine(t)
if err := dispEngine.RCP.Call(utils.ThresholdSv1ProcessEvent, args, &ids); err != nil {
if err := dispEngine.RPC.Call(utils.ThresholdSv1ProcessEvent, args, &ids); err != nil {
t.Error(err)
} else if !reflect.DeepEqual(eIDs, ids) {
t.Errorf("expecting: %+v, received: %+v", eIDs, ids)
@@ -116,12 +116,12 @@ func testDspThProcessEventFailover(t *testing.T) {
func testDspThPing(t *testing.T) {
var reply string
if err := allEngine.RCP.Call(utils.ThresholdSv1Ping, new(utils.CGREvent), &reply); err != nil {
if err := allEngine.RPC.Call(utils.ThresholdSv1Ping, new(utils.CGREvent), &reply); err != nil {
t.Error(err)
} else if reply != utils.Pong {
t.Errorf("Received: %s", reply)
}
if err := dispEngine.RCP.Call(utils.ThresholdSv1Ping, &utils.CGREventWithArgDispatcher{
if err := dispEngine.RPC.Call(utils.ThresholdSv1Ping, &utils.CGREventWithArgDispatcher{
CGREvent: &utils.CGREvent{
Tenant: "cgrates.org",
},
@@ -151,12 +151,12 @@ func testDspThTestAuthKey(t *testing.T) {
},
}
if err := dispEngine.RCP.Call(utils.ThresholdSv1ProcessEvent,
if err := dispEngine.RPC.Call(utils.ThresholdSv1ProcessEvent,
args, &ids); err == nil || err.Error() != utils.ErrUnauthorizedApi.Error() {
t.Error(err)
}
var th *engine.Thresholds
if err := dispEngine.RCP.Call(utils.ThresholdSv1GetThresholdsForEvent, args,
if err := dispEngine.RPC.Call(utils.ThresholdSv1GetThresholdsForEvent, args,
&th); err == nil || err.Error() != utils.ErrUnauthorizedApi.Error() {
t.Error(err)
}
@@ -179,7 +179,7 @@ func testDspThTestAuthKey2(t *testing.T) {
},
}
if err := dispEngine.RCP.Call(utils.ThresholdSv1ProcessEvent, args, &ids); err != nil {
if err := dispEngine.RPC.Call(utils.ThresholdSv1ProcessEvent, args, &ids); err != nil {
t.Error(err)
} else if !reflect.DeepEqual(eIDs, ids) {
t.Errorf("expecting: %+v, received: %+v", eIDs, ids)
@@ -192,7 +192,7 @@ func testDspThTestAuthKey2(t *testing.T) {
Hits: 1,
},
}
if err := dispEngine.RCP.Call(utils.ThresholdSv1GetThresholdsForEvent, args, &th); err != nil {
if err := dispEngine.RPC.Call(utils.ThresholdSv1GetThresholdsForEvent, args, &th); err != nil {
t.Error(err)
} else if !reflect.DeepEqual((*eTh)[0].Tenant, (*th)[0].Tenant) {
t.Errorf("expecting: %+v, received: %+v", (*eTh)[0].Tenant, (*th)[0].Tenant)
@@ -210,7 +210,7 @@ func testDspThTestAuthKey3(t *testing.T) {
ID: "THD_ACNT_1002",
Hits: 1,
}
if err := dispEngine.RCP.Call(utils.ThresholdSv1GetThreshold, &utils.TenantIDWithArgDispatcher{
if err := dispEngine.RPC.Call(utils.ThresholdSv1GetThreshold, &utils.TenantIDWithArgDispatcher{
TenantID: &utils.TenantID{
Tenant: "cgrates.org",
ID: "THD_ACNT_1002",
@@ -231,7 +231,7 @@ func testDspThTestAuthKey3(t *testing.T) {
var ids []string
eIDs := []string{"THD_ACNT_1002"}
if err := dispEngine.RCP.Call(utils.ThresholdSv1GetThresholdIDs, &utils.TenantWithArgDispatcher{
if err := dispEngine.RPC.Call(utils.ThresholdSv1GetThresholdIDs, &utils.TenantWithArgDispatcher{
TenantArg: &utils.TenantArg{
Tenant: "cgrates.org",
},

View File

@@ -26,11 +26,11 @@ agts=$?
echo 'go test github.com/cgrates/cgrates/sessions -tags=integration -rpc=*gob'
go test github.com/cgrates/cgrates/sessions -tags=integration -rpc=*gob
smg=$?
# echo 'go test github.com/cgrates/cgrates/dispatchers -tags=integration'
# go test github.com/cgrates/cgrates/dispatchers -tags=integration
# dis=$?
echo 'go test github.com/cgrates/cgrates/dispatchers -tags=integration -rpc=*gob'
go test github.com/cgrates/cgrates/dispatchers -tags=integration -rpc=*gob
dis=$?
echo 'go test github.com/cgrates/cgrates/loaders -tags=integration -rpc=*gob'
go test github.com/cgrates/cgrates/loaders -tags=integration -rpc=*gob
lds=$?
exit $gen && $ap1 && $ap2 && $en && $cdrc && $gnr && $agts && $smg #&& $dis && $lds && $ers
exit $gen && $ap1 && $ap2 && $en && $cdrc && $gnr && $agts && $smg && $dis && $lds && $ers

View File

@@ -96,7 +96,7 @@ func (dspS *DispatcherService) Start() (err error) {
// for the moment we dispable Apier through dispatcher
// until we figured out a better sollution in case of gob server
// server.SetDispatched()
// dspS.server.SetDispatched()
dspS.server.RpcRegister(v1.NewDispatcherSv1(dspS.dspS))