From e0898fe7bc3579b29100b9eec084d92891aab670 Mon Sep 17 00:00:00 2001 From: DanB Date: Mon, 25 Sep 2017 14:28:19 +0200 Subject: [PATCH 1/3] StatsV1.GetQueueIDs API, add integration tests for StatS --- apier/v1/stats.go | 5 ++ apier/v1/stats_it_test.go | 79 +++++++++++++---------------- data/tariffplans/tutorial/Stats.csv | 2 +- engine/stats.go | 15 ++++++ engine/tp_reader.go | 14 ++++- 5 files changed, 69 insertions(+), 46 deletions(-) diff --git a/apier/v1/stats.go b/apier/v1/stats.go index 3c46e457f..bc857c176 100644 --- a/apier/v1/stats.go +++ b/apier/v1/stats.go @@ -100,6 +100,11 @@ func (stsv1 *StatSV1) Call(serviceMethod string, args interface{}, reply interfa return err } +// GetQueueIDs returns list of queueIDs registered for a tenant +func (stsv1 *StatSV1) GetQueueIDs(tenant string, qIDs *[]string) error { + return stsv1.sS.V1GetQueueIDs(tenant, qIDs) +} + // ProcessEvent returns processes a new Event func (stsv1 *StatSV1) ProcessEvent(ev *engine.StatEvent, reply *string) error { return stsv1.sS.V1ProcessEvent(ev, reply) diff --git a/apier/v1/stats_it_test.go b/apier/v1/stats_it_test.go index b32173f09..68d0adb30 100644 --- a/apier/v1/stats_it_test.go +++ b/apier/v1/stats_it_test.go @@ -19,7 +19,6 @@ along with this program. If not, see */ package v1 -/* import ( "math/rand" "net/rpc" @@ -43,16 +42,22 @@ var ( statsDelay int ) -var evs = []engine.StatsEvent{ - engine.StatsEvent{ - utils.ID: "event1", - utils.ANSWER_TIME: time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC).Local()}, - engine.StatsEvent{ - utils.ID: "event2", - utils.ANSWER_TIME: time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC).Local()}, - engine.StatsEvent{ - utils.ID: "event3", - utils.SETUP_TIME: time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC).Local()}, +var evs = []*engine.StatEvent{ + &engine.StatEvent{ + Tenant: "cgrates.org", + ID: "event1", + Fields: map[string]interface{}{ + utils.ANSWER_TIME: time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC).Local()}}, + &engine.StatEvent{ + Tenant: "cgrates.org", + ID: "event2", + Fields: map[string]interface{}{ + utils.ANSWER_TIME: time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC).Local()}}, + &engine.StatEvent{ + Tenant: "cgrates.org", + ID: "event3", + Fields: map[string]interface{}{ + utils.SETUP_TIME: time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC).Local()}}, } func init() { @@ -66,15 +71,15 @@ var sTestsStatSV1 = []func(t *testing.T){ testV1STSRpcConn, testV1STSFromFolder, testV1STSGetStats, - testV1STSProcessEvent, - testV1STSGetStatQueueProfileBeforeSet, - testV1STSSetStatQueueProfile, - testV1STSGetStatQueueProfileAfterSet, - testV1STSUpdateStatQueueProfile, - testV1STSGetStatQueueProfileAfterUpdate, - testV1STSRemoveStatQueueProfile, - testV1STSGetStatQueueProfileAfterRemove, - testV1STSStopEngine, + //testV1STSProcessEvent, + //testV1STSGetStatQueueProfileBeforeSet, + //testV1STSSetStatQueueProfile, + //testV1STSGetStatQueueProfileAfterSet, + //testV1STSUpdateStatQueueProfile, + //testV1STSGetStatQueueProfileAfterUpdate, + //testV1STSRemoveStatQueueProfile, + //testV1STSGetStatQueueProfileAfterRemove, + //testV1STSStopEngine, } //Test start here @@ -128,47 +133,35 @@ func testV1STSRpcConn(t *testing.T) { func testV1STSFromFolder(t *testing.T) { var reply string - time.Sleep(time.Duration(2000) * time.Millisecond) attrs := &utils.AttrLoadTpFromFolder{FolderPath: path.Join(*dataDir, "tariffplans", "tutorial")} if err := stsV1Rpc.Call("ApierV1.LoadTariffPlanFromFolder", attrs, &reply); err != nil { t.Error(err) } - time.Sleep(time.Duration(1000) * time.Millisecond) } func testV1STSGetStats(t *testing.T) { var reply []string - // first attempt should be empty since there is no queue in cache yet - if err := stsV1Rpc.Call("StatSV1.GetQueueIDs", struct{}{}, &reply); err == nil || err.Error() != utils.ErrNotFound.Error() { - t.Error(err) - } - var metrics map[string]string - if err := stsV1Rpc.Call("StatSV1.GetStringMetrics", "Stats1", &metrics); err == nil || err.Error() != utils.ErrNotFound.Error() { - t.Error(err) - } - var replyStr string - if err := stsV1Rpc.Call("StatSV1.LoadQueues", nil, &replyStr); err != nil { - t.Error(err) - } else if replyStr != utils.OK { - t.Errorf("reply received: %s", replyStr) - } - expectedIDs := []string{"Stats1"} - if err := stsV1Rpc.Call("StatSV1.GetQueueIDs", struct{}{}, &reply); err != nil { + expectedIDs := []string{"STATS_1"} + if err := stsV1Rpc.Call("StatSV1.GetQueueIDs", "cgrates.org", &reply); err != nil { t.Error(err) } else if !reflect.DeepEqual(expectedIDs, reply) { t.Errorf("expecting: %+v, received reply: %s", expectedIDs, reply) } + var metrics map[string]string expectedMetrics := map[string]string{ utils.MetaASR: utils.NOT_AVAILABLE, utils.MetaACD: "", } - if err := stsV1Rpc.Call("StatSV1.GetStringMetrics", "Stats1", &metrics); err != nil { + if err := stsV1Rpc.Call("StatSV1.GetQueueStringMetrics", + &utils.TenantID{"cgrates.org", expectedIDs[0]}, &metrics); err != nil { t.Error(err) } else if !reflect.DeepEqual(expectedMetrics, metrics) { t.Errorf("expecting: %+v, received reply: %s", expectedMetrics, metrics) } } +/* + func testV1STSProcessEvent(t *testing.T) { var reply string if err := stsV1Rpc.Call("StatSV1.ProcessEvent", @@ -203,7 +196,7 @@ func testV1STSProcessEvent(t *testing.T) { utils.MetaACD: "", } var metrics map[string]string - if err := stsV1Rpc.Call("StatSV1.GetStringMetrics", "Stats1", &metrics); err != nil { + if err := stsV1Rpc.Call("StatSV1.GetQueueStringMetrics", "Stats1", &metrics); err != nil { t.Error(err) } else if !reflect.DeepEqual(expectedMetrics, metrics) { t.Errorf("expecting: %+v, received reply: %s", expectedMetrics, metrics) @@ -337,11 +330,11 @@ func BenchmarkStatSV1SetEvent(b *testing.B) { } } -// BenchmarkStatSV1GetStringMetrics 20000 94607 ns/op -func BenchmarkStatSV1GetStringMetrics(b *testing.B) { +// BenchmarkStatSV1GetQueueStringMetrics 20000 94607 ns/op +func BenchmarkStatSV1GetQueueStringMetrics(b *testing.B) { for i := 0; i < b.N; i++ { var metrics map[string]string - if err := stsV1Rpc.Call("StatSV1.GetStringMetrics", "Stats1", + if err := stsV1Rpc.Call("StatSV1.GetQueueStringMetrics", "Stats1", &metrics); err != nil { b.Error(err) } diff --git a/data/tariffplans/tutorial/Stats.csv b/data/tariffplans/tutorial/Stats.csv index 6832735d3..b3122b4db 100755 --- a/data/tariffplans/tutorial/Stats.csv +++ b/data/tariffplans/tutorial/Stats.csv @@ -1,2 +1,2 @@ #Tenant[0],Id[1],FilterType[2],FilterFieldName[3],FilterFieldValues[4],ActivationInterval[5],QueueLength[6],TTL[7],Metrics[8],Blocker[9],Stored[10],Weight[11],Thresholds[12] -cgrates.org,STATS_1,*string,Account,1001;1002,2014-07-29T15:00:00Z,100,1s,*asr;*acd;*acc,true,true,20,THRESH1;THRESH2 \ No newline at end of file +cgrates.org,STATS_1,*string,Account,1001;1002,2014-07-29T15:00:00Z,100,1s,*asr;*acd,true,true,20,THRESH1;THRESH2 \ No newline at end of file diff --git a/engine/stats.go b/engine/stats.go index 1d878755a..00418245e 100644 --- a/engine/stats.go +++ b/engine/stats.go @@ -307,3 +307,18 @@ func (sS *StatService) V1GetQueueFloatMetrics(args *utils.TenantID, reply *map[s *reply = metrics return } + +// V1GetQueueIDs returns list of queueIDs registered for a tenant +func (sS *StatService) V1GetQueueIDs(tenant string, qIDs *[]string) (err error) { + prfx := utils.StatQueuePrefix + tenant + utils.CONCATENATED_KEY_SEP + keys, err := sS.dm.DataDB().GetKeysForPrefix(prfx) + if err != nil { + return err + } + retIDs := make([]string, len(keys)) + for i, key := range keys { + retIDs[i] = key[len(prfx):] + } + *qIDs = retIDs + return +} diff --git a/engine/tp_reader.go b/engine/tp_reader.go index 9c2073ce6..f5040bafc 100755 --- a/engine/tp_reader.go +++ b/engine/tp_reader.go @@ -34,6 +34,7 @@ type TpReader struct { tpid string timezone string dataStorage DataDB + dm *DataManager lr LoadReader actions map[string][]*Action actionPlans map[string]*ActionPlan @@ -69,6 +70,7 @@ func NewTpReader(db DataDB, lr LoadReader, tpid, timezone string) *TpReader { tpid: tpid, timezone: timezone, dataStorage: db, + dm: NewDataManager(db), lr: lr, } tpr.Init() @@ -2010,8 +2012,16 @@ func (tpr *TpReader) WriteToDatabase(flush, verbose, disable_reverse bool) (err log.Print("StatQueues:") } for _, sqTntID := range tpr.statQueues { - if err = tpr.dataStorage.SetStoredStatQueue(&StoredStatQueue{Tenant: sqTntID.Tenant, ID: sqTntID.ID, - SQMetrics: make(map[string][]byte)}); err != nil { + sq := &StatQueue{Tenant: sqTntID.Tenant, ID: sqTntID.ID, + SQMetrics: make(map[string]StatMetric)} + for _, metricID := range tpr.sqProfiles[sqTntID.Tenant][sqTntID.ID].Metrics { + if metric, err := NewStatMetric(metricID); err != nil { + return err + } else { + sq.SQMetrics[metricID] = metric + } + } + if err = tpr.dm.SetStatQueue(sq); err != nil { return } if verbose { From 80a3c59d3d47d6bfdd65086979a52c6037d5dc43 Mon Sep 17 00:00:00 2001 From: DanB Date: Mon, 25 Sep 2017 18:51:20 +0200 Subject: [PATCH 2/3] StatS matching only fields in filters, integration tests for StatSV1.ProcessEvent --- apier/v1/stats_it_test.go | 46 +++++++++++++++++++++++++------------- apier/v1/tp_it_test.go | 5 ----- config/config_defaults.go | 8 +++---- config/config_json_test.go | 13 ++++++----- config/config_test.go | 10 ++++----- engine/libstats.go | 1 - engine/stats.go | 2 +- utils/consts.go | 8 +++---- 8 files changed, 51 insertions(+), 42 deletions(-) diff --git a/apier/v1/stats_it_test.go b/apier/v1/stats_it_test.go index 68d0adb30..e8c633147 100644 --- a/apier/v1/stats_it_test.go +++ b/apier/v1/stats_it_test.go @@ -71,7 +71,7 @@ var sTestsStatSV1 = []func(t *testing.T){ testV1STSRpcConn, testV1STSFromFolder, testV1STSGetStats, - //testV1STSProcessEvent, + testV1STSProcessEvent, //testV1STSGetStatQueueProfileBeforeSet, //testV1STSSetStatQueueProfile, //testV1STSGetStatQueueProfileAfterSet, @@ -79,7 +79,7 @@ var sTestsStatSV1 = []func(t *testing.T){ //testV1STSGetStatQueueProfileAfterUpdate, //testV1STSRemoveStatQueueProfile, //testV1STSGetStatQueueProfileAfterRemove, - //testV1STSStopEngine, + testV1STSStopEngine, } //Test start here @@ -150,7 +150,7 @@ func testV1STSGetStats(t *testing.T) { var metrics map[string]string expectedMetrics := map[string]string{ utils.MetaASR: utils.NOT_AVAILABLE, - utils.MetaACD: "", + utils.MetaACD: utils.NOT_AVAILABLE, } if err := stsV1Rpc.Call("StatSV1.GetQueueStringMetrics", &utils.TenantID{"cgrates.org", expectedIDs[0]}, &metrics); err != nil { @@ -160,32 +160,42 @@ func testV1STSGetStats(t *testing.T) { } } -/* - func testV1STSProcessEvent(t *testing.T) { var reply string if err := stsV1Rpc.Call("StatSV1.ProcessEvent", - engine.StatsEvent{ - utils.ID: "event1", - utils.ANSWER_TIME: time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC)}, + engine.StatEvent{ + Tenant: "cgrates.org", + ID: "event1", + Fields: map[string]interface{}{ + utils.ACCOUNT: "1001", + utils.ANSWER_TIME: time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC), + utils.USAGE: time.Duration(125 * time.Second)}}, &reply); err != nil { t.Error(err) } else if reply != utils.OK { t.Errorf("received reply: %s", reply) } if err := stsV1Rpc.Call("StatSV1.ProcessEvent", - engine.StatsEvent{ - utils.ID: "event2", - utils.ANSWER_TIME: time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC)}, + engine.StatEvent{ + Tenant: "cgrates.org", + ID: "event2", + Fields: map[string]interface{}{ + utils.ACCOUNT: "1002", + utils.ANSWER_TIME: time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC), + utils.USAGE: time.Duration(45 * time.Second)}}, &reply); err != nil { t.Error(err) } else if reply != utils.OK { t.Errorf("received reply: %s", reply) } if err := stsV1Rpc.Call("StatSV1.ProcessEvent", - engine.StatsEvent{ - utils.ID: "event3", - utils.SETUP_TIME: time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC)}, + engine.StatEvent{ + Tenant: "cgrates.org", + ID: "event3", + Fields: map[string]interface{}{ + utils.ACCOUNT: "1002", + utils.SETUP_TIME: time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC), + utils.USAGE: 0}}, &reply); err != nil { t.Error(err) } else if reply != utils.OK { @@ -193,16 +203,18 @@ func testV1STSProcessEvent(t *testing.T) { } expectedMetrics := map[string]string{ utils.MetaASR: "66.66667%", - utils.MetaACD: "", + utils.MetaACD: "0", } var metrics map[string]string - if err := stsV1Rpc.Call("StatSV1.GetQueueStringMetrics", "Stats1", &metrics); err != nil { + if err := stsV1Rpc.Call("StatSV1.GetQueueStringMetrics", &utils.TenantID{"cgrates.org", "STATS_1"}, &metrics); err != nil { t.Error(err) } else if !reflect.DeepEqual(expectedMetrics, metrics) { t.Errorf("expecting: %+v, received reply: %s", expectedMetrics, metrics) } } +/* + func testV1STSGetStatQueueProfileBeforeSet(t *testing.T) { var reply *engine.StatQueueProfile if err := stsV1Rpc.Call("ApierV1.GetStatQueueProfile", &AttrGetStatsCfg{ID: "SCFG1"}, &reply); err == nil || err.Error() != utils.ErrNotFound.Error() { @@ -300,6 +312,7 @@ func testV1STSGetStatQueueProfileAfterRemove(t *testing.T) { t.Error(err) } } +*/ func testV1STSStopEngine(t *testing.T) { if err := engine.KillEngine(100); err != nil { @@ -307,6 +320,7 @@ func testV1STSStopEngine(t *testing.T) { } } +/* // BenchmarkStatSV1SetEvent 5000 263437 ns/op func BenchmarkStatSV1SetEvent(b *testing.B) { if _, err := engine.StopStartEngine(stsV1CfgPath, 1000); err != nil { diff --git a/apier/v1/tp_it_test.go b/apier/v1/tp_it_test.go index b548b5152..65e9a54e4 100644 --- a/apier/v1/tp_it_test.go +++ b/apier/v1/tp_it_test.go @@ -73,7 +73,6 @@ func TestTPITPG(t *testing.T) { } func testTPInitCfg(t *testing.T) { - utils.Logger.Debug("init config") var err error tpCfgPath = path.Join(tpDataDir, "conf", "samples", tpConfigDIR) tpCfg, err = config.NewCGRConfigFromFolder(tpCfgPath) @@ -92,7 +91,6 @@ func testTPInitCfg(t *testing.T) { // Wipe out the cdr database func testTPResetStorDb(t *testing.T) { - utils.Logger.Debug("ResetStorDB") if err := engine.InitStorDb(tpCfg); err != nil { t.Fatal(err) } @@ -100,7 +98,6 @@ func testTPResetStorDb(t *testing.T) { // Start CGR Engine func testTPStartEngine(t *testing.T) { - utils.Logger.Debug("StartEngine") if _, err := engine.StopStartEngine(tpCfgPath, tpDelay); err != nil { t.Fatal(err) } @@ -108,7 +105,6 @@ func testTPStartEngine(t *testing.T) { // Connect rpc client to rater func testTPRpcConn(t *testing.T) { - utils.Logger.Debug("RPCCONN") var err error tpRPC, err = jsonrpc.Dial("tcp", tpCfg.RPCJSONListen) // We connect over JSON so we can also troubleshoot if needed if err != nil { @@ -149,7 +145,6 @@ func testTPExportTPToFolder(t *testing.T) { } func testTPKillEngine(t *testing.T) { - utils.Logger.Debug("KillEngine") if err := engine.KillEngine(tpDelay); err != nil { t.Error(err) } diff --git a/config/config_defaults.go b/config/config_defaults.go index 0ce7301c9..153f4fa99 100755 --- a/config/config_defaults.go +++ b/config/config_defaults.go @@ -29,7 +29,7 @@ const CGRATES_CFG_JSON = ` "general": { "instance_id": "", // identifier of this instance in the cluster, if empty it will be autogenerated - "logger":"*syslog", // controls the destination of logs <*syslog|*stdout> + "logger":"*syslog", // controls the destination of logs <*syslog|*stdout> "log_level": 6, // control the level of messages logged (0-emerg to 7-debug) "http_skip_tls_verify": false, // if enabled Http Client will accept any TLS certificate "rounding_decimals": 5, // system level precision for floats @@ -66,12 +66,12 @@ const CGRATES_CFG_JSON = ` "aliases": {"limit": -1, "ttl": "", "static_ttl": false, "precache": false}, // aliases caching "reverse_aliases": {"limit": -1, "ttl": "", "static_ttl": false, "precache": false}, // reverse aliases index caching "derived_chargers": {"limit": -1, "ttl": "", "static_ttl": false, "precache": false}, // derived charging rule caching + "timings": {"limit": -1, "ttl": "", "static_ttl": false, "precache": false}, // timings caching "resource_profiles": {"limit": -1, "ttl": "", "static_ttl": false, "precache": false}, // control resource profiles caching "resources": {"limit": -1, "ttl": "", "static_ttl": false, "precache": false}, // control resources caching "event_resources": {"limit": -1, "ttl": "1m", "static_ttl": false}, // matching resources to events - "timings": {"limit": -1, "ttl": "", "static_ttl": false, "precache": false}, // timings caching - "stats_queues": {"limit": -1, "ttl": "1m", "static_ttl": false, "precache": false}, // queues with metrics - "event_queues": {"limit": -1, "ttl": "1m", "static_ttl": false}, // matching queues to events + "statqueue_profiles": {"limit": -1, "ttl": "1m", "static_ttl": false, "precache": false}, // statqueue profiles + "statqueues": {"limit": -1, "ttl": "1m", "static_ttl": false, "precache": false}, // statqueues with metrics }, diff --git a/config/config_json_test.go b/config/config_json_test.go index ce60eca24..3fde3d27c 100755 --- a/config/config_json_test.go +++ b/config/config_json_test.go @@ -110,6 +110,9 @@ func TestCacheJsonCfg(t *testing.T) { utils.CacheDerivedChargers: &CacheParamJsonCfg{Limit: utils.IntPointer(-1), Ttl: utils.StringPointer(""), Static_ttl: utils.BoolPointer(false), Precache: utils.BoolPointer(false)}, + utils.CacheTimings: &CacheParamJsonCfg{Limit: utils.IntPointer(-1), + Ttl: utils.StringPointer(""), Static_ttl: utils.BoolPointer(false), + Precache: utils.BoolPointer(false)}, utils.CacheResourceProfiles: &CacheParamJsonCfg{Limit: utils.IntPointer(-1), Ttl: utils.StringPointer(""), Static_ttl: utils.BoolPointer(false), Precache: utils.BoolPointer(false)}, @@ -118,14 +121,12 @@ func TestCacheJsonCfg(t *testing.T) { Precache: utils.BoolPointer(false)}, utils.CacheEventResources: &CacheParamJsonCfg{Limit: utils.IntPointer(-1), Ttl: utils.StringPointer("1m"), Static_ttl: utils.BoolPointer(false)}, - utils.CacheTimings: &CacheParamJsonCfg{Limit: utils.IntPointer(-1), - Ttl: utils.StringPointer(""), Static_ttl: utils.BoolPointer(false), - Precache: utils.BoolPointer(false)}, - utils.CacheStatSQueues: &CacheParamJsonCfg{Limit: utils.IntPointer(-1), + utils.CacheStatQueueProfiles: &CacheParamJsonCfg{Limit: utils.IntPointer(-1), + Ttl: utils.StringPointer("1m"), Static_ttl: utils.BoolPointer(false), + Precache: utils.BoolPointer(false)}, + utils.CacheStatQueues: &CacheParamJsonCfg{Limit: utils.IntPointer(-1), Ttl: utils.StringPointer("1m"), Static_ttl: utils.BoolPointer(false), Precache: utils.BoolPointer(false)}, - utils.CacheEventQueues: &CacheParamJsonCfg{Limit: utils.IntPointer(-1), - Ttl: utils.StringPointer("1m"), Static_ttl: utils.BoolPointer(false)}, } if gCfg, err := dfCgrJsonCfg.CacheJsonCfg(); err != nil { diff --git a/config/config_test.go b/config/config_test.go index a1a7a662b..8cf538ade 100755 --- a/config/config_test.go +++ b/config/config_test.go @@ -438,18 +438,18 @@ func TestCgrCfgJSONDefaultsCacheCFG(t *testing.T) { TTL: time.Duration(0), StaticTTL: false, Precache: false}, utils.CacheDerivedChargers: &CacheParamConfig{Limit: -1, TTL: time.Duration(0), StaticTTL: false, Precache: false}, + utils.CacheTimings: &CacheParamConfig{Limit: -1, + TTL: time.Duration(0), StaticTTL: false, Precache: false}, utils.CacheResourceProfiles: &CacheParamConfig{Limit: -1, TTL: time.Duration(0), StaticTTL: false, Precache: false}, utils.CacheResources: &CacheParamConfig{Limit: -1, TTL: time.Duration(0), StaticTTL: false, Precache: false}, utils.CacheEventResources: &CacheParamConfig{Limit: -1, TTL: time.Duration(1 * time.Minute), StaticTTL: false}, - utils.CacheTimings: &CacheParamConfig{Limit: -1, - TTL: time.Duration(0), StaticTTL: false, Precache: false}, - utils.CacheStatSQueues: &CacheParamConfig{Limit: -1, + utils.CacheStatQueueProfiles: &CacheParamConfig{Limit: -1, + TTL: time.Duration(1 * time.Minute), StaticTTL: false, Precache: false}, + utils.CacheStatQueues: &CacheParamConfig{Limit: -1, TTL: time.Duration(1 * time.Minute), StaticTTL: false, Precache: false}, - utils.CacheEventQueues: &CacheParamConfig{Limit: -1, - TTL: time.Duration(1 * time.Minute), StaticTTL: false}, } if !reflect.DeepEqual(eCacheCfg, cgrCfg.CacheConfig) { t.Errorf("received: %s, \nexpecting: %s", utils.ToJSON(eCacheCfg), utils.ToJSON(cgrCfg.CacheConfig)) diff --git a/engine/libstats.go b/engine/libstats.go index ce09b4d4a..3aa4f5027 100755 --- a/engine/libstats.go +++ b/engine/libstats.go @@ -36,7 +36,6 @@ type StatQueueProfile struct { QueueLength int TTL time.Duration Metrics []string // list of metrics to build - Store bool // store to DB Thresholds []string // list of thresholds to be checked after changes Blocker bool // blocker flag to stop processing on filters matched Stored bool diff --git a/engine/stats.go b/engine/stats.go index 00418245e..ed7e68ee2 100644 --- a/engine/stats.go +++ b/engine/stats.go @@ -154,7 +154,7 @@ func (sS *StatService) matchingStatQueuesForEvent(ev *StatEvent) (sqs StatQueues } passAllFilters := true for _, fltr := range sqPrfl.Filters { - if pass, err := fltr.Pass(ev, "", sS); err != nil { + if pass, err := fltr.Pass(ev.Fields, "", sS); err != nil { return nil, err } else if !pass { passAllFilters = false diff --git a/utils/consts.go b/utils/consts.go index 473b23bcd..565a6a19d 100755 --- a/utils/consts.go +++ b/utils/consts.go @@ -59,8 +59,8 @@ var ( CacheResources: ResourcesPrefix, CacheEventResources: EventResourcesPrefix, CacheTimings: TimingsPrefix, - CacheStatSQueues: META_NONE, - CacheEventQueues: META_NONE, + CacheStatQueueProfiles: StatQueueProfilePrefix, + CacheStatQueues: StatQueuePrefix, } CachePrefixToInstance map[string]string // will be built on init ) @@ -441,9 +441,9 @@ const ( CostSource = "CostSource" ExtraInfo = "ExtraInfo" MetaPrefix = "*" - CacheStatSQueues = "stats_queues" - CacheEventQueues = "event_queues" CacheEventResources = "event_resources" + CacheStatQueueProfiles = "statqueue_profiles" + CacheStatQueues = "statqueues" EventResourcesPrefix = "ers_" MetaSysLog = "*syslog" MetaStdLog = "*stdout" From 6c044502eac0802dfa9ba26588a30e5b62692af6 Mon Sep 17 00:00:00 2001 From: DanB Date: Mon, 25 Sep 2017 20:18:17 +0200 Subject: [PATCH 3/3] Loader test using non supported *acc metric --- engine/loader_csv_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/engine/loader_csv_test.go b/engine/loader_csv_test.go index 2fc583059..0f860dc56 100755 --- a/engine/loader_csv_test.go +++ b/engine/loader_csv_test.go @@ -274,7 +274,7 @@ cgrates.org,ResGroup22,*destinations,HdrDestination,DST_FS,2014-07-29T15:00:00Z, ` stats = ` #Tenant[0],Id[1],FilterType[2],FilterFieldName[3],FilterFieldValues[4],ActivationInterval[5],QueueLength[6],TTL[7],Metrics[8],Blocker[9],Stored[10],Weight[11],Thresholds[12] -cgrates.org,Stats1,*string,Account,1001;1002,2014-07-29T15:00:00Z,100,1s,*asr;*acd;*acc,true,true,20,THRESH1;THRESH2 +cgrates.org,Stats1,*string,Account,1001;1002,2014-07-29T15:00:00Z,100,1s,*asr;*acd,true,true,20,THRESH1;THRESH2 ` thresholds = ` #Id[0],FilterType[1],FilterFieldName[2],FilterFieldValues[3],ActivationInterval[4],ThresholdType[5],ThresholdValue[6],MinItems[7],Recurrent[8],MinSleep[9],Blocker[10],Stored[11],Weight[12],ActionIDs[13] @@ -1452,7 +1452,7 @@ func TestLoadStats(t *testing.T) { }, QueueLength: 100, TTL: "1s", - Metrics: []string{"*asr", "*acd", "*acc"}, + Metrics: []string{"*asr", "*acd"}, Thresholds: []string{"THRESH1", "THRESH2"}, Blocker: true, Stored: true,