diff --git a/data/tariffplans/dispatchers/DispatcherHosts.csv b/data/tariffplans/dispatchers/DispatcherHosts.csv index f142aece6..62c6fc740 100644 --- a/data/tariffplans/dispatchers/DispatcherHosts.csv +++ b/data/tariffplans/dispatchers/DispatcherHosts.csv @@ -2,3 +2,4 @@ cgrates.org,SELF,*internal,, cgrates.org,ALL,127.0.0.1:6012,*json,false cgrates.org,ALL2,127.0.0.1:7012,*json,false +cgrates.org,UnexistedHost,127.0.0.1:10012,*json,false diff --git a/data/tariffplans/dispatchers/DispatcherProfiles.csv b/data/tariffplans/dispatchers/DispatcherProfiles.csv index 38223d7e9..224651a12 100644 --- a/data/tariffplans/dispatchers/DispatcherProfiles.csv +++ b/data/tariffplans/dispatchers/DispatcherProfiles.csv @@ -1,6 +1,8 @@ #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,PING2,*any,*string:~*req.EventName:UnexistedHost,,*weight,,UnexistedHost,,20,false,,20 +cgrates.org,PING2,,,,,,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 diff --git a/data/tariffplans/dispatchers_gob/DispatcherHosts.csv b/data/tariffplans/dispatchers_gob/DispatcherHosts.csv index bb4fb23db..21cc64f50 100644 --- a/data/tariffplans/dispatchers_gob/DispatcherHosts.csv +++ b/data/tariffplans/dispatchers_gob/DispatcherHosts.csv @@ -2,3 +2,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 +cgrates.org,UnexistedHost,127.0.0.1:10012,*json,false \ No newline at end of file diff --git a/data/tariffplans/dispatchers_gob/DispatcherProfiles.csv b/data/tariffplans/dispatchers_gob/DispatcherProfiles.csv index 38223d7e9..224651a12 100644 --- a/data/tariffplans/dispatchers_gob/DispatcherProfiles.csv +++ b/data/tariffplans/dispatchers_gob/DispatcherProfiles.csv @@ -1,6 +1,8 @@ #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,PING2,*any,*string:~*req.EventName:UnexistedHost,,*weight,,UnexistedHost,,20,false,,20 +cgrates.org,PING2,,,,,,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 diff --git a/dispatchers/attributes_it_test.go b/dispatchers/attributes_it_test.go index cd5358717..95f3bcf0f 100755 --- a/dispatchers/attributes_it_test.go +++ b/dispatchers/attributes_it_test.go @@ -32,6 +32,7 @@ import ( var sTestsDspAttr = []func(t *testing.T){ testDspAttrPingFailover, testDspAttrPingFailover2, + testDspAttrPingFailoverNotFoundHost, testDspAttrGetAttrFailover, testDspAttrGetAttrRoundRobin, @@ -133,6 +134,43 @@ func testDspAttrPingFailover(t *testing.T) { } } +func testDspAttrPingFailoverNotFoundHost(t *testing.T) { + var reply string + 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) + } + ev := utils.CGREventWithArgDispatcher{ + CGREvent: &utils.CGREvent{ + Tenant: "cgrates.org", + Event: map[string]interface{}{ + "EventName": "UnexistedHost", + }, + }, + ArgDispatcher: &utils.ArgDispatcher{ + APIKey: utils.StringPointer("attr12345"), + }, + } + + 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) // stop the engine and we expect to get error + if err := dispEngine.RPC.Call(utils.AttributeSv1Ping, &ev, &reply); err == nil { + t.Errorf("Expected error but recived %v and reply %v\n", err, reply) + } + allEngine2.startEngine(t) + reply = "" + if err := dispEngine.RPC.Call(utils.AttributeSv1Ping, &ev, &reply); err != nil { + t.Error(err) + } else if reply != utils.Pong { + t.Errorf("Received: %s", reply) + } +} + func testDspAttrPingFailover2(t *testing.T) { var reply string if err := allEngine.RPC.Call(utils.AttributeSv1Ping, new(utils.CGREvent), &reply); err != nil {