Added tests for mew *broadcast strategy

This commit is contained in:
Trial97
2019-03-19 15:04:44 +02:00
committed by Dan Christian Bogos
parent 471c97b205
commit eafaf12697
5 changed files with 43 additions and 3 deletions

View File

@@ -8,6 +8,7 @@
"general": {
"node_id": "DispatcherS1",
"log_level": 7,
"reconnects": 1,
},

View File

@@ -8,6 +8,7 @@
"general": {
"node_id": "DispatcherS1",
"log_level": 7,
"reconnects": 1,
},

View File

@@ -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
1 #Tenant ID Contexts FilterIDs ActivationInterval AttributeFilterIDs FieldName Substitute Blocker Weight
8 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
9 cgrates.org ATTR_API_RES_AUTH *auth *string:~APIKey:res12345 APIMethods ResourceSv1.Ping&ResourceSv1.GetResourcesForEvent&ResourceSv1.AuthorizeResources&ResourceSv1.AllocateResources&ResourceSv1.ReleaseResources false 20
10 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
11 cgrates.org ATTR_API_RSP_AUTH *auth *string:~APIKey:rsp12345 APIMethods Responder.Status&Responder.GetTimeout&Responder.Shutdown Responder.Status&Responder.GetTimeout&Responder.Shutdown&Responder.Ping false 20
12 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

View File

@@ -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,,,
1 #Tenant ID Subsystems FilterIDs ActivationInterval Strategy StrategyParameters ConnID ConnFilterIDs ConnWeight ConnBlocker ConnParameters Weight
7 cgrates.org EVENT2 ALL 10
8 cgrates.org EVENT3 *any *string:~EventName:Random *random ALL2 20 false 20
9 cgrates.org EVENT3 ALL 10
10 cgrates.org EVENT4 *any *string:~EventName:Broadcast *broadcast ALL2 20 false 20
11 cgrates.org EVENT4 ALL 10

View File

@@ -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)
}