Merge fixes

This commit is contained in:
DanB
2018-03-06 17:16:07 +01:00
parent db14b0184e
commit 9aad1a9f4e
3 changed files with 29 additions and 38 deletions

View File

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

View File

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

View File

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