Local test for offline cdrstats persistence

This commit is contained in:
DanB
2015-06-29 15:12:04 +02:00
parent 1abd6d526e
commit 7055573f4c
2 changed files with 25 additions and 5 deletions

View File

@@ -159,6 +159,29 @@ func TestCDRStatsLclGetMetrics1(t *testing.T) {
}
}
// Test stats persistence
func TestCDRStatsLclStatsPersistence(t *testing.T) {
if !*testLocal {
return
}
time.Sleep(time.Duration(2) * time.Second) // Allow stats to be updated in dataDb
if _, err := engine.StopStartEngine(cdrstCfgPath, *waitRater); err != nil {
t.Fatal(err)
}
var err error
cdrstRpc, err = jsonrpc.Dial("tcp", cdrstCfg.RPCJSONListen) // We connect over JSON so we can also troubleshoot if needed
if err != nil {
t.Fatal("Could not connect to rater: ", err.Error())
}
var rcvMetrics map[string]float64
expectedMetrics := map[string]float64{"ASR": 75, "ACD": 15}
if err := cdrstRpc.Call("CDRStatsV1.GetMetrics", AttrGetMetrics{StatsQueueId: "CDRST4"}, &rcvMetrics); err != nil {
t.Error("Calling CDRStatsV1.GetMetrics, got error: ", err.Error())
} else if !reflect.DeepEqual(expectedMetrics, rcvMetrics) {
t.Errorf("Expecting: %v, received: %v", expectedMetrics, rcvMetrics)
}
}
func TestCDRStatsLclResetMetrics(t *testing.T) {
if !*testLocal {
return

View File

@@ -7,8 +7,7 @@
"rater": {
"enabled": true, // enable Rater service: <true|false>
},
"cdrs": {
"cdrs": {
"enabled": true, // start the CDR Server service: <true|false>
"store_cdrs": false, // store cdrs in storDb
"rater": "internal", // address where to reach the Rater for cost calculation, empty to disable functionality: <""|internal|x.y.z.y:1234>
@@ -17,9 +16,7 @@
"cdrstats": {
"enabled": true, // starts the cdrstats service: <true|false>
"queue_length": 5, // number of items in the stats buffer
"time_window": "0", // will only keep the CDRs who's call setup time is not older than time.Now()-TimeWindow
"save_interval": "5s",
"save_interval": "1s",
},
}