mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-13 02:56:24 +05:00
Route with accounts lcr
This commit is contained in:
@@ -12,10 +12,6 @@
|
||||
"data_db": {
|
||||
"db_type": "*internal"
|
||||
},
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
"attributes": {
|
||||
"enabled": true,
|
||||
@@ -67,7 +63,7 @@
|
||||
"prefix_indexed_fields":["*req.Destination"],
|
||||
"stats_conns": ["*internal"],
|
||||
"resources_conns": ["*internal"],
|
||||
"accounts_conns": ["*internal"],
|
||||
"accounts_conns": ["*localhost"],
|
||||
"rates_conns": ["*internal"]
|
||||
},
|
||||
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
#Tenant,ID,FilterIDs,Weights,Blockers,Opts,BalanceID,BalanceFilterIDs,BalanceWeights,BalanceBlockers,BalanceType,BalanceUnits,BalanceUnitFactors,BalanceOpts,BalanceCostIncrements,BalanceAttributeIDs,BalanceRateProfileIDs,ThresholdIDs
|
||||
|
||||
cgrates.org,1001,*string:~*req.Account:1001,,,,Concrete1,,;30,,*concrete,15,,,;1s;0;0.01,,,*none
|
||||
cgrates.org,1001,*string:~*req.Account:1001,,,,Concrete1,,;30,,*concrete,15,,,;1s;0;0.01,,,*none
|
||||
cgrates.org,ACCNT_ROUTES1,*string:~*req.Account:acnt22,;10,,,Concrete1,,;30,,*concrete,130,,,;1s;0;0.1,,,*none
|
||||
cgrates.org,ACCNT_ROUTES2,*string:~*req.Account:acnt22,,,,Abstract1,,;40,,*abstract,70s,,,;1s;0;0.1,,,*none
|
||||
|
@@ -1,4 +1,7 @@
|
||||
#ActionsId[0],Action[1],ExtraParameters[2],Filter[3],BalanceId[4],BalanceType[5],Categories[6],DestinationIds[7],RatingSubject[8],SharedGroup[9],ExpiryTime[10],Units[11],BalanceWeight[12],BalanceBlocker[13],BalanceDisabled[14],Weight[15]
|
||||
#Tenant,ID,FilterIDs,Weights,Blockers,Schedule,TargetType,TargetIDs,ActionID,ActionFilterIDs,ActionTTL,ActionType,ActionOpts,ActionPath,ActionValue
|
||||
|
||||
# TOPUP_RST_MONETARY_10 resets the <*default> <*monetary> balance to 10 units
|
||||
TOPUP_RST_MONETARY_10,*topup_reset,,,*default,*monetary,,,,,,10,10,,,10
|
||||
|
||||
#cgrates.org,TOPUP_RST_MONETARY_10,,;10,,*asap,*accounts,1001,TOPUP,,0s,*add_balance,,;10,;false,*asap,,,,,,10,10,,,10
|
||||
|
||||
cgrates.org,TOPUP_RST_MONETARY_10,,;10,,*asap,*accounts,1001,TOPUP,,0s,*add_balance,,*balance.Concrete1.Units,10
|
||||
|
||||
|
@@ -36,4 +36,10 @@ cgrates.org,ROUTE_LCR,,,,,,route1,*gte:~*stats.STATS_TOP3.*acd:1m;*lte:~*stats.S
|
||||
cgrates.org,ROUTE_LCR,,,,,,route2,*eq:~*stats.STATS_TOP3.*asr:100,,RP_STANDARD,,,;15,,
|
||||
cgrates.org,ROUTE_LCR,,,,,,route3,*gt:~*stats.STATS_TOP1.*acd:30s,,RP_VENDOR2,,,;10,,
|
||||
|
||||
cgrates.org,ROUTE_LCR_ACCOUNTS,*string:~*req.Account:acnt22,,,*lc,,,,,,,,,,
|
||||
cgrates.org,ROUTE_LCR_ACCOUNTS,,,,,,route1,*prefix:~*req.Destination:1044,ACCNT_ROUTES1,,,,;20,,
|
||||
cgrates.org,ROUTE_LCR_ACCOUNTS,,,,,,route2,*gte:~*accounts.ACCNT_ROUTES1.Balances[Concrete1].Units:130,ACCNT_ROUTES1,,,,;15,,
|
||||
cgrates.org,ROUTE_LCR_ACCOUNTS,,,,,,route3,,ACCNT_ROUTES1,,,,;10,,
|
||||
cgrates.org,ROUTE_LCR_ACCOUNTS,,,,,,route4,*lt:~*accounts.ACCNT_ROUTES2.Balances[Abstract1].Units:200s,ACCNT_ROUTES2,,,,;55,,
|
||||
|
||||
|
||||
|
||||
|
@@ -72,6 +72,7 @@ var (
|
||||
testV1RtsCasesSortRoutesHigherCostAllocateRes,
|
||||
testV1RtsCasesSortRoutesHigherCostV1V3,
|
||||
testV1RtsCasesSortRoutesHigherCostAllRoutes,
|
||||
testV1RtsCasesSortingRoutesLowestCostAccounts,
|
||||
|
||||
testV1RtsCaseStopEngine,
|
||||
}
|
||||
@@ -1718,6 +1719,70 @@ func testV1RtsCasesSortRoutesHigherCostAllRoutes(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func testV1RtsCasesSortingRoutesLowestCostAccounts(t *testing.T) {
|
||||
//gonna match all routes from ROUTE_LCR_ACCOUNTS
|
||||
ev := &utils.CGREvent{
|
||||
ID: "LC_SORT",
|
||||
Tenant: "cgrates.org",
|
||||
Event: map[string]interface{}{
|
||||
utils.AccountField: "acnt22",
|
||||
utils.Destination: "104423",
|
||||
},
|
||||
APIOpts: map[string]interface{}{
|
||||
utils.MetaStartTime: "2013-06-01T05:00:00Z",
|
||||
utils.MetaUsage: "50s",
|
||||
},
|
||||
}
|
||||
expSrtdRoutes := &engine.SortedRoutesList{
|
||||
{
|
||||
ProfileID: "ROUTE_LCR_ACCOUNTS",
|
||||
Sorting: "*lc",
|
||||
Routes: []*engine.SortedRoute{
|
||||
{
|
||||
RouteID: "route4",
|
||||
SortingData: map[string]interface{}{
|
||||
utils.Cost: nil,
|
||||
utils.AccountIDs: []interface{}{"ACCNT_ROUTES2"},
|
||||
utils.Weight: 55.,
|
||||
},
|
||||
},
|
||||
{
|
||||
RouteID: "route1",
|
||||
SortingData: map[string]interface{}{
|
||||
utils.Cost: 5.,
|
||||
utils.AccountIDs: []interface{}{"ACCNT_ROUTES1"},
|
||||
utils.Weight: 20.,
|
||||
},
|
||||
},
|
||||
{
|
||||
RouteID: "route2",
|
||||
SortingData: map[string]interface{}{
|
||||
utils.Cost: 5.,
|
||||
utils.AccountIDs: []interface{}{"ACCNT_ROUTES1"},
|
||||
utils.Weight: 15.,
|
||||
},
|
||||
},
|
||||
{
|
||||
RouteID: "route3",
|
||||
SortingData: map[string]interface{}{
|
||||
utils.Cost: 5.,
|
||||
utils.AccountIDs: []interface{}{"ACCNT_ROUTES1"},
|
||||
utils.Weight: 10.,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
var reply *engine.SortedRoutesList
|
||||
//gonna match one route because the totalUsage by ne-allocated resources is 0
|
||||
if err := rtsCaseSv1BiRpc.Call(context.Background(), utils.RouteSv1GetRoutes,
|
||||
ev, &reply); err != nil {
|
||||
t.Error(err)
|
||||
} else if !reflect.DeepEqual(expSrtdRoutes, reply) {
|
||||
t.Errorf("Expected %+v \n, received %+v", utils.ToJSON(expSrtdRoutes), utils.ToJSON(reply))
|
||||
}
|
||||
}
|
||||
|
||||
func testV1RtsCaseStopEngine(t *testing.T) {
|
||||
if err := engine.KillEngine(100); err != nil {
|
||||
t.Error(err)
|
||||
|
||||
Reference in New Issue
Block a user