mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-23 16:18:44 +05:00
Add more cases to suppliers
This commit is contained in:
committed by
Dan Christian Bogos
parent
bf334c3340
commit
c441c7496a
@@ -56,6 +56,7 @@ var sTestsSupplierSV1 = []func(t *testing.T){
|
||||
testV1SplSGetHighestCostSuppliers,
|
||||
testV1SplSPolulateStatsForQOS,
|
||||
testV1SplSGetQOSSuppliers,
|
||||
testV1SplSGetQOSSuppliers2,
|
||||
testV1SplSGetSupplierWithoutFilter,
|
||||
testV1SplSSetSupplierProfiles,
|
||||
testV1SplSUpdateSupplierProfiles,
|
||||
@@ -536,6 +537,62 @@ func testV1SplSGetQOSSuppliers(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func testV1SplSGetQOSSuppliers2(t *testing.T) {
|
||||
ev := &engine.ArgsGetSuppliers{
|
||||
CGREvent: utils.CGREvent{
|
||||
Tenant: "cgrates.org",
|
||||
ID: "testV1SplSGetQOSSuppliers",
|
||||
Event: map[string]interface{}{
|
||||
"DistincMatch": "*qos2",
|
||||
},
|
||||
},
|
||||
}
|
||||
eSpls := engine.SortedSuppliers{
|
||||
ProfileID: "SPL_QOS_2",
|
||||
Sorting: utils.MetaQOS,
|
||||
SortedSuppliers: []*engine.SortedSupplier{
|
||||
&engine.SortedSupplier{
|
||||
SupplierID: "supplier3",
|
||||
SortingData: map[string]interface{}{
|
||||
utils.MetaACD: 11.0,
|
||||
utils.MetaASR: 100.0,
|
||||
utils.MetaTCD: 11.0,
|
||||
utils.MetaPDD: -1.0,
|
||||
utils.Weight: 35.0,
|
||||
},
|
||||
},
|
||||
&engine.SortedSupplier{
|
||||
SupplierID: "supplier2",
|
||||
SortingData: map[string]interface{}{
|
||||
utils.MetaACD: 5.5,
|
||||
utils.MetaASR: 100.0,
|
||||
utils.MetaTCD: 11.0,
|
||||
utils.MetaPDD: -1.0,
|
||||
utils.Weight: 20.0,
|
||||
},
|
||||
},
|
||||
&engine.SortedSupplier{
|
||||
SupplierID: "supplier1",
|
||||
SortingData: map[string]interface{}{
|
||||
utils.MetaACD: 11.0,
|
||||
utils.MetaASR: 100.0,
|
||||
utils.MetaTCD: 22.0,
|
||||
utils.MetaPDD: -1.0,
|
||||
utils.Weight: 10.0,
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
var suplsReply engine.SortedSuppliers
|
||||
if err := splSv1Rpc.Call(utils.SupplierSv1GetSuppliers,
|
||||
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))
|
||||
}
|
||||
|
||||
}
|
||||
func testV1SplSGetSupplierWithoutFilter(t *testing.T) {
|
||||
ev := &engine.ArgsGetSuppliers{
|
||||
CGREvent: utils.CGREvent{
|
||||
|
||||
@@ -13,4 +13,5 @@ cgrates.org,FLTR_SPP_2,*string,DistincMatch,*highest_cost,
|
||||
cgrates.org,FLTR_SPP_3,*string,DistincMatch,*qos,2014-07-29T15:00:00Z
|
||||
cgrates.org,FLTR_STAT_1,*string,Account,1001,2014-07-29T15:00:00Z
|
||||
cgrates.org,FLTR_STAT_2,*string,Account,1002,2014-07-29T15:00:00Z
|
||||
cgrates.org,FLTR_STAT_3,*string,Account,1003,2014-07-29T15:00:00Z
|
||||
cgrates.org,FLTR_STAT_3,*string,Account,1003,2014-07-29T15:00:00Z
|
||||
cgrates.org,FLTR_SPP_4,*string,DistincMatch,*qos2,2014-07-29T15:00:00Z
|
||||
|
@@ -14,4 +14,6 @@ cgrates.org,SPL_HIGHESTCOST_1,,,,,supplier3,,,RP_SPECIAL_1002,,,15,,,
|
||||
cgrates.org,SPL_QOS_1,FLTR_SPP_3,2017-11-27T00:00:00Z,*qos,*acd;*tcd;*asr,supplier1,,,,,Stat_1,10,false,,10
|
||||
cgrates.org,SPL_QOS_1,,,,,supplier2,,,,,Stat_2,20,,,
|
||||
cgrates.org,SPL_QOS_1,,,,,supplier3,,,,,Stat_3,35,,,
|
||||
|
||||
cgrates.org,SPL_QOS_2,FLTR_SPP_4,2017-11-27T00:00:00Z,*qos,*pdd,supplier1,,,,,Stat_1,10,false,,10
|
||||
cgrates.org,SPL_QOS_2,,,,,supplier2,,,,,Stat_2,20,,,
|
||||
cgrates.org,SPL_QOS_2,,,,,supplier3,,,,,Stat_3,35,,,
|
||||
|
||||
|
@@ -95,13 +95,6 @@ func (sSpls *SortedSuppliers) SortHighestCost() {
|
||||
func (sSpls *SortedSuppliers) SortQOS(params []string) {
|
||||
sort.Slice(sSpls.SortedSuppliers, func(i, j int) bool {
|
||||
for _, param := range params {
|
||||
// if one of the supplier is missing the qos parram skip to next one
|
||||
if _, exists := sSpls.SortedSuppliers[i].SortingData[param]; !exists {
|
||||
continue
|
||||
}
|
||||
if _, exists := sSpls.SortedSuppliers[j].SortingData[param]; !exists {
|
||||
continue
|
||||
}
|
||||
// skip to next param
|
||||
if sSpls.SortedSuppliers[i].SortingData[param].(float64) == sSpls.SortedSuppliers[j].SortingData[param].(float64) {
|
||||
continue
|
||||
|
||||
@@ -59,6 +59,11 @@ func (lcs *QOSSupplierSorter) SortSuppliers(prflID string, suppls []*Supplier,
|
||||
for k, v := range metricSupp { //transfer data from metric into srtData
|
||||
srtData[k] = v
|
||||
}
|
||||
for _, metricParam := range extraOpts.sortingParameters {
|
||||
if _, has := srtData[metricParam]; !has {
|
||||
srtData[metricParam] = -1.0
|
||||
}
|
||||
}
|
||||
|
||||
sortedSuppls.SortedSuppliers = append(sortedSuppls.SortedSuppliers,
|
||||
&SortedSupplier{
|
||||
|
||||
Reference in New Issue
Block a user