diff --git a/data/conf/samples/ers_internal/cgrates.json b/data/conf/samples/ers_internal/cgrates.json index 49d72ac6d..5c2532b18 100644 --- a/data/conf/samples/ers_internal/cgrates.json +++ b/data/conf/samples/ers_internal/cgrates.json @@ -481,7 +481,64 @@ {"tag": "ExtraInfo1", "path": "*cgreq.ExtraInfo1", "type": "*constant", "value": "ExtraInfo1"}, {"tag": "ExtraInfo2", "path": "*cgreq.ExtraInfo2", "type": "*constant", "value": "ExtraInfo2"}, ], - } + }, + { + "id": "PartialWithMultipleMethods", + "enabled": true, + "run_delay": "-1", + "type": "*file_csv", + "opts": { + "csvFieldSeparator":",", + "partialcsvFieldSeparator": ",", + "partialCacheAction": "*dump_to_file", + "partialOrderField": "~*opts.orderID", + "partialPath": "/tmp/flatstoreMMErs/out", + "csvLazyQuotes": true, + }, + "source_path": "/tmp/flatstoreMMErs/in", + "processed_path": "/tmp/flatstoreMMErs/out", + "flags": ["*cdrs"], + "fields":[ + {"tag": "OriginHost", "path": "*cgreq.OriginHost", "type": "*constant","value":"flatStoreACK", "mandatory": true}, + {"tag": "OriginID", "path": "*cgreq.OriginID", "type": "*variable","value":"~*req.4;~*req.2;~*req.3", "mandatory": true}, + {"tag": "RequestType", "path": "*cgreq.RequestType", "type": "*constant", "value": "*postpaid", "mandatory": true,"filters": ["*string:~*req.1:INVITE"]}, + {"tag": "Account", "path": "*cgreq.Account", "type": "*variable", "value": "~*req.8", "mandatory": true,"filters": ["*string:~*req.1:INVITE"]}, + {"tag": "Subject", "path": "*cgreq.Subject", "type": "*variable", "value": "~*req.8", "mandatory": true,"filters": ["*string:~*req.1:INVITE"]}, + {"tag": "Destination", "path": "*cgreq.Destination", "type": "*variable", "value": "~*req.14", "mandatory": true,"filters": ["*string:~*req.1:INVITE"]}, + {"tag": "SetupTime", "path": "*cgreq.SetupTime", "type": "*variable", "value": "~*req.7", "mandatory": true,"filters": ["*string:~*req.1:INVITE"]}, + {"tag": "AnswerTime", "path": "*cgreq.AnswerTime", "type": "*variable", "value": "~*req.7", "mandatory": true,"filters": ["*string:~*req.1:ACK"]}, + {"tag": "EndTime", "path": "*cgreq.EndTime", "type": "*variable","value": "~*req.7", "mandatory": true, "filters": ["*string:~*req.1:BYE"]}, + {"tag": "DisconnectCause", "path": "*cgreq.DisconnectCause", "type": "*variable", "value": "~*req.5; ;~*req.6", "mandatory": true}, + {"tag": "DialogId", "path": "*cgreq.DialogId", "type": "*variable", "value": "~*req.12"}, + {"tag": "Partial", "path": "*opts.*partial", "type": "*constant", "value": "true", "filters": ["*notstring:~*req.1:CANCEL"]}, + {"tag": "Invite", "path": "*opts.invite", "type": "*constant", "value": "true", "filters":["*string:~*req.1:INVITE"]}, + {"tag": "Bye", "path": "*opts.bye", "type": "*constant", "value": "true", "filters":["*string:~*req.1:BYE"]}, + {"tag": "Ack", "path": "*opts.ack", "type": "*constant", "value": "true", "filters":["*string:~*req.1:ACK"]}, + {"tag": "Order", "path": "*opts.orderID", "type": "*variable", "value": "~*req.1"}, + + {"tag": "Partial", "path": "*opts.*partial", "type": "*constant", "value": "false", "filters": ["*string:~*req.1:CANCEL"]}, + {"tag": "Usage", "path": "*cgreq.Usage", "type": "*constant","value": "0", "mandatory": true, "filters": ["*string:~*req.1:CANCEL"]}, + + ], + "partial_commit_fields": [ + {"tag": "Usage", "path": "*cgreq.Usage", "type": "*usage_difference","value": "~*req.EndTime;~*req.AnswerTime", "mandatory": true, "filters": ["*exists:~*opts.invite:","*exists:~*opts.bye:","*exists:~*opts.ack:"]}, + {"tag": "Partial", "path": "*opts.*partial", "type": "*constant", "value": "false","filters": ["*exists:~*opts.invite:","*exists:~*opts.bye:","*exists:~*opts.ack:"]}, + ], + "cache_dump_fields": [ + {"tag": "OriginHost", "path": "*exp.OriginHost", "type": "*variable", "value":"~*req.OriginHost"}, + {"tag": "OriginID", "path": "*exp.OriginID", "type": "*variable", "value":"~*req.OriginID"}, + {"tag": "RequestType", "path": "*exp.RequestType", "type": "*variable", "value":"~*req.RequestType"}, + {"tag": "Account", "path": "*exp.Account", "type": "*variable", "value":"~*req.Account"}, + {"tag": "Subject", "path": "*exp.Subject", "type": "*variable", "value":"~*req.Subject"}, + {"tag": "Destination", "path": "*exp.Destination", "type": "*variable", "value":"~*req.Destination"}, + {"tag": "SetupTime", "path": "*exp.SetupTime", "type": "*variable", "value":"~*req.SetupTime"}, + {"tag": "AnswerTime", "path": "*exp.AnswerTime", "type": "*variable", "value":"~*req.AnswerTime"}, + {"tag": "EndTime", "path": "*exp.EndTime", "type": "*variable", "value":"~*req.EndTime"}, + {"tag": "DisconnectCause", "path": "*exp.DisconnectCause", "type": "*variable", "value":"~*req.DisconnectCause"}, + {"tag": "DialogId", "path": "*exp.DialogId", "type": "*variable", "value":"~*req.DialogId"}, + ], + + }, ], }, diff --git a/data/conf/samples/ers_mongo/cgrates.json b/data/conf/samples/ers_mongo/cgrates.json index 8b2999493..90de26bae 100644 --- a/data/conf/samples/ers_mongo/cgrates.json +++ b/data/conf/samples/ers_mongo/cgrates.json @@ -483,7 +483,64 @@ {"tag": "ExtraInfo1", "path": "*cgreq.ExtraInfo1", "type": "*constant", "value": "ExtraInfo1"}, {"tag": "ExtraInfo2", "path": "*cgreq.ExtraInfo2", "type": "*constant", "value": "ExtraInfo2"}, ], - } + }, + { + "id": "PartialWithMultipleMethods", + "enabled": true, + "run_delay": "-1", + "type": "*file_csv", + "opts": { + "csvFieldSeparator":",", + "partialcsvFieldSeparator": ",", + "partialCacheAction": "*dump_to_file", + "partialOrderField": "~*opts.orderID", + "partialPath": "/tmp/flatstoreMMErs/out", + "csvLazyQuotes": true, + }, + "source_path": "/tmp/flatstoreMMErs/in", + "processed_path": "/tmp/flatstoreMMErs/out", + "flags": ["*cdrs"], + "fields":[ + {"tag": "OriginHost", "path": "*cgreq.OriginHost", "type": "*constant","value":"flatStoreACK", "mandatory": true}, + {"tag": "OriginID", "path": "*cgreq.OriginID", "type": "*variable","value":"~*req.4;~*req.2;~*req.3", "mandatory": true}, + {"tag": "RequestType", "path": "*cgreq.RequestType", "type": "*constant", "value": "*postpaid", "mandatory": true,"filters": ["*string:~*req.1:INVITE"]}, + {"tag": "Account", "path": "*cgreq.Account", "type": "*variable", "value": "~*req.8", "mandatory": true,"filters": ["*string:~*req.1:INVITE"]}, + {"tag": "Subject", "path": "*cgreq.Subject", "type": "*variable", "value": "~*req.8", "mandatory": true,"filters": ["*string:~*req.1:INVITE"]}, + {"tag": "Destination", "path": "*cgreq.Destination", "type": "*variable", "value": "~*req.14", "mandatory": true,"filters": ["*string:~*req.1:INVITE"]}, + {"tag": "SetupTime", "path": "*cgreq.SetupTime", "type": "*variable", "value": "~*req.7", "mandatory": true,"filters": ["*string:~*req.1:INVITE"]}, + {"tag": "AnswerTime", "path": "*cgreq.AnswerTime", "type": "*variable", "value": "~*req.7", "mandatory": true,"filters": ["*string:~*req.1:ACK"]}, + {"tag": "EndTime", "path": "*cgreq.EndTime", "type": "*variable","value": "~*req.7", "mandatory": true, "filters": ["*string:~*req.1:BYE"]}, + {"tag": "DisconnectCause", "path": "*cgreq.DisconnectCause", "type": "*variable", "value": "~*req.5; ;~*req.6", "mandatory": true}, + {"tag": "DialogId", "path": "*cgreq.DialogId", "type": "*variable", "value": "~*req.12"}, + {"tag": "Partial", "path": "*opts.*partial", "type": "*constant", "value": "true", "filters": ["*notstring:~*req.1:CANCEL"]}, + {"tag": "Invite", "path": "*opts.invite", "type": "*constant", "value": "true", "filters":["*string:~*req.1:INVITE"]}, + {"tag": "Bye", "path": "*opts.bye", "type": "*constant", "value": "true", "filters":["*string:~*req.1:BYE"]}, + {"tag": "Ack", "path": "*opts.ack", "type": "*constant", "value": "true", "filters":["*string:~*req.1:ACK"]}, + {"tag": "Order", "path": "*opts.orderID", "type": "*variable", "value": "~*req.1"}, + + {"tag": "Partial", "path": "*opts.*partial", "type": "*constant", "value": "false", "filters": ["*string:~*req.1:CANCEL"]}, + {"tag": "Usage", "path": "*cgreq.Usage", "type": "*constant","value": "0", "mandatory": true, "filters": ["*string:~*req.1:CANCEL"]}, + + ], + "partial_commit_fields": [ + {"tag": "Usage", "path": "*cgreq.Usage", "type": "*usage_difference","value": "~*req.EndTime;~*req.AnswerTime", "mandatory": true, "filters": ["*exists:~*opts.invite:","*exists:~*opts.bye:","*exists:~*opts.ack:"]}, + {"tag": "Partial", "path": "*opts.*partial", "type": "*constant", "value": "false","filters": ["*exists:~*opts.invite:","*exists:~*opts.bye:","*exists:~*opts.ack:"]}, + ], + "cache_dump_fields": [ + {"tag": "OriginHost", "path": "*exp.OriginHost", "type": "*variable", "value":"~*req.OriginHost"}, + {"tag": "OriginID", "path": "*exp.OriginID", "type": "*variable", "value":"~*req.OriginID"}, + {"tag": "RequestType", "path": "*exp.RequestType", "type": "*variable", "value":"~*req.RequestType"}, + {"tag": "Account", "path": "*exp.Account", "type": "*variable", "value":"~*req.Account"}, + {"tag": "Subject", "path": "*exp.Subject", "type": "*variable", "value":"~*req.Subject"}, + {"tag": "Destination", "path": "*exp.Destination", "type": "*variable", "value":"~*req.Destination"}, + {"tag": "SetupTime", "path": "*exp.SetupTime", "type": "*variable", "value":"~*req.SetupTime"}, + {"tag": "AnswerTime", "path": "*exp.AnswerTime", "type": "*variable", "value":"~*req.AnswerTime"}, + {"tag": "EndTime", "path": "*exp.EndTime", "type": "*variable", "value":"~*req.EndTime"}, + {"tag": "DisconnectCause", "path": "*exp.DisconnectCause", "type": "*variable", "value":"~*req.DisconnectCause"}, + {"tag": "DialogId", "path": "*exp.DialogId", "type": "*variable", "value":"~*req.DialogId"}, + ], + + }, ], }, diff --git a/data/conf/samples/ers_mysql/cgrates.json b/data/conf/samples/ers_mysql/cgrates.json index dfc0206f2..0414347da 100644 --- a/data/conf/samples/ers_mysql/cgrates.json +++ b/data/conf/samples/ers_mysql/cgrates.json @@ -480,7 +480,64 @@ {"tag": "ExtraInfo1", "path": "*cgreq.ExtraInfo1", "type": "*constant", "value": "ExtraInfo1"}, {"tag": "ExtraInfo2", "path": "*cgreq.ExtraInfo2", "type": "*constant", "value": "ExtraInfo2"}, ], - } + }, + { + "id": "PartialWithMultipleMethods", + "enabled": true, + "run_delay": "-1", + "type": "*file_csv", + "opts": { + "csvFieldSeparator":",", + "partialcsvFieldSeparator": ",", + "partialCacheAction": "*dump_to_file", + "partialOrderField": "~*opts.orderID", + "partialPath": "/tmp/flatstoreMMErs/out", + "csvLazyQuotes": true, + }, + "source_path": "/tmp/flatstoreMMErs/in", + "processed_path": "/tmp/flatstoreMMErs/out", + "flags": ["*cdrs"], + "fields":[ + {"tag": "OriginHost", "path": "*cgreq.OriginHost", "type": "*constant","value":"flatStoreACK", "mandatory": true}, + {"tag": "OriginID", "path": "*cgreq.OriginID", "type": "*variable","value":"~*req.4;~*req.2;~*req.3", "mandatory": true}, + {"tag": "RequestType", "path": "*cgreq.RequestType", "type": "*constant", "value": "*postpaid", "mandatory": true,"filters": ["*string:~*req.1:INVITE"]}, + {"tag": "Account", "path": "*cgreq.Account", "type": "*variable", "value": "~*req.8", "mandatory": true,"filters": ["*string:~*req.1:INVITE"]}, + {"tag": "Subject", "path": "*cgreq.Subject", "type": "*variable", "value": "~*req.8", "mandatory": true,"filters": ["*string:~*req.1:INVITE"]}, + {"tag": "Destination", "path": "*cgreq.Destination", "type": "*variable", "value": "~*req.14", "mandatory": true,"filters": ["*string:~*req.1:INVITE"]}, + {"tag": "SetupTime", "path": "*cgreq.SetupTime", "type": "*variable", "value": "~*req.7", "mandatory": true,"filters": ["*string:~*req.1:INVITE"]}, + {"tag": "AnswerTime", "path": "*cgreq.AnswerTime", "type": "*variable", "value": "~*req.7", "mandatory": true,"filters": ["*string:~*req.1:ACK"]}, + {"tag": "EndTime", "path": "*cgreq.EndTime", "type": "*variable","value": "~*req.7", "mandatory": true, "filters": ["*string:~*req.1:BYE"]}, + {"tag": "DisconnectCause", "path": "*cgreq.DisconnectCause", "type": "*variable", "value": "~*req.5; ;~*req.6", "mandatory": true}, + {"tag": "DialogId", "path": "*cgreq.DialogId", "type": "*variable", "value": "~*req.12"}, + {"tag": "Partial", "path": "*opts.*partial", "type": "*constant", "value": "true", "filters": ["*notstring:~*req.1:CANCEL"]}, + {"tag": "Invite", "path": "*opts.invite", "type": "*constant", "value": "true", "filters":["*string:~*req.1:INVITE"]}, + {"tag": "Bye", "path": "*opts.bye", "type": "*constant", "value": "true", "filters":["*string:~*req.1:BYE"]}, + {"tag": "Ack", "path": "*opts.ack", "type": "*constant", "value": "true", "filters":["*string:~*req.1:ACK"]}, + {"tag": "Order", "path": "*opts.orderID", "type": "*variable", "value": "~*req.1"}, + + {"tag": "Partial", "path": "*opts.*partial", "type": "*constant", "value": "false", "filters": ["*string:~*req.1:CANCEL"]}, + {"tag": "Usage", "path": "*cgreq.Usage", "type": "*constant","value": "0", "mandatory": true, "filters": ["*string:~*req.1:CANCEL"]}, + + ], + "partial_commit_fields": [ + {"tag": "Usage", "path": "*cgreq.Usage", "type": "*usage_difference","value": "~*req.EndTime;~*req.AnswerTime", "mandatory": true, "filters": ["*exists:~*opts.invite:","*exists:~*opts.bye:","*exists:~*opts.ack:"]}, + {"tag": "Partial", "path": "*opts.*partial", "type": "*constant", "value": "false","filters": ["*exists:~*opts.invite:","*exists:~*opts.bye:","*exists:~*opts.ack:"]}, + ], + "cache_dump_fields": [ + {"tag": "OriginHost", "path": "*exp.OriginHost", "type": "*variable", "value":"~*req.OriginHost"}, + {"tag": "OriginID", "path": "*exp.OriginID", "type": "*variable", "value":"~*req.OriginID"}, + {"tag": "RequestType", "path": "*exp.RequestType", "type": "*variable", "value":"~*req.RequestType"}, + {"tag": "Account", "path": "*exp.Account", "type": "*variable", "value":"~*req.Account"}, + {"tag": "Subject", "path": "*exp.Subject", "type": "*variable", "value":"~*req.Subject"}, + {"tag": "Destination", "path": "*exp.Destination", "type": "*variable", "value":"~*req.Destination"}, + {"tag": "SetupTime", "path": "*exp.SetupTime", "type": "*variable", "value":"~*req.SetupTime"}, + {"tag": "AnswerTime", "path": "*exp.AnswerTime", "type": "*variable", "value":"~*req.AnswerTime"}, + {"tag": "EndTime", "path": "*exp.EndTime", "type": "*variable", "value":"~*req.EndTime"}, + {"tag": "DisconnectCause", "path": "*exp.DisconnectCause", "type": "*variable", "value":"~*req.DisconnectCause"}, + {"tag": "DialogId", "path": "*exp.DialogId", "type": "*variable", "value":"~*req.DialogId"}, + ], + + }, ], }, diff --git a/data/conf/samples/ers_postgres/cgrates.json b/data/conf/samples/ers_postgres/cgrates.json index e9544b676..5b37b21b4 100644 --- a/data/conf/samples/ers_postgres/cgrates.json +++ b/data/conf/samples/ers_postgres/cgrates.json @@ -477,7 +477,64 @@ {"tag": "ExtraInfo1", "path": "*cgreq.ExtraInfo1", "type": "*constant", "value": "ExtraInfo1"}, {"tag": "ExtraInfo2", "path": "*cgreq.ExtraInfo2", "type": "*constant", "value": "ExtraInfo2"}, ], - } + }, + { + "id": "PartialWithMultipleMethods", + "enabled": true, + "run_delay": "-1", + "type": "*file_csv", + "opts": { + "csvFieldSeparator":",", + "partialcsvFieldSeparator": ",", + "partialCacheAction": "*dump_to_file", + "partialOrderField": "~*opts.orderID", + "partialPath": "/tmp/flatstoreMMErs/out", + "csvLazyQuotes": true, + }, + "source_path": "/tmp/flatstoreMMErs/in", + "processed_path": "/tmp/flatstoreMMErs/out", + "flags": ["*cdrs"], + "fields":[ + {"tag": "OriginHost", "path": "*cgreq.OriginHost", "type": "*constant","value":"flatStoreACK", "mandatory": true}, + {"tag": "OriginID", "path": "*cgreq.OriginID", "type": "*variable","value":"~*req.4;~*req.2;~*req.3", "mandatory": true}, + {"tag": "RequestType", "path": "*cgreq.RequestType", "type": "*constant", "value": "*postpaid", "mandatory": true,"filters": ["*string:~*req.1:INVITE"]}, + {"tag": "Account", "path": "*cgreq.Account", "type": "*variable", "value": "~*req.8", "mandatory": true,"filters": ["*string:~*req.1:INVITE"]}, + {"tag": "Subject", "path": "*cgreq.Subject", "type": "*variable", "value": "~*req.8", "mandatory": true,"filters": ["*string:~*req.1:INVITE"]}, + {"tag": "Destination", "path": "*cgreq.Destination", "type": "*variable", "value": "~*req.14", "mandatory": true,"filters": ["*string:~*req.1:INVITE"]}, + {"tag": "SetupTime", "path": "*cgreq.SetupTime", "type": "*variable", "value": "~*req.7", "mandatory": true,"filters": ["*string:~*req.1:INVITE"]}, + {"tag": "AnswerTime", "path": "*cgreq.AnswerTime", "type": "*variable", "value": "~*req.7", "mandatory": true,"filters": ["*string:~*req.1:ACK"]}, + {"tag": "EndTime", "path": "*cgreq.EndTime", "type": "*variable","value": "~*req.7", "mandatory": true, "filters": ["*string:~*req.1:BYE"]}, + {"tag": "DisconnectCause", "path": "*cgreq.DisconnectCause", "type": "*variable", "value": "~*req.5; ;~*req.6", "mandatory": true}, + {"tag": "DialogId", "path": "*cgreq.DialogId", "type": "*variable", "value": "~*req.12"}, + {"tag": "Partial", "path": "*opts.*partial", "type": "*constant", "value": "true", "filters": ["*notstring:~*req.1:CANCEL"]}, + {"tag": "Invite", "path": "*opts.invite", "type": "*constant", "value": "true", "filters":["*string:~*req.1:INVITE"]}, + {"tag": "Bye", "path": "*opts.bye", "type": "*constant", "value": "true", "filters":["*string:~*req.1:BYE"]}, + {"tag": "Ack", "path": "*opts.ack", "type": "*constant", "value": "true", "filters":["*string:~*req.1:ACK"]}, + {"tag": "Order", "path": "*opts.orderID", "type": "*variable", "value": "~*req.1"}, + + {"tag": "Partial", "path": "*opts.*partial", "type": "*constant", "value": "false", "filters": ["*string:~*req.1:CANCEL"]}, + {"tag": "Usage", "path": "*cgreq.Usage", "type": "*constant","value": "0", "mandatory": true, "filters": ["*string:~*req.1:CANCEL"]}, + + ], + "partial_commit_fields": [ + {"tag": "Usage", "path": "*cgreq.Usage", "type": "*usage_difference","value": "~*req.EndTime;~*req.AnswerTime", "mandatory": true, "filters": ["*exists:~*opts.invite:","*exists:~*opts.bye:","*exists:~*opts.ack:"]}, + {"tag": "Partial", "path": "*opts.*partial", "type": "*constant", "value": "false","filters": ["*exists:~*opts.invite:","*exists:~*opts.bye:","*exists:~*opts.ack:"]}, + ], + "cache_dump_fields": [ + {"tag": "OriginHost", "path": "*exp.OriginHost", "type": "*variable", "value":"~*req.OriginHost"}, + {"tag": "OriginID", "path": "*exp.OriginID", "type": "*variable", "value":"~*req.OriginID"}, + {"tag": "RequestType", "path": "*exp.RequestType", "type": "*variable", "value":"~*req.RequestType"}, + {"tag": "Account", "path": "*exp.Account", "type": "*variable", "value":"~*req.Account"}, + {"tag": "Subject", "path": "*exp.Subject", "type": "*variable", "value":"~*req.Subject"}, + {"tag": "Destination", "path": "*exp.Destination", "type": "*variable", "value":"~*req.Destination"}, + {"tag": "SetupTime", "path": "*exp.SetupTime", "type": "*variable", "value":"~*req.SetupTime"}, + {"tag": "AnswerTime", "path": "*exp.AnswerTime", "type": "*variable", "value":"~*req.AnswerTime"}, + {"tag": "EndTime", "path": "*exp.EndTime", "type": "*variable", "value":"~*req.EndTime"}, + {"tag": "DisconnectCause", "path": "*exp.DisconnectCause", "type": "*variable", "value":"~*req.DisconnectCause"}, + {"tag": "DialogId", "path": "*exp.DialogId", "type": "*variable", "value":"~*req.DialogId"}, + ], + + }, ], }, diff --git a/ers/lib_test.go b/ers/lib_test.go index 8ad95b312..d99c6ac8b 100644 --- a/ers/lib_test.go +++ b/ers/lib_test.go @@ -57,7 +57,8 @@ func testCreateDirs(t *testing.T) { "/tmp/partErs1/in", "/tmp/partErs1/out", "/tmp/partErs2/in", "/tmp/partErs2/out", "/tmp/flatstoreErs/in", "/tmp/flatstoreErs/out", "/tmp/ErsJSON/in", "/tmp/ErsJSON/out", "/tmp/readerWithTemplate/in", "/tmp/readerWithTemplate/out", - "/tmp/flatstoreACKErs/in", "/tmp/flatstoreACKErs/out"} { + "/tmp/flatstoreACKErs/in", "/tmp/flatstoreACKErs/out", + "/tmp/flatstoreMMErs/in", "/tmp/flatstoreMMErs/out"} { if err := os.RemoveAll(dir); err != nil { t.Fatal("Error removing folder: ", dir, err) }