mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-11 18:16:24 +05:00
Multiple configuration files local tests
This commit is contained in:
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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: <true|false>.
|
||||
|
||||
[cdrs]
|
||||
enabled = true # Start the CDR Server service: <true|false>.
|
||||
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: <true|false>.
|
||||
rater = internal # Address where to reach the Rater: <internal|x.y.z.y:1234>
|
||||
|
||||
[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 <true|false>.
|
||||
@@ -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"},
|
||||
|
||||
Reference in New Issue
Block a user