mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-22 07:38:45 +05:00
Remove default request_processor configuration for diameter_agent
This commit is contained in:
@@ -136,7 +136,33 @@ func TestDmtAgentCCRAsSMGenericEvent(t *testing.T) {
|
||||
"Account": "*users", "AnswerTime": "2015-11-23 12:22:24 +0000 UTC", "Category": "call",
|
||||
"Destination": "4986517174964", "Direction": "*out", "RequestType": "*users", "SetupTime": "2015-11-23 12:22:24 +0000 UTC",
|
||||
"Subject": "*users", "SubscriberId": "4986517174963", "ToR": "*voice", "Tenant": "*users", "Usage": "300"}
|
||||
if smge, err := ccr.AsSMGenericEvent(cfgDefaults.DiameterAgentCfg().RequestProcessors[0].CCRFields); err != nil {
|
||||
ccrFields := []*config.CfgCdrField{
|
||||
&config.CfgCdrField{Tag: "TOR", FieldId: "ToR", Type: "*composed",
|
||||
Value: utils.ParseRSRFieldsMustCompile("^*voice", utils.INFIELD_SEP), Mandatory: true},
|
||||
&config.CfgCdrField{Tag: "OriginID", FieldId: "OriginID", Type: "*composed",
|
||||
Value: utils.ParseRSRFieldsMustCompile("Session-Id", utils.INFIELD_SEP), Mandatory: true},
|
||||
&config.CfgCdrField{Tag: "RequestType", FieldId: "RequestType", Type: "*composed",
|
||||
Value: utils.ParseRSRFieldsMustCompile("^*users", utils.INFIELD_SEP), Mandatory: true},
|
||||
&config.CfgCdrField{Tag: "Direction", FieldId: "Direction", Type: "*composed",
|
||||
Value: utils.ParseRSRFieldsMustCompile("^*out", utils.INFIELD_SEP), Mandatory: true},
|
||||
&config.CfgCdrField{Tag: "Tenant", FieldId: "Tenant", Type: "*composed",
|
||||
Value: utils.ParseRSRFieldsMustCompile("^*users", utils.INFIELD_SEP), Mandatory: true},
|
||||
&config.CfgCdrField{Tag: "Category", FieldId: "Category", Type: "*composed",
|
||||
Value: utils.ParseRSRFieldsMustCompile("^call", utils.INFIELD_SEP), Mandatory: true},
|
||||
&config.CfgCdrField{Tag: "Account", FieldId: "Account", Type: "*composed",
|
||||
Value: utils.ParseRSRFieldsMustCompile("^*users", utils.INFIELD_SEP), Mandatory: true},
|
||||
&config.CfgCdrField{Tag: "Subject", FieldId: "Subject", Type: "*composed",
|
||||
Value: utils.ParseRSRFieldsMustCompile("^*users", utils.INFIELD_SEP), Mandatory: true},
|
||||
&config.CfgCdrField{Tag: "Destination", FieldId: "Destination", Type: "*composed",
|
||||
Value: utils.ParseRSRFieldsMustCompile("Service-Information>IN-Information>Real-Called-Number", utils.INFIELD_SEP), Mandatory: true},
|
||||
&config.CfgCdrField{Tag: "SetupTime", FieldId: "SetupTime", Type: "*composed",
|
||||
Value: utils.ParseRSRFieldsMustCompile("Event-Timestamp", utils.INFIELD_SEP), Mandatory: true},
|
||||
&config.CfgCdrField{Tag: "AnswerTime", FieldId: "AnswerTime", Type: "*composed",
|
||||
Value: utils.ParseRSRFieldsMustCompile("Event-Timestamp", utils.INFIELD_SEP), Mandatory: true},
|
||||
&config.CfgCdrField{Tag: "Usage", FieldId: "Usage", Type: "*handler", HandlerId: "*ccr_usage", Mandatory: true},
|
||||
&config.CfgCdrField{Tag: "SubscriberID", FieldId: "SubscriberId", Type: "*composed",
|
||||
Value: utils.ParseRSRFieldsMustCompile("Subscription-Id>Subscription-Id-Data", utils.INFIELD_SEP), Mandatory: true}}
|
||||
if smge, err := ccr.AsSMGenericEvent(ccrFields); err != nil {
|
||||
t.Error(err)
|
||||
} else if !reflect.DeepEqual(eSMGE, smge) {
|
||||
t.Errorf("Expecting: %+v, received: %+v", eSMGE, smge)
|
||||
|
||||
@@ -317,7 +317,6 @@ func composedFieldvalue(m *diam.Message, outTpl utils.RSRFields, avpIdx int, pro
|
||||
}
|
||||
continue
|
||||
}
|
||||
|
||||
if len(matchingAvps) <= avpIdx {
|
||||
utils.Logger.Warning(fmt.Sprintf("<Diameter> Cannot retrieve AVP with index %d for field template with id: %s", avpIdx, rsrTpl.Id))
|
||||
continue // Not convertible, ignore
|
||||
|
||||
@@ -350,35 +350,7 @@ const CGRATES_CFG_JSON = `
|
||||
"origin_realm": "cgrates.org", // diameter Origin-Realm AVP used in replies
|
||||
"vendor_id": 0, // diameter Vendor-Id AVP used in replies
|
||||
"product_name": "CGRateS", // diameter Product-Name AVP used in replies
|
||||
"request_processors": [
|
||||
{
|
||||
"id": "*default", // formal identifier of this processor
|
||||
"dry_run": false, // do not send the events to SMG, just log them
|
||||
"publish_event": false, // if enabled, it will publish internal event to pubsub
|
||||
"request_filter": "Subscription-Id>Subscription-Id-Type(0)", // filter requests processed by this processor
|
||||
"flags": [], // flags to influence processing behavior
|
||||
"continue_on_success": false, // continue to the next template if executed
|
||||
"append_cca": true, // when continuing will append cca fields of the the previous one
|
||||
"ccr_fields":[ // import content_fields template, tag will match internally CDR field
|
||||
{"tag": "TOR", "field_id": "ToR", "type": "*composed", "value": "^*voice", "mandatory": true},
|
||||
{"tag": "OriginID", "field_id": "OriginID", "type": "*composed", "value": "Session-Id", "mandatory": true},
|
||||
{"tag": "RequestType", "field_id": "RequestType", "type": "*composed", "value": "^*users", "mandatory": true},
|
||||
{"tag": "Direction", "field_id": "Direction", "type": "*composed", "value": "^*out", "mandatory": true},
|
||||
{"tag": "Tenant", "field_id": "Tenant", "type": "*composed", "value": "^*users", "mandatory": true},
|
||||
{"tag": "Category", "field_id": "Category", "type": "*composed", "value": "^call", "mandatory": true},
|
||||
{"tag": "Account", "field_id": "Account", "type": "*composed", "value": "^*users", "mandatory": true},
|
||||
{"tag": "Subject", "field_id": "Subject", "type": "*composed", "value": "^*users", "mandatory": true},
|
||||
{"tag": "Destination", "field_id": "Destination", "type": "*composed", "value": "Service-Information>IN-Information>Real-Called-Number", "mandatory": true},
|
||||
{"tag": "SetupTime", "field_id": "SetupTime", "type": "*composed", "value": "Event-Timestamp", "mandatory": true},
|
||||
{"tag": "AnswerTime", "field_id": "AnswerTime", "type": "*composed", "value": "Event-Timestamp", "mandatory": true},
|
||||
{"tag": "Usage", "field_id": "Usage", "type": "*handler", "handler_id": "*ccr_usage", "mandatory": true},
|
||||
{"tag": "SubscriberID", "field_id": "SubscriberId", "type": "*composed", "value": "Subscription-Id>Subscription-Id-Data", "mandatory": true},
|
||||
],
|
||||
"cca_fields":[ // fields returned in CCA
|
||||
{"tag": "GrantedUnits", "field_id": "Granted-Service-Unit>CC-Time", "type": "*handler", "handler_id": "*cca_usage", "mandatory": true},
|
||||
],
|
||||
},
|
||||
],
|
||||
"request_processors": [],
|
||||
},
|
||||
|
||||
|
||||
|
||||
@@ -553,49 +553,7 @@ func TestDiameterAgentJsonCfg(t *testing.T) {
|
||||
Origin_realm: utils.StringPointer("cgrates.org"),
|
||||
Vendor_id: utils.IntPointer(0),
|
||||
Product_name: utils.StringPointer("CGRateS"),
|
||||
Request_processors: &[]*DARequestProcessorJsnCfg{
|
||||
&DARequestProcessorJsnCfg{
|
||||
Id: utils.StringPointer("*default"),
|
||||
Dry_run: utils.BoolPointer(false),
|
||||
Publish_event: utils.BoolPointer(false),
|
||||
Request_filter: utils.StringPointer("Subscription-Id>Subscription-Id-Type(0)"),
|
||||
Flags: utils.StringSlicePointer([]string{}),
|
||||
Continue_on_success: utils.BoolPointer(false),
|
||||
Append_cca: utils.BoolPointer(true),
|
||||
CCR_fields: &[]*CdrFieldJsonCfg{
|
||||
&CdrFieldJsonCfg{Tag: utils.StringPointer("TOR"), Field_id: utils.StringPointer(utils.TOR), Type: utils.StringPointer(utils.META_COMPOSED),
|
||||
Value: utils.StringPointer("^*voice"), Mandatory: utils.BoolPointer(true)},
|
||||
&CdrFieldJsonCfg{Tag: utils.StringPointer("OriginID"), Field_id: utils.StringPointer(utils.ACCID), Type: utils.StringPointer(utils.META_COMPOSED),
|
||||
Value: utils.StringPointer("Session-Id"), Mandatory: utils.BoolPointer(true)},
|
||||
&CdrFieldJsonCfg{Tag: utils.StringPointer("RequestType"), Field_id: utils.StringPointer(utils.REQTYPE), Type: utils.StringPointer(utils.META_COMPOSED),
|
||||
Value: utils.StringPointer("^*users"), Mandatory: utils.BoolPointer(true)},
|
||||
&CdrFieldJsonCfg{Tag: utils.StringPointer("Direction"), Field_id: utils.StringPointer(utils.DIRECTION), Type: utils.StringPointer(utils.META_COMPOSED),
|
||||
Value: utils.StringPointer("^*out"), Mandatory: utils.BoolPointer(true)},
|
||||
&CdrFieldJsonCfg{Tag: utils.StringPointer("Tenant"), Field_id: utils.StringPointer(utils.TENANT), Type: utils.StringPointer(utils.META_COMPOSED),
|
||||
Value: utils.StringPointer("^*users"), Mandatory: utils.BoolPointer(true)},
|
||||
&CdrFieldJsonCfg{Tag: utils.StringPointer("Category"), Field_id: utils.StringPointer(utils.CATEGORY), Type: utils.StringPointer(utils.META_COMPOSED),
|
||||
Value: utils.StringPointer("^call"), Mandatory: utils.BoolPointer(true)},
|
||||
&CdrFieldJsonCfg{Tag: utils.StringPointer("Account"), Field_id: utils.StringPointer(utils.ACCOUNT), Type: utils.StringPointer(utils.META_COMPOSED),
|
||||
Value: utils.StringPointer("^*users"), Mandatory: utils.BoolPointer(true)},
|
||||
&CdrFieldJsonCfg{Tag: utils.StringPointer("Subject"), Field_id: utils.StringPointer(utils.SUBJECT), Type: utils.StringPointer(utils.META_COMPOSED),
|
||||
Value: utils.StringPointer("^*users"), Mandatory: utils.BoolPointer(true)},
|
||||
&CdrFieldJsonCfg{Tag: utils.StringPointer("Destination"), Field_id: utils.StringPointer(utils.DESTINATION), Type: utils.StringPointer(utils.META_COMPOSED),
|
||||
Value: utils.StringPointer("Service-Information>IN-Information>Real-Called-Number"), Mandatory: utils.BoolPointer(true)},
|
||||
&CdrFieldJsonCfg{Tag: utils.StringPointer("SetupTime"), Field_id: utils.StringPointer(utils.SETUP_TIME), Type: utils.StringPointer(utils.META_COMPOSED),
|
||||
Value: utils.StringPointer("Event-Timestamp"), Mandatory: utils.BoolPointer(true)},
|
||||
&CdrFieldJsonCfg{Tag: utils.StringPointer("AnswerTime"), Field_id: utils.StringPointer(utils.ANSWER_TIME), Type: utils.StringPointer(utils.META_COMPOSED),
|
||||
Value: utils.StringPointer("Event-Timestamp"), Mandatory: utils.BoolPointer(true)},
|
||||
&CdrFieldJsonCfg{Tag: utils.StringPointer("Usage"), Field_id: utils.StringPointer(utils.USAGE), Type: utils.StringPointer(utils.META_HANDLER),
|
||||
Handler_id: utils.StringPointer("*ccr_usage"), Mandatory: utils.BoolPointer(true)},
|
||||
&CdrFieldJsonCfg{Tag: utils.StringPointer("SubscriberID"), Field_id: utils.StringPointer("SubscriberId"), Type: utils.StringPointer(utils.META_COMPOSED),
|
||||
Value: utils.StringPointer("Subscription-Id>Subscription-Id-Data"), Mandatory: utils.BoolPointer(true)},
|
||||
},
|
||||
CCA_fields: &[]*CdrFieldJsonCfg{
|
||||
&CdrFieldJsonCfg{Tag: utils.StringPointer("GrantedUnits"), Type: utils.StringPointer(utils.META_HANDLER), Handler_id: utils.StringPointer("*cca_usage"),
|
||||
Field_id: utils.StringPointer("Granted-Service-Unit>CC-Time"), Mandatory: utils.BoolPointer(true)},
|
||||
},
|
||||
},
|
||||
},
|
||||
Request_processors: &[]*DARequestProcessorJsnCfg{},
|
||||
}
|
||||
if cfg, err := dfCgrJsonCfg.DiameterAgentJsonCfg(); err != nil {
|
||||
t.Error(err)
|
||||
|
||||
@@ -527,34 +527,6 @@ func TestCgrCfgJSONDefaultsResLimCfg(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestCgrCfgJSONDefaultsDiameterAgentCfg(t *testing.T) {
|
||||
reqProc := []*DARequestProcessor{&DARequestProcessor{
|
||||
Id: "*default",
|
||||
DryRun: false,
|
||||
PublishEvent: false,
|
||||
RequestFilter: utils.ParseRSRFieldsMustCompile("Subscription-Id>Subscription-Id-Type(0)", utils.INFIELD_SEP),
|
||||
Flags: utils.StringMap{},
|
||||
ContinueOnSuccess: false,
|
||||
AppendCCA: true,
|
||||
CCRFields: []*CfgCdrField{
|
||||
&CfgCdrField{Tag: "TOR", FieldId: "ToR", Type: "*composed", Value: utils.ParseRSRFieldsMustCompile("^*voice", utils.INFIELD_SEP), Mandatory: true},
|
||||
&CfgCdrField{Tag: "OriginID", FieldId: "OriginID", Type: "*composed", Value: utils.ParseRSRFieldsMustCompile("Session-Id", utils.INFIELD_SEP), Mandatory: true},
|
||||
&CfgCdrField{Tag: "RequestType", FieldId: "RequestType", Type: "*composed", Value: utils.ParseRSRFieldsMustCompile("^*users", utils.INFIELD_SEP), Mandatory: true},
|
||||
&CfgCdrField{Tag: "Direction", FieldId: "Direction", Type: "*composed", Value: utils.ParseRSRFieldsMustCompile("^*out", utils.INFIELD_SEP), Mandatory: true},
|
||||
&CfgCdrField{Tag: "Tenant", FieldId: "Tenant", Type: "*composed", Value: utils.ParseRSRFieldsMustCompile("^*users", utils.INFIELD_SEP), Mandatory: true},
|
||||
&CfgCdrField{Tag: "Category", FieldId: "Category", Type: "*composed", Value: utils.ParseRSRFieldsMustCompile("^call", utils.INFIELD_SEP), Mandatory: true},
|
||||
&CfgCdrField{Tag: "Account", FieldId: "Account", Type: "*composed", Value: utils.ParseRSRFieldsMustCompile("^*users", utils.INFIELD_SEP), Mandatory: true},
|
||||
&CfgCdrField{Tag: "Subject", FieldId: "Subject", Type: "*composed", Value: utils.ParseRSRFieldsMustCompile("^*users", utils.INFIELD_SEP), Mandatory: true},
|
||||
&CfgCdrField{Tag: "Destination", FieldId: "Destination", Type: "*composed", Value: utils.ParseRSRFieldsMustCompile("Service-Information>IN-Information>Real-Called-Number", utils.INFIELD_SEP), Mandatory: true},
|
||||
&CfgCdrField{Tag: "SetupTime", FieldId: "SetupTime", Type: "*composed", Value: utils.ParseRSRFieldsMustCompile("Event-Timestamp", utils.INFIELD_SEP), Mandatory: true},
|
||||
&CfgCdrField{Tag: "AnswerTime", FieldId: "AnswerTime", Type: "*composed", Value: utils.ParseRSRFieldsMustCompile("Event-Timestamp", utils.INFIELD_SEP), Mandatory: true},
|
||||
&CfgCdrField{Tag: "Usage", FieldId: "Usage", Type: "*handler", HandlerId: "*ccr_usage", Mandatory: true},
|
||||
&CfgCdrField{Tag: "SubscriberID", FieldId: "SubscriberId", Type: "*composed", Value: utils.ParseRSRFieldsMustCompile("Subscription-Id>Subscription-Id-Data", utils.INFIELD_SEP), Mandatory: true},
|
||||
},
|
||||
CCAFields: []*CfgCdrField{
|
||||
&CfgCdrField{Tag: "GrantedUnits", FieldId: "Granted-Service-Unit>CC-Time", Type: "*handler", HandlerId: "*cca_usage", Mandatory: true}},
|
||||
},
|
||||
}
|
||||
|
||||
testDA := &DiameterAgentCfg{
|
||||
Enabled: false,
|
||||
Listen: "127.0.0.1:3868",
|
||||
@@ -568,7 +540,7 @@ func TestCgrCfgJSONDefaultsDiameterAgentCfg(t *testing.T) {
|
||||
OriginRealm: "cgrates.org",
|
||||
VendorId: 0,
|
||||
ProductName: "CGRateS",
|
||||
RequestProcessors: reqProc,
|
||||
RequestProcessors: nil,
|
||||
}
|
||||
|
||||
if !reflect.DeepEqual(cgrCfg.diameterAgentCfg.Enabled, testDA.Enabled) {
|
||||
|
||||
Reference in New Issue
Block a user