Merge branch 'master' into aliases

Conflicts:
	general_tests/tutorial_local_test.go
This commit is contained in:
Radu Ioan Fericean
2015-08-11 19:05:08 +03:00
4 changed files with 27 additions and 17 deletions

View File

@@ -38,14 +38,17 @@ func (self *ApierV1) GetLcr(lcrReq engine.LcrRequest, lcrReply *engine.LcrReply)
if lcrQried.Entry == nil {
return utils.ErrNotFound
}
if lcrQried.HasErrors() {
lcrQried.LogErrors()
return fmt.Errorf("%s:%s", utils.ErrServerError.Error(), "LCR_COMPUTE_ERRORS")
}
lcrReply.DestinationId = lcrQried.Entry.DestinationId
lcrReply.RPCategory = lcrQried.Entry.RPCategory
lcrReply.Strategy = lcrQried.Entry.Strategy
for _, qriedSuppl := range lcrQried.SupplierCosts {
if qriedSuppl.Error != "" {
engine.Logger.Err(fmt.Sprintf("LCR_ERROR: supplier <%s>, error <%s>", qriedSuppl.Supplier, qriedSuppl.Error))
if !lcrReq.IgnoreErrors {
return fmt.Errorf("%s:%s", utils.ErrServerError.Error(), "LCR_COMPUTE_ERRORS")
}
continue
}
if dtcs, err := utils.NewDTCSFromRPKey(qriedSuppl.Supplier); err != nil {
return utils.NewErrServerError(err)
} else {
@@ -65,7 +68,7 @@ func (self *ApierV1) GetLcrSuppliers(lcrReq engine.LcrRequest, suppliers *string
if err := self.Responder.GetLCR(&engine.AttrGetLcr{CallDescriptor: cd, Paginator: lcrReq.Paginator}, &lcrQried); err != nil {
return utils.NewErrServerError(err)
}
if lcrQried.HasErrors() {
if lcrQried.HasErrors() && !lcrReq.IgnoreErrors {
lcrQried.LogErrors()
return fmt.Errorf("%s:%s", utils.ErrServerError.Error(), "LCR_ERRORS")
}

View File

@@ -310,6 +310,8 @@ func (cdre *CdrExporter) composeTrailer() error {
func (cdre *CdrExporter) processCdr(cdr *engine.StoredCdr) error {
if cdr == nil || len(cdr.CgrId) == 0 { // We do not export empty CDRs
return nil
} else if cdr.ExtraFields == nil { // Avoid assignment in nil map if not initialized
cdr.ExtraFields = make(map[string]string)
}
// Cost multiply
if cdre.dataUsageMultiplyFactor != 0.0 && cdr.TOR == utils.DATA {

View File

@@ -48,14 +48,15 @@ const (
// A request for LCR, used in APIer and SM where we need to expose it
type LcrRequest struct {
Direction string
Tenant string
Category string
Account string
Subject string
Destination string
StartTime string
Duration string
Direction string
Tenant string
Category string
Account string
Subject string
Destination string
StartTime string
Duration string
IgnoreErrors bool
*utils.Paginator
}
@@ -434,6 +435,9 @@ func (lc *LCRCost) SuppliersSlice() ([]string, error) {
}
supps := []string{}
for _, supplCost := range lc.SupplierCosts {
if supplCost.Error != "" {
continue // Do not add the supplier with cost errors to list of suppliers available
}
if dtcs, err := utils.NewDTCSFromRPKey(supplCost.Supplier); err != nil {
return nil, err
} else if len(dtcs.Subject) != 0 {

View File

@@ -116,6 +116,7 @@ func TestTutLocalCacheStats(t *testing.T) {
return
}
var rcvStats *utils.CacheStats
expectedStats := &utils.CacheStats{Destinations: 4, RatingPlans: 3, RatingProfiles: 8, Actions: 7, SharedGroups: 1, Aliases: 3,
DerivedChargers: 1, LcrProfiles: 5, CdrStats: 6, Users: 2}
var args utils.AttrCacheStats
@@ -898,8 +899,8 @@ func TestTutLocalLeastCost(t *testing.T) {
Direction: "*out",
Category: "call",
Tenant: "cgrates.org",
Subject: "1004",
Account: "1004",
Subject: "1005",
Account: "1005",
Destination: "1002",
TimeStart: tStart,
TimeEnd: tEnd,
@@ -924,8 +925,8 @@ func TestTutLocalLeastCost(t *testing.T) {
Direction: "*out",
Category: "call",
Tenant: "cgrates.org",
Subject: "1004",
Account: "1004",
Subject: "1005",
Account: "1005",
Destination: "1003",
TimeStart: tStart,
TimeEnd: tEnd,