mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-11 18:16:24 +05:00
CDR processing benchmarks attached to local tests in apier/v2/cdrs_*
This commit is contained in:
@@ -23,6 +23,7 @@ import (
|
||||
"net/rpc"
|
||||
"net/rpc/jsonrpc"
|
||||
"path"
|
||||
"strconv"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
@@ -304,6 +305,82 @@ func TestV2CdrsMysqlRateWithTP(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
// Benchmark speed of processing 1000 CDRs
|
||||
func TestV2CdrsMysqlProcessRatedExternalCdrBenchmark(t *testing.T) {
|
||||
if !*testLocal {
|
||||
return
|
||||
}
|
||||
cdr := &engine.ExternalCdr{TOR: utils.VOICE,
|
||||
AccId: "benchratedcdr", CdrHost: "192.168.1.1", CdrSource: utils.UNIT_TEST, ReqType: utils.META_RATED, Direction: utils.OUT,
|
||||
Tenant: "cgrates.org", Category: "call", Account: "1003", Subject: "1003", Destination: "1001", Supplier: "SUPPL1",
|
||||
SetupTime: "2014-08-04T13:00:00Z", AnswerTime: "2014-08-04T13:00:07Z",
|
||||
Usage: "15", Pdd: "7.0", ExtraFields: map[string]string{"field_extr1": "val_extr1", "fieldextr2": "valextr2"},
|
||||
}
|
||||
var reply string
|
||||
tStart := time.Now()
|
||||
nrCdrs := 1000
|
||||
for i := 0; i < nrCdrs; i++ {
|
||||
cdr.AccId = "benchratedcdr" + strconv.Itoa(i)
|
||||
if err := cdrsRpc.Call("CdrsV2.ProcessExternalCdr", cdr, &reply); err != nil {
|
||||
t.Error("Unexpected error: ", err.Error())
|
||||
} else if reply != utils.OK {
|
||||
t.Error("Unexpected reply received: ", reply)
|
||||
}
|
||||
}
|
||||
if durExec := time.Now().Sub(tStart); durExec > time.Duration(1)*time.Second {
|
||||
t.Errorf("Processing of %d rated CDRs took: %v", nrCdrs, durExec)
|
||||
}
|
||||
}
|
||||
|
||||
// Benchmark speed of re-rating 1000 CDRs
|
||||
func TestV2CdrsMysqlReRateWithTPBenchmark(t *testing.T) {
|
||||
if !*testLocal {
|
||||
return
|
||||
}
|
||||
var nrCdrs int64
|
||||
req := utils.AttrRateCdrs{RerateRated: true, RerateErrors: true}
|
||||
if err := cdrsRpc.Call("ApierV2.CountCdrs", req, &nrCdrs); err != nil {
|
||||
t.Error("Unexpected error: ", err.Error())
|
||||
}
|
||||
tStart := time.Now()
|
||||
var reply string
|
||||
if err := cdrsRpc.Call("CdrsV2.RateCdrs", req, &reply); err != nil {
|
||||
t.Error("Unexpected error: ", err.Error())
|
||||
} else if reply != utils.OK {
|
||||
t.Error("Unexpected reply received: ", reply)
|
||||
}
|
||||
if durExec := time.Now().Sub(tStart); durExec > time.Duration(1)*time.Second {
|
||||
t.Errorf("Rerating of %d rated CDRs took: %v", nrCdrs, durExec)
|
||||
}
|
||||
}
|
||||
|
||||
// Benchmark speed of processing 1000 postpaid CDRs
|
||||
func TestV2CdrsMysqlProcessPostpaidExternalCdrBenchmark(t *testing.T) {
|
||||
if !*testLocal {
|
||||
return
|
||||
}
|
||||
cdr := &engine.ExternalCdr{TOR: utils.VOICE,
|
||||
AccId: "benchpostpaidcdr", CdrHost: "192.168.1.1", CdrSource: utils.UNIT_TEST, ReqType: utils.META_POSTPAID, Direction: utils.OUT,
|
||||
Tenant: "cgrates.org", Category: "call", Account: "1001", Subject: "1001", Destination: "1002", Supplier: "SUPPL1",
|
||||
SetupTime: "2014-08-04T13:00:00Z", AnswerTime: "2014-08-04T13:00:07Z",
|
||||
Usage: "15", Pdd: "7.0", ExtraFields: map[string]string{"field_extr1": "val_extr1", "fieldextr2": "valextr2"},
|
||||
}
|
||||
var reply string
|
||||
tStart := time.Now()
|
||||
nrCdrs := 1000
|
||||
for i := 0; i < nrCdrs; i++ {
|
||||
cdr.AccId = "benchpostpaidcdr" + strconv.Itoa(i)
|
||||
if err := cdrsRpc.Call("CdrsV2.ProcessExternalCdr", cdr, &reply); err != nil {
|
||||
t.Error("Unexpected error: ", err.Error())
|
||||
} else if reply != utils.OK {
|
||||
t.Error("Unexpected reply received: ", reply)
|
||||
}
|
||||
}
|
||||
if durExec := time.Now().Sub(tStart); durExec > time.Duration(1)*time.Second {
|
||||
t.Errorf("Processing of %d postpaid CDRs took: %v", nrCdrs, durExec)
|
||||
}
|
||||
}
|
||||
|
||||
func TestV2CdrsMysqlKillEngine(t *testing.T) {
|
||||
if !*testLocal {
|
||||
return
|
||||
|
||||
@@ -23,6 +23,7 @@ import (
|
||||
"net/rpc/jsonrpc"
|
||||
"os/exec"
|
||||
"path"
|
||||
"strconv"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
@@ -302,6 +303,82 @@ func TestV2CdrsPsqlRateWithTP(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
// Benchmark speed of processing 1000 CDRs
|
||||
func TestV2CdrsPsqlProcessRatedExternalCdrBenchmark(t *testing.T) {
|
||||
if !*testLocal {
|
||||
return
|
||||
}
|
||||
cdr := &engine.ExternalCdr{TOR: utils.VOICE,
|
||||
AccId: "benchratedcdr", CdrHost: "192.168.1.1", CdrSource: utils.UNIT_TEST, ReqType: utils.META_RATED, Direction: utils.OUT,
|
||||
Tenant: "cgrates.org", Category: "call", Account: "1003", Subject: "1003", Destination: "1001", Supplier: "SUPPL1",
|
||||
SetupTime: "2014-08-04T13:00:00Z", AnswerTime: "2014-08-04T13:00:07Z",
|
||||
Usage: "15", Pdd: "7.0", ExtraFields: map[string]string{"field_extr1": "val_extr1", "fieldextr2": "valextr2"},
|
||||
}
|
||||
var reply string
|
||||
tStart := time.Now()
|
||||
nrCdrs := 1000
|
||||
for i := 0; i < nrCdrs; i++ {
|
||||
cdr.AccId = "benchratedcdr" + strconv.Itoa(i)
|
||||
if err := cdrsPsqlRpc.Call("CdrsV2.ProcessExternalCdr", cdr, &reply); err != nil {
|
||||
t.Error("Unexpected error: ", err.Error())
|
||||
} else if reply != utils.OK {
|
||||
t.Error("Unexpected reply received: ", reply)
|
||||
}
|
||||
}
|
||||
if durExec := time.Now().Sub(tStart); durExec > time.Duration(1)*time.Second {
|
||||
t.Errorf("Processing of %d rated CDRs took: %v", nrCdrs, durExec)
|
||||
}
|
||||
}
|
||||
|
||||
// Benchmark speed of re-rating 1000 CDRs
|
||||
func TestV2CdrsPsqlReRateWithTPBenchmark(t *testing.T) {
|
||||
if !*testLocal {
|
||||
return
|
||||
}
|
||||
var nrCdrs int64
|
||||
req := utils.AttrRateCdrs{RerateRated: true, RerateErrors: true}
|
||||
if err := cdrsPsqlRpc.Call("ApierV2.CountCdrs", req, &nrCdrs); err != nil {
|
||||
t.Error("Unexpected error: ", err.Error())
|
||||
}
|
||||
tStart := time.Now()
|
||||
var reply string
|
||||
if err := cdrsPsqlRpc.Call("CdrsV2.RateCdrs", req, &reply); err != nil {
|
||||
t.Error("Unexpected error: ", err.Error())
|
||||
} else if reply != utils.OK {
|
||||
t.Error("Unexpected reply received: ", reply)
|
||||
}
|
||||
if durExec := time.Now().Sub(tStart); durExec > time.Duration(1)*time.Second {
|
||||
t.Errorf("Rerating of %d rated CDRs took: %v", nrCdrs, durExec)
|
||||
}
|
||||
}
|
||||
|
||||
// Benchmark speed of processing 1000 postpaid CDRs
|
||||
func TestV2CdrsPsqlProcessPostpaidExternalCdrBenchmark(t *testing.T) {
|
||||
if !*testLocal {
|
||||
return
|
||||
}
|
||||
cdr := &engine.ExternalCdr{TOR: utils.VOICE,
|
||||
AccId: "benchpostpaidcdr", CdrHost: "192.168.1.1", CdrSource: utils.UNIT_TEST, ReqType: utils.META_POSTPAID, Direction: utils.OUT,
|
||||
Tenant: "cgrates.org", Category: "call", Account: "1001", Subject: "1001", Destination: "1002", Supplier: "SUPPL1",
|
||||
SetupTime: "2014-08-04T13:00:00Z", AnswerTime: "2014-08-04T13:00:07Z",
|
||||
Usage: "15", Pdd: "7.0", ExtraFields: map[string]string{"field_extr1": "val_extr1", "fieldextr2": "valextr2"},
|
||||
}
|
||||
var reply string
|
||||
tStart := time.Now()
|
||||
nrCdrs := 1000
|
||||
for i := 0; i < nrCdrs; i++ {
|
||||
cdr.AccId = "benchpostpaidcdr" + strconv.Itoa(i)
|
||||
if err := cdrsPsqlRpc.Call("CdrsV2.ProcessExternalCdr", cdr, &reply); err != nil {
|
||||
t.Error("Unexpected error: ", err.Error())
|
||||
} else if reply != utils.OK {
|
||||
t.Error("Unexpected reply received: ", reply)
|
||||
}
|
||||
}
|
||||
if durExec := time.Now().Sub(tStart); durExec > time.Duration(1)*time.Second {
|
||||
t.Errorf("Processing of %d postpaid CDRs took: %v", nrCdrs, durExec)
|
||||
}
|
||||
}
|
||||
|
||||
func TestV2CdrsPsqlKillEngine(t *testing.T) {
|
||||
if !*testLocal {
|
||||
return
|
||||
|
||||
@@ -20,7 +20,6 @@ package engine
|
||||
|
||||
import (
|
||||
"path"
|
||||
//"reflect"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
|
||||
@@ -21,14 +21,11 @@ package general_tests
|
||||
import (
|
||||
"net/rpc"
|
||||
"net/rpc/jsonrpc"
|
||||
//"os"
|
||||
"path"
|
||||
"reflect"
|
||||
//"strings"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
//"github.com/cgrates/cgrates/apier/v1"
|
||||
"github.com/cgrates/cgrates/config"
|
||||
"github.com/cgrates/cgrates/engine"
|
||||
"github.com/cgrates/cgrates/utils"
|
||||
|
||||
Reference in New Issue
Block a user