Merge pull request #1872 from adragusin/master

Updated it tests
This commit is contained in:
Dan Christian Bogos
2020-01-15 17:06:30 +01:00
committed by GitHub
47 changed files with 1596 additions and 291 deletions

View File

@@ -30,7 +30,38 @@ import (
"github.com/cgrates/cgrates/utils"
)
func TestNewCgrJsonCfgFromHttp(t *testing.T) {
var (
cgrConfigDIR string
cgrTests = []func(t *testing.T){
testNewCgrJsonCfgFromHttp,
testNewCGRConfigFromPath,
testCGRConfigReloadAttributeS,
testCGRConfigReloadChargerS,
testCGRConfigReloadThresholdS,
testCGRConfigReloadStatS,
testCGRConfigReloadResourceS,
testCGRConfigReloadSupplierS,
testCGRConfigReloadSchedulerS,
testCGRConfigReloadCDRs,
testCGRConfigReloadRALs,
testCGRConfigReloadSessionS,
testCGRConfigReloadERs,
testCGRConfigReloadDNSAgent,
testCGRConfigReloadFreeswitchAgent,
testCgrCfgV1ReloadConfigSection,
testCGRConfigReloadConfigFromJSONSessionS,
testCGRConfigReloadAll,
}
)
func TestCGRConfig(t *testing.T) {
for _, test := range cgrTests {
t.Run("CGRConfig", test)
}
}
func testNewCgrJsonCfgFromHttp(t *testing.T) {
addr := "https://raw.githubusercontent.com/cgrates/cgrates/master/data/conf/samples/tutmongo/cgrates.json"
expVal, err := NewDefaultCGRConfig()
if err != nil {
@@ -58,7 +89,7 @@ func TestNewCgrJsonCfgFromHttp(t *testing.T) {
}
func TestNewCGRConfigFromPath(t *testing.T) {
func testNewCGRConfigFromPath(t *testing.T) {
for key, val := range map[string]string{"LOGGER": "*syslog", "LOG_LEVEL": "6", "TLS_VERIFY": "false", "ROUND_DEC": "5",
"DB_ENCODING": "*msgpack", "TP_EXPORT_DIR": "/var/spool/cgrates/tpe", "FAILED_POSTS_DIR": "/var/spool/cgrates/failed_posts",
"DF_TENANT": "cgrates.org", "TIMEZONE": "Local"} {
@@ -81,7 +112,7 @@ func TestNewCGRConfigFromPath(t *testing.T) {
}
}
func TestCGRConfigReloadAttributeS(t *testing.T) {
func testCGRConfigReloadAttributeS(t *testing.T) {
cfg, err := NewDefaultCGRConfig()
if err != nil {
t.Fatal(err)
@@ -107,7 +138,7 @@ func TestCGRConfigReloadAttributeS(t *testing.T) {
}
}
func TestCGRConfigReloadChargerS(t *testing.T) {
func testCGRConfigReloadChargerS(t *testing.T) {
cfg, err := NewDefaultCGRConfig()
if err != nil {
t.Fatal(err)
@@ -133,7 +164,7 @@ func TestCGRConfigReloadChargerS(t *testing.T) {
}
}
func TestCGRConfigReloadThresholdS(t *testing.T) {
func testCGRConfigReloadThresholdS(t *testing.T) {
cfg, err := NewDefaultCGRConfig()
if err != nil {
t.Fatal(err)
@@ -158,7 +189,7 @@ func TestCGRConfigReloadThresholdS(t *testing.T) {
}
}
func TestCGRConfigReloadStatS(t *testing.T) {
func testCGRConfigReloadStatS(t *testing.T) {
cfg, err := NewDefaultCGRConfig()
if err != nil {
t.Fatal(err)
@@ -184,7 +215,7 @@ func TestCGRConfigReloadStatS(t *testing.T) {
}
}
func TestCGRConfigReloadResourceS(t *testing.T) {
func testCGRConfigReloadResourceS(t *testing.T) {
cfg, err := NewDefaultCGRConfig()
if err != nil {
t.Fatal(err)
@@ -210,7 +241,7 @@ func TestCGRConfigReloadResourceS(t *testing.T) {
}
}
func TestCGRConfigReloadSupplierS(t *testing.T) {
func testCGRConfigReloadSupplierS(t *testing.T) {
cfg, err := NewDefaultCGRConfig()
if err != nil {
t.Fatal(err)
@@ -239,7 +270,7 @@ func TestCGRConfigReloadSupplierS(t *testing.T) {
}
}
func TestCGRConfigReloadSchedulerS(t *testing.T) {
func testCGRConfigReloadSchedulerS(t *testing.T) {
cfg, err := NewDefaultCGRConfig()
if err != nil {
t.Fatal(err)
@@ -263,7 +294,7 @@ func TestCGRConfigReloadSchedulerS(t *testing.T) {
}
}
func TestCGRConfigReloadCDRs(t *testing.T) {
func testCGRConfigReloadCDRs(t *testing.T) {
cfg, err := NewDefaultCGRConfig()
if err != nil {
t.Fatal(err)
@@ -298,7 +329,7 @@ func TestCGRConfigReloadCDRs(t *testing.T) {
}
}
func TestCGRConfigReloadRALs(t *testing.T) {
func testCGRConfigReloadRALs(t *testing.T) {
cfg, err := NewDefaultCGRConfig()
if err != nil {
t.Fatal(err)
@@ -329,7 +360,7 @@ func TestCGRConfigReloadRALs(t *testing.T) {
}
}
func TestCGRConfigReloadSessionS(t *testing.T) {
func testCGRConfigReloadSessionS(t *testing.T) {
cfg, err := NewDefaultCGRConfig()
if err != nil {
t.Fatal(err)
@@ -369,7 +400,7 @@ func TestCGRConfigReloadSessionS(t *testing.T) {
}
}
func TestCGRConfigReloadERs(t *testing.T) {
func testCGRConfigReloadERs(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)
@@ -448,7 +479,7 @@ func TestCGRConfigReloadERs(t *testing.T) {
}
}
func TestCGRConfigReloadDNSAgent(t *testing.T) {
func testCGRConfigReloadDNSAgent(t *testing.T) {
cfg, err := NewDefaultCGRConfig()
if err != nil {
t.Fatal(err)
@@ -476,7 +507,7 @@ func TestCGRConfigReloadDNSAgent(t *testing.T) {
}
}
func TestCGRConfigReloadFreeswitchAgent(t *testing.T) {
func testCGRConfigReloadFreeswitchAgent(t *testing.T) {
cfg, err := NewDefaultCGRConfig()
if err != nil {
t.Fatal(err)
@@ -511,7 +542,7 @@ func TestCGRConfigReloadFreeswitchAgent(t *testing.T) {
}
}
func TestCgrCfgV1ReloadConfigSection(t *testing.T) {
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)
@@ -879,7 +910,7 @@ func TestCgrCfgV1ReloadConfigSection(t *testing.T) {
}
}
func TestCGRConfigReloadConfigFromJSONSessionS(t *testing.T) {
func testCGRConfigReloadConfigFromJSONSessionS(t *testing.T) {
cfg, err := NewDefaultCGRConfig()
if err != nil {
t.Fatal(err)
@@ -928,7 +959,7 @@ func TestCGRConfigReloadConfigFromJSONSessionS(t *testing.T) {
}
}
func TestCGRConfigReloadAll(t *testing.T) {
func testCGRConfigReloadAll(t *testing.T) {
cfg, err := NewDefaultCGRConfig()
if err != nil {
t.Fatal(err)

View File

@@ -0,0 +1,268 @@
{
// CGRateS Configuration file
//
// Used for SessionSv1 integration tests
"general": {
"log_level": 7,
"reply_timeout": "10s", // consider connection down for replies taking longer than this value
},
"listen": {
"rpc_json": ":2012",
"rpc_gob": ":2013",
"http": ":2080",
},
"data_db": {
"db_type": "*internal",
},
"stor_db": {
"db_type": "*internal",
},
"rals": {
"enabled": true,
},
"schedulers": {
"enabled": true,
},
"chargers": {
"enabled": true,
"attributes_conns": ["*internal"],
},
"resources": {
"enabled": true,
"store_interval": "-1",
},
"attributes": {
"enabled": true,
},
"cdrs": {
"enabled": true,
"chargers_conns": ["*localhost"],
"rals_conns": ["*internal"],
"session_cost_retries": 0,
},
"sessions": {
"enabled": true,
"chargers_conns": ["*localhost"],
"rals_conns": ["*internal"],
"cdrs_conns": ["*internal"],
"resources_conns": ["*internal"],
"attributes_conns": ["*internal"],
},
"ers": {
"enabled": true,
"sessions_conns": ["*internal"],
"readers": [
{
"id": "file_reader1",
"run_delay": -1,
"type": "*file_csv",
"flags": ["*dryrun"],
"source_path": "/tmp/ers/in",
"processed_path": "/tmp/ers/out",
},
{
"id": "file_reader2",
"run_delay": -1,
"field_separator": ";",
"type": "*file_csv",
"source_path": "/tmp/ers2/in",
"flags": ["*dryrun"],
"processed_path": "/tmp/ers2/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": "*constant", "value": "*voice", "mandatory": true},
{"tag": "OriginID", "field_id": "OriginID", "type": "*composed", "value": "~*req.0", "mandatory": true},
{"tag": "RequestType", "field_id": "RequestType", "type": "*composed", "value": "~*req.1", "mandatory": true},
{"tag": "Direction", "field_id": "Direction", "type": "*constant", "value": "*out", "mandatory": true},
{"tag": "Tenant", "field_id": "Tenant", "type": "*composed", "value": "~*req.2", "mandatory": true},
{"tag": "Category", "field_id": "Category", "type": "*constant", "value": "call", "mandatory": true},
{"tag": "Account", "field_id": "Account", "type": "*composed", "value": "~*req.3", "mandatory": true},
{"tag": "Subject", "field_id": "Subject", "type": "*composed", "value": "~*req.3", "mandatory": true},
{"tag": "Destination", "field_id": "Destination", "type": "*composed", "value": "~*req.4:s/0([1-9]\\d+)/+49${1}/", "mandatory": true},
{"tag": "SetupTime", "field_id": "SetupTime", "type": "*composed", "value": "~*req.5", "mandatory": true},
{"tag": "AnswerTime", "field_id": "AnswerTime", "type": "*composed", "value": "~*req.5", "mandatory": true},
{"tag": "Usage", "field_id": "Usage", "type": "*composed", "value": "~*req.6", "mandatory": true},
{"tag": "HDRExtra3", "field_id": "HDRExtra3", "type": "*composed", "value": "~*req.6", "mandatory": true},
{"tag": "HDRExtra2", "field_id": "HDRExtra2", "type": "*composed", "value": "~*req.6", "mandatory": true},
{"tag": "HDRExtra1", "field_id": "HDRExtra1", "type": "*composed", "value": "~*req.6", "mandatory": true},
],
},
{
"id": "init_session",
"run_delay": -1,
"field_separator": ",",
"type": "*file_csv",
"source_path": "/tmp/init_session/in",
"flags": ["*initiate","*accounts","*resources","*attributes","*log"],
"processed_path": "/tmp/init_session/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": "Tenant", "field_id": "Tenant", "type": "*variable", "value": "~*req.0", "mandatory": true},
{"tag": "TOR", "field_id": "ToR", "type": "*constant", "value": "*voice", "mandatory": true},
{"tag": "OriginID", "field_id": "OriginID", "type": "*variable", "value": "~*req.2", "mandatory": true},
{"tag": "RequestType", "field_id": "RequestType", "type": "*variable", "value": "~*req.3", "mandatory": true},
{"tag": "Category", "field_id": "Category", "type": "*constant", "value": "call", "mandatory": true},
{"tag": "Account", "field_id": "Account", "type": "*variable", "value": "~*req.4", "mandatory": true},
{"tag": "Subject", "field_id": "Subject", "type": "*variable", "value": "~*req.5", "mandatory": true},
{"tag": "Destination", "field_id": "Destination", "type": "*variable", "value": "~*req.6", "mandatory": true},
{"tag": "SetupTime", "field_id": "SetupTime", "type": "*variable", "value": "~*req.7", "mandatory": true},
{"tag": "AnswerTime", "field_id": "AnswerTime", "type": "*variable", "value": "~*req.8", "mandatory": true},
{"tag": "Usage", "field_id": "Usage", "type": "*variable", "value": "~*req.9", "mandatory": true},
],
},
{
"id": "terminate_session",
"run_delay": -1,
"field_separator": ",",
"type": "*file_csv",
"source_path": "/tmp/terminate_session/in",
"flags": ["*terminate","*accounts","*resources","*log"],
"processed_path": "/tmp/terminate_session/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": "Tenant", "field_id": "Tenant", "type": "*variable", "value": "~*req.0", "mandatory": true},
{"tag": "OriginID", "field_id": "OriginID", "type": "*variable", "value": "~*req.2", "mandatory": true},
{"tag": "RequestType", "field_id": "RequestType", "type": "*variable", "value": "~*req.3", "mandatory": true},
{"tag": "Usage", "field_id": "Usage", "type": "*variable", "value": "~*req.9", "mandatory": true},
],
},
{
"id": "create_cdr",
"run_delay": -1,
"field_separator": ",",
"type": "*file_csv",
"source_path": "/tmp/cdrs/in",
"flags": ["*cdrs","*log"],
"processed_path": "/tmp/cdrs/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": "Tenant", "field_id": "Tenant", "type": "*variable", "value": "~*req.0", "mandatory": true},
{"tag": "TOR", "field_id": "ToR", "type": "*constant", "value": "*voice", "mandatory": true},
{"tag": "OriginID", "field_id": "OriginID", "type": "*variable", "value": "~*req.2", "mandatory": true},
{"tag": "RequestType", "field_id": "RequestType", "type": "*variable", "value": "~*req.3", "mandatory": true},
{"tag": "Category", "field_id": "Category", "type": "*constant", "value": "call", "mandatory": true},
{"tag": "Account", "field_id": "Account", "type": "*variable", "value": "~*req.4", "mandatory": true},
{"tag": "Subject", "field_id": "Subject", "type": "*variable", "value": "~*req.5", "mandatory": true},
{"tag": "Destination", "field_id": "Destination", "type": "*variable", "value": "~*req.6", "mandatory": true},
{"tag": "SetupTime", "field_id": "SetupTime", "type": "*variable", "value": "~*req.7", "mandatory": true},
{"tag": "AnswerTime", "field_id": "AnswerTime", "type": "*variable", "value": "~*req.8", "mandatory": true},
{"tag": "Usage", "field_id": "Usage", "type": "*variable", "value": "~*req.9", "mandatory": true},
{"tag": "ExtraInfo1", "field_id": "ExtraInfo1", "type": "*constant", "value": "ExtraInfo1", "mandatory": true},
{"tag": "ExtraInfo2", "field_id": "ExtraInfo2", "type": "*constant", "value": "ExtraInfo2", "mandatory": true},
],
},
{
"id": "file_reader_with_filters",
"run_delay": -1,
"type": "*file_csv",
"field_separator": ";",
"source_path": "/tmp/ers_with_filters/in",
"processed_path": "/tmp/ers_with_filters/out",
"flags": ["*cdrs","*log"],
"filters":["*string:~*req.3:1002"],
"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": "*constant", "value": "*voice", "mandatory": true},
{"tag": "OriginID", "field_id": "OriginID", "type": "*composed", "value": "~*req.0", "mandatory": true},
{"tag": "RequestType", "field_id": "RequestType", "type": "*composed", "value": "~*req.1", "mandatory": true},
{"tag": "Tenant", "field_id": "Tenant", "type": "*composed", "value": "~*req.2", "mandatory": true},
{"tag": "Category", "field_id": "Category", "type": "*composed", "value": "call", "mandatory": true},
{"tag": "Account", "field_id": "Account", "type": "*composed", "value": "~*req.3", "mandatory": true},
{"tag": "Source", "field_id": "Source", "type": "*constant", "value": "ers_csv", "mandatory": true},
{"tag": "Subject", "field_id": "Subject", "type": "*composed", "value": "~*req.3", "mandatory": true},
{"tag": "Destination", "field_id": "Destination", "type": "*composed", "value": "~*req.4:s/0([1-9]\\d+)/+49${1}/", "mandatory": true},
{"tag": "SetupTime", "field_id": "SetupTime", "type": "*composed", "value": "~*req.5", "mandatory": true},
{"tag": "AnswerTime", "field_id": "AnswerTime", "type": "*composed", "value": "~*req.5", "mandatory": true},
{"tag": "Usage", "field_id": "Usage", "type": "*composed", "value": "~*req.6", "mandatory": true},
{"tag": "HDRExtra3", "field_id": "HDRExtra3", "type": "*composed", "value": "~*req.6", "mandatory": true},
{"tag": "HDRExtra2", "field_id": "HDRExtra2", "type": "*composed", "value": "~*req.6", "mandatory": true},
{"tag": "HDRExtra1", "field_id": "HDRExtra1", "type": "*composed", "value": "~*req.6", "mandatory": true},
],
},
{
"id": "XmlDryRun",
"run_delay": -1,
"type": "*file_xml",
"source_path": "/tmp/xmlErs/in",
"flags": ["*cdrs","*log"],
"processed_path": "/tmp/xmlErs/out",
"xml_root_path": "broadWorksCDR.cdrData",
"content_fields":[
{"tag": "TOR", "field_id": "ToR", "type": "*constant", "value": "*voice", "mandatory": true},
{"tag": "OriginID", "field_id": "OriginID", "type": "*variable", "value": "~*req.broadWorksCDR.cdrData.basicModule.localCallId", "mandatory": true},
{"tag": "RequestType", "field_id": "RequestType", "type": "*constant", "value": "*rated", "mandatory": true},
{"tag": "Direction", "field_id": "Direction", "type": "*constant", "value": "*out", "mandatory": true},
{"tag": "Tenant", "field_id": "Tenant", "type": "*variable", "value": "~*req.broadWorksCDR.cdrData.basicModule.userId:s/.*@(.*)/${1}/", "mandatory": true},
{"tag": "Category", "field_id": "Category", "type": "*constant", "value": "call", "mandatory": true},
{"tag": "Account", "field_id": "Account", "type": "*variable", "value": "~*req.broadWorksCDR.cdrData.basicModule.userNumber", "mandatory": true},
{"tag": "Destination", "field_id": "Destination", "type": "*variable", "value": "~*req.broadWorksCDR.cdrData.basicModule.calledNumber", "mandatory": true},
{"tag": "SetupTime", "field_id": "SetupTime", "type": "*variable", "value": "~*req.broadWorksCDR.cdrData.basicModule.startTime", "mandatory": true},
{"tag": "AnswerTime", "field_id": "AnswerTime", "type": "*variable", "value": "~*req.broadWorksCDR.cdrData.basicModule.answerTime", "mandatory": true},
{"tag": "Usage", "field_id": "Usage", "type": "*usage_difference", "value": "~*req.broadWorksCDR.cdrData.basicModule.releaseTime;~*req.broadWorksCDR.cdrData.basicModule.answerTime", "mandatory": true}
],
},
{
"id": "FWV1",
"run_delay": -1,
"type": "*file_fwv",
"source_path": "/tmp/fwvErs/in",
"flags": ["*cdrs"],
"processed_path": "/tmp/fwvErs/out",
"header_fields": [
{"tag": "FileName", "field_id": "CdrFileName", "type": "*composed", "value": "~*req.95-135", "padding":"right"},
{"tag": "FileSeqNr", "field_id": "FileSeqNr", "type": "*composed", "value": "~*req.135-141", "padding":"zeroleft"},
{"tag": "AccId1", "field_id": "AccId1", "type": "*composed", "value": "~*req.135-141", "padding":"zeroleft"},
],
"content_fields": [
{"tag": "Tor", "field_id": "ToR", "type": "*constant", "value": "*voice", "mandatory": true},
{"tag": "RequestType", "field_id": "RequestType", "type": "*constant", "value": "rated", "mandatory": true},
{"tag": "OriginID", "field_id": "OriginID", "type": "*variable", "value": "~*req.0-10", "padding":"right", "mandatory": true},
{"tag": "OriginHost", "field_id": "OriginHost", "type": "*constant", "value": "0.0.0.0", "mandatory": true},
{"tag": "Tenant", "field_id": "Tenant", "type": "*constant", "value": "cgrates.org", "mandatory": true},
{"tag": "Category", "field_id": "Category", "type": "*constant", "value": "call", "mandatory": true},
{"tag": "Account", "field_id": "Account", "type": "*variable", "value": "~*req.30-49", "padding":"right", "mandatory": true},
{"tag": "Subject", "field_id": "Subject", "type": "*variable", "value": "~*req.30-49", "padding":"right", "mandatory": true},
{"tag": "Destination", "field_id": "Destination", "type": "*variable", "value": "~*req.52-80", "padding":"right", "mandatory": true},
{"tag": "SetupTime", "field_id": "SetupTime", "type": "*variable", "value": "~*req.14-30:s/(\\d{4})(\\d{2})(\\d{2})(\\d{2})(\\d{2})(\\d{2})(\\d{2})/${1}-${2}-${3} ${4}:${5}:${6}/", "mandatory": true},
{"tag": "AnswerTime", "field_id": "AnswerTime", "type": "*variable", "value": "~*req.14-30:s/(\\d{4})(\\d{2})(\\d{2})(\\d{2})(\\d{2})(\\d{2})(\\d{2})/${1}-${2}-${3} ${4}:${5}:${6}/", "mandatory": true},
{"tag": "Usage", "field_id": "Usage", "type": "*variable", "value": "~*req.127-135:s/(\\d{2})(\\d{2})(\\d{2})(\\d{2})/${1}h${2}m${3}s/", "mandatory": true},
{"tag": "DisconnectCause", "field_id": "DisconnectCause", "type": "*variable", "value": "~*req.138-139", "mandatory": true},
{"tag": "RetailAmount", "field_id": "RetailAmount", "type": "*variable", "value": "~*req.103-111", "padding":"zeroleft"},
{"tag": "WholesaleAmount", "field_id": "RetailAmount", "type": "*variable", "value": "~*req.115-123", "padding":"zeroleft"},
{"tag": "AccId1", "field_id": "AccId1", "type": "*variable", "value": "~*req.3-6", "padding":"zeroleft", "mandatory": true},
{"tag": "AccId2", "field_id": "AccId2", "type": "*variable", "value": "~*req.14-30", "padding":"right", "mandatory": true},
],
"trailer_fields": [
{"tag": "NrOfCdrs", "type": "metatag", "metatag_id":"total_cdrs", "value": "~*req.142-150"},
{"tag": "TotalDuration", "type": "metatag", "metatag_id":"total_duration", "value": "~*req.150-162"},
],
}
],
},
"apier": {
"scheduler_conns": ["*internal"],
},
}

View File

@@ -0,0 +1,271 @@
{
// CGRateS Configuration file
//
// Used for SessionSv1 integration tests
"general": {
"log_level": 7,
"reply_timeout": "10s", // consider connection down for replies taking longer than this value
},
"listen": {
"rpc_json": ":2012",
"rpc_gob": ":2013",
"http": ":2080",
},
"data_db": {
"db_type": "mongo",
"db_name": "10",
"db_port": 27017,
},
"stor_db": {
"db_type": "mongo",
"db_name": "cgrates",
"db_port": 27017,
},
"rals": {
"enabled": true,
},
"schedulers": {
"enabled": true,
},
"chargers": {
"enabled": true,
"attributes_conns": ["*internal"],
},
"resources": {
"enabled": true,
},
"attributes": {
"enabled": true,
},
"cdrs": {
"enabled": true,
"chargers_conns": ["*localhost"],
"rals_conns": ["*internal"],
"session_cost_retries": 0,
},
"sessions": {
"enabled": true,
"chargers_conns": ["*localhost"],
"rals_conns": ["*internal"],
"cdrs_conns": ["*internal"],
"resources_conns": ["*internal"],
"attributes_conns": ["*internal"],
},
"ers": {
"enabled": true,
"sessions_conns": ["*internal"],
"readers": [
{
"id": "file_reader1",
"run_delay": -1,
"type": "*file_csv",
"flags": ["*dryrun"],
"source_path": "/tmp/ers/in",
"processed_path": "/tmp/ers/out",
},
{
"id": "file_reader2",
"run_delay": -1,
"field_separator": ";",
"type": "*file_csv",
"source_path": "/tmp/ers2/in",
"flags": ["*dryrun"],
"processed_path": "/tmp/ers2/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": "*constant", "value": "*voice", "mandatory": true},
{"tag": "OriginID", "field_id": "OriginID", "type": "*composed", "value": "~*req.0", "mandatory": true},
{"tag": "RequestType", "field_id": "RequestType", "type": "*composed", "value": "~*req.1", "mandatory": true},
{"tag": "Direction", "field_id": "Direction", "type": "*constant", "value": "*out", "mandatory": true},
{"tag": "Tenant", "field_id": "Tenant", "type": "*composed", "value": "~*req.2", "mandatory": true},
{"tag": "Category", "field_id": "Category", "type": "*constant", "value": "call", "mandatory": true},
{"tag": "Account", "field_id": "Account", "type": "*composed", "value": "~*req.3", "mandatory": true},
{"tag": "Subject", "field_id": "Subject", "type": "*composed", "value": "~*req.3", "mandatory": true},
{"tag": "Destination", "field_id": "Destination", "type": "*composed", "value": "~*req.4:s/0([1-9]\\d+)/+49${1}/", "mandatory": true},
{"tag": "SetupTime", "field_id": "SetupTime", "type": "*composed", "value": "~*req.5", "mandatory": true},
{"tag": "AnswerTime", "field_id": "AnswerTime", "type": "*composed", "value": "~*req.5", "mandatory": true},
{"tag": "Usage", "field_id": "Usage", "type": "*composed", "value": "~*req.6", "mandatory": true},
{"tag": "HDRExtra3", "field_id": "HDRExtra3", "type": "*composed", "value": "~*req.6", "mandatory": true},
{"tag": "HDRExtra2", "field_id": "HDRExtra2", "type": "*composed", "value": "~*req.6", "mandatory": true},
{"tag": "HDRExtra1", "field_id": "HDRExtra1", "type": "*composed", "value": "~*req.6", "mandatory": true},
],
},
{
"id": "init_session",
"run_delay": -1,
"field_separator": ",",
"type": "*file_csv",
"source_path": "/tmp/init_session/in",
"flags": ["*initiate","*accounts","*resources","*attributes","*log"],
"processed_path": "/tmp/init_session/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": "Tenant", "field_id": "Tenant", "type": "*variable", "value": "~*req.0", "mandatory": true},
{"tag": "TOR", "field_id": "ToR", "type": "*constant", "value": "*voice", "mandatory": true},
{"tag": "OriginID", "field_id": "OriginID", "type": "*variable", "value": "~*req.2", "mandatory": true},
{"tag": "RequestType", "field_id": "RequestType", "type": "*variable", "value": "~*req.3", "mandatory": true},
{"tag": "Category", "field_id": "Category", "type": "*constant", "value": "call", "mandatory": true},
{"tag": "Account", "field_id": "Account", "type": "*variable", "value": "~*req.4", "mandatory": true},
{"tag": "Subject", "field_id": "Subject", "type": "*variable", "value": "~*req.5", "mandatory": true},
{"tag": "Destination", "field_id": "Destination", "type": "*variable", "value": "~*req.6", "mandatory": true},
{"tag": "SetupTime", "field_id": "SetupTime", "type": "*variable", "value": "~*req.7", "mandatory": true},
{"tag": "AnswerTime", "field_id": "AnswerTime", "type": "*variable", "value": "~*req.8", "mandatory": true},
{"tag": "Usage", "field_id": "Usage", "type": "*variable", "value": "~*req.9", "mandatory": true},
],
},
{
"id": "terminate_session",
"run_delay": -1,
"field_separator": ",",
"type": "*file_csv",
"source_path": "/tmp/terminate_session/in",
"flags": ["*terminate","*accounts","*resources","*log"],
"processed_path": "/tmp/terminate_session/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": "Tenant", "field_id": "Tenant", "type": "*variable", "value": "~*req.0", "mandatory": true},
{"tag": "OriginID", "field_id": "OriginID", "type": "*variable", "value": "~*req.2", "mandatory": true},
{"tag": "RequestType", "field_id": "RequestType", "type": "*variable", "value": "~*req.3", "mandatory": true},
{"tag": "Usage", "field_id": "Usage", "type": "*variable", "value": "~*req.9", "mandatory": true},
],
},
{
"id": "create_cdr",
"run_delay": -1,
"field_separator": ",",
"type": "*file_csv",
"source_path": "/tmp/cdrs/in",
"flags": ["*cdrs","*log"],
"processed_path": "/tmp/cdrs/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": "Tenant", "field_id": "Tenant", "type": "*variable", "value": "~*req.0", "mandatory": true},
{"tag": "TOR", "field_id": "ToR", "type": "*constant", "value": "*voice", "mandatory": true},
{"tag": "OriginID", "field_id": "OriginID", "type": "*variable", "value": "~*req.2", "mandatory": true},
{"tag": "RequestType", "field_id": "RequestType", "type": "*variable", "value": "~*req.3", "mandatory": true},
{"tag": "Category", "field_id": "Category", "type": "*constant", "value": "call", "mandatory": true},
{"tag": "Account", "field_id": "Account", "type": "*variable", "value": "~*req.4", "mandatory": true},
{"tag": "Subject", "field_id": "Subject", "type": "*variable", "value": "~*req.5", "mandatory": true},
{"tag": "Destination", "field_id": "Destination", "type": "*variable", "value": "~*req.6", "mandatory": true},
{"tag": "SetupTime", "field_id": "SetupTime", "type": "*variable", "value": "~*req.7", "mandatory": true},
{"tag": "AnswerTime", "field_id": "AnswerTime", "type": "*variable", "value": "~*req.8", "mandatory": true},
{"tag": "Usage", "field_id": "Usage", "type": "*variable", "value": "~*req.9", "mandatory": true},
{"tag": "ExtraInfo1", "field_id": "ExtraInfo1", "type": "*constant", "value": "ExtraInfo1", "mandatory": true},
{"tag": "ExtraInfo2", "field_id": "ExtraInfo2", "type": "*constant", "value": "ExtraInfo2", "mandatory": true},
],
},
{
"id": "file_reader_with_filters",
"run_delay": -1,
"type": "*file_csv",
"field_separator": ";",
"source_path": "/tmp/ers_with_filters/in",
"processed_path": "/tmp/ers_with_filters/out",
"flags": ["*cdrs","*log"],
"filters":["*string:~*req.3:1002"],
"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": "*constant", "value": "*voice", "mandatory": true},
{"tag": "OriginID", "field_id": "OriginID", "type": "*composed", "value": "~*req.0", "mandatory": true},
{"tag": "RequestType", "field_id": "RequestType", "type": "*composed", "value": "~*req.1", "mandatory": true},
{"tag": "Tenant", "field_id": "Tenant", "type": "*composed", "value": "~*req.2", "mandatory": true},
{"tag": "Category", "field_id": "Category", "type": "*composed", "value": "call", "mandatory": true},
{"tag": "Account", "field_id": "Account", "type": "*composed", "value": "~*req.3", "mandatory": true},
{"tag": "Source", "field_id": "Source", "type": "*constant", "value": "ers_csv", "mandatory": true},
{"tag": "Subject", "field_id": "Subject", "type": "*composed", "value": "~*req.3", "mandatory": true},
{"tag": "Destination", "field_id": "Destination", "type": "*composed", "value": "~*req.4:s/0([1-9]\\d+)/+49${1}/", "mandatory": true},
{"tag": "SetupTime", "field_id": "SetupTime", "type": "*composed", "value": "~*req.5", "mandatory": true},
{"tag": "AnswerTime", "field_id": "AnswerTime", "type": "*composed", "value": "~*req.5", "mandatory": true},
{"tag": "Usage", "field_id": "Usage", "type": "*composed", "value": "~*req.6", "mandatory": true},
{"tag": "HDRExtra3", "field_id": "HDRExtra3", "type": "*composed", "value": "~*req.6", "mandatory": true},
{"tag": "HDRExtra2", "field_id": "HDRExtra2", "type": "*composed", "value": "~*req.6", "mandatory": true},
{"tag": "HDRExtra1", "field_id": "HDRExtra1", "type": "*composed", "value": "~*req.6", "mandatory": true},
],
},
{
"id": "XmlDryRun",
"run_delay": -1,
"type": "*file_xml",
"source_path": "/tmp/xmlErs/in",
"flags": ["*cdrs","*log"],
"processed_path": "/tmp/xmlErs/out",
"xml_root_path": "broadWorksCDR.cdrData",
"content_fields":[
{"tag": "TOR", "field_id": "ToR", "type": "*constant", "value": "*voice", "mandatory": true},
{"tag": "OriginID", "field_id": "OriginID", "type": "*variable", "value": "~*req.broadWorksCDR.cdrData.basicModule.localCallId", "mandatory": true},
{"tag": "RequestType", "field_id": "RequestType", "type": "*constant", "value": "*rated", "mandatory": true},
{"tag": "Direction", "field_id": "Direction", "type": "*constant", "value": "*out", "mandatory": true},
{"tag": "Tenant", "field_id": "Tenant", "type": "*variable", "value": "~*req.broadWorksCDR.cdrData.basicModule.userId:s/.*@(.*)/${1}/", "mandatory": true},
{"tag": "Category", "field_id": "Category", "type": "*constant", "value": "call", "mandatory": true},
{"tag": "Account", "field_id": "Account", "type": "*variable", "value": "~*req.broadWorksCDR.cdrData.basicModule.userNumber", "mandatory": true},
{"tag": "Destination", "field_id": "Destination", "type": "*variable", "value": "~*req.broadWorksCDR.cdrData.basicModule.calledNumber", "mandatory": true},
{"tag": "SetupTime", "field_id": "SetupTime", "type": "*variable", "value": "~*req.broadWorksCDR.cdrData.basicModule.startTime", "mandatory": true},
{"tag": "AnswerTime", "field_id": "AnswerTime", "type": "*variable", "value": "~*req.broadWorksCDR.cdrData.basicModule.answerTime", "mandatory": true},
{"tag": "Usage", "field_id": "Usage", "type": "*usage_difference", "value": "~*req.broadWorksCDR.cdrData.basicModule.releaseTime;~*req.broadWorksCDR.cdrData.basicModule.answerTime", "mandatory": true}
],
},
{
"id": "FWV1",
"run_delay": -1,
"type": "*file_fwv",
"source_path": "/tmp/fwvErs/in",
"flags": ["*cdrs"],
"processed_path": "/tmp/fwvErs/out",
"header_fields": [
{"tag": "FileName", "field_id": "CdrFileName", "type": "*composed", "value": "~*req.95-135", "padding":"right"},
{"tag": "FileSeqNr", "field_id": "FileSeqNr", "type": "*composed", "value": "~*req.135-141", "padding":"zeroleft"},
{"tag": "AccId1", "field_id": "AccId1", "type": "*composed", "value": "~*req.135-141", "padding":"zeroleft"},
],
"content_fields": [
{"tag": "Tor", "field_id": "ToR", "type": "*constant", "value": "*voice", "mandatory": true},
{"tag": "RequestType", "field_id": "RequestType", "type": "*constant", "value": "rated", "mandatory": true},
{"tag": "OriginID", "field_id": "OriginID", "type": "*variable", "value": "~*req.0-10", "padding":"right", "mandatory": true},
{"tag": "OriginHost", "field_id": "OriginHost", "type": "*constant", "value": "0.0.0.0", "mandatory": true},
{"tag": "Tenant", "field_id": "Tenant", "type": "*constant", "value": "cgrates.org", "mandatory": true},
{"tag": "Category", "field_id": "Category", "type": "*constant", "value": "call", "mandatory": true},
{"tag": "Account", "field_id": "Account", "type": "*variable", "value": "~*req.30-49", "padding":"right", "mandatory": true},
{"tag": "Subject", "field_id": "Subject", "type": "*variable", "value": "~*req.30-49", "padding":"right", "mandatory": true},
{"tag": "Destination", "field_id": "Destination", "type": "*variable", "value": "~*req.52-80", "padding":"right", "mandatory": true},
{"tag": "SetupTime", "field_id": "SetupTime", "type": "*variable", "value": "~*req.14-30:s/(\\d{4})(\\d{2})(\\d{2})(\\d{2})(\\d{2})(\\d{2})(\\d{2})/${1}-${2}-${3} ${4}:${5}:${6}/", "mandatory": true},
{"tag": "AnswerTime", "field_id": "AnswerTime", "type": "*variable", "value": "~*req.14-30:s/(\\d{4})(\\d{2})(\\d{2})(\\d{2})(\\d{2})(\\d{2})(\\d{2})/${1}-${2}-${3} ${4}:${5}:${6}/", "mandatory": true},
{"tag": "Usage", "field_id": "Usage", "type": "*variable", "value": "~*req.127-135:s/(\\d{2})(\\d{2})(\\d{2})(\\d{2})/${1}h${2}m${3}s/", "mandatory": true},
{"tag": "DisconnectCause", "field_id": "DisconnectCause", "type": "*variable", "value": "~*req.138-139", "mandatory": true},
{"tag": "RetailAmount", "field_id": "RetailAmount", "type": "*variable", "value": "~*req.103-111", "padding":"zeroleft"},
{"tag": "WholesaleAmount", "field_id": "RetailAmount", "type": "*variable", "value": "~*req.115-123", "padding":"zeroleft"},
{"tag": "AccId1", "field_id": "AccId1", "type": "*variable", "value": "~*req.3-6", "padding":"zeroleft", "mandatory": true},
{"tag": "AccId2", "field_id": "AccId2", "type": "*variable", "value": "~*req.14-30", "padding":"right", "mandatory": true},
],
"trailer_fields": [
{"tag": "NrOfCdrs", "type": "metatag", "metatag_id":"total_cdrs", "value": "~*req.142-150"},
{"tag": "TotalDuration", "type": "metatag", "metatag_id":"total_duration", "value": "~*req.150-162"},
],
}
],
},
"apier": {
"scheduler_conns": ["*internal"],
},
}

View File

@@ -0,0 +1,268 @@
{
// CGRateS Configuration file
//
// Used for SessionSv1 integration tests
"general": {
"log_level": 7,
"reply_timeout": "10s", // consider connection down for replies taking longer than this value
},
"listen": {
"rpc_json": ":2012",
"rpc_gob": ":2013",
"http": ":2080",
},
"data_db": { // database used to store runtime data (eg: accounts, cdr stats)
"db_type": "redis", // data_db type: <redis|mongo>
"db_port": 6379, // data_db port to reach the database
"db_name": "10", // data_db database name to connect to
},
"stor_db": {
"db_password": "CGRateS.org",
},
"rals": {
"enabled": true,
},
"schedulers": {
"enabled": true,
},
"chargers": {
"enabled": true,
"attributes_conns": ["*internal"],
},
"resources": {
"enabled": true,
},
"attributes": {
"enabled": true,
},
"cdrs": {
"enabled": true,
"chargers_conns": ["*localhost"],
"rals_conns": ["*internal"],
"session_cost_retries": 0,
},
"sessions": {
"enabled": true,
"chargers_conns": ["*localhost"],
"rals_conns": ["*internal"],
"cdrs_conns": ["*internal"],
"resources_conns": ["*internal"],
"attributes_conns": ["*internal"],
},
"ers": {
"enabled": true,
"sessions_conns": ["*internal"],
"readers": [
{
"id": "file_reader1",
"run_delay": -1,
"type": "*file_csv",
"flags": ["*dryrun"],
"source_path": "/tmp/ers/in",
"processed_path": "/tmp/ers/out",
},
{
"id": "file_reader2",
"run_delay": -1,
"field_separator": ";",
"type": "*file_csv",
"source_path": "/tmp/ers2/in",
"flags": ["*dryrun"],
"processed_path": "/tmp/ers2/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": "*constant", "value": "*voice", "mandatory": true},
{"tag": "OriginID", "field_id": "OriginID", "type": "*composed", "value": "~*req.0", "mandatory": true},
{"tag": "RequestType", "field_id": "RequestType", "type": "*composed", "value": "~*req.1", "mandatory": true},
{"tag": "Direction", "field_id": "Direction", "type": "*constant", "value": "*out", "mandatory": true},
{"tag": "Tenant", "field_id": "Tenant", "type": "*composed", "value": "~*req.2", "mandatory": true},
{"tag": "Category", "field_id": "Category", "type": "*constant", "value": "call", "mandatory": true},
{"tag": "Account", "field_id": "Account", "type": "*composed", "value": "~*req.3", "mandatory": true},
{"tag": "Subject", "field_id": "Subject", "type": "*composed", "value": "~*req.3", "mandatory": true},
{"tag": "Destination", "field_id": "Destination", "type": "*composed", "value": "~*req.4:s/0([1-9]\\d+)/+49${1}/", "mandatory": true},
{"tag": "SetupTime", "field_id": "SetupTime", "type": "*composed", "value": "~*req.5", "mandatory": true},
{"tag": "AnswerTime", "field_id": "AnswerTime", "type": "*composed", "value": "~*req.5", "mandatory": true},
{"tag": "Usage", "field_id": "Usage", "type": "*composed", "value": "~*req.6", "mandatory": true},
{"tag": "HDRExtra3", "field_id": "HDRExtra3", "type": "*composed", "value": "~*req.6", "mandatory": true},
{"tag": "HDRExtra2", "field_id": "HDRExtra2", "type": "*composed", "value": "~*req.6", "mandatory": true},
{"tag": "HDRExtra1", "field_id": "HDRExtra1", "type": "*composed", "value": "~*req.6", "mandatory": true},
],
},
{
"id": "init_session",
"run_delay": -1,
"field_separator": ",",
"type": "*file_csv",
"source_path": "/tmp/init_session/in",
"flags": ["*initiate","*accounts","*resources","*attributes","*log"],
"processed_path": "/tmp/init_session/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": "Tenant", "field_id": "Tenant", "type": "*variable", "value": "~*req.0", "mandatory": true},
{"tag": "TOR", "field_id": "ToR", "type": "*constant", "value": "*voice", "mandatory": true},
{"tag": "OriginID", "field_id": "OriginID", "type": "*variable", "value": "~*req.2", "mandatory": true},
{"tag": "RequestType", "field_id": "RequestType", "type": "*variable", "value": "~*req.3", "mandatory": true},
{"tag": "Category", "field_id": "Category", "type": "*constant", "value": "call", "mandatory": true},
{"tag": "Account", "field_id": "Account", "type": "*variable", "value": "~*req.4", "mandatory": true},
{"tag": "Subject", "field_id": "Subject", "type": "*variable", "value": "~*req.5", "mandatory": true},
{"tag": "Destination", "field_id": "Destination", "type": "*variable", "value": "~*req.6", "mandatory": true},
{"tag": "SetupTime", "field_id": "SetupTime", "type": "*variable", "value": "~*req.7", "mandatory": true},
{"tag": "AnswerTime", "field_id": "AnswerTime", "type": "*variable", "value": "~*req.8", "mandatory": true},
{"tag": "Usage", "field_id": "Usage", "type": "*variable", "value": "~*req.9", "mandatory": true},
],
},
{
"id": "terminate_session",
"run_delay": -1,
"field_separator": ",",
"type": "*file_csv",
"source_path": "/tmp/terminate_session/in",
"flags": ["*terminate","*accounts","*resources","*log"],
"processed_path": "/tmp/terminate_session/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": "Tenant", "field_id": "Tenant", "type": "*variable", "value": "~*req.0", "mandatory": true},
{"tag": "OriginID", "field_id": "OriginID", "type": "*variable", "value": "~*req.2", "mandatory": true},
{"tag": "RequestType", "field_id": "RequestType", "type": "*variable", "value": "~*req.3", "mandatory": true},
{"tag": "Usage", "field_id": "Usage", "type": "*variable", "value": "~*req.9", "mandatory": true},
],
},
{
"id": "create_cdr",
"run_delay": -1,
"field_separator": ",",
"type": "*file_csv",
"source_path": "/tmp/cdrs/in",
"flags": ["*cdrs","*log"],
"processed_path": "/tmp/cdrs/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": "Tenant", "field_id": "Tenant", "type": "*variable", "value": "~*req.0", "mandatory": true},
{"tag": "TOR", "field_id": "ToR", "type": "*constant", "value": "*voice", "mandatory": true},
{"tag": "OriginID", "field_id": "OriginID", "type": "*variable", "value": "~*req.2", "mandatory": true},
{"tag": "RequestType", "field_id": "RequestType", "type": "*variable", "value": "~*req.3", "mandatory": true},
{"tag": "Category", "field_id": "Category", "type": "*constant", "value": "call", "mandatory": true},
{"tag": "Account", "field_id": "Account", "type": "*variable", "value": "~*req.4", "mandatory": true},
{"tag": "Subject", "field_id": "Subject", "type": "*variable", "value": "~*req.5", "mandatory": true},
{"tag": "Destination", "field_id": "Destination", "type": "*variable", "value": "~*req.6", "mandatory": true},
{"tag": "SetupTime", "field_id": "SetupTime", "type": "*variable", "value": "~*req.7", "mandatory": true},
{"tag": "AnswerTime", "field_id": "AnswerTime", "type": "*variable", "value": "~*req.8", "mandatory": true},
{"tag": "Usage", "field_id": "Usage", "type": "*variable", "value": "~*req.9", "mandatory": true},
{"tag": "ExtraInfo1", "field_id": "ExtraInfo1", "type": "*constant", "value": "ExtraInfo1", "mandatory": true},
{"tag": "ExtraInfo2", "field_id": "ExtraInfo2", "type": "*constant", "value": "ExtraInfo2", "mandatory": true},
],
},
{
"id": "file_reader_with_filters",
"run_delay": -1,
"type": "*file_csv",
"field_separator": ";",
"source_path": "/tmp/ers_with_filters/in",
"processed_path": "/tmp/ers_with_filters/out",
"flags": ["*cdrs","*log"],
"filters":["*string:~*req.3:1002"],
"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": "*constant", "value": "*voice", "mandatory": true},
{"tag": "OriginID", "field_id": "OriginID", "type": "*composed", "value": "~*req.0", "mandatory": true},
{"tag": "RequestType", "field_id": "RequestType", "type": "*composed", "value": "~*req.1", "mandatory": true},
{"tag": "Tenant", "field_id": "Tenant", "type": "*composed", "value": "~*req.2", "mandatory": true},
{"tag": "Category", "field_id": "Category", "type": "*composed", "value": "call", "mandatory": true},
{"tag": "Account", "field_id": "Account", "type": "*composed", "value": "~*req.3", "mandatory": true},
{"tag": "Source", "field_id": "Source", "type": "*constant", "value": "ers_csv", "mandatory": true},
{"tag": "Subject", "field_id": "Subject", "type": "*composed", "value": "~*req.3", "mandatory": true},
{"tag": "Destination", "field_id": "Destination", "type": "*composed", "value": "~*req.4:s/0([1-9]\\d+)/+49${1}/", "mandatory": true},
{"tag": "SetupTime", "field_id": "SetupTime", "type": "*composed", "value": "~*req.5", "mandatory": true},
{"tag": "AnswerTime", "field_id": "AnswerTime", "type": "*composed", "value": "~*req.5", "mandatory": true},
{"tag": "Usage", "field_id": "Usage", "type": "*composed", "value": "~*req.6", "mandatory": true},
{"tag": "HDRExtra3", "field_id": "HDRExtra3", "type": "*composed", "value": "~*req.6", "mandatory": true},
{"tag": "HDRExtra2", "field_id": "HDRExtra2", "type": "*composed", "value": "~*req.6", "mandatory": true},
{"tag": "HDRExtra1", "field_id": "HDRExtra1", "type": "*composed", "value": "~*req.6", "mandatory": true},
],
},
{
"id": "XmlDryRun",
"run_delay": -1,
"type": "*file_xml",
"source_path": "/tmp/xmlErs/in",
"flags": ["*cdrs","*log"],
"processed_path": "/tmp/xmlErs/out",
"xml_root_path": "broadWorksCDR.cdrData",
"content_fields":[
{"tag": "TOR", "field_id": "ToR", "type": "*constant", "value": "*voice", "mandatory": true},
{"tag": "OriginID", "field_id": "OriginID", "type": "*variable", "value": "~*req.broadWorksCDR.cdrData.basicModule.localCallId", "mandatory": true},
{"tag": "RequestType", "field_id": "RequestType", "type": "*constant", "value": "*rated", "mandatory": true},
{"tag": "Direction", "field_id": "Direction", "type": "*constant", "value": "*out", "mandatory": true},
{"tag": "Tenant", "field_id": "Tenant", "type": "*variable", "value": "~*req.broadWorksCDR.cdrData.basicModule.userId:s/.*@(.*)/${1}/", "mandatory": true},
{"tag": "Category", "field_id": "Category", "type": "*constant", "value": "call", "mandatory": true},
{"tag": "Account", "field_id": "Account", "type": "*variable", "value": "~*req.broadWorksCDR.cdrData.basicModule.userNumber", "mandatory": true},
{"tag": "Destination", "field_id": "Destination", "type": "*variable", "value": "~*req.broadWorksCDR.cdrData.basicModule.calledNumber", "mandatory": true},
{"tag": "SetupTime", "field_id": "SetupTime", "type": "*variable", "value": "~*req.broadWorksCDR.cdrData.basicModule.startTime", "mandatory": true},
{"tag": "AnswerTime", "field_id": "AnswerTime", "type": "*variable", "value": "~*req.broadWorksCDR.cdrData.basicModule.answerTime", "mandatory": true},
{"tag": "Usage", "field_id": "Usage", "type": "*usage_difference", "value": "~*req.broadWorksCDR.cdrData.basicModule.releaseTime;~*req.broadWorksCDR.cdrData.basicModule.answerTime", "mandatory": true}
],
},
{
"id": "FWV1",
"run_delay": -1,
"type": "*file_fwv",
"source_path": "/tmp/fwvErs/in",
"flags": ["*cdrs"],
"processed_path": "/tmp/fwvErs/out",
"header_fields": [
{"tag": "FileName", "field_id": "CdrFileName", "type": "*composed", "value": "~*req.95-135", "padding":"right"},
{"tag": "FileSeqNr", "field_id": "FileSeqNr", "type": "*composed", "value": "~*req.135-141", "padding":"zeroleft"},
{"tag": "AccId1", "field_id": "AccId1", "type": "*composed", "value": "~*req.135-141", "padding":"zeroleft"},
],
"content_fields": [
{"tag": "Tor", "field_id": "ToR", "type": "*constant", "value": "*voice", "mandatory": true},
{"tag": "RequestType", "field_id": "RequestType", "type": "*constant", "value": "rated", "mandatory": true},
{"tag": "OriginID", "field_id": "OriginID", "type": "*variable", "value": "~*req.0-10", "padding":"right", "mandatory": true},
{"tag": "OriginHost", "field_id": "OriginHost", "type": "*constant", "value": "0.0.0.0", "mandatory": true},
{"tag": "Tenant", "field_id": "Tenant", "type": "*constant", "value": "cgrates.org", "mandatory": true},
{"tag": "Category", "field_id": "Category", "type": "*constant", "value": "call", "mandatory": true},
{"tag": "Account", "field_id": "Account", "type": "*variable", "value": "~*req.30-49", "padding":"right", "mandatory": true},
{"tag": "Subject", "field_id": "Subject", "type": "*variable", "value": "~*req.30-49", "padding":"right", "mandatory": true},
{"tag": "Destination", "field_id": "Destination", "type": "*variable", "value": "~*req.52-80", "padding":"right", "mandatory": true},
{"tag": "SetupTime", "field_id": "SetupTime", "type": "*variable", "value": "~*req.14-30:s/(\\d{4})(\\d{2})(\\d{2})(\\d{2})(\\d{2})(\\d{2})(\\d{2})/${1}-${2}-${3} ${4}:${5}:${6}/", "mandatory": true},
{"tag": "AnswerTime", "field_id": "AnswerTime", "type": "*variable", "value": "~*req.14-30:s/(\\d{4})(\\d{2})(\\d{2})(\\d{2})(\\d{2})(\\d{2})(\\d{2})/${1}-${2}-${3} ${4}:${5}:${6}/", "mandatory": true},
{"tag": "Usage", "field_id": "Usage", "type": "*variable", "value": "~*req.127-135:s/(\\d{2})(\\d{2})(\\d{2})(\\d{2})/${1}h${2}m${3}s/", "mandatory": true},
{"tag": "DisconnectCause", "field_id": "DisconnectCause", "type": "*variable", "value": "~*req.138-139", "mandatory": true},
{"tag": "RetailAmount", "field_id": "RetailAmount", "type": "*variable", "value": "~*req.103-111", "padding":"zeroleft"},
{"tag": "WholesaleAmount", "field_id": "RetailAmount", "type": "*variable", "value": "~*req.115-123", "padding":"zeroleft"},
{"tag": "AccId1", "field_id": "AccId1", "type": "*variable", "value": "~*req.3-6", "padding":"zeroleft", "mandatory": true},
{"tag": "AccId2", "field_id": "AccId2", "type": "*variable", "value": "~*req.14-30", "padding":"right", "mandatory": true},
],
"trailer_fields": [
{"tag": "NrOfCdrs", "type": "metatag", "metatag_id":"total_cdrs", "value": "~*req.142-150"},
{"tag": "TotalDuration", "type": "metatag", "metatag_id":"total_duration", "value": "~*req.150-162"},
],
}
],
},
"apier": {
"scheduler_conns": ["*internal"],
},
}

View File

@@ -18,10 +18,13 @@
"stor_db": {
"db_type": "postgres",
"db_port": 5432,
"db_password": "CGRateS.org",
},
"rals": {
"enabled": true,
},

View File

@@ -0,0 +1,79 @@
{
// CGRateS Configuration file
//
// Used for SessionSv1 integration tests
"general": {
"log_level": 7,
},
"listen": {
"rpc_json": ":2012",
"rpc_gob": ":2013",
"http": ":2080",
},
"data_db": {
"db_type": "*internal",
},
"stor_db": {
"db_type": "*internal",
},
"rals": {
"enabled": true,
},
"schedulers": {
"enabled": true,
},
"chargers": {
"enabled": true,
"attributes_conns": ["*internal"],
},
"resources": {
"enabled": true,
"store_interval": "-1",
},
"attributes": {
"enabled": true,
},
"cdrs": {
"enabled": true,
"chargers_conns": ["*localhost"],
"rals_conns": ["*internal"],
},
"sessions": {
"enabled": true,
"chargers_conns": ["*localhost"],
"rals_conns": ["*internal"],
"cdrs_conns": ["*internal"],
"resources_conns": ["*internal"],
"attributes_conns": ["*internal"],
},
"apier": {
"scheduler_conns": ["*internal"],
},
}

View File

@@ -0,0 +1,80 @@
{
// CGRateS Configuration file
//
// Used for SessionSv1 integration tests
"general": {
"log_level": 7,
},
"listen": {
"rpc_json": ":2012",
"rpc_gob": ":2013",
"http": ":2080",
},
"data_db": {
"db_type": "mongo",
"db_name": "10",
"db_port": 27017,
},
"stor_db": {
"db_type": "mongo",
"db_name": "cgrates",
"db_port": 27017,
},
"rals": {
"enabled": true,
},
"schedulers": {
"enabled": true,
},
"chargers": {
"enabled": true,
"attributes_conns": ["*internal"],
},
"resources": {
"enabled": true,
},
"attributes": {
"enabled": true,
},
"cdrs": {
"enabled": true,
"chargers_conns": ["*localhost"],
"rals_conns": ["*internal"],
},
"sessions": {
"enabled": true,
"chargers_conns": ["*localhost"],
"rals_conns": ["*internal"],
"cdrs_conns": ["*internal"],
"resources_conns": ["*internal"],
"attributes_conns": ["*internal"],
},
"apier": {
"scheduler_conns": ["*internal"],
},
}

View File

@@ -0,0 +1,79 @@
{
// CGRateS Configuration file
//
// Used for SessionSv1 integration tests
"general": {
"log_level": 7,
},
"listen": {
"rpc_json": ":2012",
"rpc_gob": ":2013",
"http": ":2080",
},
"data_db": {
"db_type": "redis",
"db_port": 6379,
"db_name": "10",
},
"stor_db": {
"db_password": "CGRateS.org",
},
"rals": {
"enabled": true,
},
"schedulers": {
"enabled": true,
},
"chargers": {
"enabled": true,
"attributes_conns": ["*internal"],
},
"resources": {
"enabled": true,
},
"attributes": {
"enabled": true,
},
"cdrs": {
"enabled": true,
"chargers_conns": ["*localhost"],
"rals_conns": ["*internal"],
},
"sessions": {
"enabled": true,
"chargers_conns": ["*localhost"],
"rals_conns": ["*internal"],
"cdrs_conns": ["*internal"],
"resources_conns": ["*internal"],
"attributes_conns": ["*internal"],
},
"apier": {
"scheduler_conns": ["*internal"],
},
}

View File

@@ -0,0 +1,80 @@
{
// CGRateS Configuration file
//
// Used for SessionSv1 integration tests
"general": {
"log_level": 7,
},
"listen": {
"rpc_json": ":2012",
"rpc_gob": ":2013",
"http": ":2080",
},
"data_db": {
"db_type": "redis",
"db_port": 6379,
"db_name": "10",
},
"stor_db": {
"db_type": "postgres",
"db_port": 5432,
"db_password": "CGRateS.org",
},
"rals": {
"enabled": true,
},
"schedulers": {
"enabled": true,
},
"chargers": {
"enabled": true,
"attributes_conns": ["*internal"],
},
"resources": {
"enabled": true,
},
"attributes": {
"enabled": true,
},
"cdrs": {
"enabled": true,
"chargers_conns": ["*localhost"],
"rals_conns": ["*internal"],
},
"sessions": {
"enabled": true,
"chargers_conns": ["*localhost"],
"rals_conns": ["*internal"],
"cdrs_conns": ["*internal"],
"resources_conns": ["*internal"],
"attributes_conns": ["*internal"],
},
"apier": {
"scheduler_conns": ["*internal"],
},
}

View File

@@ -67,7 +67,7 @@ func TestFilterIndexerIT(t *testing.T) {
switch *dbType {
case utils.MetaInternal:
dataManager = NewDataManager(NewInternalDB(nil, nil, true, config.CgrConfig().DataDbCfg().Items),
config.CgrConfig().CacheCfg(), nil)
config.CgrConfig().CacheCfg(), nil)
case utils.MetaSQL:
cfg, _ := config.NewDefaultCGRConfig()
redisDB, err := NewRedisStorage(

View File

@@ -29,72 +29,99 @@ import (
"github.com/cgrates/cgrates/utils"
)
// Globals used
var dataDbCsv, dataDbStor, dataDbApier *DataManager // Each dataDb will have it's own sources to collect data
var storDb LoadStorage
var lCfg *config.CGRConfig
var loader *TpReader
var (
// Globals used
dataDbCsv *DataManager // Each dataDb will have it's own sources to collect data
storDb LoadStorage
lCfg *config.CGRConfig
loader *TpReader
loaderConfigDIR string
loaderCfgPath string
var tpCsvScenario = flag.String("tp_scenario", "testtp", "Use this scenario folder to import tp csv data from")
tpCsvScenario = flag.String("tp_scenario", "testtp", "Use this scenario folder to import tp csv data from")
// Create connection to dataDb
// Will use 3 different datadbs in order to be able to see differences in data loaded
func TestLoaderITConnDataDbs(t *testing.T) {
lCfg, _ = config.NewDefaultCGRConfig()
lCfg.StorDbCfg().Password = "CGRateS.org"
loaderTests = []func(t *testing.T){
testLoaderITInitConfig,
testLoaderITInitDataDB,
testLoaderITInitStoreDB,
testLoaderITRemoveLoad,
testLoaderITLoadFromCSV,
testLoaderITWriteToDatabase,
testLoaderITImportToStorDb,
testLoaderITInitDataDB,
testLoaderITLoadFromStorDb,
testLoaderITInitDataDB,
testLoaderITLoadIndividualProfiles,
}
)
func TestLoaderIT(t *testing.T) {
switch *dbType {
case utils.MetaInternal:
loaderConfigDIR = "tutinternal"
case utils.MetaSQL:
loaderConfigDIR = "tutmysql"
case utils.MetaMongo:
loaderConfigDIR = "tutmongo"
case utils.MetaPostgres:
loaderConfigDIR = "tutpostgres"
default:
t.Fatal("Unknown Database type")
}
for _, stest := range loaderTests {
t.Run(loaderConfigDIR, stest)
}
}
func testLoaderITInitConfig(t *testing.T) {
loaderCfgPath = path.Join(*dataDir, "conf", "samples", loaderConfigDIR)
lCfg, err = config.NewCGRConfigFromPath(loaderCfgPath)
if err != nil {
t.Error(err)
}
}
func testLoaderITInitDataDB(t *testing.T) {
var err error
dbConn, err := NewDataDBConn(lCfg.DataDbCfg().DataDbType,
lCfg.DataDbCfg().DataDbHost, lCfg.DataDbCfg().DataDbPort, "7",
lCfg.DataDbCfg().DataDbUser, lCfg.DataDbCfg().DataDbPass,
lCfg.GeneralCfg().DBDataEncoding, "", lCfg.DataDbCfg().Items)
lCfg.DataDbCfg().DataDbHost, lCfg.DataDbCfg().DataDbPort, lCfg.DataDbCfg().DataDbName,
lCfg.DataDbCfg().DataDbUser, lCfg.DataDbCfg().DataDbPass, lCfg.GeneralCfg().DBDataEncoding,
lCfg.DataDbCfg().DataDbSentinelName, lCfg.DataDbCfg().Items)
if err != nil {
t.Fatal("Error on dataDb connection: ", err.Error())
}
dataDbCsv = NewDataManager(dbConn, nil, nil)
dbConn, err = NewDataDBConn(lCfg.DataDbCfg().DataDbType,
lCfg.DataDbCfg().DataDbHost, lCfg.DataDbCfg().DataDbPort, "8",
lCfg.DataDbCfg().DataDbUser, lCfg.DataDbCfg().DataDbPass,
lCfg.GeneralCfg().DBDataEncoding, "", lCfg.DataDbCfg().Items)
if err != nil {
t.Fatal("Error on dataDb connection: ", err.Error())
}
dataDbStor = NewDataManager(dbConn, nil, nil)
dbConn, err = NewDataDBConn(lCfg.DataDbCfg().DataDbType,
lCfg.DataDbCfg().DataDbHost, lCfg.DataDbCfg().DataDbPort, "9",
lCfg.DataDbCfg().DataDbUser, lCfg.DataDbCfg().DataDbPass,
lCfg.GeneralCfg().DBDataEncoding, "", lCfg.DataDbCfg().Items)
if err != nil {
t.Fatal("Error on dataDb connection: ", err.Error())
}
dataDbApier = NewDataManager(dbConn, nil, nil)
for _, db := range []Storage{dataDbCsv.DataDB(), dataDbStor.DataDB(), dataDbApier.DataDB(),
dataDbCsv.DataDB(), dataDbStor.DataDB(), dataDbApier.DataDB()} {
if err = db.Flush(""); err != nil {
t.Fatal("Error when flushing datadb")
}
if err = dbConn.Flush(utils.EmptyString); err != nil {
t.Fatal("Error when flushing datadb")
}
}
// Create/reset storage tariff plan tables, used as database connectin establishment also
func TestLoaderITCreateStorTpTables(t *testing.T) {
db, err := NewMySQLStorage(lCfg.StorDbCfg().Host,
lCfg.StorDbCfg().Port, lCfg.StorDbCfg().Name,
lCfg.StorDbCfg().User, lCfg.StorDbCfg().Password,
lCfg.StorDbCfg().MaxOpenConns, lCfg.StorDbCfg().MaxIdleConns,
lCfg.StorDbCfg().ConnMaxLifetime)
func testLoaderITInitStoreDB(t *testing.T) {
// NewStorDBConn
db, err := NewStorDBConn(lCfg.StorDbCfg().Type,
lCfg.StorDbCfg().Host, lCfg.StorDbCfg().Port, lCfg.StorDbCfg().Name,
lCfg.StorDbCfg().User, lCfg.StorDbCfg().Password, lCfg.StorDbCfg().SSLMode,
lCfg.StorDbCfg().MaxOpenConns, lCfg.StorDbCfg().MaxIdleConns, lCfg.StorDbCfg().ConnMaxLifetime,
lCfg.StorDbCfg().StringIndexedFields, lCfg.StorDbCfg().PrefixIndexedFields, lCfg.StorDbCfg().Items)
if err != nil {
t.Error("Error on opening database connection: ", err)
}
storDb = db
// Creating the table serves also as reset since there is a drop prior to create
if err := db.CreateTablesFromScript(path.Join(*dataDir, "storage", "mysql", utils.CREATE_TARIFFPLAN_TABLES_SQL)); err != nil {
dbdir := "mysql"
if *dbType == utils.MetaPostgres {
dbdir = "postgres"
}
if err := db.Flush(path.Join(*dataDir, "storage", dbdir)); err != nil {
t.Error("Error on db creation: ", err.Error())
return // No point in going further
}
}
// Loads data from csv files in tp scenario to dataDbCsv
func TestLoaderITRemoveLoad(t *testing.T) {
func testLoaderITRemoveLoad(t *testing.T) {
var err error
/*for fn, v := range FileValidators {
if err = ValidateCSVData(path.Join(*dataDir, "tariffplans", *tpCsvScenario, fn), v.Rule); err != nil {
@@ -172,7 +199,7 @@ func TestLoaderITRemoveLoad(t *testing.T) {
}
// Loads data from csv files in tp scenario to dataDbCsv
func TestLoaderITLoadFromCSV(t *testing.T) {
func testLoaderITLoadFromCSV(t *testing.T) {
var err error
/*for fn, v := range FileValidators {
if err = ValidateCSVData(path.Join(*dataDir, "tariffplans", *tpCsvScenario, fn), v.Rule); err != nil {
@@ -245,7 +272,7 @@ func TestLoaderITLoadFromCSV(t *testing.T) {
}
}
func TestLoaderITWriteToDatabase(t *testing.T) {
func testLoaderITWriteToDatabase(t *testing.T) {
for k, as := range loader.actions {
rcv, err := loader.dm.GetActions(k, true, utils.NonTransactional)
if err != nil {
@@ -459,11 +486,10 @@ func TestLoaderITWriteToDatabase(t *testing.T) {
t.Errorf("Expecting: %v, received: %v", dp, rcv)
}
}
}
// Imports data from csv files in tpScenario to storDb
func TestLoaderITImportToStorDb(t *testing.T) {
func testLoaderITImportToStorDb(t *testing.T) {
csvImporter := TPCSVImporter{
TPid: utils.TEST_SQL,
StorDb: storDb,
@@ -482,8 +508,8 @@ func TestLoaderITImportToStorDb(t *testing.T) {
}
// Loads data from storDb into dataDb
func TestLoaderITLoadFromStorDb(t *testing.T) {
loader, _ := NewTpReader(dataDbStor.DataDB(), storDb, utils.TEST_SQL, "", nil, nil)
func testLoaderITLoadFromStorDb(t *testing.T) {
loader, _ := NewTpReader(dataDbCsv.DataDB(), storDb, utils.TEST_SQL, "", nil, nil)
if err := loader.LoadDestinations(); err != nil && err.Error() != utils.NotFoundCaps {
t.Error("Failed loading destinations: ", err.Error())
}
@@ -516,8 +542,8 @@ func TestLoaderITLoadFromStorDb(t *testing.T) {
}
}
func TestLoaderITLoadIndividualProfiles(t *testing.T) {
loader, _ := NewTpReader(dataDbApier.DataDB(), storDb, utils.TEST_SQL, "", nil, nil)
func testLoaderITLoadIndividualProfiles(t *testing.T) {
loader, _ := NewTpReader(dataDbCsv.DataDB(), storDb, utils.TEST_SQL, "", nil, nil)
// Load ratingPlans. This will also set destination keys
if rps, err := storDb.GetTPRatingPlans(utils.TEST_SQL, "", nil); err != nil {
t.Fatal("Could not retrieve rating plans")

View File

@@ -20,10 +20,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
package ers
import (
"errors"
"flag"
"net/rpc"
"net/rpc/jsonrpc"
"os"
"path"
"testing"
@@ -34,10 +31,12 @@ import (
)
var (
reloadCfgPath string
reloadCfg *config.CGRConfig
reloadRPC *rpc.Client
reloadTests = []func(t *testing.T){
reloadCfgPath string
reloadCfg *config.CGRConfig
reloadRPC *rpc.Client
ersReloadConfigDIR string
reloadTests = []func(t *testing.T){
testReloadITCreateCdrDirs,
testReloadITInitConfig,
testReloadITInitCdrDb,
@@ -49,29 +48,30 @@ var (
testReloadVerifyFirstReload,
testReloadITKillEngine,
}
encoding = flag.String("rpc", utils.MetaJSON, "what encoding whould be uused for rpc comunication")
)
func newRPCClient(cfg *config.ListenCfg) (c *rpc.Client, err error) {
switch *encoding {
case utils.MetaJSON:
return jsonrpc.Dial(utils.TCP, cfg.RPCJSONListen)
case utils.MetaGOB:
return rpc.Dial(utils.TCP, cfg.RPCGOBListen)
default:
return nil, errors.New("UNSUPPORTED_RPC")
}
}
func TestERsReload(t *testing.T) {
reloadCfgPath = path.Join(*dataDir, "conf", "samples", "ers_reload", "disabled")
for _, test := range reloadTests {
t.Run("TestERsReload", test)
switch *dbType {
case utils.MetaInternal:
ersReloadConfigDIR = "disabled_internal"
case utils.MetaSQL:
ersReloadConfigDIR = "disabled_mysql"
case utils.MetaMongo:
ersReloadConfigDIR = "disabled_mongo"
case utils.MetaPostgres:
ersReloadConfigDIR = "disabled_postgres"
default:
t.Fatal("Unknown Database type")
}
for _, stest := range reloadTests {
t.Run(ersReloadConfigDIR, stest)
}
}
func testReloadITInitConfig(t *testing.T) {
var err error
reloadCfgPath = path.Join(*dataDir, "conf", "samples", "ers_reload", ersReloadConfigDIR)
if reloadCfg, err = config.NewCGRConfigFromPath(reloadCfgPath); err != nil {
t.Fatal("Got config error: ", err.Error())
}

View File

@@ -20,7 +20,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
package ers
import (
"flag"
"io/ioutil"
"net/rpc"
"os"
@@ -36,10 +35,9 @@ import (
var (
csvCfgPath string
csvCfgDIR string
csvCfg *config.CGRConfig
csvRPC *rpc.Client
dataDir = flag.String("data_dir", "/usr/share/cgrates", "CGR data dir path here")
waitRater = flag.Int("wait_rater", 500, "Number of miliseconds to wait for rater to start and cache")
fileContent1 = `dbafe9c8614c785a65aabd116dd3959c3c56f7f6,default,*voice,dsafdsaf,*rated,*out,cgrates.org,call,1001,1001,+4986517174963,2013-11-07 08:42:25 +0000 UTC,2013-11-07 08:42:26 +0000 UTC,10s,1.0100,val_extra3,"",val_extra1
dbafe9c8614c785a65aabd116dd3959c3c56f7f7,default,*voice,dsafdsag,*rated,*out,cgrates.org,call,1001,1001,+4986517174964,2013-11-07 09:42:25 +0000 UTC,2013-11-07 09:42:26 +0000 UTC,20s,1.0100,val_extra3,"",val_extra1
@@ -81,14 +79,28 @@ accid23;*rated;cgrates.org;1001;086517174963;2013-02-03 19:54:00;26;val_extra3;"
)
func TestCsvReadFile(t *testing.T) {
csvCfgPath = path.Join(*dataDir, "conf", "samples", "ers")
switch *dbType {
case utils.MetaInternal:
csvCfgDIR = "ers_internal"
case utils.MetaSQL:
csvCfgDIR = "ers_mysql"
case utils.MetaMongo:
csvCfgDIR = "ers_mongo"
case utils.MetaPostgres:
csvCfgDIR = "ers_postgres"
default:
t.Fatal("Unknown Database type")
}
for _, test := range csvTests {
t.Run("TestCsvReadFile", test)
t.Run(csvCfgDIR, test)
}
}
func testCsvITInitConfig(t *testing.T) {
var err error
csvCfgPath = path.Join(*dataDir, "conf", "samples", csvCfgDIR)
if csvCfg, err = config.NewCGRConfigFromPath(csvCfgPath); err != nil {
t.Fatal("Got config error: ", err.Error())
}

View File

@@ -36,6 +36,7 @@ import (
var (
fwvCfgPath string
fwvCfgDIR string
fwvCfg *config.CGRConfig
fwvRPC *rpc.Client
@@ -55,9 +56,21 @@ var (
)
func TestFWVReadFile(t *testing.T) {
fwvCfgPath = path.Join(*dataDir, "conf", "samples", "ers")
switch *dbType {
case utils.MetaInternal:
fwvCfgDIR = "ers_internal"
case utils.MetaSQL:
fwvCfgDIR = "ers_mysql"
case utils.MetaMongo:
fwvCfgDIR = "ers_mongo"
case utils.MetaPostgres:
fwvCfgDIR = "ers_postgres"
default:
t.Fatal("Unknown Database type")
}
for _, test := range fwvTests {
t.Run("TestFWVReadFile", test)
t.Run(fwvCfgDIR, test)
}
}
@@ -78,6 +91,7 @@ func testFWVITCreateCdrDirs(t *testing.T) {
func testFWVITInitConfig(t *testing.T) {
var err error
fwvCfgPath = path.Join(*dataDir, "conf", "samples", fwvCfgDIR)
if fwvCfg, err = config.NewCGRConfigFromPath(fwvCfgPath); err != nil {
t.Fatal("Got config error: ", err.Error())
}

View File

@@ -35,6 +35,7 @@ import (
var (
xmlCfgPath string
xmlCfgDIR string
xmlCfg *config.CGRConfig
xmlRPC *rpc.Client
@@ -54,9 +55,20 @@ var (
)
func TestXMLReadFile(t *testing.T) {
xmlCfgPath = path.Join(*dataDir, "conf", "samples", "ers")
switch *dbType {
case utils.MetaInternal:
xmlCfgDIR = "ers_internal"
case utils.MetaSQL:
xmlCfgDIR = "ers_mysql"
case utils.MetaMongo:
xmlCfgDIR = "ers_mongo"
case utils.MetaPostgres:
xmlCfgDIR = "ers_postgres"
default:
t.Fatal("Unknown Database type")
}
for _, test := range xmlTests {
t.Run("TestXMLReadFile", test)
t.Run(xmlCfgDIR, test)
}
}
@@ -77,6 +89,7 @@ func testXMLITCreateCdrDirs(t *testing.T) {
func testXMLITInitConfig(t *testing.T) {
var err error
xmlCfgPath = path.Join(*dataDir, "conf", "samples", xmlCfgDIR)
if xmlCfg, err = config.NewCGRConfigFromPath(xmlCfgPath); err != nil {
t.Fatal("Got config error: ", err.Error())
}

47
ers/lib_test.go Normal file
View File

@@ -0,0 +1,47 @@
/*
Real-time Online/Offline Charging System (OCS) for Telecom & ISP environments
Copyright (C) ITsysCOM GmbH
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package ers
import (
"errors"
"flag"
"net/rpc"
"net/rpc/jsonrpc"
"github.com/cgrates/cgrates/config"
"github.com/cgrates/cgrates/utils"
)
var (
dataDir = flag.String("data_dir", "/usr/share/cgrates", "CGR data dir path here")
waitRater = flag.Int("wait_rater", 500, "Number of miliseconds to wait for rater to start and cache")
encoding = flag.String("rpc", utils.MetaJSON, "what encoding whould be uused for rpc comunication")
dbType = flag.String("dbtype", utils.MetaInternal, "The type of DataBase (Internal/Mongo/mySql)")
)
func newRPCClient(cfg *config.ListenCfg) (c *rpc.Client, err error) {
switch *encoding {
case utils.MetaJSON:
return jsonrpc.Dial(utils.TCP, cfg.RPCJSONListen)
case utils.MetaGOB:
return rpc.Dial(utils.TCP, cfg.RPCGOBListen)
default:
return nil, errors.New("UNSUPPORTED_RPC")
}
}

View File

@@ -41,44 +41,42 @@ var (
a1CfgPath string
a1Cfg *config.CGRConfig
a1rpc *rpc.Client
sTestsA1it = []func(t *testing.T){
testA1itLoadConfig,
testA1itResetDataDB,
testA1itResetStorDb,
testA1itStartEngine,
testA1itRPCConn,
testA1itLoadTPFromFolder,
testA1itAddBalance1,
testA1itDataSession1,
testA1itConcurrentAPs,
testA1itStopCgrEngine,
}
)
var sTestsA1it = []func(t *testing.T){
testA1itLoadConfig,
testA1itResetDataDB,
testA1itResetStorDb,
testA1itStartEngine,
testA1itRPCConn,
testA1itLoadTPFromFolder,
testA1itAddBalance1,
testA1itDataSession1,
testA1itConcurrentAPs,
testA1itStopCgrEngine,
}
func TestA1ItMongo(t *testing.T) {
a1ConfigDir = "tutmongo"
for _, stest := range sTestsA1it {
t.Run(a1ConfigDir, stest)
func TestA1It(t *testing.T) {
switch *dbType {
case utils.MetaInternal:
a1ConfigDir = "tutinternal"
case utils.MetaSQL:
a1ConfigDir = "tutmysql"
case utils.MetaMongo:
a1ConfigDir = "tutmongo"
case utils.MetaPostgres:
t.SkipNow()
default:
t.Fatal("Unknown Database type")
}
}
func TestA1ItRedis(t *testing.T) {
a1ConfigDir = "tutmysql"
for _, stest := range sTestsA1it {
t.Run(a1ConfigDir, stest)
}
}
func TestA1ItInternal(t *testing.T) {
a1ConfigDir = "tutinternal"
for _, stest := range sTestsA1it {
t.Run(a1ConfigDir, stest)
}
}
func testA1itLoadConfig(t *testing.T) {
a1CfgPath = path.Join(dataDir, "conf", "samples", a1ConfigDir)
a1CfgPath = path.Join(*dataDir, "conf", "samples", a1ConfigDir)
if a1Cfg, err = config.NewCGRConfigFromPath(a1CfgPath); err != nil {
t.Error(err)
}
@@ -97,7 +95,7 @@ func testA1itResetStorDb(t *testing.T) {
}
func testA1itStartEngine(t *testing.T) {
if _, err := engine.StopStartEngine(a1CfgPath, waitRater); err != nil {
if _, err := engine.StopStartEngine(a1CfgPath, *waitRater); err != nil {
t.Fatal(err)
}
}
@@ -112,7 +110,7 @@ func testA1itRPCConn(t *testing.T) {
func testA1itLoadTPFromFolder(t *testing.T) {
var reply string
attrs := &utils.AttrLoadTpFromFolder{FolderPath: path.Join(dataDir, "tariffplans", "test", "a1")}
attrs := &utils.AttrLoadTpFromFolder{FolderPath: path.Join(*dataDir, "tariffplans", "test", "a1")}
if err := a1rpc.Call(utils.ApierV1LoadTariffPlanFromFolder, attrs, &reply); err != nil {
t.Error(err)
} else if reply != utils.OK {
@@ -184,7 +182,6 @@ func testA1itAddBalance1(t *testing.T) {
}
func testA1itDataSession1(t *testing.T) {
usage := time.Duration(10240)
initArgs := &sessions.V1InitSessionArgs{
InitSession: true,

View File

@@ -61,15 +61,20 @@ var (
)
// Test start here
func TestAccITMySQL(t *testing.T) {
accConfDIR = "tutmysql"
for _, stest := range sTestsAcc {
t.Run(accConfDIR, stest)
func TestAccIT(t *testing.T) {
switch *dbType {
case utils.MetaInternal:
accConfDIR = "tutinternal"
case utils.MetaSQL:
accConfDIR = "tutmysql"
case utils.MetaMongo:
accConfDIR = "tutmongo"
case utils.MetaPostgres:
t.SkipNow()
default:
t.Fatal("Unknown Database type")
}
}
func TestAccITMongo(t *testing.T) {
accConfDIR = "tutmongo"
for _, stest := range sTestsAcc {
t.Run(accConfDIR, stest)
}
@@ -77,7 +82,7 @@ func TestAccITMongo(t *testing.T) {
func testV1AccLoadConfig(t *testing.T) {
var err error
accCfgPath = path.Join(dataDir, "conf", "samples", accConfDIR)
accCfgPath = path.Join(*dataDir, "conf", "samples", accConfDIR)
if accCfg, err = config.NewCGRConfigFromPath(accCfgPath); err != nil {
t.Error(err)
}
@@ -121,7 +126,7 @@ func testV1AccGetAccountBeforeSet(t *testing.T) {
func testV1AccLoadTarrifPlans(t *testing.T) {
var reply string
attrs := &utils.AttrLoadTpFromFolder{FolderPath: path.Join(dataDir, "tariffplans", "testit")}
attrs := &utils.AttrLoadTpFromFolder{FolderPath: path.Join(*dataDir, "tariffplans", "testit")}
if err := accRpc.Call(utils.ApierV1LoadTariffPlanFromFolder, attrs, &reply); err != nil {
t.Error(err)
} else if reply != utils.OK {

View File

@@ -34,6 +34,7 @@ import (
var (
brodcastCfgPath string
brodcastInternalCfgPath string
brodcastInternalCfgDIR string
brodcastCfg *config.CGRConfig
brodcastInternalCfg *config.CGRConfig
brodcastRPC *rpc.Client
@@ -55,19 +56,32 @@ var (
)
func TestBrodcastRPC(t *testing.T) {
switch *dbType {
case utils.MetaInternal:
brodcastInternalCfgDIR = "tutinternal"
case utils.MetaSQL:
brodcastInternalCfgDIR = "tutmysql"
case utils.MetaMongo:
brodcastInternalCfgDIR = "tutmongo"
case utils.MetaPostgres:
t.SkipNow()
default:
t.Fatal("Unknown Database type")
}
for _, stest := range sTestBrodcastIt {
t.Run("TestBrodcastRPC", stest)
t.Run(brodcastInternalCfgDIR, stest)
}
}
// test for 0 balance with session terminate with 1s usage
func testbrodcastItLoadConfig(t *testing.T) {
var err error
brodcastCfgPath = path.Join(dataDir, "conf", "samples", "internal_broadcast_replication")
brodcastCfgPath = path.Join(*dataDir, "conf", "samples", "internal_broadcast_replication")
if brodcastCfg, err = config.NewCGRConfigFromPath(brodcastCfgPath); err != nil {
t.Error(err)
}
brodcastInternalCfgPath = path.Join(dataDir, "conf", "samples", "tutinternal")
brodcastInternalCfgPath = path.Join(*dataDir, "conf", "samples", brodcastInternalCfgDIR)
if brodcastInternalCfg, err = config.NewCGRConfigFromPath(brodcastInternalCfgPath); err != nil {
t.Error(err)
}
@@ -86,10 +100,10 @@ func testbrodcastItLoadConfig(t *testing.T) {
// }
func testbrodcastItStartEngine(t *testing.T) {
if _, err := engine.StopStartEngine(brodcastCfgPath, waitRater); err != nil {
if _, err := engine.StopStartEngine(brodcastCfgPath, *waitRater); err != nil {
t.Fatal(err)
}
if _, err := engine.StartEngine(brodcastInternalCfgPath, waitRater); err != nil {
if _, err := engine.StartEngine(brodcastInternalCfgPath, *waitRater); err != nil {
t.Fatal(err)
}
}
@@ -108,7 +122,7 @@ func testbrodcastItRPCConn(t *testing.T) {
func testbrodcastItLoadFromFolder(t *testing.T) {
var reply string
attrs := &utils.AttrLoadTpFromFolder{FolderPath: path.Join(dataDir, "tariffplans", "tutorial")}
attrs := &utils.AttrLoadTpFromFolder{FolderPath: path.Join(*dataDir, "tariffplans", "tutorial")}
if err := brodcastRPC.Call(utils.ApierV1LoadTariffPlanFromFolder, attrs, &reply); err != nil {
t.Error(err)
}
@@ -189,7 +203,9 @@ func testbrodcastItGetCDRs(t *testing.T) {
} else if len(cdrs) != 1 {
t.Error("Unexpected number of CDRs returned: ", len(cdrs))
}
cdrs[0].OrderID = 0 // reset the OrderID
cdrs[0].OrderID = 0 // reset the OrderID
cdrs[0].SetupTime = cdrs[0].SetupTime.UTC() // uniform time
cdrs[0].AnswerTime = cdrs[0].AnswerTime.UTC() // uniform time
if !reflect.DeepEqual(eCDR, cdrs[0]) {
t.Errorf("Expected: %s ,received: %s", utils.ToJSON(eCDR), utils.ToJSON(cdrs[0]))
}

View File

@@ -66,7 +66,7 @@ func testCdrsIntInitCfg(t *testing.T) {
}
func testCdrsIntStartEngine(t *testing.T) {
if _, err := engine.StopStartEngine(cdrsIntCfgPath, waitRater); err != nil {
if _, err := engine.StopStartEngine(cdrsIntCfgPath, *waitRater); err != nil {
t.Fatal(err)
}
}
@@ -119,7 +119,7 @@ func testCdrsIntTestTTL(t *testing.T) {
}
func testCdrsIntStopEngine(t *testing.T) {
if err := engine.KillEngine(waitRater); err != nil {
if err := engine.KillEngine(*waitRater); err != nil {
t.Error(err)
}
}

View File

@@ -95,9 +95,9 @@ func TestCDRsITMongo(t *testing.T) {
func testV2CDRsInitConfig(t *testing.T) {
var err error
cdrsCfgPath = path.Join(dataDir, "conf", "samples", cdrsConfDIR)
if encoding == utils.MetaGOB {
cdrsCfgPath = path.Join(dataDir, "conf", "samples", cdrsConfDIR+"_gob")
cdrsCfgPath = path.Join(*dataDir, "conf", "samples", cdrsConfDIR)
if *encoding == utils.MetaGOB {
cdrsCfgPath = path.Join(*dataDir, "conf", "samples", cdrsConfDIR+"_gob")
}
if cdrsCfg, err = config.NewCGRConfigFromPath(cdrsCfgPath); err != nil {
t.Fatal("Got config error: ", err.Error())
@@ -118,7 +118,7 @@ func testV2CDRsInitCdrDb(t *testing.T) {
}
func testV2CDRsStartEngine(t *testing.T) {
if _, err := engine.StopStartEngine(cdrsCfgPath, waitRater); err != nil {
if _, err := engine.StopStartEngine(cdrsCfgPath, *waitRater); err != nil {
t.Fatal(err)
}
}
@@ -135,10 +135,10 @@ func testV2CDRsLoadTariffPlanFromFolder(t *testing.T) {
var loadInst utils.LoadInstance
if err := cdrsRpc.Call(utils.ApierV2LoadTariffPlanFromFolder,
&utils.AttrLoadTpFromFolder{FolderPath: path.Join(
dataDir, "tariffplans", "testit")}, &loadInst); err != nil {
*dataDir, "tariffplans", "testit")}, &loadInst); err != nil {
t.Error(err)
}
time.Sleep(time.Duration(waitRater) * time.Millisecond) // Give time for scheduler to execute topups
time.Sleep(time.Duration(*waitRater) * time.Millisecond) // Give time for scheduler to execute topups
var resp string
if err := cdrsRpc.Call(utils.ApierV1RemoveChargerProfile,
&utils.TenantID{Tenant: "cgrates.org", ID: "SupplierCharges"}, &resp); err != nil {
@@ -755,7 +755,7 @@ func testV2CDRsGetCdrs7(t *testing.T) {
}
func testV2CDRsKillEngine(t *testing.T) {
if err := engine.KillEngine(waitRater); err != nil {
if err := engine.KillEngine(*waitRater); err != nil {
t.Error(err)
}
}

View File

@@ -78,11 +78,11 @@ func TestCDRsOnExp(t *testing.T) {
func testCDRsOnExpInitConfig(t *testing.T) {
var err error
cdrsMasterCfgPath = path.Join(dataDir, "conf", "samples", "cdrsonexpmaster")
cdrsMasterCfgPath = path.Join(*dataDir, "conf", "samples", "cdrsonexpmaster")
if cdrsMasterCfg, err = config.NewCGRConfigFromPath(cdrsMasterCfgPath); err != nil {
t.Fatal("Got config error: ", err.Error())
}
cdrsSlaveCfgPath = path.Join(dataDir, "conf", "samples", "cdrsonexpslave")
cdrsSlaveCfgPath = path.Join(*dataDir, "conf", "samples", "cdrsonexpslave")
if cdrsSlaveCfg, err = config.NewCGRConfigFromPath(cdrsSlaveCfgPath); err != nil {
t.Fatal("Got config error: ", err.Error())
}
@@ -113,13 +113,13 @@ func testCDRsOnExpInitCdrDb(t *testing.T) {
}
func testCDRsOnExpStartMasterEngine(t *testing.T) {
if _, err := engine.StopStartEngine(cdrsMasterCfgPath, waitRater); err != nil {
if _, err := engine.StopStartEngine(cdrsMasterCfgPath, *waitRater); err != nil {
t.Fatal(err)
}
}
func testCDRsOnExpStartSlaveEngine(t *testing.T) {
if _, err := engine.StartEngine(cdrsSlaveCfgPath, waitRater); err != nil {
if _, err := engine.StartEngine(cdrsSlaveCfgPath, *waitRater); err != nil {
t.Fatal(err)
}
}
@@ -213,7 +213,7 @@ func testCDRsOnExpDisableOnlineExport(t *testing.T) {
} else if reply != utils.OK {
t.Error("Unexpected reply received: ", reply)
}
time.Sleep(time.Duration(waitRater) * time.Millisecond)
time.Sleep(time.Duration(*waitRater) * time.Millisecond)
filesInDir, _ := ioutil.ReadDir(cdrsMasterCfg.GeneralCfg().FailedPostsDir)
if len(filesInDir) != 0 {
t.Fatalf("Should be no files in directory: %s", cdrsMasterCfg.GeneralCfg().FailedPostsDir)
@@ -253,7 +253,7 @@ func testCDRsOnExpHttpCdrReplication(t *testing.T) {
} else if reply != utils.OK {
t.Error("Unexpected reply received: ", reply)
}
time.Sleep(time.Duration(waitRater) * time.Millisecond)
time.Sleep(time.Duration(*waitRater) * time.Millisecond)
cdrsSlaveRpc, err := rpcclient.NewRPCClient(utils.TCP, "127.0.0.1:12012", false, "", "", "", 1, 1,
time.Duration(1*time.Second), time.Duration(2*time.Second), rpcclient.JSONrpc, nil, false)
if err != nil {
@@ -384,7 +384,7 @@ func testCDRsOnExpAMQPReplication(t *testing.T) {
} else if reply != utils.OK {
t.Error("Unexpected reply received: ", reply)
}
time.Sleep(time.Duration(waitRater) * time.Millisecond)
time.Sleep(time.Duration(*waitRater) * time.Millisecond)
if conn, err = amqp.Dial("amqp://guest:guest@localhost:5672/"); err != nil {
t.Fatal(err)
}

View File

@@ -84,7 +84,7 @@ func TestCDRsITPEMySql(t *testing.T) {
func testV1CDRsInitConfig(t *testing.T) {
var err error
pecdrsCfgPath = path.Join(dataDir, "conf", "samples", pecdrsConfDIR)
pecdrsCfgPath = path.Join(*dataDir, "conf", "samples", pecdrsConfDIR)
if pecdrsCfg, err = config.NewCGRConfigFromPath(pecdrsCfgPath); err != nil {
t.Fatal("Got config error: ", err.Error())
}
@@ -103,7 +103,7 @@ func testV1CDRsInitCdrDb(t *testing.T) {
}
func testV1CDRsStartEngine(t *testing.T) {
if _, err := engine.StopStartEngine(pecdrsCfgPath, waitRater); err != nil {
if _, err := engine.StopStartEngine(pecdrsCfgPath, *waitRater); err != nil {
t.Fatal(err)
}
}
@@ -120,10 +120,10 @@ func testV1CDRsLoadTariffPlanFromFolder(t *testing.T) {
var loadInst string
if err := pecdrsRpc.Call(utils.ApierV1LoadTariffPlanFromFolder,
&utils.AttrLoadTpFromFolder{FolderPath: path.Join(
dataDir, "tariffplans", "testit")}, &loadInst); err != nil {
*dataDir, "tariffplans", "testit")}, &loadInst); err != nil {
t.Error(err)
}
time.Sleep(time.Duration(waitRater) * time.Millisecond)
time.Sleep(time.Duration(*waitRater) * time.Millisecond)
}
func testV1CDRsProcessEventAttrS(t *testing.T) {
@@ -599,7 +599,7 @@ func testV1CDRsProcessEventExportCheck(t *testing.T) {
}
}
func testV1CDRsKillEngine(t *testing.T) {
if err := engine.KillEngine(waitRater); err != nil {
if err := engine.KillEngine(*waitRater); err != nil {
t.Error(err)
}
}

View File

@@ -69,7 +69,7 @@ func TestDataITMongo(t *testing.T) {
func testV1DataLoadConfig(t *testing.T) {
var err error
dataCfgPath = path.Join(dataDir, "conf", "samples", dataConfDIR)
dataCfgPath = path.Join(*dataDir, "conf", "samples", dataConfDIR)
if dataCfg, err = config.NewCGRConfigFromPath(dataCfgPath); err != nil {
t.Error(err)
}
@@ -113,7 +113,7 @@ func testV1DataGetAccountBeforeSet(t *testing.T) {
func testV1DataLoadTarrifPlans(t *testing.T) {
var reply string
attrs := &utils.AttrLoadTpFromFolder{FolderPath: path.Join(dataDir, "tariffplans", "testData")}
attrs := &utils.AttrLoadTpFromFolder{FolderPath: path.Join(*dataDir, "tariffplans", "testData")}
if err := dataRpc.Call(utils.ApierV1LoadTariffPlanFromFolder, attrs, &reply); err != nil {
t.Error(err)
} else if reply != utils.OK {

View File

@@ -55,7 +55,7 @@ func TestDestinationCombinesMySQL(t *testing.T) {
func testDestinationLoadConfig(t *testing.T) {
var err error
tutorialCfgPath = path.Join(dataDir, "conf", "samples", tutorialConfDIR)
tutorialCfgPath = path.Join(*dataDir, "conf", "samples", tutorialConfDIR)
if tutorialCfg, err = config.NewCGRConfigFromPath(tutorialCfgPath); err != nil {
t.Error(err)
}
@@ -88,7 +88,7 @@ func testDestinationRpcConn(t *testing.T) {
func testDestinationFromFolder(t *testing.T) {
var reply string
attrs := &utils.AttrLoadTpFromFolder{FolderPath: path.Join(dataDir, "tariffplans", "tp_destination_with_any")}
attrs := &utils.AttrLoadTpFromFolder{FolderPath: path.Join(*dataDir, "tariffplans", "tp_destination_with_any")}
if err := tutorialRpc.Call(utils.ApierV1LoadTariffPlanFromFolder, attrs, &reply); err != nil {
t.Error(err)
}

View File

@@ -67,9 +67,9 @@ func TestFltrIT(t *testing.T) {
func testV1FltrLoadConfig(t *testing.T) {
var err error
fltrCfgPath = path.Join(dataDir, "conf", "samples", fltrConfDIR)
if encoding == utils.MetaGOB {
cdrsCfgPath = path.Join(dataDir, "conf", "samples", fltrConfDIR+"_gob")
fltrCfgPath = path.Join(*dataDir, "conf", "samples", fltrConfDIR)
if *encoding == utils.MetaGOB {
cdrsCfgPath = path.Join(*dataDir, "conf", "samples", fltrConfDIR+"_gob")
}
if fltrCfg, err = config.NewCGRConfigFromPath(fltrCfgPath); err != nil {
t.Error(err)
@@ -105,7 +105,7 @@ func testV1FltrRpcConn(t *testing.T) {
func testV1FltrLoadTarrifPlans(t *testing.T) {
var reply string
attrs := &utils.AttrLoadTpFromFolder{FolderPath: path.Join(dataDir, "tariffplans", "testit")}
attrs := &utils.AttrLoadTpFromFolder{FolderPath: path.Join(*dataDir, "tariffplans", "testit")}
if err := fltrRpc.Call(utils.ApierV1LoadTariffPlanFromFolder, attrs, &reply); err != nil {
t.Error(err)
} else if reply != utils.OK {

View File

@@ -69,17 +69,17 @@ func TestGOCSIT(t *testing.T) {
//Init Config
func testGOCSInitCfg(t *testing.T) {
auCfgPath = path.Join(dataDir, "conf", "samples", "gocs", "au_site")
auCfgPath = path.Join(*dataDir, "conf", "samples", "gocs", "au_site")
if auCfg, err = config.NewCGRConfigFromPath(auCfgPath); err != nil {
t.Fatal(err)
}
auCfg.DataFolderPath = dataDir
auCfg.DataFolderPath = *dataDir
config.SetCgrConfig(auCfg)
usCfgPath = path.Join(dataDir, "conf", "samples", "gocs", "us_site")
usCfgPath = path.Join(*dataDir, "conf", "samples", "gocs", "us_site")
if usCfg, err = config.NewCGRConfigFromPath(usCfgPath); err != nil {
t.Fatal(err)
}
dspCfgPath = path.Join(dataDir, "conf", "samples", "gocs", "dsp_site")
dspCfgPath = path.Join(*dataDir, "conf", "samples", "gocs", "dsp_site")
if dspCfg, err = config.NewCGRConfigFromPath(dspCfgPath); err != nil {
t.Fatal(err)
}
@@ -111,13 +111,13 @@ func testGOCSResetDB(t *testing.T) {
// Start CGR Engine
func testGOCSStartEngine(t *testing.T) {
if usEngine, err = engine.StopStartEngine(usCfgPath, waitRater); err != nil {
if usEngine, err = engine.StopStartEngine(usCfgPath, *waitRater); err != nil {
t.Fatal(err)
}
if auEngine, err = engine.StartEngine(auCfgPath, waitRater); err != nil {
if auEngine, err = engine.StartEngine(auCfgPath, *waitRater); err != nil {
t.Fatal(err)
}
if dspEngine, err = engine.StartEngine(dspCfgPath, waitRater); err != nil {
if dspEngine, err = engine.StartEngine(dspCfgPath, *waitRater); err != nil {
t.Fatal(err)
}
time.Sleep(10 * time.Millisecond)
@@ -178,7 +178,7 @@ func testGOCSLoadData(t *testing.T) {
if err != nil {
t.Error(err)
}
loader := exec.Command(loaderPath, "-config_path", dspCfgPath, "-path", path.Join(dataDir, "tariffplans", "gocs", "dsp_site"))
loader := exec.Command(loaderPath, "-config_path", dspCfgPath, "-path", path.Join(*dataDir, "tariffplans", "gocs", "dsp_site"))
if err := loader.Start(); err != nil {
t.Error(err)
@@ -218,7 +218,7 @@ func testGOCSLoadData(t *testing.T) {
} else if rply := acnt.BalanceMap[utils.VOICE].GetTotalValue(); rply != expectedVoice {
t.Errorf("Expecting: %v, received: %v", expectedVoice, rply)
}
time.Sleep(time.Duration(waitRater) * time.Millisecond) // Give time for scheduler to execute topups on au_site
time.Sleep(time.Duration(*waitRater) * time.Millisecond) // Give time for scheduler to execute topups on au_site
}
func testGOCSAuthSession(t *testing.T) {

View File

@@ -19,7 +19,7 @@ package general_tests
import (
"errors"
//"flag"
"flag"
"net/rpc"
"net/rpc/jsonrpc"
@@ -28,17 +28,15 @@ import (
)
var (
//dataDir = flag.String("data_dir", "/usr/share/cgrates", "CGR data dir path here")
//waitRater = flag.Int("wait_rater", 100, "Number of miliseconds to wait for rater to start and cache")
waitRater = 100
//encoding = flag.String("rpc", utils.MetaJSON, "what encoding whould be uused for rpc comunication")
encoding = utils.MetaJSON
err error
dataDir = "/usr/share/cgrates"
dataDir = flag.String("data_dir", "/usr/share/cgrates", "CGR data dir path here")
waitRater = flag.Int("wait_rater", 100, "Number of miliseconds to wait for rater to start and cache")
encoding = flag.String("rpc", utils.MetaJSON, "what encoding whould be uused for rpc comunication")
dbType = flag.String("dbtype", utils.MetaInternal, "The type of DataBase (Internal/Mongo/mySql)")
err error
)
func newRPCClient(cfg *config.ListenCfg) (c *rpc.Client, err error) {
switch encoding {
switch *encoding {
case utils.MetaJSON:
return jsonrpc.Dial(utils.TCP, cfg.RPCJSONListen)
case utils.MetaGOB:

View File

@@ -64,7 +64,7 @@ func TestMCDRC(t *testing.T) {
func testMCDRCLoadConfig(t *testing.T) {
var err error
cfgPath = path.Join(dataDir, "conf", "samples", "multiplecdrc")
cfgPath = path.Join(*dataDir, "conf", "samples", "multiplecdrc")
if cfg, err = config.NewCGRConfigFromPath(cfgPath); err != nil {
t.Error(err)
}
@@ -98,7 +98,7 @@ func testMCDRCCreateCdrDirs(t *testing.T) {
}
}
func testMCDRCStartEngine(t *testing.T) {
if _, err := engine.StopStartEngine(cfgPath, waitRater); err != nil {
if _, err := engine.StopStartEngine(cfgPath, *waitRater); err != nil {
t.Fatal(err)
}
}
@@ -116,13 +116,13 @@ func testMCDRCRpcConn(t *testing.T) {
func testMCDRCApierLoadTariffPlanFromFolder(t *testing.T) {
reply := ""
// Simple test that command is executed without errors
attrs := &utils.AttrLoadTpFromFolder{FolderPath: path.Join(dataDir, "tariffplans", "testtp")}
attrs := &utils.AttrLoadTpFromFolder{FolderPath: path.Join(*dataDir, "tariffplans", "testtp")}
if err := rater.Call(utils.ApierV1LoadTariffPlanFromFolder, attrs, &reply); err != nil {
t.Error("Got error on ApierV1.LoadTariffPlanFromFolder: ", err.Error())
} else if reply != utils.OK {
t.Error("Calling ApierV1.LoadTariffPlanFromFolder got reply: ", reply)
}
time.Sleep(time.Duration(waitRater) * time.Millisecond) // Give time for scheduler to execute topups
time.Sleep(time.Duration(*waitRater) * time.Millisecond) // Give time for scheduler to execute topups
}
// The default scenario, out of cdrc defined in .cfg file

View File

@@ -43,14 +43,14 @@ package general_tests
// var loadInst utils.LoadInstance // Share load information between tests
// func TestTutITInitCfg(t *testing.T) {
// tutLocalCfgPath = path.Join(*dataDir, "conf", "samples", "tutmysql")
// tutLocalCfgPath = path.Join(**dataDir, "conf", "samples", "tutmysql")
// // Init config first
// var err error
// tutFsLocalCfg, err = config.NewCGRConfigFromPath(tutLocalCfgPath)
// if err != nil {
// t.Error(err)
// }
// tutFsLocalCfg.DataFolderPath = *dataDir // Share DataFolderPath through config towards StoreDb for Flush()
// tutFsLocalCfg.DataFolderPath = **dataDir // Share DataFolderPath through config towards StoreDb for Flush()
// config.SetCgrConfig(tutFsLocalCfg)
// }
@@ -70,7 +70,7 @@ package general_tests
// // Start CGR Engine
// func TestTutITStartEngine(t *testing.T) {
// if _, err := engine.StopStartEngine(tutLocalCfgPath, *waitRater); err != nil {
// if _, err := engine.StopStartEngine(tutLocalCfgPath, **waitRater); err != nil {
// t.Fatal(err)
// }
// }
@@ -86,11 +86,11 @@ package general_tests
// // Load the tariff plan, creating accounts and their balances
// func TestTutITLoadTariffPlanFromFolder(t *testing.T) {
// attrs := &utils.AttrLoadTpFromFolder{FolderPath: path.Join(*dataDir, "tariffplans", "oldtutorial")}
// attrs := &utils.AttrLoadTpFromFolder{FolderPath: path.Join(**dataDir, "tariffplans", "oldtutorial")}
// if err := tutLocalRpc.Call(utils.ApierV2LoadTariffPlanFromFolder, attrs, &loadInst); err != nil {
// t.Error(err)
// }
// time.Sleep(100*time.Millisecond + time.Duration(*waitRater)*time.Millisecond) // Give time for scheduler to execute topups
// time.Sleep(100*time.Millisecond + time.Duration(**waitRater)*time.Millisecond) // Give time for scheduler to execute topups
// }
// // Check loaded stats
@@ -593,7 +593,7 @@ package general_tests
// } else if reply != utils.OK {
// t.Error("Unexpected reply received: ", reply)
// }
// time.Sleep(time.Duration(*waitRater) * time.Millisecond)
// time.Sleep(time.Duration(**waitRater) * time.Millisecond)
// eCdr := &engine.ExternalCDR{CGRID: "63a8d2bfeca2cfb790826c3ec461696d6574cfde", OrderID: 2,
// ToR: utils.VOICE,
// OriginID: "testextcdr2", OriginHost: "192.168.1.1", Source: utils.UNIT_TEST, RequestType: utils.META_RATED,
@@ -662,7 +662,7 @@ package general_tests
// } else if reply != utils.OK {
// t.Error("Unexpected reply received: ", reply)
// }
// time.Sleep(time.Duration(*waitRater) * time.Millisecond)
// time.Sleep(time.Duration(**waitRater) * time.Millisecond)
// var cdrs []*engine.ExternalCDR
// req := utils.RPCCDRsFilter{RunIDs: []string{utils.MetaDefault}, Accounts: []string{cdr.Account}, DestinationPrefixes: []string{cdr.Destination}}
// if err := tutLocalRpc.Call(utils.ApierV2GetCDRs, req, &cdrs); err != nil {
@@ -688,7 +688,7 @@ package general_tests
// } else if reply != utils.OK {
// t.Error("Unexpected reply received: ", reply)
// }
// time.Sleep(time.Duration(*waitRater) * time.Millisecond) // Give time for CDR to be processed
// time.Sleep(time.Duration(**waitRater) * time.Millisecond) // Give time for CDR to be processed
// req = utils.RPCCDRsFilter{RunIDs: []string{utils.MetaDefault}, Accounts: []string{cdr2.Account}, DestinationPrefixes: []string{cdr2.Destination}}
// if err := tutLocalRpc.Call(utils.ApierV2GetCDRs, req, &cdrs); err != nil {
// t.Error("Unexpected error: ", err.Error())
@@ -713,7 +713,7 @@ package general_tests
// } else if reply != utils.OK {
// t.Error("Unexpected reply received: ", reply)
// }
// time.Sleep(time.Duration(*waitRater) * time.Millisecond) // Give time for CDR to be processed
// time.Sleep(time.Duration(**waitRater) * time.Millisecond) // Give time for CDR to be processed
// req = utils.RPCCDRsFilter{RunIDs: []string{utils.MetaDefault}, Accounts: []string{cdr3.Account}, DestinationPrefixes: []string{cdr3.Destination}}
// if err := tutLocalRpc.Call(utils.ApierV2GetCDRs, req, &cdrs); err != nil {
// t.Error("Unexpected error: ", err.Error())
@@ -1198,7 +1198,7 @@ package general_tests
// Offset int // Set the item offset
// Limit int // Limit number of items retrieved
// }
// time.Sleep(time.Duration(*waitRater) * time.Millisecond) // Give time for scheduler to execute topups
// time.Sleep(time.Duration(**waitRater) * time.Millisecond) // Give time for scheduler to execute topups
// var acnts []*engine.Account
// if err := tutLocalRpc.Call("ApierV2.GetAccounts", utils.AttrGetAccounts{Tenant: attrs.Tenant, AccountIds: []string{attrs.Account}}, &acnts); err != nil {
// t.Error(err)
@@ -1260,7 +1260,7 @@ package general_tests
// } else if reply != utils.OK {
// t.Errorf("Calling ApierV2.SetAccount received: %s", reply)
// }
// time.Sleep(100*time.Millisecond + time.Duration(*waitRater)*time.Millisecond) // Give time for scheduler to execute topups
// time.Sleep(100*time.Millisecond + time.Duration(**waitRater)*time.Millisecond) // Give time for scheduler to execute topups
// if err := tutLocalRpc.Call("ApierV2.GetAccounts", utils.AttrGetAccounts{Tenant: attrs.Tenant, AccountIds: []string{attrs.Account}}, &acnts); err != nil {
// t.Error(err)
// } else if len(acnts) != 1 {
@@ -1384,7 +1384,7 @@ package general_tests
// } else if reply != utils.OK {
// t.Error("Unexpected reply received: ", reply)
// }
// time.Sleep(time.Duration(*waitRater) * time.Millisecond) // Give time for CDR to be processed
// time.Sleep(time.Duration(**waitRater) * time.Millisecond) // Give time for CDR to be processed
// var cdrs []*engine.ExternalCDR
// req := utils.RPCCDRsFilter{RunIDs: []string{utils.MetaDefault}, CGRIDs: []string{cdr.CGRID}}
// if err := tutLocalRpc.Call(utils.ApierV2GetCDRs, req, &cdrs); err != nil {

View File

@@ -67,7 +67,7 @@ func TestRsV1ITMongo(t *testing.T) {
func testV1RsLoadConfig(t *testing.T) {
var err error
rlsV1CfgPath = path.Join(dataDir, "conf", "samples", rlsV1ConfDIR)
rlsV1CfgPath = path.Join(*dataDir, "conf", "samples", rlsV1ConfDIR)
if rlsV1Cfg, err = config.NewCGRConfigFromPath(rlsV1CfgPath); err != nil {
t.Error(err)
}
@@ -87,7 +87,7 @@ func testV1RsResetStorDb(t *testing.T) {
}
func testV1RsStartEngine(t *testing.T) {
if _, err := engine.StopStartEngine(rlsV1CfgPath, waitRater); err != nil {
if _, err := engine.StopStartEngine(rlsV1CfgPath, *waitRater); err != nil {
t.Fatal(err)
}
}
@@ -219,7 +219,7 @@ func testV1RsAuthorize(t *testing.T) {
}
func testV1RsStopEngine(t *testing.T) {
if err := engine.KillEngine(waitRater); err != nil {
if err := engine.KillEngine(*waitRater); err != nil {
t.Error(err)
}
}

View File

@@ -78,7 +78,7 @@ func TestRPCMethods(t *testing.T) {
func testRPCMethodsLoadConfig(t *testing.T) {
var err error
rpcCfgPath = path.Join(dataDir, "conf", "samples", rpcConfDIR)
rpcCfgPath = path.Join(*dataDir, "conf", "samples", rpcConfDIR)
if rpcCfg, err = config.NewCGRConfigFromPath(rpcCfgPath); err != nil {
t.Error(err)
}
@@ -98,7 +98,7 @@ func testRPCMethodsResetStorDb(t *testing.T) {
}
func testRPCMethodsStartEngine(t *testing.T) {
if _, err := engine.StopStartEngine(rpcCfgPath, waitRater); err != nil {
if _, err := engine.StopStartEngine(rpcCfgPath, *waitRater); err != nil {
t.Fatal(err)
}
}
@@ -113,7 +113,7 @@ func testRPCMethodsRpcConn(t *testing.T) {
func testRPCMethodsFromFolder(t *testing.T) {
var reply string
attrs := &utils.AttrLoadTpFromFolder{FolderPath: path.Join(dataDir, "tariffplans", "testit")}
attrs := &utils.AttrLoadTpFromFolder{FolderPath: path.Join(*dataDir, "tariffplans", "testit")}
if err := rpcRpc.Call(utils.ApierV1LoadTariffPlanFromFolder, attrs, &reply); err != nil {
t.Error(err)
}
@@ -806,11 +806,11 @@ func testRPCMethodsCdrsStoreSessionCost(t *testing.T) {
// Load the tariff plan, creating accounts and their balances
func testRPCMethodsLoadData(t *testing.T) {
attrs := &utils.AttrLoadTpFromFolder{FolderPath: path.Join(dataDir, "tariffplans", "testtp")}
attrs := &utils.AttrLoadTpFromFolder{FolderPath: path.Join(*dataDir, "tariffplans", "testtp")}
if err := rpcRpc.Call(utils.ApierV2LoadTariffPlanFromFolder, attrs, &tpLoadInst); err != nil {
t.Error(err)
}
time.Sleep(time.Duration(waitRater) * time.Millisecond) // Give time for scheduler to execute topups
time.Sleep(time.Duration(*waitRater) * time.Millisecond) // Give time for scheduler to execute topups
}
func testRPCMethodsResponderDebit(t *testing.T) {

View File

@@ -78,8 +78,8 @@ func TestRPCITLcl(t *testing.T) {
}
func testRPCITLclInitCfg(t *testing.T) {
rpcITCfgPath1 = path.Join(dataDir, "conf", "samples", "multiral1")
rpcITCfgPath2 = path.Join(dataDir, "conf", "samples", "multiral2")
rpcITCfgPath1 = path.Join(*dataDir, "conf", "samples", "multiral1")
rpcITCfgPath2 = path.Join(*dataDir, "conf", "samples", "multiral2")
rpcITCfg1, err = config.NewCGRConfigFromPath(rpcITCfgPath1)
if err != nil {
t.Error(err)
@@ -94,7 +94,7 @@ func testRPCITLclInitCfg(t *testing.T) {
}
func testRPCITLclStartSecondEngine(t *testing.T) {
if ral2, err = engine.StopStartEngine(rpcITCfgPath2, waitRater); err != nil {
if ral2, err = engine.StopStartEngine(rpcITCfgPath2, *waitRater); err != nil {
t.Fatal(err)
}
}
@@ -133,7 +133,7 @@ func testRPCITLclStatusSecondEngine(t *testing.T) {
// Start first engine
func testRPCITLclStartFirstEngine(t *testing.T) {
if ral1, err = engine.StartEngine(rpcITCfgPath1, waitRater); err != nil {
if ral1, err = engine.StartEngine(rpcITCfgPath1, *waitRater); err != nil {
t.Fatal(err)
}
}
@@ -160,7 +160,7 @@ func testRPCITLclStatusFirstFailover(t *testing.T) {
if err := ral1.Process.Kill(); err != nil { // Kill the first RAL
t.Error(err)
}
time.Sleep(time.Duration(waitRater) * time.Millisecond)
time.Sleep(time.Duration(*waitRater) * time.Millisecond)
var status map[string]interface{}
if err := rpcPoolFirst.Call(utils.CoreSv1Status, utils.TenantWithArgDispatcher{}, &status); err != nil {
t.Error(err)
@@ -177,7 +177,7 @@ func testRPCITLclStatusFirstFailover(t *testing.T) {
}
func testRPCITLclStatusFirstFailback(t *testing.T) {
if ral1, err = engine.StartEngine(rpcITCfgPath1, waitRater); err != nil {
if ral1, err = engine.StartEngine(rpcITCfgPath1, *waitRater); err != nil {
t.Fatal(err)
}
var status map[string]interface{}
@@ -235,7 +235,7 @@ func testRPCITLclBcastStatusNoRals1(t *testing.T) {
if err := ral1.Process.Kill(); err != nil { // Kill the first RAL
t.Error(err)
}
time.Sleep(time.Duration(waitRater) * time.Millisecond)
time.Sleep(time.Duration(*waitRater) * time.Millisecond)
var status map[string]interface{}
if err := rpcPoolBroadcast.Call(utils.CoreSv1Status, utils.TenantWithArgDispatcher{}, &status); err != nil {
t.Error(err)
@@ -253,7 +253,7 @@ func testRPCITLclBcastStatusBcastNoRals(t *testing.T) {
if err := ral2.Process.Kill(); err != nil { // Kill the first RAL
t.Error(err)
}
time.Sleep(time.Duration(waitRater) * time.Millisecond)
time.Sleep(time.Duration(*waitRater) * time.Millisecond)
var status map[string]interface{}
if err := rpcPoolBroadcast.Call(utils.CoreSv1Status, utils.TenantWithArgDispatcher{}, &status); err == nil {
t.Error("Should get error")
@@ -261,7 +261,7 @@ func testRPCITLclBcastStatusBcastNoRals(t *testing.T) {
}
func testRPCITLclBcastStatusRALs2Up(t *testing.T) {
if ral2, err = engine.StartEngine(rpcITCfgPath2, waitRater); err != nil {
if ral2, err = engine.StartEngine(rpcITCfgPath2, *waitRater); err != nil {
t.Fatal(err)
}
var status map[string]interface{}
@@ -278,7 +278,7 @@ func testRPCITLclBcastStatusRALs2Up(t *testing.T) {
}
func testRPCITLclStatusBcastRALs1Up(t *testing.T) {
if ral1, err = engine.StartEngine(rpcITCfgPath1, waitRater); err != nil {
if ral1, err = engine.StartEngine(rpcITCfgPath1, *waitRater); err != nil {
t.Fatal(err)
}
var status map[string]interface{}
@@ -303,7 +303,7 @@ func TestRPCITStatusBcastCmd(t *testing.T) {
t.Errorf("Received unexpected stats: %+v", stats)
}
var loadInst utils.LoadInstance
attrs := &utils.AttrLoadTpFromFolder{FolderPath: path.Join(*dataDir, "tariffplans", "oldtutorial")}
attrs := &utils.AttrLoadTpFromFolder{FolderPath: path.Join(**dataDir, "tariffplans", "oldtutorial")}
if err := rpcRAL1.Call(utils.ApierV2LoadTariffPlanFromFolder, attrs, &loadInst); err != nil {
t.Error(err)
} else if loadInst.RatingLoadID == "" || loadInst.AccountingLoadID == "" {

View File

@@ -34,11 +34,11 @@ import (
)
var (
node1ConfigPath = path.Join(dataDir, "redis_sentinel", "node1.conf")
node2ConfigPath = path.Join(dataDir, "redis_sentinel", "node2.conf")
sentinel1ConfigPath = path.Join(dataDir, "redis_sentinel", "sentinel1.conf")
sentinel2ConfigPath = path.Join(dataDir, "redis_sentinel", "sentinel2.conf")
engineConfigPath = path.Join(dataDir, "conf", "samples", "tutsentinel")
node1ConfigPath = path.Join(*dataDir, "redis_sentinel", "node1.conf")
node2ConfigPath = path.Join(*dataDir, "redis_sentinel", "node2.conf")
sentinel1ConfigPath = path.Join(*dataDir, "redis_sentinel", "sentinel1.conf")
sentinel2ConfigPath = path.Join(*dataDir, "redis_sentinel", "sentinel2.conf")
engineConfigPath = path.Join(*dataDir, "conf", "samples", "tutsentinel")
sentinelConfig *config.CGRConfig
sentinelRPC *rpc.Client
node1Exec, node2Exec,
@@ -97,7 +97,7 @@ func testRedisSentinelInitConfig(t *testing.T) {
if err != nil {
t.Error(err)
}
sentinelConfig.DataFolderPath = dataDir // Share DataFolderPath through config towards StoreDb for Flush()
sentinelConfig.DataFolderPath = *dataDir // Share DataFolderPath through config towards StoreDb for Flush()
config.SetCgrConfig(sentinelConfig)
}

View File

@@ -66,7 +66,7 @@ func TestSes2ItTutMysql(t *testing.T) {
}
func testSes2ItLoadConfig(t *testing.T) {
ses2CfgPath = path.Join(dataDir, "conf", "samples", ses2CfgDir)
ses2CfgPath = path.Join(*dataDir, "conf", "samples", ses2CfgDir)
if ses2Cfg, err = config.NewCGRConfigFromPath(ses2CfgPath); err != nil {
t.Error(err)
}
@@ -85,7 +85,7 @@ func testSes2ItResetStorDb(t *testing.T) {
}
func testSes2ItStartEngine(t *testing.T) {
if _, err := engine.StopStartEngine(ses2CfgPath, waitRater); err != nil {
if _, err := engine.StopStartEngine(ses2CfgPath, *waitRater); err != nil {
t.Fatal(err)
}
}
@@ -100,7 +100,7 @@ func testSes2ItRPCConn(t *testing.T) {
func testSes2ItLoadFromFolder(t *testing.T) {
var reply string
attrs := &utils.AttrLoadTpFromFolder{FolderPath: path.Join(dataDir, "tariffplans", "tutorial")}
attrs := &utils.AttrLoadTpFromFolder{FolderPath: path.Join(*dataDir, "tariffplans", "tutorial")}
if err := ses2RPC.Call(utils.ApierV1LoadTariffPlanFromFolder, attrs, &reply); err != nil {
t.Error(err)
}

View File

@@ -71,7 +71,7 @@ func TestSes3ItSessions(t *testing.T) {
}
func testSes3ItLoadConfig(t *testing.T) {
ses3CfgPath = path.Join(dataDir, "conf", "samples", ses3CfgDir)
ses3CfgPath = path.Join(*dataDir, "conf", "samples", ses3CfgDir)
if ses3Cfg, err = config.NewCGRConfigFromPath(ses3CfgPath); err != nil {
t.Error(err)
}
@@ -90,7 +90,7 @@ func testSes3ItResetStorDb(t *testing.T) {
}
func testSes3ItStartEngine(t *testing.T) {
if _, err := engine.StopStartEngine(ses3CfgPath, waitRater); err != nil {
if _, err := engine.StopStartEngine(ses3CfgPath, *waitRater); err != nil {
t.Fatal(err)
}
}
@@ -105,7 +105,7 @@ func testSes3ItRPCConn(t *testing.T) {
func testSes3ItLoadFromFolder(t *testing.T) {
var reply string
attrs := &utils.AttrLoadTpFromFolder{FolderPath: path.Join(dataDir, "tariffplans", "testit")}
attrs := &utils.AttrLoadTpFromFolder{FolderPath: path.Join(*dataDir, "tariffplans", "testit")}
if err := ses3RPC.Call(utils.ApierV1LoadTariffPlanFromFolder, attrs, &reply); err != nil {
t.Error(err)
}
@@ -174,7 +174,7 @@ func testSes3ItProcessEvent(t *testing.T) {
},
},
}
if encoding == utils.MetaGOB {
if *encoding == utils.MetaGOB {
eAttrs.CGREvent.Event[utils.Usage] = 5 * time.Minute
eAttrs.CGREvent.Event[utils.SetupTime], _ = utils.IfaceAsTime("2018-01-07T17:00:00Z", "")
eAttrs.CGREvent.Event[utils.AnswerTime], _ = utils.IfaceAsTime("2018-01-07T17:00:10Z", "")

View File

@@ -60,7 +60,7 @@ func TestSesIt(t *testing.T) {
// test for 0 balance with session terminate with 1s usage
func testSesItLoadConfig(t *testing.T) {
sesCfgPath = path.Join(dataDir, "conf", "samples", "tutmysql_internal")
sesCfgPath = path.Join(*dataDir, "conf", "samples", "tutmysql_internal")
if sesCfg, err = config.NewCGRConfigFromPath(sesCfgPath); err != nil {
t.Error(err)
}
@@ -79,7 +79,7 @@ func testSesItResetStorDb(t *testing.T) {
}
func testSesItStartEngine(t *testing.T) {
if _, err := engine.StopStartEngine(sesCfgPath, waitRater); err != nil {
if _, err := engine.StopStartEngine(sesCfgPath, *waitRater); err != nil {
t.Fatal(err)
}
}
@@ -94,7 +94,7 @@ func testSesItRPCConn(t *testing.T) {
func testSesItLoadFromFolder(t *testing.T) {
var reply string
attrs := &utils.AttrLoadTpFromFolder{FolderPath: path.Join(dataDir, "tariffplans", "testit")}
attrs := &utils.AttrLoadTpFromFolder{FolderPath: path.Join(*dataDir, "tariffplans", "testit")}
if err := sesRPC.Call(utils.ApierV1LoadTariffPlanFromFolder, attrs, &reply); err != nil {
t.Error(err)
}

View File

@@ -93,13 +93,13 @@ func testSessionSRplAddVoiceBalance(t *testing.T) {
//Init Config
func testSessionSRplInitCfg(t *testing.T) {
smgRplcMasterCfgPath = path.Join(dataDir, "conf", "samples", "sessions_replication", "smgreplcmaster")
smgRplcMasterCfgPath = path.Join(*dataDir, "conf", "samples", "sessions_replication", "smgreplcmaster")
if smgRplcMasterCfg, err = config.NewCGRConfigFromPath(smgRplcMasterCfgPath); err != nil {
t.Fatal(err)
}
smgRplcMasterCfg.DataFolderPath = dataDir
smgRplcMasterCfg.DataFolderPath = *dataDir
config.SetCgrConfig(smgRplcMasterCfg)
smgRplcSlaveCfgPath = path.Join(dataDir, "conf", "samples", "sessions_replication", "smgreplcslave")
smgRplcSlaveCfgPath = path.Join(*dataDir, "conf", "samples", "sessions_replication", "smgreplcslave")
if smgRplcSlaveCfg, err = config.NewCGRConfigFromPath(smgRplcSlaveCfgPath); err != nil {
t.Fatal(err)
}
@@ -117,10 +117,10 @@ func testSessionSRplResetDB(t *testing.T) {
// Start CGR Engine
func testSessionSRplStartEngine(t *testing.T) {
if _, err = engine.StopStartEngine(smgRplcSlaveCfgPath, waitRater); err != nil {
if _, err = engine.StopStartEngine(smgRplcSlaveCfgPath, *waitRater); err != nil {
t.Fatal(err)
}
if masterEngine, err = engine.StartEngine(smgRplcMasterCfgPath, waitRater); err != nil {
if masterEngine, err = engine.StartEngine(smgRplcMasterCfgPath, *waitRater); err != nil {
t.Fatal(err)
}
@@ -138,12 +138,12 @@ func testSessionSRplApierRpcConn(t *testing.T) {
// Load the tariff plan, creating accounts and their balances
func testSessionSRplTPFromFolder(t *testing.T) {
attrs := &utils.AttrLoadTpFromFolder{FolderPath: path.Join(dataDir, "tariffplans", "oldtutorial")}
attrs := &utils.AttrLoadTpFromFolder{FolderPath: path.Join(*dataDir, "tariffplans", "oldtutorial")}
var loadInst utils.LoadInstance
if err := smgRplcMstrRPC.Call(utils.ApierV2LoadTariffPlanFromFolder, attrs, &loadInst); err != nil {
t.Error(err)
}
time.Sleep(time.Duration(waitRater) * time.Millisecond) // Give time for scheduler to execute topups
time.Sleep(time.Duration(*waitRater) * time.Millisecond) // Give time for scheduler to execute topups
}
func testSessionSRplInitiate(t *testing.T) {
@@ -372,7 +372,7 @@ func testSessionSRplTerminate(t *testing.T) {
if err := smgRplcSlvRPC.Call(utils.SessionSv1TerminateSession, args, &reply); err != nil {
t.Error(err)
}
time.Sleep(time.Duration(waitRater) * time.Millisecond) // Wait for the sessions to be populated
time.Sleep(time.Duration(*waitRater) * time.Millisecond) // Wait for the sessions to be populated
var aSessions []*sessions.ExternalSession
//check if the session was terminated on slave

View File

@@ -62,7 +62,7 @@ func TestSrIt(t *testing.T) {
}
func testSrItLoadConfig(t *testing.T) {
srCfgPath = path.Join(dataDir, "conf", "samples", "tutmongo")
srCfgPath = path.Join(*dataDir, "conf", "samples", "tutmongo")
if srCfg, err = config.NewCGRConfigFromPath(srCfgPath); err != nil {
t.Error(err)
}
@@ -81,7 +81,7 @@ func testSrItResetStorDb(t *testing.T) {
}
func testSrItStartEngine(t *testing.T) {
if _, err := engine.StopStartEngine(srCfgPath, waitRater); err != nil {
if _, err := engine.StopStartEngine(srCfgPath, *waitRater); err != nil {
t.Fatal(err)
}
}
@@ -96,7 +96,7 @@ func testSrItRPCConn(t *testing.T) {
func testSrItLoadFromFolder(t *testing.T) {
var reply string
attrs := &utils.AttrLoadTpFromFolder{FolderPath: path.Join(dataDir, "tariffplans", "oldtutorial")}
attrs := &utils.AttrLoadTpFromFolder{FolderPath: path.Join(*dataDir, "tariffplans", "oldtutorial")}
if err := srrpc.Call(utils.ApierV1LoadTariffPlanFromFolder, attrs, &reply); err != nil {
t.Error(err)
}

View File

@@ -78,7 +78,7 @@ var sTestsSCncrIT = []func(t *testing.T){
}
func testSCncrInitConfig(t *testing.T) {
sCncrCfgPath = path.Join(dataDir, "conf", "samples", sCncrCfgDIR)
sCncrCfgPath = path.Join(*dataDir, "conf", "samples", sCncrCfgDIR)
if sCncrCfg, err = config.NewCGRConfigFromPath(sCncrCfgPath); err != nil {
t.Fatal(err)
}
@@ -98,7 +98,7 @@ func testSCncrInitStorDB(t *testing.T) {
}
func testSCncrStartEngine(t *testing.T) {
if _, err := engine.StopStartEngine(sCncrCfgPath, waitRater); err != nil {
if _, err := engine.StopStartEngine(sCncrCfgPath, *waitRater); err != nil {
t.Fatal(err)
}
}
@@ -113,7 +113,7 @@ func testSCncrRPCConn(t *testing.T) {
}
func testSCncrKillEngine(t *testing.T) {
if err := engine.KillEngine(waitRater); err != nil {
if err := engine.KillEngine(*waitRater); err != nil {
t.Error(err)
}
}
@@ -122,7 +122,7 @@ func testSCncrLoadTP(t *testing.T) {
var loadInst string
if err := sCncrRPC.Call(utils.ApierV1LoadTariffPlanFromFolder,
&utils.AttrLoadTpFromFolder{FolderPath: path.Join(
dataDir, "tariffplans", "tp1cnt")}, &loadInst); err != nil {
*dataDir, "tariffplans", "tp1cnt")}, &loadInst); err != nil {
t.Error(err)
}
attrPrfl := &v2.AttributeWithCache{

View File

@@ -77,7 +77,7 @@ func TestSuplSV1ITMongo(t *testing.T) {
func testV1SplSLoadConfig(t *testing.T) {
var err error
splSv1CfgPath = path.Join(dataDir, "conf", "samples", splSv1ConfDIR)
splSv1CfgPath = path.Join(*dataDir, "conf", "samples", splSv1ConfDIR)
if splSv1Cfg, err = config.NewCGRConfigFromPath(splSv1CfgPath); err != nil {
t.Error(err)
}
@@ -97,7 +97,7 @@ func testV1SplSResetStorDb(t *testing.T) {
}
func testV1SplSStartEngine(t *testing.T) {
if _, err := engine.StopStartEngine(splSv1CfgPath, waitRater); err != nil {
if _, err := engine.StopStartEngine(splSv1CfgPath, *waitRater); err != nil {
t.Fatal(err)
}
}
@@ -112,7 +112,7 @@ func testV1SplSRpcConn(t *testing.T) {
func testV1SplSFromFolder(t *testing.T) {
var reply string
attrs := &utils.AttrLoadTpFromFolder{FolderPath: path.Join(dataDir, "tariffplans", "testit")}
attrs := &utils.AttrLoadTpFromFolder{FolderPath: path.Join(*dataDir, "tariffplans", "testit")}
if err := splSv1Rpc.Call(utils.ApierV1LoadTariffPlanFromFolder, attrs, &reply); err != nil {
t.Error(err)
}

View File

@@ -60,9 +60,9 @@ func TestTLS(t *testing.T) {
func testTLSLoadConfig(t *testing.T) {
var err error
tlsCfgPath = path.Join(dataDir, "conf", "samples", tlsConfDIR)
if encoding == utils.MetaGOB {
tlsCfgPath = path.Join(dataDir, "conf", "samples", tlsConfDIR+"_gob")
tlsCfgPath = path.Join(*dataDir, "conf", "samples", tlsConfDIR)
if *encoding == utils.MetaGOB {
tlsCfgPath = path.Join(*dataDir, "conf", "samples", tlsConfDIR+"_gob")
}
if tlsCfg, err = config.NewCGRConfigFromPath(tlsCfgPath); err != nil {
t.Error(err)

View File

@@ -67,14 +67,14 @@ func TestTp(t *testing.T) {
}
}
func testTpInitCfg(t *testing.T) {
tpCfgPath = path.Join(dataDir, "conf", "samples", "tutmysql")
tpCfgPath = path.Join(*dataDir, "conf", "samples", "tutmysql")
// Init config first
var err error
tpCfg, err = config.NewCGRConfigFromPath(tpCfgPath)
if err != nil {
t.Error(err)
}
tpCfg.DataFolderPath = dataDir // Share DataFolderPath through config towards StoreDb for Flush()
tpCfg.DataFolderPath = *dataDir // Share DataFolderPath through config towards StoreDb for Flush()
config.SetCgrConfig(tpCfg)
}
@@ -110,11 +110,11 @@ func testTpRpcConn(t *testing.T) {
// Load the tariff plan, creating accounts and their balances
func testTpLoadTariffPlanFromFolder(t *testing.T) {
attrs := &utils.AttrLoadTpFromFolder{FolderPath: path.Join(dataDir, "tariffplans", "testtp")}
attrs := &utils.AttrLoadTpFromFolder{FolderPath: path.Join(*dataDir, "tariffplans", "testtp")}
if err := tpRPC.Call(utils.ApierV2LoadTariffPlanFromFolder, attrs, &tpLoadInst); err != nil {
t.Error(err)
}
time.Sleep(time.Duration(waitRater) * time.Millisecond) // Give time for scheduler to execute topups
time.Sleep(time.Duration(*waitRater) * time.Millisecond) // Give time for scheduler to execute topups
}
func testTpBalanceCounter(t *testing.T) {

View File

@@ -58,14 +58,14 @@ func TestTutSMG(t *testing.T) {
}
func testTutSMGInitCfg(t *testing.T) {
tutSMGCfgPath = path.Join(dataDir, "conf", "samples", "smgeneric")
tutSMGCfgPath = path.Join(*dataDir, "conf", "samples", "smgeneric")
// Init config first
var err error
tutSMGCfg, err = config.NewCGRConfigFromPath(tutSMGCfgPath)
if err != nil {
t.Error(err)
}
tutSMGCfg.DataFolderPath = dataDir // Share DataFolderPath through config towards StoreDb for Flush()
tutSMGCfg.DataFolderPath = *dataDir // Share DataFolderPath through config towards StoreDb for Flush()
config.SetCgrConfig(tutSMGCfg)
}
@@ -85,7 +85,7 @@ func testTutSMGResetStorDb(t *testing.T) {
// Start CGR Engine
func testTutSMGStartEngine(t *testing.T) {
if _, err := engine.StopStartEngine(tutSMGCfgPath, waitRater); err != nil {
if _, err := engine.StopStartEngine(tutSMGCfgPath, *waitRater); err != nil {
t.Fatal(err)
}
}
@@ -101,11 +101,11 @@ func testTutSMGRpcConn(t *testing.T) {
// Load the tariff plan, creating accounts and their balances
func testTutSMGLoadTariffPlanFromFolder(t *testing.T) {
attrs := &utils.AttrLoadTpFromFolder{FolderPath: path.Join(dataDir, "tariffplans", "oldtutorial")}
attrs := &utils.AttrLoadTpFromFolder{FolderPath: path.Join(*dataDir, "tariffplans", "oldtutorial")}
if err := tutSMGRpc.Call(utils.ApierV2LoadTariffPlanFromFolder, attrs, &smgLoadInst); err != nil {
t.Error(err)
}
time.Sleep(time.Duration(waitRater) * time.Millisecond) // Give time for scheduler to execute topups
time.Sleep(time.Duration(*waitRater) * time.Millisecond) // Give time for scheduler to execute topups
}
// Check loaded stats

View File

@@ -69,9 +69,9 @@ func TestTutorial2Mongo(t *testing.T) {
func testTutLoadConfig(t *testing.T) {
var err error
tutCfgPath = path.Join(dataDir, "conf", "samples", tutCfgDir)
if encoding == utils.MetaGOB {
tutCfgPath = path.Join(dataDir, "conf", "samples", tutCfgDir+"_gob")
tutCfgPath = path.Join(*dataDir, "conf", "samples", tutCfgDir)
if *encoding == utils.MetaGOB {
tutCfgPath = path.Join(*dataDir, "conf", "samples", tutCfgDir+"_gob")
}
if tutCfg, err = config.NewCGRConfigFromPath(tutCfgPath); err != nil {
t.Error(err)
@@ -110,7 +110,7 @@ func testTutRpcConn(t *testing.T) {
func testTutFromFolder(t *testing.T) {
var reply string
attrs := &utils.AttrLoadTpFromFolder{
FolderPath: path.Join(dataDir, "tariffplans", "tutorial2")}
FolderPath: path.Join(*dataDir, "tariffplans", "tutorial2")}
if err := tutRpc.Call(utils.ApierV1LoadTariffPlanFromFolder,
attrs, &reply); err != nil {
t.Error(err)

View File

@@ -79,7 +79,7 @@ func TestTutorialMySQL(t *testing.T) {
func testTutorialLoadConfig(t *testing.T) {
var err error
tutorialCfgPath = path.Join(dataDir, "conf", "samples", tutorialConfDIR)
tutorialCfgPath = path.Join(*dataDir, "conf", "samples", tutorialConfDIR)
if tutorialCfg, err = config.NewCGRConfigFromPath(tutorialCfgPath); err != nil {
t.Error(err)
}
@@ -116,7 +116,7 @@ func testTutorialRpcConn(t *testing.T) {
func testTutorialFromFolder(t *testing.T) {
var reply string
attrs := &utils.AttrLoadTpFromFolder{FolderPath: path.Join(dataDir, "tariffplans", "tutorial")}
attrs := &utils.AttrLoadTpFromFolder{FolderPath: path.Join(*dataDir, "tariffplans", "tutorial")}
if err := tutorialRpc.Call(utils.ApierV1LoadTariffPlanFromFolder, attrs, &reply); err != nil {
t.Error(err)
}

View File

@@ -2,6 +2,7 @@
go clean --cache
./test.sh
gen=$?
# Internal
echo 'go test github.com/cgrates/cgrates/apier/v1 -tags=integration -dbtype=*internal'
go test github.com/cgrates/cgrates/apier/v1 -tags=integration -dbtype=*internal
@@ -9,6 +10,12 @@ ap1_internal=$?
echo 'go test github.com/cgrates/cgrates/apier/v2 -tags=integration -dbtype=*internal'
go test github.com/cgrates/cgrates/apier/v2 -tags=integration -dbtype=*internal
ap2_internal=$?
echo 'go test github.com/cgrates/cgrates/engine -tags=integration -dbtype=*internal'
go test github.com/cgrates/cgrates/engine -tags=integration -dbtype=*internal
en_internal=$?
echo 'go test github.com/cgrates/cgrates/ers -tags=integration -dbtype=*internal'
go test github.com/cgrates/cgrates/ers -tags=integration -dbtype=*internal
ers_internal=$?
# SQL
echo 'go test github.com/cgrates/cgrates/apier/v1 -tags=integration -dbtype=*sql'
@@ -17,6 +24,12 @@ ap1_sql=$?
echo 'go test github.com/cgrates/cgrates/apier/v2 -tags=integration -dbtype=*sql'
go test github.com/cgrates/cgrates/apier/v2 -tags=integration -dbtype=*sql
ap2_sql=$?
echo 'go test github.com/cgrates/cgrates/engine -tags=integration -dbtype=*sql'
go test github.com/cgrates/cgrates/engine -tags=integration -dbtype=*sql
en_sql=$?
echo 'go test github.com/cgrates/cgrates/ers -tags=integration -dbtype=*sql'
go test github.com/cgrates/cgrates/ers -tags=integration -dbtype=*sql
ers_sql=$?
# Mongo
echo 'go test github.com/cgrates/cgrates/apier/v1 -tags=integration -dbtype=*mongo'
@@ -25,6 +38,12 @@ ap1_mongo=$?
echo 'go test github.com/cgrates/cgrates/apier/v2 -tags=integration -dbtype=*mongo'
go test github.com/cgrates/cgrates/apier/v2 -tags=integration -dbtype=*mongo
ap2_mongo=$?
echo 'go test github.com/cgrates/cgrates/engine -tags=integration -dbtype=*mongo'
go test github.com/cgrates/cgrates/engine -tags=integration -dbtype=*mongo
en_mongo=$?
echo 'go test github.com/cgrates/cgrates/ers -tags=integration -dbtype=*mongo'
go test github.com/cgrates/cgrates/ers -tags=integration -dbtype=*mongo
ers_mongo=$?
# Postgres
echo 'go test github.com/cgrates/cgrates/apier/v1 -tags=integration -dbtype=*postgres'
@@ -33,22 +52,21 @@ ap1_postgres=$?
echo 'go test github.com/cgrates/cgrates/apier/v2 -tags=integration -dbtype=*postgres'
go test github.com/cgrates/cgrates/apier/v2 -tags=integration -dbtype=*postgres
ap2_postgres=$?
echo 'go test github.com/cgrates/cgrates/engine -tags=integration -dbtype=*postgres'
go test github.com/cgrates/cgrates/engine -tags=integration -dbtype=*postgres
en_postgres=$?
echo 'go test github.com/cgrates/cgrates/ers -tags=integration -dbtype=*postgres'
go test github.com/cgrates/cgrates/ers -tags=integration -dbtype=*postgres
ers_postgres=$?
echo 'go test github.com/cgrates/cgrates/engine -tags=integration'
go test github.com/cgrates/cgrates/engine -tags=integration
en=$?
echo 'go test github.com/cgrates/cgrates/cdrc -tags=integration'
go test github.com/cgrates/cgrates/cdrc -tags=integration
cdrc=$?
echo 'go test github.com/cgrates/cgrates/ers -tags=integration'
go test github.com/cgrates/cgrates/ers -tags=integration
ers=$?
echo 'go test github.com/cgrates/cgrates/config -tags=integration'
go test github.com/cgrates/cgrates/config -tags=integration
cfg=$?
echo 'go test github.com/cgrates/cgrates/utils -tags=integration'
go test github.com/cgrates/cgrates/utils -tags=integration
utl=$?
#All
echo 'go test github.com/cgrates/cgrates/general_tests -tags=integration'
go test github.com/cgrates/cgrates/general_tests -tags=integration
gnr=$?