Add test for Unreachable host

This commit is contained in:
TeoV
2020-05-28 16:22:20 +03:00
committed by Dan Christian Bogos
parent 6dc6ab02d4
commit 7a93429198
5 changed files with 44 additions and 0 deletions

View File

@@ -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 #Tenant[0] ID[1] Address[2] Transport[3] TLS[4]
2 cgrates.org SELF *internal
3 cgrates.org ALL 127.0.0.1:6012 *json false
4 cgrates.org ALL2 127.0.0.1:7012 *json false
5 cgrates.org UnexistedHost 127.0.0.1:10012 *json false

View File

@@ -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
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 PING2 *any *string:~*req.EventName:UnexistedHost *weight UnexistedHost 20 false 20
5 cgrates.org PING2 ALL2 10
6 cgrates.org EVENT1 *any *string:~*req.EventName:Event1 *weight ALL2 20 false 30
7 cgrates.org EVENT1 ALL 10
8 cgrates.org EVENT2 *any *string:~*req.EventName:RoundRobin *round_robin ALL2 20 false 20

View File

@@ -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 #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
5 cgrates.org UnexistedHost 127.0.0.1:10012 *json false

View File

@@ -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
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 PING2 *any *string:~*req.EventName:UnexistedHost *weight UnexistedHost 20 false 20
5 cgrates.org PING2 ALL2 10
6 cgrates.org EVENT1 *any *string:~*req.EventName:Event1 *weight ALL2 20 false 30
7 cgrates.org EVENT1 ALL 10
8 cgrates.org EVENT2 *any *string:~*req.EventName:RoundRobin *round_robin ALL2 20 false 20

View File

@@ -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 {