From 0be9fb5a0162334c2e719bca0dc580423dda9e1b Mon Sep 17 00:00:00 2001 From: TeoV Date: Wed, 18 Dec 2019 08:49:08 -0500 Subject: [PATCH] When checking Cache in case of *internal DataDB consider only DataDB cache partitions --- config/configsanity.go | 8 +------- config/configsanity_test.go | 32 +++++++++++--------------------- utils/consts.go | 9 +++++++++ 3 files changed, 21 insertions(+), 28 deletions(-) diff --git a/config/configsanity.go b/config/configsanity.go index b3ee37b3d..af5dc658c 100644 --- a/config/configsanity.go +++ b/config/configsanity.go @@ -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) } } diff --git a/config/configsanity_test.go b/config/configsanity_test.go index 46ba0a352..e02b06268 100644 --- a/config/configsanity_test.go +++ b/config/configsanity_test.go @@ -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 := " *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 = " 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 := " *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 = " StoreInterval needs to be -1 when DataBD is *internal, received : 0" if err := cfg.checkConfigSanity(); err == nil || err.Error() != expected { diff --git a/utils/consts.go b/utils/consts.go index bbba9507f..5318188a7 100755 --- a/utils/consts.go +++ b/utils/consts.go @@ -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 (