mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-11 18:16:24 +05:00
Updated routes matching
This commit is contained in:
committed by
Dan Christian Bogos
parent
307337b6bc
commit
806f627b95
@@ -509,7 +509,7 @@ func testV1RouteGetHighestCostRoutes(t *testing.T) {
|
||||
}
|
||||
|
||||
func testV1RouteGetLeastCostRoutesErr(t *testing.T) {
|
||||
ev := &engine.ArgsGetRoutes{
|
||||
ev := &engine.ArgsGetRoutes{ // it gives error to leastCost but try next because of ignoreErrors flag
|
||||
IgnoreErrors: true,
|
||||
CGREvent: &utils.CGREvent{
|
||||
Tenant: "cgrates.org",
|
||||
@@ -522,10 +522,25 @@ func testV1RouteGetLeastCostRoutesErr(t *testing.T) {
|
||||
},
|
||||
},
|
||||
}
|
||||
eSpls := engine.SortedRoutesList{{
|
||||
ProfileID: "ROUTE_WEIGHT_2",
|
||||
Sorting: utils.MetaWeight,
|
||||
Routes: []*engine.SortedRoute{
|
||||
{
|
||||
RouteID: "route1",
|
||||
SortingData: map[string]interface{}{
|
||||
utils.Weight: 10.0,
|
||||
},
|
||||
},
|
||||
},
|
||||
}}
|
||||
var suplsReply engine.SortedRoutesList
|
||||
if err := routeSv1Rpc.Call(utils.RouteSv1GetRoutes,
|
||||
ev, &suplsReply); err.Error() != utils.ErrNotFound.Error() {
|
||||
ev, &suplsReply); err != nil {
|
||||
t.Error(err)
|
||||
} else if !reflect.DeepEqual(eSpls, suplsReply) {
|
||||
t.Errorf("Expecting: %s, received: %s",
|
||||
utils.ToJSON(eSpls), utils.ToJSON(suplsReply))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -245,13 +245,7 @@ func (ssd RouteSortDispatcher) SortRoutes(prflID, strategy string,
|
||||
if !has {
|
||||
return nil, fmt.Errorf("unsupported sorting strategy: %s", strategy)
|
||||
}
|
||||
if sortedRoutes, err = sd.SortRoutes(prflID, suppls, suplEv, extraOpts); err != nil {
|
||||
return
|
||||
}
|
||||
if len(sortedRoutes.Routes) == 0 {
|
||||
return nil, utils.ErrNotFound
|
||||
}
|
||||
return
|
||||
return sd.SortRoutes(prflID, suppls, suplEv, extraOpts)
|
||||
}
|
||||
|
||||
// SortedRoutesList represents the list of matched routes grouped based of profile
|
||||
|
||||
@@ -740,12 +740,17 @@ func (rpS *RouteService) sortedRoutesForEvent(tnt string, args *ArgsGetRoutes) (
|
||||
if sr, err = rpS.sortedRoutesForProfile(tnt, rPrfl, args.CGREvent, prfPag, extraOpts); err != nil {
|
||||
return
|
||||
}
|
||||
noSrtRoutes += len(sr.Routes)
|
||||
sortedRoutes = append(sortedRoutes, sr)
|
||||
if len(sortedRoutes) == prfCount { // the profile count was reached
|
||||
break
|
||||
if len(sr.Routes) != 0 {
|
||||
noSrtRoutes += len(sr.Routes)
|
||||
sortedRoutes = append(sortedRoutes, sr)
|
||||
if len(sortedRoutes) == prfCount { // the profile count was reached
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
if len(sortedRoutes) == 0 {
|
||||
err = utils.ErrNotFound
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user