Update compose_filter_indexes to rebuild indexes for *any context

This commit is contained in:
TeoV
2019-05-17 10:40:37 +03:00
committed by Dan Christian Bogos
parent 5cb5fb5661
commit e1d92f4f6d
2 changed files with 38 additions and 2 deletions

View File

@@ -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))

View File

@@ -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,