Renamed join func + fixed intgration indexes tests for internal

This commit is contained in:
porosnicuadrian
2021-03-16 14:11:24 +02:00
committed by Dan Christian Bogos
parent 4fe03d1a2d
commit 2b8b7a3b96
6 changed files with 19 additions and 4 deletions

View File

@@ -381,6 +381,7 @@ func (apierSv1 *APIerSv1) ComputeFilterIndexes(args *utils.ArgsComputeFilterInde
for key := range rpr.Rates {
rtIds = append(rtIds, key)
}
_, e = engine.ComputeIndexes(apierSv1.DataManager, tnt, id, utils.CacheRateFilterIndexes,
&rtIds, transactionID, func(_, id, _ string) (*[]string, error) {
rateFilters := make([]string, len(rpr.Rates[id].FilterIDs))

View File

@@ -93,6 +93,7 @@ var (
testVF1ComputeIDsRateProfileRateIndexes,
testVF1RemoveRateProfileRates,
testV1FIdxdxInitDataDb,
testV1IndexClearCache,
testV1FISetRateProfileIndexes,
testV1FIComputeRateProfileIndexes,
@@ -158,6 +159,13 @@ func testV1FIdxdxInitDataDb(t *testing.T) {
}
}
func testV1IndexClearCache(t *testing.T) {
var reply string
if err := tFIdxRpc.Call(utils.CacheSv1Clear, &utils.AttrCacheIDsWithOpts{}, &reply); err != nil {
t.Fatal(err)
}
}
// Wipe out the cdr database
func testV1FIdxResetStorDb(t *testing.T) {
if err := engine.InitStorDb(tSv1Cfg); err != nil {
@@ -1804,7 +1812,7 @@ func testV1FISetRateProfileRatesIndexes(t *testing.T) {
//there are not any rates in db
var reply *engine.RateProfile
if err := tFIdxRpc.Call(utils.APIerSv1GetRateProfile,
&utils.TenantIDWithOpts{TenantID: &utils.TenantID{Tenant: tenant, ID: "RRATE_PRF"}}, &reply); err == nil ||
&utils.TenantIDWithOpts{TenantID: &utils.TenantID{Tenant: tenant, ID: "RP1"}}, &reply); err == nil ||
err.Error() != utils.ErrNotFound.Error() {
t.Error(err)
}
@@ -2197,6 +2205,7 @@ func testVF1RemoveRateProfileRates(t *testing.T) {
&indexes); err == nil || err.Error() != utils.ErrNotFound.Error() {
t.Error(err)
}
}
//RateProfile Indexes

View File

@@ -921,6 +921,10 @@ func (iDB *InternalDB) SetIndexesDrv(idxItmType, tntCtx string,
cacheCommit(utils.NonTransactional), utils.NonTransactional)
continue
}
//to be the same as HMSET
if x, ok := Cache.Get(idxItmType, dbKey); ok && x != nil {
indx = utils.JoinStringSet(indx, x.(utils.StringSet))
}
Cache.SetWithoutReplicate(idxItmType, dbKey, indx, []string{tntCtx},
cacheCommit(utils.NonTransactional), utils.NonTransactional)
}

View File

@@ -66,7 +66,7 @@ var (
CacheTBLTPDispatcherHosts, CacheTBLTPRateProfiles, CacheTBLTPActionProfiles, CacheTBLTPAccountProfiles})
// CachePartitions enables creation of cache partitions
CachePartitions = Join(extraDBPartition, dataDBPartition, storDBPartition)
CachePartitions = JoinStringSet(extraDBPartition, dataDBPartition, storDBPartition)
CacheInstanceToPrefix = map[string]string{
CacheDestinations: DestinationPrefix,

View File

@@ -115,7 +115,8 @@ func (s StringSet) GetOne() string {
return EmptyString
}
func Join(s ...StringSet) (conc StringSet) {
// JoinStringSet intersect multiple StringSets in one
func JoinStringSet(s ...StringSet) (conc StringSet) {
conc = make(StringSet)
for _, k := range s {
for key := range k {

View File

@@ -253,7 +253,7 @@ func TestStringSetJoin(t *testing.T) {
set3 := StringSet{
"test3": struct{}{},
}
rcv := Join(set1, set2, set3)
rcv := JoinStringSet(set1, set2, set3)
expected := StringSet{
"test1": struct{}{},