Update integration test for Route with RateProfile

This commit is contained in:
TeoV
2020-11-20 11:03:21 +02:00
committed by Dan Christian Bogos
parent 58e00909c7
commit 3cde559ced
6 changed files with 20 additions and 14 deletions

View File

@@ -39,7 +39,7 @@ var (
testV1RouteSWithRateSRpcConn,
testV1RouteSWithRateSFromFolder,
testV1RouteSWithRateSGetRoutes,
//testV1RouteSWithRateSAccountWithRateProfile, //need to be discussed
testV1RouteSWithRateSAccountWithRateProfile, //need to be discussed
testV1RouteSWithRateSStopEngine,
}
)
@@ -165,7 +165,6 @@ func testV1RouteSWithRateSGetRoutes(t *testing.T) {
}
}
/*
func testV1RouteSWithRateSAccountWithRateProfile(t *testing.T) {
routePrf = &RouteWithCache{
RouteProfile: &engine.RouteProfile{
@@ -250,10 +249,10 @@ func testV1RouteSWithRateSAccountWithRateProfile(t *testing.T) {
{
RouteID: "RouteWithAccAndRatePrf",
SortingData: map[string]interface{}{
utils.Account: "AccWithVoice",
"Cost": 0.0,
"MaxUsage": 30000000000.0,
utils.Weight: 20.0,
utils.Account: "AccWithVoice",
utils.Cost: 0.0,
utils.CapMaxUsage: 30000000000.0,
utils.Weight: 20.0,
},
},
{
@@ -302,8 +301,8 @@ func testV1RouteSWithRateSAccountWithRateProfile(t *testing.T) {
RouteID: "RouteWithAccAndRatePrf",
SortingData: map[string]interface{}{
utils.Account: "AccWithVoice",
"Cost": 0.6,
"MaxUsage": 30000000000.0,
utils.Cost: 0.6,
utils.CapMaxUsage: 30000000000.0,
utils.RateProfileMatched: "RT_ANY2CNT_SEC",
utils.Weight: 20.0,
},
@@ -311,7 +310,7 @@ func testV1RouteSWithRateSAccountWithRateProfile(t *testing.T) {
{
RouteID: "RouteWithRP",
SortingData: map[string]interface{}{
"Cost": 0.6,
utils.Cost: 0.6,
utils.RateProfileMatched: "RT_ANY1CNT_SEC",
utils.Weight: 10.0,
},
@@ -363,7 +362,7 @@ func testV1RouteSWithRateSAccountWithRateProfile(t *testing.T) {
SortingData: map[string]interface{}{
utils.Account: "AccWithVoice",
utils.Cost: 0.62,
"MaxUsage": 30000000000.0,
utils.CapMaxUsage: 30000000000.0,
utils.RateProfileMatched: "RT_ANY2CNT_SEC",
utils.Weight: 20.0,
},
@@ -380,7 +379,6 @@ func testV1RouteSWithRateSAccountWithRateProfile(t *testing.T) {
}
}
*/
func testV1RouteSWithRateSStopEngine(t *testing.T) {
if err := engine.KillEngine(100); err != nil {

View File

@@ -0,0 +1,2 @@
#Id,DestinationId,RatesTag,RoundingMethod,RoundingDecimals,MaxCost,MaxCostStrategy
DR_ANY_1CNT,*any,RT_1CNT,*up,5,0,
1 #Id DestinationId RatesTag RoundingMethod RoundingDecimals MaxCost MaxCostStrategy
2 DR_ANY_1CNT *any RT_1CNT *up 5 0

View File

@@ -0,0 +1,2 @@
#Id,ConnectFee,Rate,RateUnit,RateIncrement,GroupIntervalStart
RT_1CNT,0,0.01,60s,1s,0s
1 #Id ConnectFee Rate RateUnit RateIncrement GroupIntervalStart
2 RT_1CNT 0 0.01 60s 1s 0s

View File

@@ -0,0 +1,2 @@
#Id,DestinationRatesId,TimingTag,Weight
RP_TESTIT1,DR_ANY_1CNT,*any,10
1 #Id DestinationRatesId TimingTag Weight
2 RP_TESTIT1 DR_ANY_1CNT *any 10

View File

@@ -0,0 +1,2 @@
#Tenant,Category,Subject,ActivationTime,RatingPlanId,RatesFallbackSubject
cgrates.org,*routes,*any,2018-01-01T00:00:00Z,RP_TESTIT1,
1 #Tenant Category Subject ActivationTime RatingPlanId RatesFallbackSubject
2 cgrates.org *routes *any 2018-01-01T00:00:00Z RP_TESTIT1

View File

@@ -262,8 +262,8 @@ func (rpS *RouteService) costForEvent(ev *utils.CGREvent,
}
if usage > accountMaxUsage {
// remain usage needs to be covered by rating plans
if len(rpIDs) == 0 {
return nil, fmt.Errorf("no rating plans defined for remaining usage")
if len(rpIDs) == 0 && len(rtPrfIDs) == 0 {
return nil, fmt.Errorf("no rating plans or rate profiles defined for remaining usage")
}
// update the setup time and the usage
sTime = sTime.Add(accountMaxUsage)
@@ -278,7 +278,7 @@ func (rpS *RouteService) costForEvent(ev *utils.CGREvent,
if accountMaxUsage == 0 || accountMaxUsage < initialUsage {
var rateRply RateProfileCost
if len(rpS.cgrcfg.RouteSCfg().RateSConns) != 0 && len(rtPrfIDs) != 0 {
if len(rpS.cgrcfg.RouteSCfg().RateSConns) != 0 {
if err := rpS.connMgr.Call(rpS.cgrcfg.RouteSCfg().RateSConns, nil, utils.RateSv1CostForEvent,
&utils.ArgsCostForEvent{
RateProfileIDs: rtPrfIDs,