From aaba103bd8f79955f204c8c3d86b451fc226c59d Mon Sep 17 00:00:00 2001 From: Trial97 Date: Wed, 15 Jul 2020 13:06:48 +0300 Subject: [PATCH] Updated SessionS.V1ProcessEvent integration tests --- apier/v1/preload_it_test.go | 7 ++- apier/v1/sessions_process_event_it_test.go | 57 ++++++++++--------- cmd/cgr-engine/cgr-engine.go | 9 ++- data/conf/samples/diam_tutmysql/sms.json | 2 +- .../samples/diamagent_internal/tests.json | 2 +- .../diamagent_internal/wrong_template.json | 2 +- data/conf/samples/diamagent_mongo/tests.json | 2 +- data/conf/samples/diamagent_mysql/tests.json | 2 +- .../diamagent_mysql/wrong_template.json | 2 +- .../samples/dispatchers/diamagent/data.json | 8 +-- .../samples/dispatchers/diamagent/dryrun.json | 4 +- .../dispatchers/diamagent/message.json | 2 +- .../samples/dispatchers/diamagent/mms.json | 2 +- .../samples/dispatchers/diamagent/simpa.json | 2 +- .../samples/dispatchers/diamagent/tests.json | 4 +- .../samples/dispatchers/diamagent/voice.json | 6 +- .../samples/sipagent_internal/redirect.json | 24 ++++---- .../conf/samples/sipagent_mongo/redirect.json | 24 ++++---- .../conf/samples/sipagent_mysql/redirect.json | 24 ++++---- .../cgrates/etc/cgrates/redirect.json | 36 ++++++------ general_tests/session2_it_test.go | 2 +- packages/debian/changelog | 1 + servmanager/servmanager.go | 2 +- sessions/sessions.go | 2 +- utils/consts.go | 2 +- 25 files changed, 122 insertions(+), 108 deletions(-) diff --git a/apier/v1/preload_it_test.go b/apier/v1/preload_it_test.go index 92cd852a6..62747f10d 100644 --- a/apier/v1/preload_it_test.go +++ b/apier/v1/preload_it_test.go @@ -29,6 +29,7 @@ import ( "os/exec" "path" "reflect" + "sort" "testing" "time" @@ -151,8 +152,12 @@ func testPreloadITVerifyAttributes(t *testing.T) { t.Fatal(err) } reply.Compile() + sort.Strings(reply.Contexts) if !reflect.DeepEqual(eAttrPrf, reply) { - t.Errorf("Expecting : %+v,\n received: %+v", utils.ToJSON(eAttrPrf), utils.ToJSON(reply)) + eAttrPrf.Attributes[1].FilterIDs = nil + if !reflect.DeepEqual(eAttrPrf, reply) { + t.Errorf("Expecting : %+v,\n received: %+v", utils.ToJSON(eAttrPrf), utils.ToJSON(reply)) + } } } diff --git a/apier/v1/sessions_process_event_it_test.go b/apier/v1/sessions_process_event_it_test.go index c64182a76..f167bad14 100644 --- a/apier/v1/sessions_process_event_it_test.go +++ b/apier/v1/sessions_process_event_it_test.go @@ -158,7 +158,7 @@ func testSSv1ItProcessEventAuth(t *testing.T) { args := &sessions.V1ProcessEventArgs{ Flags: []string{utils.ConcatenatedKey(utils.MetaResources, utils.MetaAuthorize), utils.ConcatenatedKey(utils.MetaRALs, utils.MetaAuthorize), - utils.MetaRoutes, utils.MetaAttributes}, + utils.MetaRoutes, utils.MetaAttributes, utils.MetaMultiple}, CGREvent: &utils.CGREvent{ Tenant: "cgrates.org", ID: "testSSv1ItProcessEventAuth", @@ -204,8 +204,8 @@ func testSSv1ItProcessEventAuth(t *testing.T) { }, }, } - if !reflect.DeepEqual(eSplrs, rply.Routes) { - t.Errorf("expecting: %+v,\n received: %+v", utils.ToJSON(eSplrs), utils.ToJSON(rply.Routes)) + if !reflect.DeepEqual(eSplrs, rply.Routes[utils.MetaRaw]) { + t.Errorf("expecting: %+v,\n received: %+v", utils.ToJSON(eSplrs), utils.ToJSON(rply.Routes[utils.MetaRaw])) } eAttrs := &engine.AttrSProcessEventReply{ MatchedProfiles: []string{"ATTR_ACNT_1001"}, @@ -227,9 +227,9 @@ func testSSv1ItProcessEventAuth(t *testing.T) { }, }, } - if !reflect.DeepEqual(eAttrs, rply.Attributes) { + if !reflect.DeepEqual(eAttrs, rply.Attributes[utils.MetaRaw]) { t.Errorf("expecting: %+v, received: %+v", - utils.ToJSON(eAttrs), utils.ToJSON(rply.Attributes)) + utils.ToJSON(eAttrs), utils.ToJSON(rply.Attributes[utils.MetaRaw])) } } @@ -237,7 +237,8 @@ func testSSv1ItProcessEventInitiateSession(t *testing.T) { initUsage := 5 * time.Minute args := &sessions.V1ProcessEventArgs{ Flags: []string{utils.ConcatenatedKey(utils.MetaRALs, utils.MetaInitiate), - utils.ConcatenatedKey(utils.MetaResources, utils.MetaAllocate), utils.MetaAttributes}, + utils.ConcatenatedKey(utils.MetaResources, utils.MetaAllocate), utils.MetaAttributes, + utils.MetaMultiple}, CGREvent: &utils.CGREvent{ Tenant: "cgrates.org", ID: "testSSv1ItProcessEventInitiateSession", @@ -290,9 +291,9 @@ func testSSv1ItProcessEventInitiateSession(t *testing.T) { }, }, } - if !reflect.DeepEqual(eAttrs, rply.Attributes) { + if !reflect.DeepEqual(eAttrs, rply.Attributes[utils.MetaRaw]) { t.Errorf("expecting: %+v, received: %+v", - utils.ToJSON(eAttrs), utils.ToJSON(rply.Attributes)) + utils.ToJSON(eAttrs), utils.ToJSON(rply.Attributes[utils.MetaRaw])) } aSessions := make([]*sessions.ExternalSession, 0) if err := sSv1BiRpc.Call(utils.SessionSv1GetActiveSessions, &utils.SessionFilter{}, &aSessions); err != nil { @@ -349,9 +350,9 @@ func testSSv1ItProcessEventUpdateSession(t *testing.T) { }, }, } - if !reflect.DeepEqual(eAttrs, rply.Attributes) { + if !reflect.DeepEqual(eAttrs, rply.Attributes[utils.MetaRaw]) { t.Errorf("expecting: %+v, received: %+v", - utils.ToJSON(eAttrs), utils.ToJSON(rply.Attributes)) + utils.ToJSON(eAttrs), utils.ToJSON(rply.Attributes[utils.MetaRaw])) } // in case of prepaid and pseudoprepade we expect a MaxUsage of 5min // and in case of postpaid and rated we expect the value of Usage field @@ -499,15 +500,15 @@ func testSSv1ItProcessEventWithGetCost(t *testing.T) { } if rply.Attributes == nil { t.Error("Received nil Attributes") - } else if !reflect.DeepEqual(rply.Attributes.MatchedProfiles, []string{"ATTR_SUBJECT_CASE1"}) { - t.Errorf("Expected: %+v,received: %+v", []string{"ATTR_SUBJECT_CASE1"}, rply.Attributes.MatchedProfiles) - } else if !reflect.DeepEqual(rply.Attributes.AlteredFields, []string{"*req.Subject"}) { - t.Errorf("Expected: %+v,received: %+v", []string{"*req.Subject"}, rply.Attributes.AlteredFields) + } else if !reflect.DeepEqual(rply.Attributes[utils.MetaRaw].MatchedProfiles, []string{"ATTR_SUBJECT_CASE1"}) { + t.Errorf("Expected: %+v,received: %+v", []string{"ATTR_SUBJECT_CASE1"}, rply.Attributes[utils.MetaRaw].MatchedProfiles) + } else if !reflect.DeepEqual(rply.Attributes[utils.MetaRaw].AlteredFields, []string{"*req.Subject"}) { + t.Errorf("Expected: %+v,received: %+v", []string{"*req.Subject"}, rply.Attributes[utils.MetaRaw].AlteredFields) } if rply.Cost == nil { t.Errorf("Received nil Cost") - } else if *rply.Cost != 0.198 { // same cost as in CDR - t.Errorf("Expected: %+v,received: %+v", 0.198, *rply.Cost) + } else if rply.Cost[utils.MetaRaw] != 0.198 { // same cost as in CDR + t.Errorf("Expected: %+v,received: %+v", 0.198, rply.Cost[utils.MetaRaw]) } } @@ -538,15 +539,15 @@ func testSSv1ItProcessEventWithGetCost2(t *testing.T) { } if rply.Attributes == nil { t.Error("Received nil Attributes") - } else if !reflect.DeepEqual(rply.Attributes.MatchedProfiles, []string{"ATTR_SUBJECT_CASE2"}) { - t.Errorf("Expected: %+v,received: %+v", []string{"ATTR_SUBJECT_CASE2"}, rply.Attributes.MatchedProfiles) - } else if !reflect.DeepEqual(rply.Attributes.AlteredFields, []string{"*req.Subject"}) { - t.Errorf("Expected: %+v,received: %+v", []string{"*req.Subject"}, rply.Attributes.AlteredFields) + } else if !reflect.DeepEqual(rply.Attributes[utils.MetaRaw].MatchedProfiles, []string{"ATTR_SUBJECT_CASE2"}) { + t.Errorf("Expected: %+v,received: %+v", []string{"ATTR_SUBJECT_CASE2"}, rply.Attributes[utils.MetaRaw].MatchedProfiles) + } else if !reflect.DeepEqual(rply.Attributes[utils.MetaRaw].AlteredFields, []string{"*req.Subject"}) { + t.Errorf("Expected: %+v,received: %+v", []string{"*req.Subject"}, rply.Attributes[utils.MetaRaw].AlteredFields) } if rply.Cost == nil { t.Errorf("Received nil Cost") - } else if *rply.Cost != 0.102 { // same cost as in CDR - t.Errorf("Expected: %+v,received: %+v", 0.102, *rply.Cost) + } else if rply.Cost[utils.MetaRaw] != 0.102 { // same cost as in CDR + t.Errorf("Expected: %+v,received: %+v", 0.102, rply.Cost[utils.MetaRaw]) } } @@ -579,15 +580,15 @@ func testSSv1ItProcessEventWithGetCost3(t *testing.T) { } if rply.Attributes == nil { t.Error("Received nil Attributes") - } else if !reflect.DeepEqual(rply.Attributes.MatchedProfiles, []string{"ATTR_SUBJECT_CASE3"}) { - t.Errorf("Expected: %+v,received: %+v", []string{"ATTR_SUBJECT_CASE3"}, rply.Attributes.MatchedProfiles) - } else if !reflect.DeepEqual(rply.Attributes.AlteredFields, []string{"*req.Subject"}) { - t.Errorf("Expected: %+v,received: %+v", []string{"*req.Subject"}, rply.Attributes.AlteredFields) + } else if !reflect.DeepEqual(rply.Attributes[utils.MetaRaw].MatchedProfiles, []string{"ATTR_SUBJECT_CASE3"}) { + t.Errorf("Expected: %+v,received: %+v", []string{"ATTR_SUBJECT_CASE3"}, rply.Attributes[utils.MetaRaw].MatchedProfiles) + } else if !reflect.DeepEqual(rply.Attributes[utils.MetaRaw].AlteredFields, []string{"*req.Subject"}) { + t.Errorf("Expected: %+v,received: %+v", []string{"*req.Subject"}, rply.Attributes[utils.MetaRaw].AlteredFields) } if rply.Cost == nil { t.Errorf("Received nil Cost") - } else if *rply.Cost != 2.9999 { - t.Errorf("Expected: %+v,received: %+v", 2.9999, *rply.Cost) + } else if rply.Cost[utils.MetaRaw] != 2.9999 { + t.Errorf("Expected: %+v,received: %+v", 2.9999, rply.Cost[utils.MetaRaw]) } } diff --git a/cmd/cgr-engine/cgr-engine.go b/cmd/cgr-engine/cgr-engine.go index bf156edae..4288f467a 100644 --- a/cmd/cgr-engine/cgr-engine.go +++ b/cmd/cgr-engine/cgr-engine.go @@ -481,12 +481,19 @@ func main() { }) dmService := services.NewDataDBService(cfg, connManager) - storDBService := services.NewStorDBService(cfg) if dmService.ShouldRun() { // Some services can run without db, ie: ERs if err = dmService.Start(); err != nil { return } } + + storDBService := services.NewStorDBService(cfg) + if storDBService.ShouldRun() { // Some services can run without db, ie: ERs + if err = storDBService.Start(); err != nil { + return + } + } + // Done initing DBs engine.SetRoundingDecimals(cfg.GeneralCfg().RoundingDecimals) engine.SetFailedPostCacheTTL(cfg.GeneralCfg().FailedPostsTTL) diff --git a/data/conf/samples/diam_tutmysql/sms.json b/data/conf/samples/diam_tutmysql/sms.json index dd20c0949..e1dcdd90f 100644 --- a/data/conf/samples/diam_tutmysql/sms.json +++ b/data/conf/samples/diam_tutmysql/sms.json @@ -73,7 +73,7 @@ {"tag": "CCATemplate", "type": "*template", "value": "*cca"}, { "tag": "ResultCode","path": "*rep.Result-Code", - "filters": ["*eq:~*cgrep.MaxUsage:0"], + "filters": ["*eq:~*cgrep.MaxUsage[*raw]:0"], "type": "*constant", "value": "4012", "blocker": true }, diff --git a/data/conf/samples/diamagent_internal/tests.json b/data/conf/samples/diamagent_internal/tests.json index d8e94867c..c383c3278 100644 --- a/data/conf/samples/diamagent_internal/tests.json +++ b/data/conf/samples/diamagent_internal/tests.json @@ -81,7 +81,7 @@ }, { "tag": "DebitInterval", - "path": "*opts.DebitInterval", + "path": "*opts.*sessionDebitInterval", "type": "*constant", "value": "1s" }, diff --git a/data/conf/samples/diamagent_internal/wrong_template.json b/data/conf/samples/diamagent_internal/wrong_template.json index 391411dd3..8fd1b6cd7 100644 --- a/data/conf/samples/diamagent_internal/wrong_template.json +++ b/data/conf/samples/diamagent_internal/wrong_template.json @@ -84,7 +84,7 @@ }, { "tag": "ResultCode","path": "*rep.Result-Code", - "filters": ["*eq:~*cgrep.MaxUsage:0"], + "filters": ["*eq:~*cgrep.MaxUsage[*raw]:0"], "type": "*constant", "value": "4012", "blocker": true }, diff --git a/data/conf/samples/diamagent_mongo/tests.json b/data/conf/samples/diamagent_mongo/tests.json index d8e94867c..c383c3278 100644 --- a/data/conf/samples/diamagent_mongo/tests.json +++ b/data/conf/samples/diamagent_mongo/tests.json @@ -81,7 +81,7 @@ }, { "tag": "DebitInterval", - "path": "*opts.DebitInterval", + "path": "*opts.*sessionDebitInterval", "type": "*constant", "value": "1s" }, diff --git a/data/conf/samples/diamagent_mysql/tests.json b/data/conf/samples/diamagent_mysql/tests.json index d8e94867c..c383c3278 100644 --- a/data/conf/samples/diamagent_mysql/tests.json +++ b/data/conf/samples/diamagent_mysql/tests.json @@ -81,7 +81,7 @@ }, { "tag": "DebitInterval", - "path": "*opts.DebitInterval", + "path": "*opts.*sessionDebitInterval", "type": "*constant", "value": "1s" }, diff --git a/data/conf/samples/diamagent_mysql/wrong_template.json b/data/conf/samples/diamagent_mysql/wrong_template.json index 391411dd3..8fd1b6cd7 100644 --- a/data/conf/samples/diamagent_mysql/wrong_template.json +++ b/data/conf/samples/diamagent_mysql/wrong_template.json @@ -84,7 +84,7 @@ }, { "tag": "ResultCode","path": "*rep.Result-Code", - "filters": ["*eq:~*cgrep.MaxUsage:0"], + "filters": ["*eq:~*cgrep.MaxUsage[*raw]:0"], "type": "*constant", "value": "4012", "blocker": true }, diff --git a/data/conf/samples/dispatchers/diamagent/data.json b/data/conf/samples/dispatchers/diamagent/data.json index 35f92df17..dea90fac0 100644 --- a/data/conf/samples/dispatchers/diamagent/data.json +++ b/data/conf/samples/dispatchers/diamagent/data.json @@ -10,7 +10,7 @@ "flags": ["*initiate", "*accounts"], "request_fields":[ {"tag": "ToR", "path": "*cgreq.ToR", "type": "*constant", "value": "*data"}, - {"tag": "APIkey", "path": "*opts.APIKey", "type": "*constant", "value": "ses12345"}, + {"tag": "APIkey", "path": "*opts.*dispatcherApiKey", "type": "*constant", "value": "ses12345"}, {"tag": "OriginID", "path": "*cgreq.OriginID", "type": "*variable", "value": "~*req.Session-Id", "mandatory": true}, {"tag": "RequestType", "path": "*cgreq.RequestType", "type": "*constant", "value": "*prepaid"}, @@ -38,7 +38,7 @@ "flags": ["*update", "*accounts","*continue"], "request_fields":[ {"tag": "ToR", "path": "*cgreq.ToR", "type": "*constant", "value": "*data"}, - {"tag": "APIkey", "path": "*opts.APIKey", "type": "*constant", "value": "ses12345"}, + {"tag": "APIkey", "path": "*opts.*dispatcherApiKey", "type": "*constant", "value": "ses12345"}, {"tag": "InitialOriginID", "path": "*cgreq.InitialOriginID", "type": "*variable", "value": "~*req.Session-Id", "mandatory": true}, {"tag": "OriginID", "path": "*cgreq.OriginID", "type": "*composed", @@ -71,7 +71,7 @@ "flags": ["*update", "*accounts"], "request_fields":[ {"tag": "ToR", "path": "*cgreq.ToR", "type": "*constant", "value": "*data"}, - {"tag": "APIkey", "path": "*opts.APIKey", "type": "*constant", "value": "ses12345"}, + {"tag": "APIkey", "path": "*opts.*dispatcherApiKey", "type": "*constant", "value": "ses12345"}, {"tag": "InitialOriginID", "path": "*cgreq.InitialOriginID", "type": "*variable", "value": "~*req.Session-Id", "mandatory": true}, {"tag": "OriginID", "path": "*cgreq.OriginID", "type": "*composed", @@ -104,7 +104,7 @@ "flags": ["*terminate", "*accounts"], "request_fields":[ {"tag": "ToR", "path": "*cgreq.ToR", "type": "*constant", "value": "*data"}, - {"tag": "APIkey", "path": "*opts.APIKey", "type": "*constant", "value": "ses12345"}, + {"tag": "APIkey", "path": "*opts.*dispatcherApiKey", "type": "*constant", "value": "ses12345"}, {"tag": "OriginID", "path": "*cgreq.OriginID", "type": "*variable", "value": "~*req.Session-Id", "mandatory": true}, {"tag": "OriginIDPrefix", "path": "*cgreq.OriginIDPrefix", "type": "*variable", diff --git a/data/conf/samples/dispatchers/diamagent/dryrun.json b/data/conf/samples/dispatchers/diamagent/dryrun.json index 86f6a6764..601092575 100644 --- a/data/conf/samples/dispatchers/diamagent/dryrun.json +++ b/data/conf/samples/dispatchers/diamagent/dryrun.json @@ -8,7 +8,7 @@ "flags": ["*dryrun","*continue"], "request_fields":[ {"tag": "ToR", "path": "*cgreq.ToR", "type": "*constant", "value": "*sms"}, - {"tag": "APIKey", "path": "*opts.APIKey", "type": "*constant", "value": "ses12345"}, + {"tag": "APIKey", "path": "*opts.*dispatcherApiKey", "type": "*constant", "value": "ses12345"}, {"tag": "Val1", "path": "*cgreq.Val1", "type": "*constant", "value": "1"}, {"tag": "Val2", "path": "*cgreq.Val2", "type": "*constant", "value": "2"}, {"tag": "Val3", "path": "*cgreq.Val3", "type": "*constant", "value": "3"}, @@ -43,7 +43,7 @@ "flags": ["*dryrun"], "request_fields":[ {"tag": "ToR", "path": "*cgreq.ToR", "type": "*constant", "value": "*sms"}, - {"tag": "APIKey", "path": "*opts.APIKey", "type": "*constant", "value": "ses12345"}, + {"tag": "APIKey", "path": "*opts.*dispatcherApiKey", "type": "*constant", "value": "ses12345"}, {"tag": "Val1", "path": "*cgreq.Val1", "type": "*constant", "value": "1"}, {"tag": "Val2", "path": "*cgreq.Val2", "type": "*constant", "value": "2"}, {"tag": "Val3", "path": "*cgreq.Val3", "type": "*constant", "value": "3"}, diff --git a/data/conf/samples/dispatchers/diamagent/message.json b/data/conf/samples/dispatchers/diamagent/message.json index d4c954001..01a44a5a3 100644 --- a/data/conf/samples/dispatchers/diamagent/message.json +++ b/data/conf/samples/dispatchers/diamagent/message.json @@ -10,7 +10,7 @@ "flags": ["*message", "*accounts", "*cdrs","*attributes"], "request_fields":[ {"tag": "ToR", "path": "*cgreq.ToR", "type": "*constant", "value": "*sms"}, - {"tag": "APIKey", "path": "*opts.APIKey", "type": "*constant", "value": "ses12345"}, + {"tag": "APIKey", "path": "*opts.*dispatcherApiKey", "type": "*constant", "value": "ses12345"}, {"tag": "OriginID", "path": "*cgreq.OriginID", "type": "*variable", "value": "~*req.Session-Id", "mandatory": true}, {"tag": "Category", "path": "*cgreq.Category", "type": "*constant", "value": "sms"}, diff --git a/data/conf/samples/dispatchers/diamagent/mms.json b/data/conf/samples/dispatchers/diamagent/mms.json index c78caf338..bb8e9dec4 100644 --- a/data/conf/samples/dispatchers/diamagent/mms.json +++ b/data/conf/samples/dispatchers/diamagent/mms.json @@ -19,7 +19,7 @@ "value": "*mms" }, { "tag": "APIKey", - "path": "*opts.APIKey", + "path": "*opts.*dispatcherApiKey", "type": "*constant", "value": "ses12345" }, diff --git a/data/conf/samples/dispatchers/diamagent/simpa.json b/data/conf/samples/dispatchers/diamagent/simpa.json index 0856fd257..3647a3b42 100644 --- a/data/conf/samples/dispatchers/diamagent/simpa.json +++ b/data/conf/samples/dispatchers/diamagent/simpa.json @@ -10,7 +10,7 @@ "flags": ["*message", "*accounts", "*log"], "request_fields":[ {"tag": "ToR", "path": "*cgreq.ToR", "type": "*constant", "value": "*generic"}, - {"tag": "APIKey", "path": "*opts.APIKey", "type": "*constant", "value": "ses12345"}, + {"tag": "APIKey", "path": "*opts.*dispatcherApiKey", "type": "*constant", "value": "ses12345"}, {"tag": "OriginID", "path": "*cgreq.OriginID", "type": "*variable", "value": "~*req.Session-Id", "mandatory": true}, {"tag": "RequestType", "path": "*cgreq.RequestType", "type": "*constant", "value": "*prepaid"}, diff --git a/data/conf/samples/dispatchers/diamagent/tests.json b/data/conf/samples/dispatchers/diamagent/tests.json index fe6d8f26a..d07250d56 100644 --- a/data/conf/samples/dispatchers/diamagent/tests.json +++ b/data/conf/samples/dispatchers/diamagent/tests.json @@ -10,7 +10,7 @@ "flags": ["*initiate", "*accounts","*attributes"], "request_fields":[ {"tag": "ToR", "path": "*cgreq.ToR", "type": "*constant", "value": "*voice"}, - {"tag": "APIKey", "path": "*opts.APIKey", "type": "*constant", "value": "ses12345"}, + {"tag": "APIKey", "path": "*opts.*dispatcherApiKey", "type": "*constant", "value": "ses12345"}, {"tag": "OriginID", "path": "*cgreq.OriginID", "type": "*variable", "value": "~*req.Session-Id", "mandatory": true}, {"tag": "OriginHost", "path": "*cgreq.OriginHost", "type": "*variable", @@ -29,7 +29,7 @@ "value": "~*req.Event-Timestamp", "mandatory": true}, {"tag": "Usage", "path": "*cgreq.Usage", "type": "*variable", "value": "~*req.Requested-Service-Unit.CC-Time:s/(.*)/${1}s/", "mandatory": true}, - {"tag": "DebitInterval", "path": "*opts.DebitInterval", + {"tag": "DebitInterval", "path": "*opts.*sessionDebitInterval", "type": "*constant", "value": "1s"}, ], "reply_fields":[ diff --git a/data/conf/samples/dispatchers/diamagent/voice.json b/data/conf/samples/dispatchers/diamagent/voice.json index 334d904ad..9ce92fcbb 100644 --- a/data/conf/samples/dispatchers/diamagent/voice.json +++ b/data/conf/samples/dispatchers/diamagent/voice.json @@ -109,7 +109,7 @@ "flags": ["*initiate", "*accounts", "*attributes"], "request_fields":[ {"tag": "ToR", "path": "*cgreq.ToR", "type": "*constant", "value": "*voice"}, - {"tag": "APIKey", "path": "*opts.APIKey", "type": "*constant", "value": "ses12345"}, + {"tag": "APIKey", "path": "*opts.*dispatcherApiKey", "type": "*constant", "value": "ses12345"}, {"tag": "OriginID", "path": "*cgreq.OriginID", "type": "*variable", "value": "~*req.Session-Id", "mandatory": true}, {"tag": "OriginHost", "path": "*cgreq.OriginHost", "type": "*remote_host", @@ -141,7 +141,7 @@ "flags": ["*update", "*accounts", "*attributes"], "request_fields":[ {"tag": "ToR", "path": "*cgreq.ToR", "type": "*constant", "value": "*voice"}, - {"tag": "APIKey", "path": "*opts.APIKey", "type": "*constant", "value": "ses12345"}, + {"tag": "APIKey", "path": "*opts.*dispatcherApiKey", "type": "*constant", "value": "ses12345"}, {"tag": "OriginID", "path": "*cgreq.OriginID", "type": "*variable", "value": "~*req.Session-Id", "mandatory": true}, {"tag": "OriginHost", "path": "*cgreq.OriginHost", "type": "*remote_host", @@ -175,7 +175,7 @@ "flags": ["*terminate", "*accounts", "*attributes", "*cdrs"], "request_fields":[ {"tag": "ToR", "path": "*cgreq.ToR", "type": "*constant", "value": "*voice"}, - {"tag": "APIKey", "path": "*opts.APIKey", "type": "*constant", "value": "ses12345"}, + {"tag": "APIKey", "path": "*opts.*dispatcherApiKey", "type": "*constant", "value": "ses12345"}, {"tag": "OriginID", "path": "*cgreq.OriginID", "type": "*variable", "value": "~*req.Session-Id", "mandatory": true}, {"tag": "OriginHost", "path": "*cgreq.OriginHost", "type": "*remote_host", diff --git a/data/conf/samples/sipagent_internal/redirect.json b/data/conf/samples/sipagent_internal/redirect.json index f5a786e94..1a0f79aec 100644 --- a/data/conf/samples/sipagent_internal/redirect.json +++ b/data/conf/samples/sipagent_internal/redirect.json @@ -32,7 +32,7 @@ { "id": "RoutesQueryOneRoute", "filters": ["*string:~*vars.Method:INVITE", - "*gte:~*cgrep.Routes.Count:1", + "*gte:~*cgrep.Routes[*raw].Count:1", ], "flags": ["*none","*continue"], // do not send request to CGRateS "reply_fields":[ @@ -49,21 +49,21 @@ {"tag": "Contact", "path": "*rep.Contact", "type": "*composed", "value":"@"}, {"tag": "Contact", "path": "*rep.Contact", "type": "*composed", - "value": "~*cgrep.Routes.SortedRoutes[0].RouteParameters"}, + "value": "~*cgrep.Routes[*raw].SortedRoutes[0].RouteParameters"}, {"tag": "Contact", "path": "*rep.Contact", "type": "*composed", "value":"`>;q=0.7; expires=3600;cgr_cost=`"}, {"tag": "Contact", "path": "*rep.Contact", "type": "*composed", - "value":"~*cgrep.Routes.SortedRoutes[0].SortingData.Cost"}, + "value":"~*cgrep.Routes[*raw].SortedRoutes[0].SortingData.Cost"}, {"tag": "Contact", "path": "*rep.Contact", "type": "*composed", "value":"`;cgr_maxusage=`"}, {"tag": "Contact", "path": "*rep.Contact", "type": "*composed", - "value":"~*cgrep.Routes.SortedRoutes[0].SortingData.MaxUsage"} + "value":"~*cgrep.Routes[*raw].SortedRoutes[0].SortingData.MaxUsage"} ] }, { "id": "RoutesQueryTwoRoutes", "filters": ["*string:~*vars.Method:INVITE", - "*gte:~*cgrep.Routes.Count:2", + "*gte:~*cgrep.Routes[*raw].Count:2", ], "flags": ["*none","*continue"], "reply_fields":[ @@ -78,21 +78,21 @@ {"tag": "Contact", "path": "*rep.Contact", "type": "*composed", "value":"@"}, {"tag": "Contact", "path": "*rep.Contact", "type": "*composed", - "value": "~*cgrep.Routes.SortedRoutes[1].RouteParameters"}, + "value": "~*cgrep.Routes[*raw].SortedRoutes[1].RouteParameters"}, {"tag": "Contact", "path": "*rep.Contact", "type": "*composed", "value":"`>;q=0.2;cgr_cost=`"}, {"tag": "Contact", "path": "*rep.Contact", "type": "*composed", - "value":"~*cgrep.Routes.SortedRoutes[1].SortingData.Cost"}, + "value":"~*cgrep.Routes[*raw].SortedRoutes[1].SortingData.Cost"}, {"tag": "Contact", "path": "*rep.Contact", "type": "*composed", "value":"`;cgr_maxusage=`"}, {"tag": "Contact", "path": "*rep.Contact", "type": "*composed", - "value":"~*cgrep.Routes.SortedRoutes[1].SortingData.MaxUsage"} + "value":"~*cgrep.Routes[*raw].SortedRoutes[1].SortingData.MaxUsage"} ] }, { "id": "RoutesQueryThreeRoutes", "filters": ["*string:~*vars.Method:INVITE", - "*gte:~*cgrep.Routes.Count:3", + "*gte:~*cgrep.Routes[*raw].Count:3", ], "flags": ["*none","*continue"], "reply_fields":[ @@ -107,15 +107,15 @@ {"tag": "Contact", "path": "*rep.Contact", "type": "*composed", "value":"@"}, {"tag": "Contact", "path": "*rep.Contact", "type": "*composed", - "value": "~*cgrep.Routes.SortedRoutes[2].RouteParameters"}, + "value": "~*cgrep.Routes[*raw].SortedRoutes[2].RouteParameters"}, {"tag": "Contact", "path": "*rep.Contact", "type": "*composed", "value":"`>;q=0.1;cgr_cost=`"}, {"tag": "Contact", "path": "*rep.Contact", "type": "*composed", - "value":"~*cgrep.Routes.SortedRoutes[2].SortingData.Cost"}, + "value":"~*cgrep.Routes[*raw].SortedRoutes[2].SortingData.Cost"}, {"tag": "Contact", "path": "*rep.Contact", "type": "*composed", "value":"`;cgr_maxusage=`"}, {"tag": "Contact", "path": "*rep.Contact", "type": "*composed", - "value":"~*cgrep.Routes.SortedRoutes[2].SortingData.MaxUsage"} + "value":"~*cgrep.Routes[*raw].SortedRoutes[2].SortingData.MaxUsage"} ] } ] diff --git a/data/conf/samples/sipagent_mongo/redirect.json b/data/conf/samples/sipagent_mongo/redirect.json index f5a786e94..1a0f79aec 100644 --- a/data/conf/samples/sipagent_mongo/redirect.json +++ b/data/conf/samples/sipagent_mongo/redirect.json @@ -32,7 +32,7 @@ { "id": "RoutesQueryOneRoute", "filters": ["*string:~*vars.Method:INVITE", - "*gte:~*cgrep.Routes.Count:1", + "*gte:~*cgrep.Routes[*raw].Count:1", ], "flags": ["*none","*continue"], // do not send request to CGRateS "reply_fields":[ @@ -49,21 +49,21 @@ {"tag": "Contact", "path": "*rep.Contact", "type": "*composed", "value":"@"}, {"tag": "Contact", "path": "*rep.Contact", "type": "*composed", - "value": "~*cgrep.Routes.SortedRoutes[0].RouteParameters"}, + "value": "~*cgrep.Routes[*raw].SortedRoutes[0].RouteParameters"}, {"tag": "Contact", "path": "*rep.Contact", "type": "*composed", "value":"`>;q=0.7; expires=3600;cgr_cost=`"}, {"tag": "Contact", "path": "*rep.Contact", "type": "*composed", - "value":"~*cgrep.Routes.SortedRoutes[0].SortingData.Cost"}, + "value":"~*cgrep.Routes[*raw].SortedRoutes[0].SortingData.Cost"}, {"tag": "Contact", "path": "*rep.Contact", "type": "*composed", "value":"`;cgr_maxusage=`"}, {"tag": "Contact", "path": "*rep.Contact", "type": "*composed", - "value":"~*cgrep.Routes.SortedRoutes[0].SortingData.MaxUsage"} + "value":"~*cgrep.Routes[*raw].SortedRoutes[0].SortingData.MaxUsage"} ] }, { "id": "RoutesQueryTwoRoutes", "filters": ["*string:~*vars.Method:INVITE", - "*gte:~*cgrep.Routes.Count:2", + "*gte:~*cgrep.Routes[*raw].Count:2", ], "flags": ["*none","*continue"], "reply_fields":[ @@ -78,21 +78,21 @@ {"tag": "Contact", "path": "*rep.Contact", "type": "*composed", "value":"@"}, {"tag": "Contact", "path": "*rep.Contact", "type": "*composed", - "value": "~*cgrep.Routes.SortedRoutes[1].RouteParameters"}, + "value": "~*cgrep.Routes[*raw].SortedRoutes[1].RouteParameters"}, {"tag": "Contact", "path": "*rep.Contact", "type": "*composed", "value":"`>;q=0.2;cgr_cost=`"}, {"tag": "Contact", "path": "*rep.Contact", "type": "*composed", - "value":"~*cgrep.Routes.SortedRoutes[1].SortingData.Cost"}, + "value":"~*cgrep.Routes[*raw].SortedRoutes[1].SortingData.Cost"}, {"tag": "Contact", "path": "*rep.Contact", "type": "*composed", "value":"`;cgr_maxusage=`"}, {"tag": "Contact", "path": "*rep.Contact", "type": "*composed", - "value":"~*cgrep.Routes.SortedRoutes[1].SortingData.MaxUsage"} + "value":"~*cgrep.Routes[*raw].SortedRoutes[1].SortingData.MaxUsage"} ] }, { "id": "RoutesQueryThreeRoutes", "filters": ["*string:~*vars.Method:INVITE", - "*gte:~*cgrep.Routes.Count:3", + "*gte:~*cgrep.Routes[*raw].Count:3", ], "flags": ["*none","*continue"], "reply_fields":[ @@ -107,15 +107,15 @@ {"tag": "Contact", "path": "*rep.Contact", "type": "*composed", "value":"@"}, {"tag": "Contact", "path": "*rep.Contact", "type": "*composed", - "value": "~*cgrep.Routes.SortedRoutes[2].RouteParameters"}, + "value": "~*cgrep.Routes[*raw].SortedRoutes[2].RouteParameters"}, {"tag": "Contact", "path": "*rep.Contact", "type": "*composed", "value":"`>;q=0.1;cgr_cost=`"}, {"tag": "Contact", "path": "*rep.Contact", "type": "*composed", - "value":"~*cgrep.Routes.SortedRoutes[2].SortingData.Cost"}, + "value":"~*cgrep.Routes[*raw].SortedRoutes[2].SortingData.Cost"}, {"tag": "Contact", "path": "*rep.Contact", "type": "*composed", "value":"`;cgr_maxusage=`"}, {"tag": "Contact", "path": "*rep.Contact", "type": "*composed", - "value":"~*cgrep.Routes.SortedRoutes[2].SortingData.MaxUsage"} + "value":"~*cgrep.Routes[*raw].SortedRoutes[2].SortingData.MaxUsage"} ] } ] diff --git a/data/conf/samples/sipagent_mysql/redirect.json b/data/conf/samples/sipagent_mysql/redirect.json index f5a786e94..1a0f79aec 100644 --- a/data/conf/samples/sipagent_mysql/redirect.json +++ b/data/conf/samples/sipagent_mysql/redirect.json @@ -32,7 +32,7 @@ { "id": "RoutesQueryOneRoute", "filters": ["*string:~*vars.Method:INVITE", - "*gte:~*cgrep.Routes.Count:1", + "*gte:~*cgrep.Routes[*raw].Count:1", ], "flags": ["*none","*continue"], // do not send request to CGRateS "reply_fields":[ @@ -49,21 +49,21 @@ {"tag": "Contact", "path": "*rep.Contact", "type": "*composed", "value":"@"}, {"tag": "Contact", "path": "*rep.Contact", "type": "*composed", - "value": "~*cgrep.Routes.SortedRoutes[0].RouteParameters"}, + "value": "~*cgrep.Routes[*raw].SortedRoutes[0].RouteParameters"}, {"tag": "Contact", "path": "*rep.Contact", "type": "*composed", "value":"`>;q=0.7; expires=3600;cgr_cost=`"}, {"tag": "Contact", "path": "*rep.Contact", "type": "*composed", - "value":"~*cgrep.Routes.SortedRoutes[0].SortingData.Cost"}, + "value":"~*cgrep.Routes[*raw].SortedRoutes[0].SortingData.Cost"}, {"tag": "Contact", "path": "*rep.Contact", "type": "*composed", "value":"`;cgr_maxusage=`"}, {"tag": "Contact", "path": "*rep.Contact", "type": "*composed", - "value":"~*cgrep.Routes.SortedRoutes[0].SortingData.MaxUsage"} + "value":"~*cgrep.Routes[*raw].SortedRoutes[0].SortingData.MaxUsage"} ] }, { "id": "RoutesQueryTwoRoutes", "filters": ["*string:~*vars.Method:INVITE", - "*gte:~*cgrep.Routes.Count:2", + "*gte:~*cgrep.Routes[*raw].Count:2", ], "flags": ["*none","*continue"], "reply_fields":[ @@ -78,21 +78,21 @@ {"tag": "Contact", "path": "*rep.Contact", "type": "*composed", "value":"@"}, {"tag": "Contact", "path": "*rep.Contact", "type": "*composed", - "value": "~*cgrep.Routes.SortedRoutes[1].RouteParameters"}, + "value": "~*cgrep.Routes[*raw].SortedRoutes[1].RouteParameters"}, {"tag": "Contact", "path": "*rep.Contact", "type": "*composed", "value":"`>;q=0.2;cgr_cost=`"}, {"tag": "Contact", "path": "*rep.Contact", "type": "*composed", - "value":"~*cgrep.Routes.SortedRoutes[1].SortingData.Cost"}, + "value":"~*cgrep.Routes[*raw].SortedRoutes[1].SortingData.Cost"}, {"tag": "Contact", "path": "*rep.Contact", "type": "*composed", "value":"`;cgr_maxusage=`"}, {"tag": "Contact", "path": "*rep.Contact", "type": "*composed", - "value":"~*cgrep.Routes.SortedRoutes[1].SortingData.MaxUsage"} + "value":"~*cgrep.Routes[*raw].SortedRoutes[1].SortingData.MaxUsage"} ] }, { "id": "RoutesQueryThreeRoutes", "filters": ["*string:~*vars.Method:INVITE", - "*gte:~*cgrep.Routes.Count:3", + "*gte:~*cgrep.Routes[*raw].Count:3", ], "flags": ["*none","*continue"], "reply_fields":[ @@ -107,15 +107,15 @@ {"tag": "Contact", "path": "*rep.Contact", "type": "*composed", "value":"@"}, {"tag": "Contact", "path": "*rep.Contact", "type": "*composed", - "value": "~*cgrep.Routes.SortedRoutes[2].RouteParameters"}, + "value": "~*cgrep.Routes[*raw].SortedRoutes[2].RouteParameters"}, {"tag": "Contact", "path": "*rep.Contact", "type": "*composed", "value":"`>;q=0.1;cgr_cost=`"}, {"tag": "Contact", "path": "*rep.Contact", "type": "*composed", - "value":"~*cgrep.Routes.SortedRoutes[2].SortingData.Cost"}, + "value":"~*cgrep.Routes[*raw].SortedRoutes[2].SortingData.Cost"}, {"tag": "Contact", "path": "*rep.Contact", "type": "*composed", "value":"`;cgr_maxusage=`"}, {"tag": "Contact", "path": "*rep.Contact", "type": "*composed", - "value":"~*cgrep.Routes.SortedRoutes[2].SortingData.MaxUsage"} + "value":"~*cgrep.Routes[*raw].SortedRoutes[2].SortingData.MaxUsage"} ] } ] diff --git a/data/tutorials/sip_redirect/cgrates/etc/cgrates/redirect.json b/data/tutorials/sip_redirect/cgrates/etc/cgrates/redirect.json index e97f9c69b..6f183cec1 100644 --- a/data/tutorials/sip_redirect/cgrates/etc/cgrates/redirect.json +++ b/data/tutorials/sip_redirect/cgrates/etc/cgrates/redirect.json @@ -28,9 +28,9 @@ "value": "*now", "mandatory": true}, {"tag": "Category", "path": "*cgreq.Category", "type": "*variable", "value": "call", "mandatory": true}, - {"tag": "STIRPublicKeyPath", "path": "*opts.STIRPublicKeyPath", "type": "*constant", + {"tag": "STIRPublicKeyPath", "path": "*opts.*stirPublicKeyPath", "type": "*constant", "value": "/usr/share/cgrates/stir/stir_pubkey.pem", "mandatory": true}, - {"tag": "STIRPrivateKeyPath", "path": "*opts.STIRPrivateKeyPath", "type": "*constant", + {"tag": "STIRPrivateKeyPath", "path": "*opts.*stirPrivateKeyPath", "type": "*constant", "value": "/usr/share/cgrates/stir/stir_privatekey.pem", "mandatory": true}, ], "reply_fields":[ @@ -39,7 +39,7 @@ { "id": "RoutesQueryOneRoute", "filters": ["*string:~*vars.Method:INVITE", - "*gte:~*cgrep.Routes.Count:1", + "*gte:~*cgrep.Routes[*raw].Count:1", ], "flags": ["*none","*continue"], // do not send request to CGRateS "reply_fields":[ @@ -48,57 +48,57 @@ {"tag": "Contact", "path": "*rep.Contact", "type": "*composed", "value":"\"1003\" `"}, {"tag": "X-Identity", "path": "*rep.X-Identity", "type": "*variable", - "value":"~*cgrep.STIRIdentity.<~*cgrep.Routes.SortedRoutes[0].RouteID>"}, + "value":"~*cgrep.STIRIdentity.<~*cgrep.Routes[*raw].SortedRoutes[0].RouteID>"}, ] }, { "id": "RoutesQueryTwoRoute", "filters": ["*string:~*vars.Method:INVITE", - "*gte:~*cgrep.Routes.Count:2", + "*gte:~*cgrep.Routes[*raw].Count:2", ], "flags": ["*none","*continue"], // do not send request to CGRateS "reply_fields":[ {"tag": "Contact", "path": "*rep.Contact", "type": "*composed", "value":",\"1004\" `"}, @@ -107,29 +107,29 @@ { "id": "RoutesQueryThreeRoute", "filters": ["*string:~*vars.Method:INVITE", - "*gte:~*cgrep.Routes.Count:2", + "*gte:~*cgrep.Routes[*raw].Count:2", ], "flags": ["*none","*continue"], // do not send request to CGRateS "reply_fields":[ {"tag": "Contact", "path": "*rep.Contact", "type": "*composed", "value":",\"1005\" `"}, diff --git a/general_tests/session2_it_test.go b/general_tests/session2_it_test.go index 6806ba2c8..514f80aa0 100644 --- a/general_tests/session2_it_test.go +++ b/general_tests/session2_it_test.go @@ -250,7 +250,7 @@ func testSes2StirInit(t *testing.T) { args, &rply); err != nil { // no error verificated with success t.Error(err) } - if err := sessions.AuthStirShaken(rply.STIRIdentity["DEFAULT"], "1001", "", "1002", "", utils.NewStringSet([]string{"A"}), 10*time.Minute); err != nil { + if err := sessions.AuthStirShaken(rply.STIRIdentity[utils.MetaRaw], "1001", "", "1002", "", utils.NewStringSet([]string{"A"}), 10*time.Minute); err != nil { t.Fatal(err) } } diff --git a/packages/debian/changelog b/packages/debian/changelog index 5abcdd6a5..853655efa 100644 --- a/packages/debian/changelog +++ b/packages/debian/changelog @@ -79,6 +79,7 @@ cgrates (0.11.0~dev) UNRELEASED; urgency=medium * [RSRParsers] Moved RSRFilter from RSRParsers to the *rsr FilterS * [SessionS] Rename from ResourceMessage to ResourceAllocation * [LoaderS] Updated file selector from *req to *file(FileName) + * [SessionS] Added *multiple flag to ProcessEvent to proccess the events from ChargerS with other subsystems -- DanB Wed, 19 Feb 2020 13:25:52 +0200 diff --git a/servmanager/servmanager.go b/servmanager/servmanager.go index e4ea603b1..2060d3a0c 100644 --- a/servmanager/servmanager.go +++ b/servmanager/servmanager.go @@ -154,7 +154,7 @@ func (srvMngr *ServiceManager) StartServices() (err error) { if err == utils.ErrServiceAlreadyRunning { // in case the service was started in another gorutine return } - utils.Logger.Err(fmt.Sprintf("<%s> failed to start %s because: %s", utils.ServiceManager, service.ServiceName(), err)) + utils.Logger.Err(fmt.Sprintf("<%s> failed to start %s because: %s", utils.ServiceManager, srv.ServiceName(), err)) srvMngr.engineShutdown <- true } }(service) diff --git a/sessions/sessions.go b/sessions/sessions.go index f3bcbc583..5014fb9e5 100644 --- a/sessions/sessions.go +++ b/sessions/sessions.go @@ -3160,7 +3160,7 @@ func (sS *SessionS) BiRPCv1ProcessEvent(clnt rpcclient.ClientConnector, ArgDispatcher: args.ArgDispatcher, }, } - if argsFlagsWithParams.GetBool(utils.OptsMultiple) { + if argsFlagsWithParams.GetBool(utils.MetaMultiple) { var chrgrs []*engine.ChrgSProcessEventReply if chrgrs, err = sS.processChargerS(&utils.CGREventWithOpts{ CGREvent: args.CGREvent, diff --git a/utils/consts.go b/utils/consts.go index 266b1bc7e..753d577e3 100755 --- a/utils/consts.go +++ b/utils/consts.go @@ -2267,7 +2267,7 @@ const ( OptsRouteID = "*dispatcherRouteID" // Others OptsContext = "*context" - OptsMultiple = "*multiple" + MetaMultiple = "*multiple" ) func buildCacheInstRevPrefixes() {