Skip to content

Commit

Permalink
Correct test and add test for rerating CDRs using ERs
Browse files Browse the repository at this point in the history
  • Loading branch information
arberkatellari authored and danbogos committed Oct 16, 2023
1 parent d560152 commit e3915b2
Show file tree
Hide file tree
Showing 3 changed files with 413 additions and 10 deletions.
39 changes: 29 additions & 10 deletions apier/v1/attributes_it_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1417,14 +1417,14 @@ func testAttributeSGetAttributeProfileIDsCount(t *testing.T) {
if err := attrSRPC.Call(context.Background(), utils.APIerSv1GetAttributeProfileCount,
&utils.TenantWithAPIOpts{}, &reply); err != nil {
t.Error(err)
} else if reply != 7 {
t.Errorf("Expecting: 7, received: %+v", reply)
} else if reply != 8 {
t.Errorf("Expecting: 8, received: %+v", reply)
}
if err := attrSRPC.Call(context.Background(), utils.APIerSv1GetAttributeProfileCount,
&utils.TenantWithAPIOpts{Tenant: "cgrates.org"}, &reply); err != nil {
t.Error(err)
} else if reply != 7 {
t.Errorf("Expecting: 7, received: %+v", reply)
} else if reply != 8 {
t.Errorf("Expecting: 8, received: %+v", reply)
}
var resp string
if err := attrSRPC.Call(context.Background(), utils.APIerSv1RemoveAttributeProfile,
Expand All @@ -1439,6 +1439,24 @@ func testAttributeSGetAttributeProfileIDsCount(t *testing.T) {
} else if resp != utils.OK {
t.Error("Unexpected reply returned", resp)
}
if err := attrSRPC.Call(context.Background(), utils.APIerSv1GetAttributeProfileCount,
&utils.TenantWithAPIOpts{Tenant: "cgrates.org"}, &reply); err != nil {
t.Error(err)
} else if reply != 7 {
t.Errorf("Expecting: 7, received: %+v", reply)
}
if err := attrSRPC.Call(context.Background(), utils.APIerSv1RemoveAttributeProfile,
&utils.TenantIDWithAPIOpts{TenantID: &utils.TenantID{
Tenant: "cgrates.org",
ID: "ATTR_2",
},
APIOpts: map[string]any{
utils.CacheOpt: utils.MetaRemove,
}}, &resp); err != nil {
t.Error(err)
} else if resp != utils.OK {
t.Error("Unexpected reply returned", resp)
}
if err := attrSRPC.Call(context.Background(), utils.APIerSv1GetAttributeProfileCount,
&utils.TenantWithAPIOpts{Tenant: "cgrates.org"}, &reply); err != nil {
t.Error(err)
Expand All @@ -1448,7 +1466,7 @@ func testAttributeSGetAttributeProfileIDsCount(t *testing.T) {
if err := attrSRPC.Call(context.Background(), utils.APIerSv1RemoveAttributeProfile,
&utils.TenantIDWithAPIOpts{TenantID: &utils.TenantID{
Tenant: "cgrates.org",
ID: "ATTR_2",
ID: "ATTR_3",
},
APIOpts: map[string]any{
utils.CacheOpt: utils.MetaRemove,
Expand All @@ -1466,7 +1484,7 @@ func testAttributeSGetAttributeProfileIDsCount(t *testing.T) {
if err := attrSRPC.Call(context.Background(), utils.APIerSv1RemoveAttributeProfile,
&utils.TenantIDWithAPIOpts{TenantID: &utils.TenantID{
Tenant: "cgrates.org",
ID: "ATTR_3",
ID: "ATTR_Header",
},
APIOpts: map[string]any{
utils.CacheOpt: utils.MetaRemove,
Expand All @@ -1484,7 +1502,7 @@ func testAttributeSGetAttributeProfileIDsCount(t *testing.T) {
if err := attrSRPC.Call(context.Background(), utils.APIerSv1RemoveAttributeProfile,
&utils.TenantIDWithAPIOpts{TenantID: &utils.TenantID{
Tenant: "cgrates.org",
ID: "ATTR_Header",
ID: "ATTR_PASS",
},
APIOpts: map[string]any{
utils.CacheOpt: utils.MetaRemove,
Expand All @@ -1502,11 +1520,12 @@ func testAttributeSGetAttributeProfileIDsCount(t *testing.T) {
if err := attrSRPC.Call(context.Background(), utils.APIerSv1RemoveAttributeProfile,
&utils.TenantIDWithAPIOpts{TenantID: &utils.TenantID{
Tenant: "cgrates.org",
ID: "ATTR_PASS",
ID: "ATTR_Search_and_replace",
},
APIOpts: map[string]any{
utils.CacheOpt: utils.MetaRemove,
}}, &resp); err != nil {
}},
&resp); err != nil {
t.Error(err)
} else if resp != utils.OK {
t.Error("Unexpected reply returned", resp)
Expand All @@ -1520,7 +1539,7 @@ func testAttributeSGetAttributeProfileIDsCount(t *testing.T) {
if err := attrSRPC.Call(context.Background(), utils.APIerSv1RemoveAttributeProfile,
&utils.TenantIDWithAPIOpts{TenantID: &utils.TenantID{
Tenant: "cgrates.org",
ID: "ATTR_Search_and_replace",
ID: "ATTR_RAD",
},
APIOpts: map[string]any{
utils.CacheOpt: utils.MetaRemove,
Expand Down
111 changes: 111 additions & 0 deletions data/conf/samples/ers_rerate/cgrates.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
{
"general": {
"log_level": 7
},

"listen": {
"rpc_json": ":2012",
"rpc_gob": ":2013",
"http": ":2080"
},

"stor_db": {
"db_password": "CGRateS.org"
},

"rals": {
"enabled": true,
"max_increments":3000000
},

"resources": {
"enabled": true
},

"attributes": {
"enabled": true
},

"cdrs": {
"enabled": true,
"rals_conns": ["*localhost"]
},

"sessions": {
"enabled": true,
"rals_conns": ["*localhost"],
"cdrs_conns": ["*localhost"],
"resources_conns": ["*localhost"],
"attributes_conns": ["*localhost"]
},

"ers": {
"enabled": true,
"sessions_conns": ["*localhost"],
"readers": [
{
"id": "file_reader1",
"run_delay": "-1",
"type": "*file_csv",
"flags": ["*cdrs", "*rals", "*rerate","*attributes", "*export"],
"source_path": "/tmp/ers/in",
"processed_path": "/tmp/ers/out",
"fields":[
{"tag": "ToR", "path": "*cgreq.ToR", "type": "*variable", "value": "~*req.2", "mandatory": true},
{"tag": "OriginID", "path": "*cgreq.OriginID", "type": "*variable", "value": "~*req.3", "mandatory": true},
{"tag": "RequestType", "path": "*cgreq.RequestType", "type": "*variable", "value": "~*req.4", "mandatory": true},
{"tag": "Tenant", "path": "*cgreq.Tenant", "type": "*variable", "value": "~*req.5", "mandatory": true},
{"tag": "Category", "path": "*cgreq.Category", "type": "*variable", "value": "~*req.6", "mandatory": true},
{"tag": "Account", "path": "*cgreq.Account", "type": "*variable", "value": "~*req.7", "mandatory": true},
{"tag": "Subject", "path": "*cgreq.Subject", "type": "*variable", "value": "~*req.8", "mandatory": true},
{"tag": "Destination", "path": "*cgreq.Destination", "type": "*variable", "value": "~*req.9", "mandatory": true},
{"tag": "SetupTime", "path": "*cgreq.SetupTime", "type": "*variable", "value": "~*req.10", "mandatory": true},
{"tag": "AnswerTime", "path": "*cgreq.AnswerTime", "type": "*variable", "value": "~*req.11", "mandatory": true},
{"tag": "Usage", "path": "*cgreq.Usage", "type": "*variable", "value": "~*req.12", "mandatory": true},
{"tag": "RunID", "path": "*cgreq.RunID", "type": "*variable", "value": "~*req.13", "mandatory": true},
{"tag": "Cost", "path": "*cgreq.Cost", "type": "*variable", "value": "~*req.14", "mandatory": true}
]
}
]
},

"ees": {
"enabled": true,
"attributes_conns":["*localhost"],
"cache": {
"*file_csv": {"limit": -1, "ttl": "1s", "static_ttl": false}
},
"exporters": [
{
"id": "CSVExporter",
"type": "*file_csv",
"export_path": "/tmp/ers/in",
"timezone": "UTC",
"synchronous": true,
"attempts": 1,
"field_separator": ",",
"fields":[
{"tag": "CGRID", "path": "*exp.CGRID", "type": "*variable", "value": "~*req.CGRID"},
{"tag": "ToR", "path": "*exp.ToR", "type": "*variable", "value": "~*req.ToR"},
{"tag": "OriginID", "path": "*exp.OriginID", "type": "*variable", "value": "~*req.OriginID"},
{"tag": "RequestType", "path": "*exp.RequestType", "type": "*variable", "value": "~*req.RequestType"},
{"tag": "Tenant", "path": "*exp.Tenant", "type": "*variable", "value": "~*req.Tenant"},
{"tag": "Category", "path": "*exp.Category", "type": "*variable", "value": "~*req.Category"},
{"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{*time_string}" },
{"tag": "AnswerTime", "path": "*exp.AnswerTime", "type": "*variable", "value": "~*req.AnswerTime{*time_string}"},
{"tag": "Usage", "path": "*exp.Usage", "type": "*variable", "value": "~*req.Usage{*duration_seconds}"},
{"tag": "RunID", "path": "*exp.RunID", "type": "*variable", "value": "~*req.RunID"},
{"tag": "Cost", "path": "*exp.Cost", "type": "*variable", "value": "~*req.Cost{*round:4}"}
]
}
]
},

"apiers": {
"enabled": true
}
}

Loading

0 comments on commit e3915b2

Please sign in to comment.