Updated integration tests

This commit is contained in:
Trial97
2019-12-10 18:12:17 +02:00
parent d22151861d
commit bbcfc6de42
9 changed files with 74 additions and 56 deletions

View File

@@ -209,6 +209,9 @@ var reqTypes = utils.NewStringSet([]string{utils.META_PSEUDOPREPAID, utils.META_
// getCostFromRater will retrieve the cost from RALs
func (cdrS *CDRServer) getCostFromRater(cdr *CDRWithArgDispatcher) (*CallCost, error) {
if cdrS.rals == nil {
return nil, utils.NewErrNotConnected(utils.RALService)
}
cc := new(CallCost)
var err error
timeStart := cdr.AnswerTime
@@ -449,6 +452,15 @@ func (cdrS *CDRServer) exportCDRs(cdrs []*CDR) (err error) {
// processEvent processes a CGREvent based on arguments
func (cdrS *CDRServer) processEvent(ev *utils.CGREventWithArgDispatcher,
chrgS, attrS, ralS, store, reRate, export, thdS, stS bool) (err error) {
if attrS {
if err = cdrS.attrSProcessEvent(ev); err != nil {
utils.Logger.Warning(
fmt.Sprintf("<%s> error: <%s> processing event %+v with %s",
utils.CDRs, err.Error(), utils.ToJSON(ev), utils.AttributeS))
err = utils.ErrPartiallyExecuted
return
}
}
var cgrEvs []*utils.CGREventWithArgDispatcher
if chrgS {
if cgrEvs, err = cdrS.chrgrSProcessEvent(ev); err != nil {
@@ -461,17 +473,6 @@ func (cdrS *CDRServer) processEvent(ev *utils.CGREventWithArgDispatcher,
} else { // ChargerS not requested, charge the original event
cgrEvs = []*utils.CGREventWithArgDispatcher{ev}
}
if attrS {
for _, cgrEv := range cgrEvs {
if err = cdrS.attrSProcessEvent(cgrEv); err != nil {
utils.Logger.Warning(
fmt.Sprintf("<%s> error: <%s> processing event %+v with %s",
utils.CDRs, err.Error(), cgrEv, utils.AttributeS))
err = utils.ErrPartiallyExecuted
return
}
}
}
// Check if the unique ID was not already processed
for _, cgrEv := range cgrEvs {
me := MapEvent(cgrEv.CGREvent.Event)
@@ -575,7 +576,7 @@ func (cdrS *CDRServer) processEvent(ev *utils.CGREventWithArgDispatcher,
utils.Logger.Warning(
fmt.Sprintf("<%s> error: <%s> exporting CDRs %+v",
utils.CDRs, err.Error(), cdrs))
partiallyExecuted = true
}
}
if thdS {
@@ -584,6 +585,7 @@ func (cdrS *CDRServer) processEvent(ev *utils.CGREventWithArgDispatcher,
utils.Logger.Warning(
fmt.Sprintf("<%s> error: <%s> processing event %+v with %s",
utils.CDRs, err.Error(), cgrEv, utils.ThresholdS))
partiallyExecuted = true
}
}
}
@@ -593,6 +595,7 @@ func (cdrS *CDRServer) processEvent(ev *utils.CGREventWithArgDispatcher,
utils.Logger.Warning(
fmt.Sprintf("<%s> error: <%s> processing event %+v with %s",
utils.CDRs, err.Error(), cgrEv, utils.StatS))
partiallyExecuted = true
}
}
}
@@ -714,13 +717,14 @@ func (cdrS *CDRServer) V1ProcessCDR(cdr *CDRWithArgDispatcher, reply *string) (e
return
}
// ArgV1ProcessEvent is the CGREvent with proccesing Flags
type ArgV1ProcessEvent struct {
Flags []string
utils.CGREvent
*utils.ArgDispatcher
}
// V1ProcessCDR will process the CDR out of CGREvent
// V1ProcessEvent will process the CGREvent
func (cdrS *CDRServer) V1ProcessEvent(arg *ArgV1ProcessEvent, reply *string) (err error) {
if arg.CGREvent.ID == "" {
arg.CGREvent.ID = utils.GenUUID()
@@ -801,7 +805,7 @@ func (cdrS *CDRServer) V1ProcessEvent(arg *ArgV1ProcessEvent, reply *string) (er
return nil
}
// V1StoreSMCost handles storing of the cost into session_costs table
// V1StoreSessionCost handles storing of the cost into session_costs table
func (cdrS *CDRServer) V1StoreSessionCost(attr *AttrCDRSStoreSMCost, reply *string) (err error) {
if attr.Cost.CGRID == "" {
return utils.NewCGRError(utils.CDRSCtx,
@@ -895,6 +899,7 @@ func (cdrS *CDRServer) V2StoreSessionCost(args *ArgsV2CDRSStoreSMCost, reply *st
}
// ArgRateCDRs a cdr with extra flags
type ArgRateCDRs struct {
Flags []string
utils.RPCCDRsFilter
@@ -952,7 +957,7 @@ func (cdrS *CDRServer) V1RateCDRs(arg *ArgRateCDRs, reply *string) (err error) {
return nil
}
// Used to process external CDRs
// V1ProcessExternalCDR is used to process external CDRs
func (cdrS *CDRServer) V1ProcessExternalCDR(eCDR *ExternalCDRWithArgDispatcher, reply *string) error {
cdr, err := NewCDRFromExternalCDR(eCDR.ExternalCDR,
cdrS.cgrCfg.GeneralCfg().DefaultTimezone)
@@ -972,11 +977,11 @@ func (cdrS *CDRServer) V1GetCDRs(args utils.RPCCDRsFilterWithArgDispatcher, cdrs
}
return err
}
if qryCDRs, _, err := cdrS.cdrDb.GetCDRs(cdrsFltr, false); err != nil {
qryCDRs, _, err := cdrS.cdrDb.GetCDRs(cdrsFltr, false)
if err != nil {
return utils.NewErrServerError(err)
} else {
*cdrs = qryCDRs
}
*cdrs = qryCDRs
return nil
}
@@ -990,11 +995,11 @@ func (cdrS *CDRServer) V1CountCDRs(args *utils.RPCCDRsFilterWithArgDispatcher, c
return err
}
cdrsFltr.Count = true
if _, qryCnt, err := cdrS.cdrDb.GetCDRs(cdrsFltr, false); err != nil {
_, qryCnt, err := cdrS.cdrDb.GetCDRs(cdrsFltr, false)
if err != nil {
return utils.NewErrServerError(err)
} else {
*cnt = qryCnt
}
*cnt = qryCnt
return nil
}