mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-11 18:16:24 +05:00
In case we have UnauthorizedDestination error in GetRatingPlansCost we go to next RatingPlan
This commit is contained in:
committed by
Dan Christian Bogos
parent
e66b9177b3
commit
5d7db1db47
@@ -28,6 +28,7 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/cgrates/cgrates/config"
|
||||
"github.com/cgrates/cgrates/dispatchers"
|
||||
"github.com/cgrates/cgrates/engine"
|
||||
"github.com/cgrates/cgrates/utils"
|
||||
)
|
||||
@@ -48,6 +49,10 @@ var sTestsAPIer = []func(t *testing.T){
|
||||
testAPIerLoadFromFolder,
|
||||
testAPIerDeleteTPFromFolder,
|
||||
testAPIerAfterDelete,
|
||||
testAPIerLoadFromFolder,
|
||||
testAPIerGetRatingPlanCost,
|
||||
testAPIerGetRatingPlanCost2,
|
||||
testAPIerGetRatingPlanCost3,
|
||||
testAPIerKillEngine,
|
||||
}
|
||||
|
||||
@@ -132,6 +137,66 @@ func testAPIerAfterDelete(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func testAPIerGetRatingPlanCost(t *testing.T) {
|
||||
arg := &utils.RatingPlanCostArg{
|
||||
Destination: "1002",
|
||||
RatingPlanIDs: []string{"RP_1001", "RP_1002"},
|
||||
SetupTime: utils.META_NOW,
|
||||
Usage: "1h",
|
||||
}
|
||||
var reply dispatchers.RatingPlanCost
|
||||
if err := apierRPC.Call(utils.RALsV1GetRatingPlansCost, arg, &reply); err != nil {
|
||||
t.Error(err)
|
||||
} else if reply.RatingPlanID != "RP_1001" {
|
||||
t.Error("Unexpected RatingPlanID: ", reply.RatingPlanID)
|
||||
} else if *reply.EventCost.Cost != 6.5118 {
|
||||
t.Error("Unexpected Cost: ", *reply.EventCost.Cost)
|
||||
} else if *reply.EventCost.Usage != time.Duration(time.Hour) {
|
||||
t.Error("Unexpected Usage: ", *reply.EventCost.Usage)
|
||||
}
|
||||
}
|
||||
|
||||
// we need to discuss about this case
|
||||
// because 1003 have the following DestinationRate
|
||||
// DR_1003_MAXCOST_DISC,DST_1003,RT_1CNT_PER_SEC,*up,4,0.12,*disconnect
|
||||
func testAPIerGetRatingPlanCost2(t *testing.T) {
|
||||
arg := &utils.RatingPlanCostArg{
|
||||
Destination: "1003",
|
||||
RatingPlanIDs: []string{"RP_1001", "RP_1002"},
|
||||
SetupTime: utils.META_NOW,
|
||||
Usage: "1h",
|
||||
}
|
||||
var reply dispatchers.RatingPlanCost
|
||||
if err := apierRPC.Call(utils.RALsV1GetRatingPlansCost, arg, &reply); err != nil {
|
||||
t.Error(err)
|
||||
} else if reply.RatingPlanID != "RP_1001" {
|
||||
t.Error("Unexpected RatingPlanID: ", reply.RatingPlanID)
|
||||
} else if *reply.EventCost.Cost != 36 {
|
||||
t.Error("Unexpected Cost: ", *reply.EventCost.Cost)
|
||||
} else if *reply.EventCost.Usage != time.Duration(time.Hour) {
|
||||
t.Error("Unexpected Usage: ", *reply.EventCost.Usage)
|
||||
}
|
||||
}
|
||||
|
||||
func testAPIerGetRatingPlanCost3(t *testing.T) {
|
||||
arg := &utils.RatingPlanCostArg{
|
||||
Destination: "1001",
|
||||
RatingPlanIDs: []string{"RP_1001", "RP_1002"},
|
||||
SetupTime: utils.META_NOW,
|
||||
Usage: "1h",
|
||||
}
|
||||
var reply dispatchers.RatingPlanCost
|
||||
if err := apierRPC.Call(utils.RALsV1GetRatingPlansCost, arg, &reply); err != nil {
|
||||
t.Error(err)
|
||||
} else if reply.RatingPlanID != "RP_1002" {
|
||||
t.Error("Unexpected RatingPlanID: ", reply.RatingPlanID)
|
||||
} else if *reply.EventCost.Cost != 36 {
|
||||
t.Error("Unexpected Cost: ", *reply.EventCost.Cost)
|
||||
} else if *reply.EventCost.Usage != time.Duration(time.Hour) {
|
||||
t.Error("Unexpected Usage: ", *reply.EventCost.Usage)
|
||||
}
|
||||
}
|
||||
|
||||
func testAPIerKillEngine(t *testing.T) {
|
||||
if err := engine.KillEngine(*waitRater); err != nil {
|
||||
t.Error(err)
|
||||
|
||||
@@ -84,7 +84,10 @@ func (rsv1 *RALsV1) GetRatingPlansCost(arg *utils.RatingPlanCostArg, reply *disp
|
||||
engine.Cache.Remove(utils.CacheRatingProfiles, rPrfl.Id,
|
||||
true, utils.NonTransactional) // Remove here so we don't overload memory
|
||||
if err != nil {
|
||||
if err != utils.ErrNotFound {
|
||||
// in case we have UnauthorizedDestination
|
||||
// or NotFound try next RatingPlan
|
||||
if err != utils.ErrUnauthorizedDestination &&
|
||||
err != utils.ErrNotFound {
|
||||
return err
|
||||
}
|
||||
continue
|
||||
|
||||
Reference in New Issue
Block a user