When checking Cache in case of *internal DataDB consider only DataDB cache partitions

This commit is contained in:
TeoV
2019-12-18 08:49:08 -05:00
parent ab5afecc4c
commit 0be9fb5a01
3 changed files with 21 additions and 28 deletions

View File

@@ -436,13 +436,7 @@ func (cfg *CGRConfig) checkConfigSanity() error {
// DataDB sanity checks
if cfg.dataDbCfg.DataDbType == utils.INTERNAL {
for key, config := range cfg.cacheCfg {
if key == utils.CacheDiameterMessages || key == utils.CacheClosedSessions || key == utils.CacheRPCConnections {
if config.Limit == 0 {
return fmt.Errorf("<%s> %s needs to be != 0 when DataBD is *internal, found 0.", utils.CacheS, key)
}
continue
}
if config.Limit != 0 {
if utils.CacheDataDBPartitions.Has(key) && config.Limit != 0 {
return fmt.Errorf("<%s> %s needs to be 0 when DataBD is *internal, received : %d", utils.CacheS, key, config.Limit)
}
}

View File

@@ -578,36 +578,26 @@ func TestConfigSanityStorDB(t *testing.T) {
func TestConfigSanityDataDB(t *testing.T) {
cfg, _ = NewDefaultCGRConfig()
cfg.dataDbCfg.DataDbType = utils.INTERNAL
cfg.cacheCfg = CacheCfg{
utils.CacheDiameterMessages: &CacheParamCfg{
Limit: 0,
},
}
expected := "<CacheS> *diameter_messages needs to be != 0 when DataBD is *internal, found 0."
if err := cfg.checkConfigSanity(); err == nil || err.Error() != expected {
t.Errorf("Expecting: %+q received: %+q", expected, err)
}
cfg.cacheCfg = CacheCfg{
utils.CacheDiameterMessages: &CacheParamCfg{
Limit: 1,
},
}
if err := cfg.checkConfigSanity(); err != nil {
t.Errorf("Expecting: nil received: %+q", err)
}
cfg.cacheCfg = CacheCfg{
"test": &CacheParamCfg{
Limit: 1,
},
}
expected = "<CacheS> test needs to be 0 when DataBD is *internal, received : 1"
if err := cfg.checkConfigSanity(); err != nil {
t.Error(err)
}
cfg.cacheCfg = CacheCfg{
utils.CacheAccounts: &CacheParamCfg{
Limit: 1,
},
}
expected := "<CacheS> *accounts needs to be 0 when DataBD is *internal, received : 1"
if err := cfg.checkConfigSanity(); err == nil || err.Error() != expected {
t.Errorf("Expecting: %+q received: %+q", expected, err)
}
cfg.cacheCfg["test"].Limit = 0
cfg.cacheCfg[utils.CacheAccounts].Limit = 0
cfg.resourceSCfg.Enabled = true
expected = "<ResourceS> StoreInterval needs to be -1 when DataBD is *internal, received : 0"
if err := cfg.checkConfigSanity(); err == nil || err.Error() != expected {

View File

@@ -148,6 +148,15 @@ var (
// AccountableRequestTypes are the ones handled by Accounting subsystem
AccountableRequestTypes = NewStringSet([]string{META_PREPAID, META_POSTPAID, META_PSEUDOPREPAID})
CacheDataDBPartitions = NewStringSet([]string{CacheDestinations, CacheReverseDestinations,
CacheRatingPlans, CacheRatingProfiles, CacheActions,
CacheActionPlans, CacheAccountActionPlans, CacheActionTriggers, CacheSharedGroups, CacheResourceProfiles, CacheResources,
CacheTimings, CacheStatQueueProfiles, CacheStatQueues, CacheThresholdProfiles, CacheThresholds,
CacheFilters, CacheSupplierProfiles, CacheAttributeProfiles, CacheChargerProfiles,
CacheDispatcherProfiles, CacheDispatcherHosts, CacheResourceFilterIndexes, CacheStatFilterIndexes,
CacheThresholdFilterIndexes, CacheSupplierFilterIndexes, CacheAttributeFilterIndexes,
CacheChargerFilterIndexes, CacheDispatcherFilterIndexes, CacheLoadIDs, CacheAccounts})
)
const (