mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-23 08:08:45 +05:00
Update compose_filter_indexes to rebuild indexes for *any context
This commit is contained in:
committed by
Dan Christian Bogos
parent
5cb5fb5661
commit
e1d92f4f6d
@@ -450,7 +450,7 @@ func (self *ApierV1) computeAttributeIndexes(tenant, context string, attrIDs *[]
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if !utils.IsSliceMember(ap.Contexts, context) {
|
||||
if !utils.IsSliceMember(ap.Contexts, context) && context != utils.META_ANY {
|
||||
continue
|
||||
}
|
||||
fltrIDs := make([]string, len(ap.FilterIDs))
|
||||
@@ -784,7 +784,7 @@ func (self *ApierV1) computeDispatcherIndexes(tenant, context string, dspIDs *[]
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if !utils.IsSliceMember(dsp.Subsystems, context) {
|
||||
if !utils.IsSliceMember(dsp.Subsystems, context) && context != utils.META_ANY {
|
||||
continue
|
||||
}
|
||||
fltrIDs := make([]string, len(dsp.FilterIDs))
|
||||
|
||||
@@ -78,6 +78,7 @@ var sTestsFilterIndexesSV1 = []func(t *testing.T){
|
||||
testV1FIdxComputeAttributeProfileIndexes,
|
||||
testV1FIdxSetSecondAttributeProfileIndexes,
|
||||
testV1FIdxSecondComputeAttributeProfileIndexes,
|
||||
testV1FIdxComputeWithAnotherContext,
|
||||
testV1FIdxRemoveAttributeProfile,
|
||||
|
||||
testV1FIdxdxInitDataDb,
|
||||
@@ -1432,6 +1433,41 @@ func testV1FIdxSecondComputeAttributeProfileIndexes(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func testV1FIdxComputeWithAnotherContext(t *testing.T) {
|
||||
var result string
|
||||
if err := tFIdxRpc.Call(utils.ApierV1ComputeFilterIndexes,
|
||||
utils.ArgsComputeFilterIndexes{
|
||||
Tenant: tenant,
|
||||
Context: utils.META_ANY,
|
||||
ThresholdIDs: &emptySlice,
|
||||
AttributeIDs: nil,
|
||||
ResourceIDs: &emptySlice,
|
||||
StatIDs: &emptySlice,
|
||||
SupplierIDs: &emptySlice,
|
||||
ChargerIDs: &emptySlice,
|
||||
DispatcherIDs: &emptySlice,
|
||||
}, &result); err != nil {
|
||||
t.Error(err)
|
||||
} else if result != utils.OK {
|
||||
t.Errorf("Error: %+v", result)
|
||||
}
|
||||
expectedIDX := []string{"*string:~Account:1001:ApierTest", "*string:~Account:1001:ApierTest2"}
|
||||
revExpectedIDX := []string{"*string:~Account:1001:ApierTest", "*string:~Account:1001:ApierTest2"}
|
||||
var indexes []string
|
||||
if err := tFIdxRpc.Call("ApierV1.GetFilterIndexes", &AttrGetFilterIndexes{
|
||||
ItemType: utils.MetaAttributes,
|
||||
Tenant: tenant,
|
||||
FilterType: engine.MetaString,
|
||||
Context: utils.META_ANY}, &indexes); err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
if !reflect.DeepEqual(expectedIDX, indexes) && !reflect.DeepEqual(revExpectedIDX, indexes) {
|
||||
t.Errorf("Expecting: %+v or %+v, received: %+v",
|
||||
expectedIDX, revExpectedIDX, utils.ToJSON(indexes))
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func testV1FIdxRemoveAttributeProfile(t *testing.T) {
|
||||
var result string
|
||||
if err := tFIdxRpc.Call(utils.ApierV1ComputeFilterIndexes,
|
||||
|
||||
Reference in New Issue
Block a user