diff --git a/config/multifiles_local_test.go b/config/multifiles_local_test.go index 99d6999dc..52116eddb 100644 --- a/config/multifiles_local_test.go +++ b/config/multifiles_local_test.go @@ -20,6 +20,7 @@ package config import ( "flag" + "github.com/cgrates/cgrates/utils" "testing" ) @@ -27,7 +28,7 @@ var testLocal = flag.Bool("local", false, "Perform the tests only on local test var mfCgrCfg *CGRConfig -func TestInitConfig(t *testing.T) { +func TestMfInitConfig(t *testing.T) { if !*testLocal { return } @@ -36,3 +37,73 @@ func TestInitConfig(t *testing.T) { t.Fatal("Got config error: ", err.Error()) } } + +func TestMfGeneralItems(t *testing.T) { + if !*testLocal { + return + } + if mfCgrCfg.DefaultReqType != utils.PSEUDOPREPAID { // Twice reconfigured + t.Error("DefaultReqType: ", mfCgrCfg.DefaultReqType) + } + if mfCgrCfg.DefaultCategory != "call" { // Not configred, should be inherited from default + t.Error("DefaultCategory: ", mfCgrCfg.DefaultCategory) + } +} + +func TestMfCdreDefaultInstance(t *testing.T) { + if !*testLocal { + return + } + for _, prflName := range []string{"*default", "export1"} { + if _, hasIt := mfCgrCfg.CdreProfiles[prflName]; !hasIt { + t.Error("Cdre does not contain profile ", prflName) + } + } + prfl := "*default" + if mfCgrCfg.CdreProfiles[prfl].CdrFormat != "csv" { + t.Error("Default instance has cdrFormat: ", mfCgrCfg.CdreProfiles[prfl].CdrFormat) + } + if mfCgrCfg.CdreProfiles[prfl].DataUsageMultiplyFactor != 1024.0 { + t.Error("Default instance has cdrFormat: ", mfCgrCfg.CdreProfiles[prfl].DataUsageMultiplyFactor) + } + if len(mfCgrCfg.CdreProfiles[prfl].HeaderFields) != 2 { + t.Error("Default instance has number of header fields: ", len(mfCgrCfg.CdreProfiles[prfl].HeaderFields)) + } + if mfCgrCfg.CdreProfiles[prfl].HeaderFields[1].Tag != "RunId" { + t.Error("Unexpected headerField value: ", mfCgrCfg.CdreProfiles[prfl].HeaderFields[1].Tag) + } + if len(mfCgrCfg.CdreProfiles[prfl].ContentFields) != 9 { + t.Error("Default instance has number of content fields: ", len(mfCgrCfg.CdreProfiles[prfl].ContentFields)) + } + if mfCgrCfg.CdreProfiles[prfl].ContentFields[2].Tag != "Account" { + t.Error("Unexpected headerField value: ", mfCgrCfg.CdreProfiles[prfl].ContentFields[2].Tag) + } +} + +func TestMfCdreExport1Instance(t *testing.T) { + if !*testLocal { + return + } + prfl := "export1" + if mfCgrCfg.CdreProfiles[prfl].CdrFormat != "csv" { + t.Error("Export1 instance has cdrFormat: ", mfCgrCfg.CdreProfiles[prfl].CdrFormat) + } + if mfCgrCfg.CdreProfiles[prfl].DataUsageMultiplyFactor != 1.0 { + t.Error("Export1 instance has cdrFormat: ", mfCgrCfg.CdreProfiles[prfl].DataUsageMultiplyFactor) + } + if mfCgrCfg.CdreProfiles[prfl].CostRoundingDecimals != 3.0 { + t.Error("Export1 instance has cdrFormat: ", mfCgrCfg.CdreProfiles[prfl].CostRoundingDecimals) + } + if len(mfCgrCfg.CdreProfiles[prfl].HeaderFields) != 2 { + t.Error("Export1 instance has number of header fields: ", len(mfCgrCfg.CdreProfiles[prfl].HeaderFields)) + } + if mfCgrCfg.CdreProfiles[prfl].HeaderFields[1].Tag != "RunId" { + t.Error("Unexpected headerField value: ", mfCgrCfg.CdreProfiles[prfl].HeaderFields[1].Tag) + } + if len(mfCgrCfg.CdreProfiles[prfl].ContentFields) != 9 { + t.Error("Export1 instance has number of content fields: ", len(mfCgrCfg.CdreProfiles[prfl].ContentFields)) + } + if mfCgrCfg.CdreProfiles[prfl].ContentFields[2].Tag != "Account" { + t.Error("Unexpected headerField value: ", mfCgrCfg.CdreProfiles[prfl].ContentFields[2].Tag) + } +} diff --git a/data/conf/samples/derived_charging1.cfg b/data/conf/samples/derived_charging1.cfg deleted file mode 100644 index 53a2fee6e..000000000 --- a/data/conf/samples/derived_charging1.cfg +++ /dev/null @@ -1,32 +0,0 @@ -# CGRateS Configuration file -# -# Used in mediator_local_test -# Starts rater, cdrs and mediator connecting over internal channel - -[rater] -enabled = true # Enable RaterCDRSExportPath service: . - -[cdrs] -enabled = true # Start the CDR Server service: . -mediator = internal # Address where to reach the Mediator. Empty for disabling mediation. <""|internal> - -[cdre] -export_dir = /tmp/cgrates/cdr/cdrexport/csv # Path where the exported CDRs will be placed - -[mediator] -enabled = true # Starts Mediator service: . -rater = internal # Address where to reach the Rater: - -[derived_charging] -run_ids = run2 # Identifiers of additional sessions control. -reqtype_fields = *default # Name of request type fields to be used during additional sessions control <""|*default|field_name>. -direction_fields = *default # Name of direction fields to be used during additional sessions control <""|*default|field_name>. -tenant_fields = *default # Name of tenant fields to be used during additional sessions control <""|*default|field_name>. -tor_fields = *default # Name of tor fields to be used during additional sessions control <""|*default|field_name>. -account_fields = ^dc2 # Name of account fields to be used during additional sessions control <""|*default|field_name>. -subject_fields = ^dc2 # Name of fields to be used during additional sessions control <""|*default|field_name>. -destination_fields = *default # Name of destination fields to be used during additional sessions control <""|*default|field_name>. -# setup_time_fields = # Name of setup_time fields to be used during additional sessions control <""|*default|field_name>. -# answer_time_fields = # Name of answer_time fields to be used during additional sessions control <""|*default|field_name>. -# duration_fields = # Name of duration fields to be used during additional sessions control <""|*default|field_name>. -# combined_chargers = true # Combine accounts specific derived_chargers with server configured ones . diff --git a/data/conf/samples/multifiles/b.json b/data/conf/samples/multifiles/b/b.json similarity index 100% rename from data/conf/samples/multifiles/b.json rename to data/conf/samples/multifiles/b/b.json diff --git a/data/conf/samples/multifiles/c.json b/data/conf/samples/multifiles/c.json index 03417ce17..e182d2b81 100644 --- a/data/conf/samples/multifiles/c.json +++ b/data/conf/samples/multifiles/c.json @@ -5,7 +5,7 @@ "cdre": { "export1": { - "cost_rounding_decimals": 1, // rounding decimals for Cost values. -1 to disable rounding + "cost_rounding_decimals": 3, // rounding decimals for Cost values. -1 to disable rounding "content_fields": [ // template of the exported content fields {"tag":"Tenant", "cdr_field_id": "tenant", "type": "cdrfield", "value": "tenant"}, {"tag":"Category", "cdr_field_id": "category", "type": "cdrfield", "value": "category"},