From 9aad1a9f4ec1a35c145e0e6fa87173ece27a345c Mon Sep 17 00:00:00 2001 From: DanB Date: Tue, 6 Mar 2018 17:16:07 +0100 Subject: [PATCH] Merge fixes --- apier/v1/filter_indexes_it_test.go | 17 ++++++----- engine/filterindexer_it_test.go | 49 ++++++++++++------------------ engine/resources.go | 1 + 3 files changed, 29 insertions(+), 38 deletions(-) diff --git a/apier/v1/filter_indexes_it_test.go b/apier/v1/filter_indexes_it_test.go index 12fefa466..f6357a8cb 100644 --- a/apier/v1/filter_indexes_it_test.go +++ b/apier/v1/filter_indexes_it_test.go @@ -253,14 +253,15 @@ func testV1FIdxComputeThresholdsIndexes(t *testing.T) { tenant := "cgrates.org" var reply2 string emptySlice := []string{} - if err := tFIdxRpc.Call(utils.ApierV1ComputeFilterIndexes, utils.ArgsComputeFilterIndexes{ - Tenant: tenant, - ThresholdIDs: nil, - AttributeIDs: &emptySlice, - ResourceIDs: &emptySlice, - StatIDs: &emptySlice, - SupplierIDs: &emptySlice, - }, &reply2); err != nil { + if err := tFIdxRpc.Call(utils.ApierV1ComputeFilterIndexes, + utils.ArgsComputeFilterIndexes{ + Tenant: tenant, + ThresholdIDs: nil, + AttributeIDs: &emptySlice, + ResourceIDs: &emptySlice, + StatIDs: &emptySlice, + SupplierIDs: &emptySlice, + }, &reply2); err != nil { t.Error(err) } if reply2 != utils.OK { diff --git a/engine/filterindexer_it_test.go b/engine/filterindexer_it_test.go index e1ae63810..2813756f6 100644 --- a/engine/filterindexer_it_test.go +++ b/engine/filterindexer_it_test.go @@ -755,45 +755,34 @@ func testITTestStoreFilterIndexesWithTransID2(t *testing.T) { "RL2": true, }, } + transID := "transaction1" if err := dataManager.SetFilterIndexes( utils.PrefixToIndexCache[utils.ResourceProfilesPrefix], "cgrates.org", - idxes, false, "transaction1"); err != nil { + idxes, false, transID); err != nil { t.Error(err) } + /* #FixMe: add transactionID to GetFilterIndexes so we can check the content of temporary key + if rcv, err := dataManager.GetFilterIndexes( + utils.TEMP_DESTINATION_PREFIX+utils.PrefixToIndexCache[utils.ResourceProfilesPrefix], + utils.ConcatenatedKey("cgrates.org", transID), + MetaString, nil); err != nil { + t.Error(err) + } else if !reflect.DeepEqual(idxes, rcv) { + t.Errorf("Expecting: %+v, received: %+v", idxes, rcv) + } + */ //commit transaction if err := dataManager.SetFilterIndexes( utils.PrefixToIndexCache[utils.ResourceProfilesPrefix], "cgrates.org", - idxes, true, "transaction1"); err != nil { + idxes, true, transID); err != nil { t.Error(err) } - - idxes = map[string]utils.StringMap{ - "*string:Account:1001": utils.StringMap{ - "RL1": true, - }, - "*string:Account:1002": utils.StringMap{ - "RL1": true, - "RL2": true, - }, - "*string:Account:dan": utils.StringMap{ - "RL2": true, - }, - "*string:Subject:dan": utils.StringMap{ - "RL2": true, - "RL3": true, - }, - utils.ConcatenatedKey(utils.MetaDefault, - utils.ANY, utils.ANY): utils.StringMap{ - "RL4": true, - "RL5": true, - }, - "*string:Event:Event1": utils.StringMap{ - "RL1": true, - }, - "*string:Event:Event2": utils.StringMap{ - "RL1": true, - "RL2": true, - }, + //verify if old key was deleted + if _, err := dataManager.GetFilterIndexes( + "tmp_"+utils.PrefixToIndexCache[utils.ResourceProfilesPrefix], + utils.ConcatenatedKey("cgrates.org", transID), + MetaString, nil); err != utils.ErrNotFound { + t.Error(err) } //verify new key and check if data was moved if rcv, err := dataManager.GetFilterIndexes( diff --git a/engine/resources.go b/engine/resources.go index 978f2d266..6790b762d 100755 --- a/engine/resources.go +++ b/engine/resources.go @@ -255,6 +255,7 @@ func (rs Resources) allocateResource(ru *ResourceUsage, dryRun bool) (alcMessage r.removeExpiredUnits() if _, hasID := r.Usages[ru.ID]; hasID { // update r.clearUsage(ru.ID) + } if r.rPrf == nil { return "", fmt.Errorf("empty configuration for resourceID: %s", r.TenantID()) }