Update *default ERs template to take data from request

This commit is contained in:
TeoV
2019-09-11 07:31:23 -04:00
committed by Dan Christian Bogos
parent 98220fdd8d
commit c4bfeb5c96
7 changed files with 225 additions and 110 deletions

View File

@@ -97,7 +97,7 @@ const CGRATES_CFG_JSON = `
"client_key":"", // path to client key
"ca_certificate":"", // path to CA certificate (populate for self-signed certificate otherwise let it empty)
"server_policy":4, // server_policy determines the TLS Client Authentication (0-NoClientCert, 1-RequestClientCert, 2-RequireAnyClientCert, 3-VerifyClientCertIfGiven, 4-RequireAndVerifyClientCert)
"server_name":"",
"server_name":"",
},
@@ -193,7 +193,7 @@ const CGRATES_CFG_JSON = `
"session_cost_retries": 5, // number of queries to session_costs before recalculating CDR
"chargers_conns": [ // connection to ChargerS for CDR forking, empty to disable billing for CDRs: <""|*internal|x.y.z.y:1234>
{"address": "*internal"}
],
],
"rals_conns": [ // connections to RALs for cost calculation: <""|*internal|x.y.z.y:1234>
{"address": "*internal"}
],
@@ -316,20 +316,20 @@ const CGRATES_CFG_JSON = `
"flags": [], // flags to influence the event processing
"header_fields": [], // template of the import header fields
"content_fields":[ // import content_fields template, tag will match internally CDR field, in case of .csv value will be represented by index of the field value
{"tag": "TOR", "field_id": "ToR", "type": "*composed", "value": "~2", "mandatory": true},
{"tag": "OriginID", "field_id": "OriginID", "type": "*composed", "value": "~3", "mandatory": true},
{"tag": "RequestType", "field_id": "RequestType", "type": "*composed", "value": "~4", "mandatory": true},
{"tag": "Tenant", "field_id": "Tenant", "type": "*composed", "value": "~6", "mandatory": true},
{"tag": "Category", "field_id": "Category", "type": "*composed", "value": "~7", "mandatory": true},
{"tag": "Account", "field_id": "Account", "type": "*composed", "value": "~8", "mandatory": true},
{"tag": "Subject", "field_id": "Subject", "type": "*composed", "value": "~9", "mandatory": true},
{"tag": "Destination", "field_id": "Destination", "type": "*composed", "value": "~10", "mandatory": true},
{"tag": "SetupTime", "field_id": "SetupTime", "type": "*composed", "value": "~11", "mandatory": true},
{"tag": "AnswerTime", "field_id": "AnswerTime", "type": "*composed", "value": "~12", "mandatory": true},
{"tag": "Usage", "field_id": "Usage", "type": "*composed", "value": "~13", "mandatory": true},
{"tag": "TOR", "field_id": "ToR", "type": "*composed", "value": "~*req.2", "mandatory": true},
{"tag": "OriginID", "field_id": "OriginID", "type": "*composed", "value": "~*req.3", "mandatory": true},
{"tag": "RequestType", "field_id": "RequestType", "type": "*composed", "value": "~*req.4", "mandatory": true},
{"tag": "Tenant", "field_id": "Tenant", "type": "*composed", "value": "~*req.6", "mandatory": true},
{"tag": "Category", "field_id": "Category", "type": "*composed", "value": "~*req.7", "mandatory": true},
{"tag": "Account", "field_id": "Account", "type": "*composed", "value": "~*req.8", "mandatory": true},
{"tag": "Subject", "field_id": "Subject", "type": "*composed", "value": "~*req.9", "mandatory": true},
{"tag": "Destination", "field_id": "Destination", "type": "*composed", "value": "~*req.10", "mandatory": true},
{"tag": "SetupTime", "field_id": "SetupTime", "type": "*composed", "value": "~*req.11", "mandatory": true},
{"tag": "AnswerTime", "field_id": "AnswerTime", "type": "*composed", "value": "~*req.12", "mandatory": true},
{"tag": "Usage", "field_id": "Usage", "type": "*composed", "value": "~*req.13", "mandatory": true},
],
"trailer_fields": [], // template of the import trailer fields
"continue": false, // continue to the next template if executed
"continue": false, // continue to the next template if executed
},
],
},
@@ -358,7 +358,7 @@ const CGRATES_CFG_JSON = `
"session_indexes": [], // index sessions based on these fields for GetActiveSessions API
"client_protocol": 1.0, // version of protocol to use when acting as JSON-PRC client <"0","1.0">
"channel_sync_interval": "0", // sync channels to detect stale sessions (0 to disable)
"terminate_attempts": 5 // attempts to get the session before terminating it
"terminate_attempts": 5 // attempts to get the session before terminating it
},
@@ -423,45 +423,45 @@ const CGRATES_CFG_JSON = `
"asr_template": "", // enable AbortSession message being sent to client on DisconnectSession
"templates":{ // default message templates
"*err": [
{"tag": "SessionId", "field_id": "Session-Id", "type": "*composed",
{"tag": "SessionId", "field_id": "Session-Id", "type": "*composed",
"value": "~*req.Session-Id", "mandatory": true},
{"tag": "OriginHost", "field_id": "Origin-Host", "type": "*composed",
{"tag": "OriginHost", "field_id": "Origin-Host", "type": "*composed",
"value": "~*vars.OriginHost", "mandatory": true},
{"tag": "OriginRealm", "field_id": "Origin-Realm", "type": "*composed",
{"tag": "OriginRealm", "field_id": "Origin-Realm", "type": "*composed",
"value": "~*vars.OriginRealm", "mandatory": true},
],
"*cca": [
{"tag": "SessionId", "field_id": "Session-Id", "type": "*composed",
{"tag": "SessionId", "field_id": "Session-Id", "type": "*composed",
"value": "~*req.Session-Id", "mandatory": true},
{"tag": "ResultCode", "field_id": "Result-Code", "type": "*constant",
{"tag": "ResultCode", "field_id": "Result-Code", "type": "*constant",
"value": "2001"},
{"tag": "OriginHost", "field_id": "Origin-Host", "type": "*composed",
{"tag": "OriginHost", "field_id": "Origin-Host", "type": "*composed",
"value": "~*vars.OriginHost", "mandatory": true},
{"tag": "OriginRealm", "field_id": "Origin-Realm", "type": "*composed",
{"tag": "OriginRealm", "field_id": "Origin-Realm", "type": "*composed",
"value": "~*vars.OriginRealm", "mandatory": true},
{"tag": "AuthApplicationId", "field_id": "Auth-Application-Id", "type": "*composed",
"value": "~*vars.*appid", "mandatory": true},
{"tag": "CCRequestType", "field_id": "CC-Request-Type", "type": "*composed",
{"tag": "CCRequestType", "field_id": "CC-Request-Type", "type": "*composed",
"value": "~*req.CC-Request-Type", "mandatory": true},
{"tag": "CCRequestNumber", "field_id": "CC-Request-Number", "type": "*composed",
{"tag": "CCRequestNumber", "field_id": "CC-Request-Number", "type": "*composed",
"value": "~*req.CC-Request-Number", "mandatory": true},
],
"*asr": [
{"tag": "SessionId", "field_id": "Session-Id", "type": "*variable",
{"tag": "SessionId", "field_id": "Session-Id", "type": "*variable",
"value": "~*req.Session-Id", "mandatory": true},
{"tag": "OriginHost", "field_id": "Origin-Host", "type": "*variable",
{"tag": "OriginHost", "field_id": "Origin-Host", "type": "*variable",
"value": "~*req.Destination-Host", "mandatory": true},
{"tag": "OriginRealm", "field_id": "Origin-Realm", "type": "*variable",
{"tag": "OriginRealm", "field_id": "Origin-Realm", "type": "*variable",
"value": "~*req.Destination-Realm", "mandatory": true},
{"tag": "DestinationRealm", "field_id": "Destination-Realm", "type": "*variable",
{"tag": "DestinationRealm", "field_id": "Destination-Realm", "type": "*variable",
"value": "~*req.Origin-Realm", "mandatory": true},
{"tag": "DestinationHost", "field_id": "Destination-Host", "type": "*variable",
{"tag": "DestinationHost", "field_id": "Destination-Host", "type": "*variable",
"value": "~*req.Origin-Host", "mandatory": true},
{"tag": "AuthApplicationId", "field_id": "Auth-Application-Id", "type": "*variable",
"value": "~*vars.*appid", "mandatory": true},
{"tag": "UserName", "field_id": "User-Name", "type": "*variable",
{"tag": "UserName", "field_id": "User-Name", "type": "*variable",
"value": "~*req.User-Name", "mandatory": true},
{"tag": "OriginStateID", "field_id": "Origin-State-Id", "type": "*constant",
{"tag": "OriginStateID", "field_id": "Origin-State-Id", "type": "*constant",
"value": "1"},
]
},
@@ -561,7 +561,7 @@ const CGRATES_CFG_JSON = `
"prefix_indexed_fields": [], // query indexes based on these fields for faster processing
"attributes_conns": [], // connections to AttributeS for altering events before supplier queries: <""|*internal|127.0.0.1:2013>
"rals_conns": [ // connections to RALs for cost/accounting <*internal>
{"address": "*internal"},
{"address": "*internal"},
],
"resources_conns": [], // connections to ResourceS for *res sorting, empty to disable functionality: <""|*internal|x.y.z.y:1234>
"stats_conns": [], // connections to StatS for *stats sorting, empty to disable stats functionality: <""|*internal|x.y.z.y:1234>
@@ -569,7 +569,7 @@ const CGRATES_CFG_JSON = `
},
"loaders": [ // LoaderS config
"loaders": [ // LoaderS config
{
"id": "*default", // identifier of the Loader
"enabled": false, // starts as service: <true|false>.
@@ -612,7 +612,7 @@ const CGRATES_CFG_JSON = `
{"tag": "FilterFieldValues", "field_id": "FilterFieldValues", "type": "*variable", "value": "~4"},
{"tag": "ActivationInterval", "field_id": "ActivationInterval", "type": "*variable", "value": "~5"},
],
},
},
{
"type": "*resources", // data source type
"file_name": "Resources.csv", // file name in the tp_in_dir
@@ -722,7 +722,7 @@ const CGRATES_CFG_JSON = `
},
{
"type": "*dispatcher_hosts", // data source type
"file_name": "DispatcherHosts.csv", // file name in the tp_in_dir
"file_name": "DispatcherHosts.csv", // file name in the tp_in_dir
"fields": [
{"tag": "Tenant", "field_id": "Tenant", "type": "*variable", "value": "~0", "mandatory": true},
{"tag": "ID", "field_id": "ID", "type": "*variable", "value": "~1", "mandatory": true},
@@ -820,13 +820,13 @@ const CGRATES_CFG_JSON = `
},
"apier": {
"apier": {
"caches_conns":[ // connections to CacheS for reloads
{"address": "*internal"},
],
"scheduler_conns": [ // connections to SchedulerS for reloads
{"address": "*internal"}
],
],
"attributes_conns": [], // connections to AttributeS for CDRExporter
},

View File

@@ -19,6 +19,14 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package config
import (
"os"
"reflect"
"testing"
"github.com/cgrates/cgrates/utils"
)
// func TestNewCgrJsonCfgFromHttp(t *testing.T) {
// addr := "https://raw.githubusercontent.com/cgrates/cgrates/master/data/conf/samples/tutmongo/cgrates.json"
// expVal, err := NewCgrJsonCfgFromFile(path.Join("/usr", "share", "cgrates", "conf", "samples", "tutmongo", "cgrates.json"))
@@ -62,8 +70,15 @@ package config
// }
/* Needs to be rewritten with a static config
func TestCgrCfgV1ReloadConfigSection(t *testing.T) {
for _, dir := range []string{"/tmp/ers/in", "/tmp/ers/out"} {
if err := os.RemoveAll(dir); err != nil {
t.Fatal("Error removing folder: ", dir, err)
}
if err := os.MkdirAll(dir, 0755); err != nil {
t.Fatal("Error creating folder: ", dir, err)
}
}
expected := map[string]interface{}{
"Enabled": true,
"Readers": []interface{}{
@@ -102,7 +117,7 @@ func TestCgrCfgV1ReloadConfigSection(t *testing.T) {
var rcv map[string]interface{}
if err := cfg.V1ReloadConfig(&ConfigReloadWithArgDispatcher{
Path: "/usr/share/cgrates/conf/samples/ers",
Path: "/usr/share/cgrates/conf/samples/ers_example",
Section: ERsJson,
}, &reply); err != nil {
t.Fatal(err)
@@ -116,4 +131,3 @@ func TestCgrCfgV1ReloadConfigSection(t *testing.T) {
t.Errorf("Expected: %+v, received: %+v", utils.ToJSON(expected), utils.ToJSON(rcv))
}
}
*/

View File

@@ -1586,27 +1586,27 @@ func TestDfApierCfg(t *testing.T) {
func TestDfEventReaderCfg(t *testing.T) {
cdrFields := []*FcTemplateJsonCfg{
{Tag: utils.StringPointer("TOR"), Field_id: utils.StringPointer(utils.ToR), Type: utils.StringPointer(utils.META_COMPOSED),
Value: utils.StringPointer("~2"), Mandatory: utils.BoolPointer(true)},
Value: utils.StringPointer("~*req.2"), Mandatory: utils.BoolPointer(true)},
{Tag: utils.StringPointer("OriginID"), Field_id: utils.StringPointer(utils.OriginID), Type: utils.StringPointer(utils.META_COMPOSED),
Value: utils.StringPointer("~3"), Mandatory: utils.BoolPointer(true)},
Value: utils.StringPointer("~*req.3"), Mandatory: utils.BoolPointer(true)},
{Tag: utils.StringPointer("RequestType"), Field_id: utils.StringPointer(utils.RequestType), Type: utils.StringPointer(utils.META_COMPOSED),
Value: utils.StringPointer("~4"), Mandatory: utils.BoolPointer(true)},
Value: utils.StringPointer("~*req.4"), Mandatory: utils.BoolPointer(true)},
{Tag: utils.StringPointer("Tenant"), Field_id: utils.StringPointer(utils.Tenant), Type: utils.StringPointer(utils.META_COMPOSED),
Value: utils.StringPointer("~6"), Mandatory: utils.BoolPointer(true)},
Value: utils.StringPointer("~*req.6"), Mandatory: utils.BoolPointer(true)},
{Tag: utils.StringPointer("Category"), Field_id: utils.StringPointer(utils.Category), Type: utils.StringPointer(utils.META_COMPOSED),
Value: utils.StringPointer("~7"), Mandatory: utils.BoolPointer(true)},
Value: utils.StringPointer("~*req.7"), Mandatory: utils.BoolPointer(true)},
{Tag: utils.StringPointer("Account"), Field_id: utils.StringPointer(utils.Account), Type: utils.StringPointer(utils.META_COMPOSED),
Value: utils.StringPointer("~8"), Mandatory: utils.BoolPointer(true)},
Value: utils.StringPointer("~*req.8"), Mandatory: utils.BoolPointer(true)},
{Tag: utils.StringPointer("Subject"), Field_id: utils.StringPointer(utils.Subject), Type: utils.StringPointer(utils.META_COMPOSED),
Value: utils.StringPointer("~9"), Mandatory: utils.BoolPointer(true)},
Value: utils.StringPointer("~*req.9"), Mandatory: utils.BoolPointer(true)},
{Tag: utils.StringPointer("Destination"), Field_id: utils.StringPointer(utils.Destination), Type: utils.StringPointer(utils.META_COMPOSED),
Value: utils.StringPointer("~10"), Mandatory: utils.BoolPointer(true)},
Value: utils.StringPointer("~*req.10"), Mandatory: utils.BoolPointer(true)},
{Tag: utils.StringPointer("SetupTime"), Field_id: utils.StringPointer(utils.SetupTime), Type: utils.StringPointer(utils.META_COMPOSED),
Value: utils.StringPointer("~11"), Mandatory: utils.BoolPointer(true)},
Value: utils.StringPointer("~*req.11"), Mandatory: utils.BoolPointer(true)},
{Tag: utils.StringPointer("AnswerTime"), Field_id: utils.StringPointer(utils.AnswerTime), Type: utils.StringPointer(utils.META_COMPOSED),
Value: utils.StringPointer("~12"), Mandatory: utils.BoolPointer(true)},
Value: utils.StringPointer("~*req.12"), Mandatory: utils.BoolPointer(true)},
{Tag: utils.StringPointer("Usage"), Field_id: utils.StringPointer(utils.Usage), Type: utils.StringPointer(utils.META_COMPOSED),
Value: utils.StringPointer("~13"), Mandatory: utils.BoolPointer(true)},
Value: utils.StringPointer("~*req.13"), Mandatory: utils.BoolPointer(true)},
}
eCfg := &ERsJsonCfg{
Enabled: utils.BoolPointer(false),

View File

@@ -1829,27 +1829,27 @@ func TestCgrCdfEventReader(t *testing.T) {
HeaderFields: make([]*FCTemplate, 0),
ContentFields: []*FCTemplate{
{Tag: "TOR", FieldId: "ToR", Type: utils.META_COMPOSED,
Value: NewRSRParsersMustCompile("~2", true, utils.INFIELD_SEP), Mandatory: true},
Value: NewRSRParsersMustCompile("~*req.2", true, utils.INFIELD_SEP), Mandatory: true},
{Tag: "OriginID", FieldId: "OriginID", Type: utils.META_COMPOSED,
Value: NewRSRParsersMustCompile("~3", true, utils.INFIELD_SEP), Mandatory: true},
Value: NewRSRParsersMustCompile("~*req.3", true, utils.INFIELD_SEP), Mandatory: true},
{Tag: "RequestType", FieldId: "RequestType", Type: utils.META_COMPOSED,
Value: NewRSRParsersMustCompile("~4", true, utils.INFIELD_SEP), Mandatory: true},
Value: NewRSRParsersMustCompile("~*req.4", true, utils.INFIELD_SEP), Mandatory: true},
{Tag: "Tenant", FieldId: "Tenant", Type: utils.META_COMPOSED,
Value: NewRSRParsersMustCompile("~6", true, utils.INFIELD_SEP), Mandatory: true},
Value: NewRSRParsersMustCompile("~*req.6", true, utils.INFIELD_SEP), Mandatory: true},
{Tag: "Category", FieldId: "Category", Type: utils.META_COMPOSED,
Value: NewRSRParsersMustCompile("~7", true, utils.INFIELD_SEP), Mandatory: true},
Value: NewRSRParsersMustCompile("~*req.7", true, utils.INFIELD_SEP), Mandatory: true},
{Tag: "Account", FieldId: "Account", Type: utils.META_COMPOSED,
Value: NewRSRParsersMustCompile("~8", true, utils.INFIELD_SEP), Mandatory: true},
Value: NewRSRParsersMustCompile("~*req.8", true, utils.INFIELD_SEP), Mandatory: true},
{Tag: "Subject", FieldId: "Subject", Type: utils.META_COMPOSED,
Value: NewRSRParsersMustCompile("~9", true, utils.INFIELD_SEP), Mandatory: true},
Value: NewRSRParsersMustCompile("~*req.9", true, utils.INFIELD_SEP), Mandatory: true},
{Tag: "Destination", FieldId: "Destination", Type: utils.META_COMPOSED,
Value: NewRSRParsersMustCompile("~10", true, utils.INFIELD_SEP), Mandatory: true},
Value: NewRSRParsersMustCompile("~*req.10", true, utils.INFIELD_SEP), Mandatory: true},
{Tag: "SetupTime", FieldId: "SetupTime", Type: utils.META_COMPOSED,
Value: NewRSRParsersMustCompile("~11", true, utils.INFIELD_SEP), Mandatory: true},
Value: NewRSRParsersMustCompile("~*req.11", true, utils.INFIELD_SEP), Mandatory: true},
{Tag: "AnswerTime", FieldId: "AnswerTime", Type: utils.META_COMPOSED,
Value: NewRSRParsersMustCompile("~12", true, utils.INFIELD_SEP), Mandatory: true},
Value: NewRSRParsersMustCompile("~*req.12", true, utils.INFIELD_SEP), Mandatory: true},
{Tag: "Usage", FieldId: "Usage", Type: utils.META_COMPOSED,
Value: NewRSRParsersMustCompile("~13", true, utils.INFIELD_SEP), Mandatory: true},
Value: NewRSRParsersMustCompile("~*req.13", true, utils.INFIELD_SEP), Mandatory: true},
},
TrailerFields: make([]*FCTemplate, 0),
},
@@ -1878,27 +1878,27 @@ func TestCgrCfgEventReaderDefault(t *testing.T) {
HeaderFields: make([]*FCTemplate, 0),
ContentFields: []*FCTemplate{
{Tag: "TOR", FieldId: "ToR", Type: utils.META_COMPOSED,
Value: NewRSRParsersMustCompile("~2", true, utils.INFIELD_SEP), Mandatory: true},
Value: NewRSRParsersMustCompile("~*req.2", true, utils.INFIELD_SEP), Mandatory: true},
{Tag: "OriginID", FieldId: "OriginID", Type: utils.META_COMPOSED,
Value: NewRSRParsersMustCompile("~3", true, utils.INFIELD_SEP), Mandatory: true},
Value: NewRSRParsersMustCompile("~*req.3", true, utils.INFIELD_SEP), Mandatory: true},
{Tag: "RequestType", FieldId: "RequestType", Type: utils.META_COMPOSED,
Value: NewRSRParsersMustCompile("~4", true, utils.INFIELD_SEP), Mandatory: true},
Value: NewRSRParsersMustCompile("~*req.4", true, utils.INFIELD_SEP), Mandatory: true},
{Tag: "Tenant", FieldId: "Tenant", Type: utils.META_COMPOSED,
Value: NewRSRParsersMustCompile("~6", true, utils.INFIELD_SEP), Mandatory: true},
Value: NewRSRParsersMustCompile("~*req.6", true, utils.INFIELD_SEP), Mandatory: true},
{Tag: "Category", FieldId: "Category", Type: utils.META_COMPOSED,
Value: NewRSRParsersMustCompile("~7", true, utils.INFIELD_SEP), Mandatory: true},
Value: NewRSRParsersMustCompile("~*req.7", true, utils.INFIELD_SEP), Mandatory: true},
{Tag: "Account", FieldId: "Account", Type: utils.META_COMPOSED,
Value: NewRSRParsersMustCompile("~8", true, utils.INFIELD_SEP), Mandatory: true},
Value: NewRSRParsersMustCompile("~*req.8", true, utils.INFIELD_SEP), Mandatory: true},
{Tag: "Subject", FieldId: "Subject", Type: utils.META_COMPOSED,
Value: NewRSRParsersMustCompile("~9", true, utils.INFIELD_SEP), Mandatory: true},
Value: NewRSRParsersMustCompile("~*req.9", true, utils.INFIELD_SEP), Mandatory: true},
{Tag: "Destination", FieldId: "Destination", Type: utils.META_COMPOSED,
Value: NewRSRParsersMustCompile("~10", true, utils.INFIELD_SEP), Mandatory: true},
Value: NewRSRParsersMustCompile("~*req.10", true, utils.INFIELD_SEP), Mandatory: true},
{Tag: "SetupTime", FieldId: "SetupTime", Type: utils.META_COMPOSED,
Value: NewRSRParsersMustCompile("~11", true, utils.INFIELD_SEP), Mandatory: true},
Value: NewRSRParsersMustCompile("~*req.11", true, utils.INFIELD_SEP), Mandatory: true},
{Tag: "AnswerTime", FieldId: "AnswerTime", Type: utils.META_COMPOSED,
Value: NewRSRParsersMustCompile("~12", true, utils.INFIELD_SEP), Mandatory: true},
Value: NewRSRParsersMustCompile("~*req.12", true, utils.INFIELD_SEP), Mandatory: true},
{Tag: "Usage", FieldId: "Usage", Type: utils.META_COMPOSED,
Value: NewRSRParsersMustCompile("~13", true, utils.INFIELD_SEP), Mandatory: true},
Value: NewRSRParsersMustCompile("~*req.13", true, utils.INFIELD_SEP), Mandatory: true},
},
TrailerFields: make([]*FCTemplate, 0),
}

View File

@@ -39,7 +39,7 @@ func TestEventRedearClone(t *testing.T) {
Tag: "TOR",
FieldId: "ToR",
Type: "*composed",
Value: NewRSRParsersMustCompile("~2", true, utils.INFIELD_SEP),
Value: NewRSRParsersMustCompile("~*req.2", true, utils.INFIELD_SEP),
Mandatory: true,
},
{
@@ -70,7 +70,7 @@ func TestEventRedearClone(t *testing.T) {
Tag: "TOR",
FieldId: "ToR",
Type: "*composed",
Value: NewRSRParsersMustCompile("~2", true, utils.INFIELD_SEP),
Value: NewRSRParsersMustCompile("~*req.2", true, utils.INFIELD_SEP),
Mandatory: true,
},
{
@@ -125,27 +125,27 @@ func TestEventReaderLoadFromJSON(t *testing.T) {
HeaderFields: make([]*FCTemplate, 0),
ContentFields: []*FCTemplate{
{Tag: "TOR", FieldId: "ToR", Type: utils.META_COMPOSED,
Value: NewRSRParsersMustCompile("~2", true, utils.INFIELD_SEP), Mandatory: true},
Value: NewRSRParsersMustCompile("~*req.2", true, utils.INFIELD_SEP), Mandatory: true},
{Tag: "OriginID", FieldId: "OriginID", Type: utils.META_COMPOSED,
Value: NewRSRParsersMustCompile("~3", true, utils.INFIELD_SEP), Mandatory: true},
Value: NewRSRParsersMustCompile("~*req.3", true, utils.INFIELD_SEP), Mandatory: true},
{Tag: "RequestType", FieldId: "RequestType", Type: utils.META_COMPOSED,
Value: NewRSRParsersMustCompile("~4", true, utils.INFIELD_SEP), Mandatory: true},
Value: NewRSRParsersMustCompile("~*req.4", true, utils.INFIELD_SEP), Mandatory: true},
{Tag: "Tenant", FieldId: "Tenant", Type: utils.META_COMPOSED,
Value: NewRSRParsersMustCompile("~6", true, utils.INFIELD_SEP), Mandatory: true},
Value: NewRSRParsersMustCompile("~*req.6", true, utils.INFIELD_SEP), Mandatory: true},
{Tag: "Category", FieldId: "Category", Type: utils.META_COMPOSED,
Value: NewRSRParsersMustCompile("~7", true, utils.INFIELD_SEP), Mandatory: true},
Value: NewRSRParsersMustCompile("~*req.7", true, utils.INFIELD_SEP), Mandatory: true},
{Tag: "Account", FieldId: "Account", Type: utils.META_COMPOSED,
Value: NewRSRParsersMustCompile("~8", true, utils.INFIELD_SEP), Mandatory: true},
Value: NewRSRParsersMustCompile("~*req.8", true, utils.INFIELD_SEP), Mandatory: true},
{Tag: "Subject", FieldId: "Subject", Type: utils.META_COMPOSED,
Value: NewRSRParsersMustCompile("~9", true, utils.INFIELD_SEP), Mandatory: true},
Value: NewRSRParsersMustCompile("~*req.9", true, utils.INFIELD_SEP), Mandatory: true},
{Tag: "Destination", FieldId: "Destination", Type: utils.META_COMPOSED,
Value: NewRSRParsersMustCompile("~10", true, utils.INFIELD_SEP), Mandatory: true},
Value: NewRSRParsersMustCompile("~*req.10", true, utils.INFIELD_SEP), Mandatory: true},
{Tag: "SetupTime", FieldId: "SetupTime", Type: utils.META_COMPOSED,
Value: NewRSRParsersMustCompile("~11", true, utils.INFIELD_SEP), Mandatory: true},
Value: NewRSRParsersMustCompile("~*req.11", true, utils.INFIELD_SEP), Mandatory: true},
{Tag: "AnswerTime", FieldId: "AnswerTime", Type: utils.META_COMPOSED,
Value: NewRSRParsersMustCompile("~12", true, utils.INFIELD_SEP), Mandatory: true},
Value: NewRSRParsersMustCompile("~*req.12", true, utils.INFIELD_SEP), Mandatory: true},
{Tag: "Usage", FieldId: "Usage", Type: utils.META_COMPOSED,
Value: NewRSRParsersMustCompile("~13", true, utils.INFIELD_SEP), Mandatory: true},
Value: NewRSRParsersMustCompile("~*req.13", true, utils.INFIELD_SEP), Mandatory: true},
},
TrailerFields: make([]*FCTemplate, 0),
},
@@ -166,27 +166,27 @@ func TestEventReaderLoadFromJSON(t *testing.T) {
HeaderFields: make([]*FCTemplate, 0),
ContentFields: []*FCTemplate{
{Tag: "TOR", FieldId: "ToR", Type: utils.META_COMPOSED,
Value: NewRSRParsersMustCompile("~2", true, utils.INFIELD_SEP), Mandatory: true},
Value: NewRSRParsersMustCompile("~*req.2", true, utils.INFIELD_SEP), Mandatory: true},
{Tag: "OriginID", FieldId: "OriginID", Type: utils.META_COMPOSED,
Value: NewRSRParsersMustCompile("~3", true, utils.INFIELD_SEP), Mandatory: true},
Value: NewRSRParsersMustCompile("~*req.3", true, utils.INFIELD_SEP), Mandatory: true},
{Tag: "RequestType", FieldId: "RequestType", Type: utils.META_COMPOSED,
Value: NewRSRParsersMustCompile("~4", true, utils.INFIELD_SEP), Mandatory: true},
Value: NewRSRParsersMustCompile("~*req.4", true, utils.INFIELD_SEP), Mandatory: true},
{Tag: "Tenant", FieldId: "Tenant", Type: utils.META_COMPOSED,
Value: NewRSRParsersMustCompile("~6", true, utils.INFIELD_SEP), Mandatory: true},
Value: NewRSRParsersMustCompile("~*req.6", true, utils.INFIELD_SEP), Mandatory: true},
{Tag: "Category", FieldId: "Category", Type: utils.META_COMPOSED,
Value: NewRSRParsersMustCompile("~7", true, utils.INFIELD_SEP), Mandatory: true},
Value: NewRSRParsersMustCompile("~*req.7", true, utils.INFIELD_SEP), Mandatory: true},
{Tag: "Account", FieldId: "Account", Type: utils.META_COMPOSED,
Value: NewRSRParsersMustCompile("~8", true, utils.INFIELD_SEP), Mandatory: true},
Value: NewRSRParsersMustCompile("~*req.8", true, utils.INFIELD_SEP), Mandatory: true},
{Tag: "Subject", FieldId: "Subject", Type: utils.META_COMPOSED,
Value: NewRSRParsersMustCompile("~9", true, utils.INFIELD_SEP), Mandatory: true},
Value: NewRSRParsersMustCompile("~*req.9", true, utils.INFIELD_SEP), Mandatory: true},
{Tag: "Destination", FieldId: "Destination", Type: utils.META_COMPOSED,
Value: NewRSRParsersMustCompile("~10", true, utils.INFIELD_SEP), Mandatory: true},
Value: NewRSRParsersMustCompile("~*req.10", true, utils.INFIELD_SEP), Mandatory: true},
{Tag: "SetupTime", FieldId: "SetupTime", Type: utils.META_COMPOSED,
Value: NewRSRParsersMustCompile("~11", true, utils.INFIELD_SEP), Mandatory: true},
Value: NewRSRParsersMustCompile("~*req.11", true, utils.INFIELD_SEP), Mandatory: true},
{Tag: "AnswerTime", FieldId: "AnswerTime", Type: utils.META_COMPOSED,
Value: NewRSRParsersMustCompile("~12", true, utils.INFIELD_SEP), Mandatory: true},
Value: NewRSRParsersMustCompile("~*req.12", true, utils.INFIELD_SEP), Mandatory: true},
{Tag: "Usage", FieldId: "Usage", Type: utils.META_COMPOSED,
Value: NewRSRParsersMustCompile("~13", true, utils.INFIELD_SEP), Mandatory: true},
Value: NewRSRParsersMustCompile("~*req.13", true, utils.INFIELD_SEP), Mandatory: true},
},
TrailerFields: make([]*FCTemplate, 0),
},

View File

@@ -93,19 +93,6 @@
"flags": ["*dryrun"],
"source_path": "/tmp/ers/in",
"processed_path": "/tmp/ers/out",
"content_fields":[ // import content_fields template, tag will match internally CDR field, in case of .csv value will be represented by index of the field value
{"tag": "TOR", "field_id": "ToR", "type": "*composed", "value": "~*req.2", "mandatory": true},
{"tag": "OriginID", "field_id": "OriginID", "type": "*composed", "value": "~*req.3", "mandatory": true},
{"tag": "RequestType", "field_id": "RequestType", "type": "*composed", "value": "~*req.4", "mandatory": true},
{"tag": "Tenant", "field_id": "Tenant", "type": "*composed", "value": "~*req.6", "mandatory": true},
{"tag": "Category", "field_id": "Category", "type": "*composed", "value": "~*req.7", "mandatory": true},
{"tag": "Account", "field_id": "Account", "type": "*composed", "value": "~*req.8", "mandatory": true},
{"tag": "Subject", "field_id": "Subject", "type": "*composed", "value": "~*req.9", "mandatory": true},
{"tag": "Destination", "field_id": "Destination", "type": "*composed", "value": "~*req.10", "mandatory": true},
{"tag": "SetupTime", "field_id": "SetupTime", "type": "*composed", "value": "~*req.11", "mandatory": true},
{"tag": "AnswerTime", "field_id": "AnswerTime", "type": "*composed", "value": "~*req.12", "mandatory": true},
{"tag": "Usage", "field_id": "Usage", "type": "*composed", "value": "~*req.13", "mandatory": true},
],
},
{
"id": "file_reader2",

View File

@@ -0,0 +1,114 @@
{
// CGRateS Configuration file
//
// Used for SessionSv1 integration tests
"general": {
"log_level": 7,
},
"listen": {
"rpc_json": ":2012",
"rpc_gob": ":2013",
"http": ":2080",
},
"stor_db": {
"db_password": "CGRateS.org",
},
"rals": {
"enabled": true,
},
"scheduler": {
"enabled": true,
},
"chargers": {
"enabled": true,
"attributes_conns": [
{"address": "*internal"}
],
},
"resources": {
"enabled": true,
},
"attributes": {
"enabled": true,
},
"cdrs": {
"enabled": true,
"chargers_conns": [
{"address": "127.0.0.1:2012", "transport": "*json"}
],
"rals_conns": [
{"address": "*internal"}
],
},
"sessions": {
"enabled": true,
"chargers_conns": [
{"address": "127.0.0.1:2012", "transport": "*json"}
],
"rals_conns": [
{"address": "*internal"}
],
"cdrs_conns": [
{"address": "*internal"}
],
"resources_conns": [
{"address": "*internal"}
],
"attributes_conns": [
{"address": "*internal"}
],
},
"ers": {
"enabled": true,
"sessions_conns": [ // connections to SessionS: <*internal|127.0.0.1:2012>
{"address": "127.0.0.1:2012", "transport": "*json"}
],
"readers": [
{
"id": "file_reader1",
"run_delay": -1,
"type": "*file_csv",
"flags": ["*dryrun"],
"source_path": "/tmp/ers/in",
"processed_path": "/tmp/ers/out",
"content_fields":[ // import content_fields template, tag will match internally CDR field, in case of .csv value will be represented by index of the field value
{"tag": "TOR", "field_id": "ToR", "type": "*composed", "value": "~*req.2", "mandatory": true},
{"tag": "OriginID", "field_id": "OriginID", "type": "*composed", "value": "~*req.3", "mandatory": true},
{"tag": "RequestType", "field_id": "RequestType", "type": "*composed", "value": "~*req.4", "mandatory": true},
{"tag": "Tenant", "field_id": "Tenant", "type": "*composed", "value": "~*req.6", "mandatory": true},
{"tag": "Category", "field_id": "Category", "type": "*composed", "value": "~*req.7", "mandatory": true},
{"tag": "Account", "field_id": "Account", "type": "*composed", "value": "~*req.8", "mandatory": true},
{"tag": "Subject", "field_id": "Subject", "type": "*composed", "value": "~*req.9", "mandatory": true},
{"tag": "Destination", "field_id": "Destination", "type": "*composed", "value": "~*req.10", "mandatory": true},
{"tag": "SetupTime", "field_id": "SetupTime", "type": "*composed", "value": "~*req.11", "mandatory": true},
{"tag": "AnswerTime", "field_id": "AnswerTime", "type": "*composed", "value": "~*req.12", "mandatory": true},
{"tag": "Usage", "field_id": "Usage", "type": "*composed", "value": "~*req.13", "mandatory": true},
],
},
],
},
}