mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-11 18:16:24 +05:00
Renamed join func + fixed intgration indexes tests for internal
This commit is contained in:
committed by
Dan Christian Bogos
parent
4fe03d1a2d
commit
2b8b7a3b96
@@ -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))
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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{}{},
|
||||
|
||||
Reference in New Issue
Block a user