mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-11 18:16:24 +05:00
Add test for Unreachable host
This commit is contained in:
committed by
Dan Christian Bogos
parent
6dc6ab02d4
commit
7a93429198
@@ -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
|
||||
|
||||
|
@@ -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
|
||||
|
||||
|
@@ -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
|
||||
|
@@ -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
|
||||
|
||||
|
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user