mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-21 15:18:44 +05:00
Updated analyzers
This commit is contained in:
committed by
Dan Christian Bogos
parent
f0158cea33
commit
0c51a3ee32
@@ -61,7 +61,7 @@ func (aS *AnalyzerService) SetFilterS(fS *engine.FilterS) {
|
||||
}
|
||||
|
||||
func (aS *AnalyzerService) initDB() (err error) {
|
||||
if aS.cfg.AnalyzerSCfg().DBPath == utils.EmptyString {
|
||||
if aS.cfg.AnalyzerSCfg().IndexType == utils.MetaInternal {
|
||||
aS.db, err = bleve.NewMemOnly(bleve.NewIndexMapping())
|
||||
return
|
||||
}
|
||||
|
||||
@@ -169,7 +169,7 @@ func TestAnalyzersListenAndServe(t *testing.T) {
|
||||
t.Fatal(err)
|
||||
}
|
||||
go func() {
|
||||
time.Sleep(1)
|
||||
time.Sleep(time.Nanosecond)
|
||||
runtime.Gosched()
|
||||
anz.db.Close()
|
||||
}()
|
||||
@@ -445,6 +445,7 @@ func TestAnalyzerSLogTrafficInternalDB(t *testing.T) {
|
||||
cfg := config.NewDefaultCGRConfig()
|
||||
|
||||
cfg.AnalyzerSCfg().DBPath = utils.EmptyString
|
||||
cfg.AnalyzerSCfg().IndexType = utils.MetaInternal
|
||||
cfg.AnalyzerSCfg().TTL = 30 * time.Minute
|
||||
anz, err := NewAnalyzerService(cfg)
|
||||
if err != nil {
|
||||
|
||||
@@ -1007,6 +1007,11 @@ func (cfg *CGRConfig) checkConfigSanity() error {
|
||||
if !utils.AnzIndexType.Has(cfg.analyzerSCfg.IndexType) {
|
||||
return fmt.Errorf("<%s> unsuported index type: %q", utils.AnalyzerS, cfg.analyzerSCfg.IndexType)
|
||||
}
|
||||
if cfg.analyzerSCfg.IndexType != utils.MetaInternal {
|
||||
if _, err := os.Stat(cfg.analyzerSCfg.DBPath); err != nil && os.IsNotExist(err) {
|
||||
return fmt.Errorf("<%s> nonexistent DB folder: %q", utils.AnalyzerS, cfg.analyzerSCfg.DBPath)
|
||||
}
|
||||
}
|
||||
// TTL and CleanupInterval should allways be biger than zero in order to not keep unecesary logs in index
|
||||
if cfg.analyzerSCfg.TTL <= 0 {
|
||||
return fmt.Errorf("<%s> the TTL needs to be bigger than 0", utils.AnalyzerS)
|
||||
|
||||
@@ -1567,9 +1567,14 @@ func TestConfigSanityAnalyzer(t *testing.T) {
|
||||
t.Errorf("Expecting: %+q received: %+q", expected, err)
|
||||
}
|
||||
|
||||
cfg.analyzerSCfg.IndexType = utils.MetaScorch
|
||||
cfg.analyzerSCfg.DBPath = "/inexistent/Path"
|
||||
expected = "<AnalyzerS> nonexistent DB folder: \"/inexistent/Path\""
|
||||
if err := cfg.checkConfigSanity(); err == nil || err.Error() != expected {
|
||||
t.Errorf("Expecting: %+q received: %+q", expected, err)
|
||||
}
|
||||
cfg.analyzerSCfg.DBPath = "/"
|
||||
|
||||
cfg.analyzerSCfg.IndexType = utils.MetaScorch
|
||||
expected = "<AnalyzerS> the TTL needs to be bigger than 0"
|
||||
if err := cfg.checkConfigSanity(); err == nil || err.Error() != expected {
|
||||
t.Errorf("Expecting: %+q received: %+q", expected, err)
|
||||
|
||||
@@ -2416,10 +2416,11 @@ const (
|
||||
)
|
||||
|
||||
var AnzIndexType = StringSet{ // AnzIndexType are the analyzers possible index types
|
||||
MetaScorch: {},
|
||||
MetaBoltdb: {},
|
||||
MetaLeveldb: {},
|
||||
MetaMoss: {},
|
||||
MetaScorch: {},
|
||||
MetaBoltdb: {},
|
||||
MetaLeveldb: {},
|
||||
MetaMoss: {},
|
||||
MetaInternal: {},
|
||||
}
|
||||
|
||||
// ActionSv1
|
||||
|
||||
Reference in New Issue
Block a user