diff --git a/apier/v1/filter_indexes.go b/apier/v1/filter_indexes.go index 0877e6fa1..2b00c1210 100644 --- a/apier/v1/filter_indexes.go +++ b/apier/v1/filter_indexes.go @@ -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)) diff --git a/apier/v1/filter_indexes_it_test.go b/apier/v1/filter_indexes_it_test.go index 1eb72968c..4585974a6 100644 --- a/apier/v1/filter_indexes_it_test.go +++ b/apier/v1/filter_indexes_it_test.go @@ -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,