mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-24 00:28:44 +05:00
When attributes is require and isn't found return mandatory ie missing fixes #1315
This commit is contained in:
committed by
Dan Christian Bogos
parent
0a1c499646
commit
7f66a22701
@@ -54,6 +54,7 @@ var sTestsAlsPrf = []func(t *testing.T){
|
||||
testAttributeSGetAttributeForEventNotFound,
|
||||
testAttributeSGetAttributeForEventWithMetaAnyContext,
|
||||
testAttributeSProcessEvent,
|
||||
testAttributeSProcessEventMissing,
|
||||
testAttributeSProcessEventWithNoneSubstitute,
|
||||
testAttributeSProcessEventWithNoneSubstitute2,
|
||||
testAttributeSProcessEventWithNoneSubstitute3,
|
||||
@@ -349,6 +350,24 @@ func testAttributeSProcessEvent(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func testAttributeSProcessEventMissing(t *testing.T) {
|
||||
ev := &utils.CGREvent{
|
||||
Tenant: "cgrates.org",
|
||||
ID: "testAttributeSProcessEvent",
|
||||
Context: utils.StringPointer(utils.MetaSessionS),
|
||||
Event: map[string]interface{}{
|
||||
utils.Account: "NonExist",
|
||||
utils.Category: "*attributes",
|
||||
utils.Destination: "+491511231234",
|
||||
},
|
||||
}
|
||||
var rplyEv engine.AttrSProcessEventReply
|
||||
if err := attrSRPC.Call(utils.AttributeSv1ProcessEvent,
|
||||
ev, &rplyEv); err == nil && err != utils.ErrMandatoryIeMissing {
|
||||
t.Error(err)
|
||||
}
|
||||
}
|
||||
|
||||
func testAttributeSProcessEventWithNoneSubstitute(t *testing.T) {
|
||||
ev := &utils.CGREvent{
|
||||
Tenant: "cgrates.org",
|
||||
|
||||
@@ -165,6 +165,15 @@ func (alS *AttributeService) processEvent(args *AttrArgsProcessEvent) (
|
||||
rply *AttrSProcessEventReply, err error) {
|
||||
attrPrf, err := alS.attributeProfileForEvent(args)
|
||||
if err != nil {
|
||||
if err == utils.ErrNotFound {
|
||||
// change the error in case that at least one field need to be processed by attributes
|
||||
for _, valIface := range args.CGREvent.Event {
|
||||
if valIface == interface{}(utils.MetaAttributes) {
|
||||
err = utils.ErrMandatoryIeMissing
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
return nil, err
|
||||
}
|
||||
rply = &AttrSProcessEventReply{
|
||||
@@ -204,11 +213,12 @@ func (alS *AttributeService) processEvent(args *AttrArgsProcessEvent) (
|
||||
}
|
||||
for _, valIface := range rply.CGREvent.Event {
|
||||
if valIface == interface{}(utils.MetaAttributes) {
|
||||
// mandatory IE missing
|
||||
return nil, utils.NewCGRError(
|
||||
utils.AttributeSv1ProcessEvent,
|
||||
utils.AttributesNotFound,
|
||||
utils.AttributesNotFound,
|
||||
utils.AttributesNotFound)
|
||||
utils.ErrMandatoryIeMissing.Error(),
|
||||
utils.ErrMandatoryIeMissing.Error(),
|
||||
utils.ErrMandatoryIeMissing.Error())
|
||||
}
|
||||
}
|
||||
return
|
||||
@@ -239,7 +249,7 @@ func (alS *AttributeService) V1ProcessEvent(args *AttrArgsProcessEvent,
|
||||
for i := 0; i < *args.ProcessRuns; i++ {
|
||||
evRply, err := alS.processEvent(args)
|
||||
if err != nil {
|
||||
if err != utils.ErrNotFound {
|
||||
if err != utils.ErrNotFound && err != utils.ErrMandatoryIeMissing {
|
||||
err = utils.NewErrServerError(err)
|
||||
} else if i != 0 { // ignore "not found" in a loop different than 0
|
||||
err = nil
|
||||
|
||||
@@ -30,6 +30,8 @@ type Metric interface {
|
||||
GetValue() float64
|
||||
}
|
||||
|
||||
// Old metric (deprecated)
|
||||
// New mtric are in statmetrics.go
|
||||
const ASR = "ASR"
|
||||
const ACD = "ACD"
|
||||
const TCD = "TCD"
|
||||
|
||||
Reference in New Issue
Block a user