Removing *default cdrstats out of .json configuration since the same functionality can be achieved over .csv load

This commit is contained in:
DanB
2015-06-08 16:53:13 +02:00
parent fcd5a13ccd
commit 175d73633c
8 changed files with 27 additions and 210 deletions

View File

@@ -77,19 +77,6 @@ func TestCDRStatsLclRpcConn(t *testing.T) {
}
}
func TestCDRStatsLclGetQueueIds(t *testing.T) {
if !*testLocal {
return
}
var queueIds []string
eQueueIds := []string{"*default"}
if err := cdrstRpc.Call("CDRStatsV1.GetQueueIds", "", &queueIds); err != nil {
t.Error("Calling CDRStatsV1.GetQueueIds, got error: ", err.Error())
} else if !reflect.DeepEqual(eQueueIds, queueIds) {
t.Errorf("Expecting: %v, received: %v", eQueueIds, queueIds)
}
}
func TestCDRStatsLclLoadTariffPlanFromFolder(t *testing.T) {
if !*testLocal {
return
@@ -110,7 +97,7 @@ func TestCDRStatsLclGetQueueIds2(t *testing.T) {
return
}
var queueIds []string
eQueueIds := []string{"*default", "CDRST3", "CDRST4"}
eQueueIds := []string{"CDRST3", "CDRST4"}
if err := cdrstRpc.Call("CDRStatsV1.GetQueueIds", "", &queueIds); err != nil {
t.Error("Calling CDRStatsV1.GetQueueIds, got error: ", err.Error())
} else if len(eQueueIds) != len(queueIds) {
@@ -163,13 +150,6 @@ func TestCDRStatsLclGetMetrics1(t *testing.T) {
if !*testLocal {
return
}
var rcvMetrics1 map[string]float64
expectedMetrics1 := map[string]float64{"ASR": 75, "ACD": 15, "ACC": 15}
if err := cdrstRpc.Call("CDRStatsV1.GetMetrics", AttrGetMetrics{StatsQueueId: "*default"}, &rcvMetrics1); err != nil {
t.Error("Calling CDRStatsV1.GetMetrics, got error: ", err.Error())
} else if !reflect.DeepEqual(expectedMetrics1, rcvMetrics1) {
t.Errorf("Expecting: %v, received: %v", expectedMetrics1, rcvMetrics1)
}
var rcvMetrics2 map[string]float64
expectedMetrics2 := map[string]float64{"ASR": 75, "ACD": 15}
if err := cdrstRpc.Call("CDRStatsV1.GetMetrics", AttrGetMetrics{StatsQueueId: "CDRST4"}, &rcvMetrics2); err != nil {
@@ -190,13 +170,6 @@ func TestCDRStatsLclResetMetrics(t *testing.T) {
t.Error("Unexpected reply received: ", reply)
}
time.Sleep(time.Duration(*waitRater) * time.Millisecond)
var rcvMetrics1 map[string]float64
expectedMetrics1 := map[string]float64{"ASR": 75, "ACD": 15, "ACC": 15}
if err := cdrstRpc.Call("CDRStatsV1.GetMetrics", AttrGetMetrics{StatsQueueId: "*default"}, &rcvMetrics1); err != nil {
t.Error("Calling CDRStatsV1.GetMetrics, got error: ", err.Error())
} else if !reflect.DeepEqual(expectedMetrics1, rcvMetrics1) {
t.Errorf("Expecting: %v, received: %v", expectedMetrics1, rcvMetrics1)
}
var rcvMetrics2 map[string]float64
expectedMetrics2 := map[string]float64{"ASR": -1, "ACD": -1}
if err := cdrstRpc.Call("CDRStatsV1.GetMetrics", AttrGetMetrics{StatsQueueId: "CDRST4"}, &rcvMetrics2); err != nil {

View File

@@ -19,7 +19,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
package config
import (
"github.com/cgrates/cgrates/utils"
"time"
)
@@ -47,85 +46,3 @@ type CdrStatsConfig struct {
RatedSubjects []string
CostInterval []float64 // 2 or less items, (>=Cost, <Cost)
}
func (self *CdrStatsConfig) loadFromJsonCfg(jsnCfg *CdrStatsJsonCfg) error {
var err error
if jsnCfg.Queue_length != nil {
self.QueueLength = *jsnCfg.Queue_length
}
if jsnCfg.Time_window != nil {
if self.TimeWindow, err = utils.ParseDurationWithSecs(*jsnCfg.Time_window); err != nil {
return err
}
}
if jsnCfg.Metrics != nil {
self.Metrics = *jsnCfg.Metrics
}
if jsnCfg.Setup_interval != nil {
for _, setupTimeStr := range *jsnCfg.Setup_interval {
if setupTime, err := utils.ParseTimeDetectLayout(setupTimeStr); err != nil {
return err
} else {
self.SetupInterval = append(self.SetupInterval, setupTime)
}
}
}
if jsnCfg.Tors != nil {
self.TORs = *jsnCfg.Tors
}
if jsnCfg.Cdr_hosts != nil {
self.CdrHosts = *jsnCfg.Cdr_hosts
}
if jsnCfg.Cdr_sources != nil {
self.CdrSources = *jsnCfg.Cdr_sources
}
if jsnCfg.Req_types != nil {
self.ReqTypes = *jsnCfg.Req_types
}
if jsnCfg.Directions != nil {
self.Directions = *jsnCfg.Directions
}
if jsnCfg.Tenants != nil {
self.Tenants = *jsnCfg.Tenants
}
if jsnCfg.Categories != nil {
self.Categories = *jsnCfg.Categories
}
if jsnCfg.Accounts != nil {
self.Accounts = *jsnCfg.Accounts
}
if jsnCfg.Subjects != nil {
self.Subjects = *jsnCfg.Subjects
}
if jsnCfg.Destination_prefixes != nil {
self.DestinationPrefixes = *jsnCfg.Destination_prefixes
}
if jsnCfg.Usage_interval != nil {
for _, usageDurStr := range *jsnCfg.Usage_interval {
if usageDur, err := utils.ParseDurationWithSecs(usageDurStr); err != nil {
return err
} else {
self.UsageInterval = append(self.UsageInterval, usageDur)
}
}
}
if jsnCfg.Suppliers != nil {
self.Suppliers = *jsnCfg.Suppliers
}
if jsnCfg.Disconnect_causes != nil {
self.DisconnectCauses = *jsnCfg.Disconnect_causes
}
if jsnCfg.Mediation_run_ids != nil {
self.MediationRunIds = *jsnCfg.Mediation_run_ids
}
if jsnCfg.Rated_accounts != nil {
self.RatedAccounts = *jsnCfg.Rated_accounts
}
if jsnCfg.Rated_subjects != nil {
self.RatedSubjects = *jsnCfg.Rated_subjects
}
if jsnCfg.Cost_interval != nil {
self.CostInterval = *jsnCfg.Cost_interval
}
return nil
}

View File

@@ -573,14 +573,6 @@ func (self *CGRConfig) loadFromJsonCfg(jsnCfg *CgrJsonCfg) error {
if jsnCdrstatsCfg.Enabled != nil {
self.CDRStatsEnabled = *jsnCdrstatsCfg.Enabled
}
if jsnCdrstatsCfg != nil { // Have CDRStats config, load it in default object
if self.CDRStatConfig == nil {
self.CDRStatConfig = &CdrStatsConfig{Id: utils.META_DEFAULT}
}
if err = self.CDRStatConfig.loadFromJsonCfg(jsnCdrstatsCfg); err != nil {
return err
}
}
}
if jsnCdreCfg != nil {

View File

@@ -108,25 +108,6 @@ const CGRATES_CFG_JSON = `
"cdrstats": {
"enabled": false, // starts the cdrstats service: <true|false>
"queue_length": 50, // number of items in the stats buffer
"time_window": "1h", // will only keep the CDRs who's call setup time is not older than time.Now()-TimeWindow
"metrics": ["ASR", "ACD", "ACC"], // stat metric ids to build
"setup_interval": [], // filter on CDR SetupTime
"tors": [], // filter on CDR TOR fields
"cdr_hosts": [], // filter on CDR CdrHost fields
"cdr_sources": [], // filter on CDR CdrSource fields
"req_types": [], // filter on CDR ReqType fields
"directions": [], // filter on CDR Direction fields
"tenants": [], // filter on CDR Tenant fields
"categories": [], // filter on CDR Category fields
"accounts": [], // filter on CDR Account fields
"subjects": [], // filter on CDR Subject fields
"destination_prefixes": [], // filter on CDR Destination prefixes
"usage_interval": [], // filter on CDR Usage
"mediation_run_ids": [], // filter on CDR MediationRunId fields
"rated_accounts": [], // filter on CDR RatedAccount fields
"rated_subjects": [], // filter on CDR RatedSubject fields
"cost_interval": [], // filter on CDR Cost
},

View File

@@ -154,26 +154,7 @@ func TestDfCdrsJsonCfg(t *testing.T) {
func TestDfCdrStatsJsonCfg(t *testing.T) {
eCfg := &CdrStatsJsonCfg{
Enabled: utils.BoolPointer(false),
Queue_length: utils.IntPointer(50),
Time_window: utils.StringPointer("1h"),
Metrics: utils.StringSlicePointer([]string{"ASR", "ACD", "ACC"}),
Setup_interval: utils.StringSlicePointer([]string{}),
Tors: utils.StringSlicePointer([]string{}),
Cdr_hosts: utils.StringSlicePointer([]string{}),
Cdr_sources: utils.StringSlicePointer([]string{}),
Req_types: utils.StringSlicePointer([]string{}),
Directions: utils.StringSlicePointer([]string{}),
Tenants: utils.StringSlicePointer([]string{}),
Categories: utils.StringSlicePointer([]string{}),
Accounts: utils.StringSlicePointer([]string{}),
Subjects: utils.StringSlicePointer([]string{}),
Destination_prefixes: utils.StringSlicePointer([]string{}),
Usage_interval: utils.StringSlicePointer([]string{}),
Mediation_run_ids: utils.StringSlicePointer([]string{}),
Rated_accounts: utils.StringSlicePointer([]string{}),
Rated_subjects: utils.StringSlicePointer([]string{}),
Cost_interval: utils.Float64SlicePointer([]float64{}),
Enabled: utils.BoolPointer(false),
}
if cfg, err := dfCgrJsonCfg.CdrStatsJsonCfg(); err != nil {
t.Error(err)

View File

@@ -86,28 +86,7 @@ type CdrReplicationJsonCfg struct {
// Cdrstats config section
type CdrStatsJsonCfg struct {
Enabled *bool
Queue_length *int
Time_window *string
Metrics *[]string
Setup_interval *[]string
Tors *[]string
Cdr_hosts *[]string
Cdr_sources *[]string
Req_types *[]string
Directions *[]string
Tenants *[]string
Categories *[]string
Accounts *[]string
Subjects *[]string
Destination_prefixes *[]string
Usage_interval *[]string
Suppliers *[]string
Disconnect_causes *[]string
Mediation_run_ids *[]string
Rated_accounts *[]string
Rated_subjects *[]string
Cost_interval *[]float64
Enabled *bool
}
// One cdr field config, used in cdre and cdrc

View File

@@ -12,6 +12,25 @@
// This file contains the default configuration hardcoded into CGRateS.
// This is what you get when you load CGRateS with an empty configuration file.
/*
Real-time Charging System for Telecom & ISP environments
Copyright (C) ITsysCOM GmbH
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>
*/
//"general": {
// "http_skip_tls_veify": false, // if enabled Http Client will accept any TLS certificate
// "rounding_decimals": 10, // system level precision for floats
@@ -93,25 +112,6 @@
//"cdrstats": {
// "enabled": false, // starts the cdrstats service: <true|false>
// "queue_length": 50, // number of items in the stats buffer
// "time_window": "1h", // will only keep the CDRs who's call setup time is not older than time.Now()-TimeWindow
// "metrics": ["ASR", "ACD", "ACC"], // stat metric ids to build
// "setup_interval": [], // filter on CDR SetupTime
// "tors": [], // filter on CDR TOR fields
// "cdr_hosts": [], // filter on CDR CdrHost fields
// "cdr_sources": [], // filter on CDR CdrSource fields
// "req_types": [], // filter on CDR ReqType fields
// "directions": [], // filter on CDR Direction fields
// "tenants": [], // filter on CDR Tenant fields
// "categories": [], // filter on CDR Category fields
// "accounts": [], // filter on CDR Account fields
// "subjects": [], // filter on CDR Subject fields
// "destination_prefixes": [], // filter on CDR Destination prefixes
// "usage_interval": [], // filter on CDR Usage
// "mediation_run_ids": [], // filter on CDR MediationRunId fields
// "rated_accounts": [], // filter on CDR RatedAccount fields
// "rated_subjects": [], // filter on CDR RatedSubject fields
// "cost_interval": [], // filter on CDR Cost
//},
@@ -143,7 +143,7 @@
// {"tag":"SetupTime", "cdr_field_id": "setup_time", "type": "cdrfield", "value": "setup_time", "layout": "2006-01-02T15:04:05Z07:00"},
// {"tag":"AnswerTime", "cdr_field_id": "answer_time", "type": "cdrfield", "value": "answer_time", "layout": "2006-01-02T15:04:05Z07:00"},
// {"tag":"Usage", "cdr_field_id": "usage", "type": "cdrfield", "value": "usage"},
// {"tag":"Cost", "cdr_field_id": "cost", "type": "cdrfield", "value": "cost"},
// {"tag":"Cost", "cdr_field_id": "cost", "type": "cdrfield", "value": "cost"},
// ],
// "trailer_fields": [], // template of the exported trailer fields
// }
@@ -176,7 +176,7 @@
// {"tag": "answer_time", "cdr_field_id": "answer_time", "type": "cdrfield", "value": "12", "mandatory": true},
// {"tag": "usage", "cdr_field_id": "usage", "type": "cdrfield", "value": "13", "mandatory": true},
// ],
// }
// },
//},
//"sm_freeswitch": {
@@ -241,7 +241,7 @@
//"mailer": {
// "server": "localhost:25", // the server to use when sending emails out
// "server": "localhost", // the server to use when sending emails out
// "auth_user": "cgrates", // authenticate to email server using this user
// "auth_passwd": "CGRateS.org", // authenticate to email server with this password
// "from_address": "cgr-mailer@localhost.localdomain" // from address used when sending emails out

View File

@@ -460,7 +460,7 @@ func TestTutFsCallsCdrStats(t *testing.T) {
return
}
var queueIds []string
eQueueIds := []string{"*default", "CDRST1", "CDRST_1001", "CDRST_1002", "CDRST_1003", "STATS_SUPPL1", "STATS_SUPPL2"}
eQueueIds := []string{"CDRST1", "CDRST_1001", "CDRST_1002", "CDRST_1003", "STATS_SUPPL1", "STATS_SUPPL2"}
if err := tutLocalRpc.Call("CDRStatsV1.GetQueueIds", "", &queueIds); err != nil {
t.Error("Calling CDRStatsV1.GetQueueIds, got error: ", err.Error())
} else if len(eQueueIds) != len(queueIds) {
@@ -860,13 +860,7 @@ func TestTutLocalCdrStatsAfter(t *testing.T) {
return
}
var statMetrics map[string]float64
eMetrics := map[string]float64{engine.ACC: 0.3452380952, engine.ACD: 111.4761904762, engine.ASR: 100}
if err := tutLocalRpc.Call("CDRStatsV1.GetMetrics", v1.AttrGetMetrics{StatsQueueId: utils.META_DEFAULT}, &statMetrics); err != nil {
t.Error("Calling CDRStatsV1.GetMetrics, got error: ", err.Error())
//} else if !reflect.DeepEqual(eMetrics, statMetrics) {
// t.Errorf("Expecting: %v, received: %v", eMetrics, statMetrics)
}
eMetrics = map[string]float64{engine.ACD: 90.2, engine.ASR: 100, engine.TCC: 1.675, engine.TCD: 451, engine.ACC: 0.335}
eMetrics := map[string]float64{engine.ACD: 90.2, engine.ASR: 100, engine.TCC: 1.675, engine.TCD: 451, engine.ACC: 0.335}
if err := tutLocalRpc.Call("CDRStatsV1.GetMetrics", v1.AttrGetMetrics{StatsQueueId: "CDRST1"}, &statMetrics); err != nil {
t.Error("Calling CDRStatsV1.GetMetrics, got error: ", err.Error())
} else if !reflect.DeepEqual(eMetrics, statMetrics) {