Added cache partitions check in checksanity

This commit is contained in:
adragusin
2019-12-19 18:05:26 +02:00
parent 460fed194e
commit 0074190207
4 changed files with 24 additions and 4 deletions

View File

@@ -486,5 +486,12 @@ func (cfg *CGRConfig) checkConfigSanity() error {
}
}
}
// Cache partitions check
for cacheID := range cfg.cacheCfg {
if _, has := utils.CachePartitions[cacheID]; !has {
return fmt.Errorf("<%s> partition <%s> not defined", utils.CacheS, cacheID)
}
}
return nil
}

View File

@@ -580,8 +580,8 @@ func TestConfigSanityDataDB(t *testing.T) {
cfg.dataDbCfg.DataDbType = utils.INTERNAL
cfg.cacheCfg = CacheCfg{
"test": &CacheParamCfg{
Limit: 1,
utils.CacheTimings: &CacheParamCfg{
Limit: 0,
},
}
if err := cfg.checkConfigSanity(); err != nil {
@@ -641,3 +641,16 @@ func TestConfigSanityDataDB(t *testing.T) {
}
}
func TestConfigSanityCacheS(t *testing.T) {
cfg, _ = NewDefaultCGRConfig()
cfg.cacheCfg = map[string]*CacheParamCfg{"wrong_partition_name": &CacheParamCfg{Limit: 10}}
if err := cfg.checkConfigSanity(); err == nil || err.Error() != "<CacheS> partition <wrong_partition_name> not defined" {
t.Error(err)
}
cfg.cacheCfg = map[string]*CacheParamCfg{utils.CacheLoadIDs: &CacheParamCfg{Limit: 9}}
if err := cfg.checkConfigSanity(); err != nil {
t.Error(err)
}
}

View File

@@ -723,7 +723,7 @@ const (
ThresholdsLow = "thresholds"
DispatcherSLow = "dispatchers"
AnalyzerSLow = "analyzers"
SchedulerSLow = "scheduler"
SchedulerSLow = "schedulers"
LoaderSLow = "loaders"
RALsLow = "rals"
ReplicatorLow = "replicator"

View File

@@ -216,7 +216,7 @@ func (md MonthDays) Contains(monthDay int) (result bool) {
// Parse MonthDay elements from string separated by sep.
func (md *MonthDays) Parse(input, sep string) {
switch input {
case "*any", "":
case META_ANY, EmptyString:
*md = []int{}
default:
elements := strings.Split(input, sep)