mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-11 18:16:24 +05:00
Added tests for mew *broadcast strategy
This commit is contained in:
committed by
Dan Christian Bogos
parent
471c97b205
commit
eafaf12697
@@ -8,6 +8,7 @@
|
||||
|
||||
"general": {
|
||||
"node_id": "DispatcherS1",
|
||||
"log_level": 7,
|
||||
"reconnects": 1,
|
||||
},
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
|
||||
"general": {
|
||||
"node_id": "DispatcherS1",
|
||||
"log_level": 7,
|
||||
"reconnects": 1,
|
||||
},
|
||||
|
||||
|
||||
@@ -8,5 +8,5 @@ cgrates.org,ATTR_API_SUP_AUTH,*auth,*string:~APIKey:sup12345,,,APIMethods,Suppli
|
||||
cgrates.org,ATTR_API_STAT_AUTH,*auth,*string:~APIKey:stat12345,,,APIMethods,StatSv1.Ping&StatSv1.GetStatQueuesForEvent&StatSv1.GetQueueStringMetrics&StatSv1.ProcessEvent&StatSv1.GetQueueIDs&StatSv1.GetQueueFloatMetrics,false,20
|
||||
cgrates.org,ATTR_API_RES_AUTH,*auth,*string:~APIKey:res12345,,,APIMethods,ResourceSv1.Ping&ResourceSv1.GetResourcesForEvent&ResourceSv1.AuthorizeResources&ResourceSv1.AllocateResources&ResourceSv1.ReleaseResources,false,20
|
||||
cgrates.org,ATTR_API_SES_AUTH,*auth,*string:~APIKey:ses12345,,,APIMethods,SessionSv1.Ping&SessionSv1.AuthorizeEventWithDigest&SessionSv1.InitiateSessionWithDigest&SessionSv1.UpdateSession&SessionSv1.TerminateSession&SessionSv1.ProcessCDR&SessionSv1.ProcessEvent&SessionSv1.GetActiveSessions&SessionSv1.GetActiveSessionsCount&SessionSv1.ForceDisconnect&SessionSv1.GetPassiveSessions&SessionSv1.GetPassiveSessionsCount&SessionSv1.SetPassiveSession&SessionSv1.ReplicateSessions,false,20
|
||||
cgrates.org,ATTR_API_RSP_AUTH,*auth,*string:~APIKey:rsp12345,,,APIMethods,Responder.Status&Responder.GetTimeout&Responder.Shutdown,false,20
|
||||
cgrates.org,ATTR_API_RSP_AUTH,*auth,*string:~APIKey:rsp12345,,,APIMethods,Responder.Status&Responder.GetTimeout&Responder.Shutdown&Responder.Ping,false,20
|
||||
cgrates.org,ATTR_API_CHC_AUTH,*auth,*string:~APIKey:chc12345,,,APIMethods,CacheSv1.Ping&CacheSv1.GetCacheStats&CacheSv1.LoadCache&CacheSv1.PrecacheStatus&CacheSv1.GetItemIDs&CacheSv1.HasItem&CacheSv1.GetItemExpiryTime&CacheSv1.ReloadCache&CacheSv1.RemoveItem&CacheSv1.FlushCache&CacheSv1.Clear,false,20
|
||||
|
||||
|
@@ -7,3 +7,5 @@ cgrates.org,EVENT2,*any,*string:~EventName:RoundRobin,,*round_robin,,ALL2,,20,fa
|
||||
cgrates.org,EVENT2,,,,,,ALL,,10,,,
|
||||
cgrates.org,EVENT3,*any,*string:~EventName:Random,,*random,,ALL2,,20,false,,20
|
||||
cgrates.org,EVENT3,,,,,,ALL,,10,,,
|
||||
cgrates.org,EVENT4,*any,*string:~EventName:Broadcast,,*broadcast,,ALL2,,20,false,,20
|
||||
cgrates.org,EVENT4,,,,,,ALL,,10,,,
|
||||
|
||||
|
@@ -32,6 +32,7 @@ var sTestsDspRsp = []func(t *testing.T){
|
||||
testDspResponderShutdown,
|
||||
|
||||
testDspResponderRandom,
|
||||
testDspResponderBroadcast,
|
||||
}
|
||||
|
||||
//Test start here
|
||||
@@ -83,7 +84,7 @@ func getNodeWithRoute(route string, t *testing.T) string {
|
||||
},
|
||||
},
|
||||
DispatcherResource: DispatcherResource{
|
||||
APIKey: "attr12345",
|
||||
APIKey: "rsp12345",
|
||||
RouteID: &route,
|
||||
},
|
||||
}
|
||||
@@ -97,7 +98,7 @@ func getNodeWithRoute(route string, t *testing.T) string {
|
||||
},
|
||||
}
|
||||
|
||||
if err := dispEngine.RCP.Call(utils.AttributeSv1Ping, pingEv, &pingReply); err != nil {
|
||||
if err := dispEngine.RCP.Call(utils.ResponderPing, pingEv, &pingReply); err != nil {
|
||||
t.Error(err)
|
||||
} else if pingReply != utils.Pong {
|
||||
t.Errorf("Received: %s", pingReply)
|
||||
@@ -147,3 +148,38 @@ func testDspResponderShutdown(t *testing.T) {
|
||||
allEngine.startEngine(t)
|
||||
allEngine2.startEngine(t)
|
||||
}
|
||||
|
||||
func testDspResponderBroadcast(t *testing.T) {
|
||||
var pingReply string
|
||||
pingEv := CGREvWithApiKey{
|
||||
CGREvent: utils.CGREvent{
|
||||
Tenant: "cgrates.org",
|
||||
Event: map[string]interface{}{
|
||||
utils.EVENT_NAME: "Broadcast",
|
||||
},
|
||||
},
|
||||
DispatcherResource: DispatcherResource{
|
||||
APIKey: "rsp12345",
|
||||
},
|
||||
}
|
||||
if err := dispEngine.RCP.Call(utils.ResponderPing, pingEv, &pingReply); err != nil {
|
||||
t.Error(err)
|
||||
} else if pingReply != utils.Pong {
|
||||
t.Errorf("Received: %s", pingReply)
|
||||
}
|
||||
|
||||
allEngine2.stopEngine(t)
|
||||
pingReply = ""
|
||||
if err := dispEngine.RCP.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 ||
|
||||
err.Error() != utils.ErrNotExecuted.Error() {
|
||||
t.Errorf("Expected error: %s received error: %v and reply %q", utils.ErrNotExecuted.Error(), err, pingReply)
|
||||
}
|
||||
allEngine.startEngine(t)
|
||||
allEngine2.startEngine(t)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user