mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-22 15:48:44 +05:00
Merge branch 'master' into hapool
This commit is contained in:
@@ -49,10 +49,10 @@ func (self *ApierV1) AddRatingSubjectAliases(attrs AttrAddRatingSubjectAliases,
|
||||
}
|
||||
var ignr string
|
||||
for _, alias := range attrs.Aliases {
|
||||
if err := aliases.Call("AliasesV1.SetAlias",
|
||||
&engine.Alias{Direction: utils.META_OUT, Tenant: attrs.Tenant, Category: attrs.Category, Account: alias, Subject: alias, Context: utils.ALIAS_CONTEXT_RATING,
|
||||
Values: engine.AliasValues{&engine.AliasValue{DestinationId: utils.META_ANY,
|
||||
Pairs: engine.AliasPairs{"Subject": map[string]string{alias: attrs.Subject}}, Weight: 10.0}}}, &ignr); err != nil {
|
||||
als := engine.Alias{Direction: utils.META_OUT, Tenant: attrs.Tenant, Category: attrs.Category, Account: alias, Subject: alias, Context: utils.ALIAS_CONTEXT_RATING,
|
||||
Values: engine.AliasValues{&engine.AliasValue{DestinationId: utils.META_ANY,
|
||||
Pairs: engine.AliasPairs{"Account": map[string]string{alias: attrs.Subject}, "Subject": map[string]string{alias: attrs.Subject}}, Weight: 10.0}}}
|
||||
if err := aliases.Call("AliasesV1.SetAlias", als, &ignr); err != nil {
|
||||
return utils.NewErrServerError(err)
|
||||
}
|
||||
}
|
||||
@@ -101,10 +101,10 @@ func (self *ApierV1) AddAccountAliases(attrs AttrAddAccountAliases, reply *strin
|
||||
}
|
||||
var ignr string
|
||||
for _, alias := range attrs.Aliases {
|
||||
if err := aliases.Call("AliasesV1.SetAlias",
|
||||
&engine.Alias{Direction: utils.META_OUT, Tenant: attrs.Tenant, Category: attrs.Category, Account: alias, Subject: alias, Context: utils.ALIAS_CONTEXT_RATING,
|
||||
Values: engine.AliasValues{&engine.AliasValue{DestinationId: utils.META_ANY,
|
||||
Pairs: engine.AliasPairs{"Account": map[string]string{alias: attrs.Account}}, Weight: 10.0}}}, &ignr); err != nil {
|
||||
als := engine.Alias{Direction: utils.META_OUT, Tenant: attrs.Tenant, Category: attrs.Category, Account: alias, Subject: alias, Context: utils.ALIAS_CONTEXT_RATING,
|
||||
Values: engine.AliasValues{&engine.AliasValue{DestinationId: utils.META_ANY,
|
||||
Pairs: engine.AliasPairs{"Account": map[string]string{alias: attrs.Account}, "Subject": map[string]string{alias: attrs.Account}}, Weight: 10.0}}}
|
||||
if err := aliases.Call("AliasesV1.SetAlias", als, &ignr); err != nil {
|
||||
return utils.NewErrServerError(err)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -97,9 +97,6 @@ func TestGetEmptyDC2(t *testing.T) {
|
||||
if err := apierDcT.GetDerivedChargers(attrs, &dcs); err != nil {
|
||||
t.Error("Unexpected error", err.Error())
|
||||
} else if !reflect.DeepEqual(dcs, apierDcT.Config.DerivedChargers) {
|
||||
for _, dc := range dcs {
|
||||
fmt.Printf("Got dc: %v\n", dc)
|
||||
}
|
||||
t.Error("Returned DerivedChargers not matching the configured ones")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -87,7 +87,7 @@ func (self *SMGenericV1) Call(serviceMethod string, args interface{}, reply inte
|
||||
if !canConvert {
|
||||
return rpcclient.ErrWrongArgsType
|
||||
}
|
||||
replyConverted, canConvert := args.(*float64)
|
||||
replyConverted, canConvert := reply.(*float64)
|
||||
if !canConvert {
|
||||
return rpcclient.ErrWrongReplyType
|
||||
}
|
||||
@@ -97,7 +97,7 @@ func (self *SMGenericV1) Call(serviceMethod string, args interface{}, reply inte
|
||||
if !canConvert {
|
||||
return rpcclient.ErrWrongArgsType
|
||||
}
|
||||
replyConverted, canConvert := args.(*[]string)
|
||||
replyConverted, canConvert := reply.(*[]string)
|
||||
if !canConvert {
|
||||
return rpcclient.ErrWrongReplyType
|
||||
}
|
||||
@@ -107,7 +107,7 @@ func (self *SMGenericV1) Call(serviceMethod string, args interface{}, reply inte
|
||||
if !canConvert {
|
||||
return rpcclient.ErrWrongArgsType
|
||||
}
|
||||
replyConverted, canConvert := args.(*float64)
|
||||
replyConverted, canConvert := reply.(*float64)
|
||||
if !canConvert {
|
||||
return rpcclient.ErrWrongReplyType
|
||||
}
|
||||
@@ -117,7 +117,7 @@ func (self *SMGenericV1) Call(serviceMethod string, args interface{}, reply inte
|
||||
if !canConvert {
|
||||
return rpcclient.ErrWrongArgsType
|
||||
}
|
||||
replyConverted, canConvert := args.(*float64)
|
||||
replyConverted, canConvert := reply.(*float64)
|
||||
if !canConvert {
|
||||
return rpcclient.ErrWrongReplyType
|
||||
}
|
||||
@@ -127,7 +127,7 @@ func (self *SMGenericV1) Call(serviceMethod string, args interface{}, reply inte
|
||||
if !canConvert {
|
||||
return rpcclient.ErrWrongArgsType
|
||||
}
|
||||
replyConverted, canConvert := args.(*string)
|
||||
replyConverted, canConvert := reply.(*string)
|
||||
if !canConvert {
|
||||
return rpcclient.ErrWrongReplyType
|
||||
}
|
||||
@@ -137,11 +137,11 @@ func (self *SMGenericV1) Call(serviceMethod string, args interface{}, reply inte
|
||||
if !canConvert {
|
||||
return rpcclient.ErrWrongArgsType
|
||||
}
|
||||
replyConverted, canConvert := args.(*string)
|
||||
replyConverted, canConvert := reply.(*string)
|
||||
if !canConvert {
|
||||
return rpcclient.ErrWrongReplyType
|
||||
}
|
||||
return self.SessionEnd(argsConverted, replyConverted)
|
||||
return self.ProcessCdr(argsConverted, replyConverted)
|
||||
}
|
||||
return rpcclient.ErrUnsupporteServiceMethod
|
||||
}
|
||||
|
||||
@@ -304,6 +304,84 @@ 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
|
||||
|
||||
@@ -302,6 +302,84 @@ 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
|
||||
|
||||
Reference in New Issue
Block a user