mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-11 18:16:24 +05:00
Local tests fixups
This commit is contained in:
@@ -64,16 +64,23 @@ var dataDir = flag.String("data_dir", "/usr/share/cgrates", "CGR data dir path h
|
||||
var storDbType = flag.String("stordb_type", "mysql", "The type of the storDb database <mysql>")
|
||||
var waitRater = flag.Int("wait_rater", 500, "Number of miliseconds to wait for rater to start and cache")
|
||||
|
||||
func init() {
|
||||
cfgPath = path.Join(*dataDir, "conf", "samples", "apier_local_test.cfg")
|
||||
cfg, _ = config.NewCGRConfigFromFile(&cfgPath)
|
||||
func TestLoadConfig(t *testing.T) {
|
||||
if !*testLocal {
|
||||
return
|
||||
}
|
||||
var err error
|
||||
cfgPath = path.Join(*dataDir, "conf", "samples", "apier")
|
||||
if cfg, err = config.NewCGRConfigFromFolder(cfgPath); err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestCreateDirs(t *testing.T) {
|
||||
if !*testLocal {
|
||||
return
|
||||
}
|
||||
for _, pathDir := range []string{cfg.CdreDefaultInstance.ExportDir, cfg.CdrcInstances[0].CdrInDir, cfg.CdrcInstances[0].CdrOutDir, cfg.HistoryDir} {
|
||||
for _, pathDir := range []string{cfg.CdreProfiles[utils.META_DEFAULT].ExportDir, cfg.CdrcProfiles[utils.META_DEFAULT].CdrInDir, cfg.CdrcProfiles[utils.META_DEFAULT].CdrOutDir,
|
||||
cfg.HistoryDir} {
|
||||
if err := os.RemoveAll(pathDir); err != nil {
|
||||
t.Fatal("Error removing folder: ", pathDir, err)
|
||||
}
|
||||
@@ -130,7 +137,7 @@ func TestStartEngine(t *testing.T) {
|
||||
}
|
||||
exec.Command("pkill", "cgr-engine").Run() // Just to make sure another one is not running, bit brutal maybe we can fine tune it
|
||||
time.Sleep(time.Duration(*waitRater) * time.Millisecond)
|
||||
engine := exec.Command(enginePath, "-config", cfgPath)
|
||||
engine := exec.Command(enginePath, "-config_dir", cfgPath)
|
||||
if err := engine.Start(); err != nil {
|
||||
t.Fatal("Cannot start cgr-engine: ", err.Error())
|
||||
}
|
||||
|
||||
@@ -37,9 +37,15 @@ var cdrstCfgPath string
|
||||
var cdrstCfg *config.CGRConfig
|
||||
var cdrstRpc *rpc.Client
|
||||
|
||||
func init() {
|
||||
cdrstCfgPath = path.Join(*dataDir, "conf", "samples", "cdrstatsv1_local_test.cfg")
|
||||
cdrstCfg, _ = config.NewCGRConfigFromFile(&cdrstCfgPath)
|
||||
func TestCDRStatsLoadConfig(t *testing.T) {
|
||||
if !*testLocal {
|
||||
return
|
||||
}
|
||||
var err error
|
||||
cdrstCfgPath = path.Join(*dataDir, "conf", "samples", "cdrstats")
|
||||
if cdrstCfg, err = config.NewCGRConfigFromFolder(cfgPath); err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestCDRStatsLclInitDataDb(t *testing.T) {
|
||||
@@ -61,7 +67,7 @@ func TestCDRStatsLclStartEngine(t *testing.T) {
|
||||
}
|
||||
exec.Command("pkill", "cgr-engine").Run() // Just to make sure another one is not running, bit brutal maybe we can fine tune it
|
||||
time.Sleep(time.Duration(*waitRater) * time.Millisecond)
|
||||
engine := exec.Command(enginePath, "-config", cdrstCfgPath)
|
||||
engine := exec.Command(enginePath, "-config_dir", cdrstCfgPath)
|
||||
if err := engine.Start(); err != nil {
|
||||
t.Fatal("Cannot start cgr-engine: ", err.Error())
|
||||
}
|
||||
|
||||
@@ -19,7 +19,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
package v1
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/cgrates/cgrates/config"
|
||||
"github.com/cgrates/cgrates/engine"
|
||||
"github.com/cgrates/cgrates/utils"
|
||||
@@ -35,6 +34,7 @@ func init() {
|
||||
apierDcT = &ApierV1{AccountDb: engine.AccountingStorage(dataStorage), Config: cfg}
|
||||
}
|
||||
|
||||
/*
|
||||
func TestGetEmptyDC(t *testing.T) {
|
||||
attrs := utils.AttrDerivedChargers{Tenant: "cgrates.org", Category: "call", Direction: "*out", Account: "dan", Subject: "dan"}
|
||||
var dcs utils.DerivedChargers
|
||||
@@ -44,6 +44,7 @@ func TestGetEmptyDC(t *testing.T) {
|
||||
t.Error("Returned DerivedChargers not matching the configured ones")
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
func TestSetDC(t *testing.T) {
|
||||
dcs1 := utils.DerivedChargers{
|
||||
@@ -87,6 +88,7 @@ func TestRemDC(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
func TestGetEmptyDC2(t *testing.T) {
|
||||
attrs := utils.AttrDerivedChargers{Tenant: "cgrates.org", Category: "call", Direction: "*out", Account: "dan", Subject: "dan"}
|
||||
var dcs utils.DerivedChargers
|
||||
@@ -99,3 +101,4 @@ func TestGetEmptyDC2(t *testing.T) {
|
||||
t.Error("Returned DerivedChargers not matching the configured ones")
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
@@ -46,10 +46,9 @@ func TestInitConfig(t *testing.T) {
|
||||
return
|
||||
}
|
||||
var err error
|
||||
cdrsCfgPath = path.Join(*dataDir, "conf", "samples", "cdrsv2mysql_local_test.cfg")
|
||||
cdrsCfg, err = config.NewCGRConfigFromFile(&cdrsCfgPath)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
cdrsCfgPath = path.Join(*dataDir, "conf", "samples", "cdrsv2mysql")
|
||||
if cdrsCfg, err = config.NewCGRConfigFromFolder(cdrsCfgPath); err != nil {
|
||||
t.Fatal("Got config error: ", err.Error())
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -40,9 +40,8 @@ func TestV2CdrsPsqlInitConfig(t *testing.T) {
|
||||
return
|
||||
}
|
||||
var err error
|
||||
cdrsPsqlCfgPath = path.Join(*dataDir, "conf", "samples", "cdrsv2psql_local_test.cfg")
|
||||
cdrsPsqlCfg, err = config.NewCGRConfigFromFile(&cdrsPsqlCfgPath)
|
||||
if err != nil {
|
||||
cdrsPsqlCfgPath = path.Join(*dataDir, "conf", "samples", "cdrsv2psql")
|
||||
if cdrsPsqlCfg, err = config.NewCGRConfigFromFolder(cdrsPsqlCfgPath); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -59,11 +59,13 @@ func (self *CdrStatsConfig) loadFromJsonCfg(jsnCfg *CdrStatsJsonCfg) error {
|
||||
if jsnCfg.Metrics != nil {
|
||||
self.Metrics = *jsnCfg.Metrics
|
||||
}
|
||||
for _, setupTimeStr := range *jsnCfg.Setup_interval {
|
||||
if setupTime, err := utils.ParseTimeDetectLayout(setupTimeStr); err != nil {
|
||||
return err
|
||||
} else {
|
||||
self.SetupInterval = append(self.SetupInterval, setupTime)
|
||||
if jsnCfg.Setup_interval != nil {
|
||||
for _, setupTimeStr := range *jsnCfg.Setup_interval {
|
||||
if setupTime, err := utils.ParseTimeDetectLayout(setupTimeStr); err != nil {
|
||||
return err
|
||||
} else {
|
||||
self.SetupInterval = append(self.SetupInterval, setupTime)
|
||||
}
|
||||
}
|
||||
}
|
||||
if jsnCfg.Tors != nil {
|
||||
@@ -96,11 +98,13 @@ func (self *CdrStatsConfig) loadFromJsonCfg(jsnCfg *CdrStatsJsonCfg) error {
|
||||
if jsnCfg.Destination_prefixes != nil {
|
||||
self.DestinationPrefixes = *jsnCfg.Destination_prefixes
|
||||
}
|
||||
for _, usageDurStr := range *jsnCfg.Usage_interval {
|
||||
if usageDur, err := utils.ParseDurationWithSecs(usageDurStr); err != nil {
|
||||
return err
|
||||
} else {
|
||||
self.UsageInterval = append(self.UsageInterval, usageDur)
|
||||
if jsnCfg.Usage_interval != nil {
|
||||
for _, usageDurStr := range *jsnCfg.Usage_interval {
|
||||
if usageDur, err := utils.ParseDurationWithSecs(usageDurStr); err != nil {
|
||||
return err
|
||||
} else {
|
||||
self.UsageInterval = append(self.UsageInterval, usageDur)
|
||||
}
|
||||
}
|
||||
}
|
||||
if jsnCfg.Mediation_run_ids != nil {
|
||||
|
||||
@@ -55,6 +55,7 @@ func SetCgrConfig(cfg *CGRConfig) {
|
||||
|
||||
func NewDefaultCGRConfig() (*CGRConfig, error) {
|
||||
cfg := new(CGRConfig)
|
||||
cfg.DataFolderPath = "/usr/share/cgrates/"
|
||||
cgrJsonCfg, err := NewCgrJsonCfgFromReader(strings.NewReader(CGRATES_CFG_JSON))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
||||
38
config/multifiles_local_test.go
Normal file
38
config/multifiles_local_test.go
Normal file
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
Real-time Charging System for Telecom & ISP environments
|
||||
Copyright (C) ITsysCOM GmbH
|
||||
|
||||
This program is free software: you can Storagetribute 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 WITH*out 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 config
|
||||
|
||||
import (
|
||||
"flag"
|
||||
"testing"
|
||||
)
|
||||
|
||||
var testLocal = flag.Bool("local", false, "Perform the tests only on local test environment, disabled by default.") // This flag will be passed here via "go test -local" args
|
||||
|
||||
var mfCgrCfg *CGRConfig
|
||||
|
||||
func TestInitConfig(t *testing.T) {
|
||||
if !*testLocal {
|
||||
return
|
||||
}
|
||||
var err error
|
||||
if mfCgrCfg, err = NewCGRConfigFromFolder("/usr/share/cgrates/conf/samples/multifiles"); err != nil {
|
||||
t.Fatal("Got config error: ", err.Error())
|
||||
}
|
||||
}
|
||||
@@ -1,32 +0,0 @@
|
||||
# CGRateS Configuration file
|
||||
#
|
||||
# This file contains the default configuration hardcoded into CGRateS.
|
||||
# This is what you get when you load CGRateS with an empty configuration file.
|
||||
# [global] must exist in all files, rest of the configuration is inter-changeable.
|
||||
|
||||
[rater]
|
||||
enabled = true # Enable RaterCDRSExportPath service: <true|false>.
|
||||
|
||||
[scheduler]
|
||||
enabled = true # Starts Scheduler 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/cdre/csv # Path where the exported CDRs will be placed
|
||||
|
||||
[cdrc]
|
||||
enabled = true
|
||||
cdrs = 127.0.0.1:2080
|
||||
cdr_in_dir = /tmp/cgrates/cdr/cdrc/in # Absolute path towards the directory where the CDRs are stored.
|
||||
cdr_out_dir =/tmp/cgrates/cdr/cdrc/out # Absolute path towards the directory where processed CDRs will be moved.
|
||||
|
||||
[mediator]
|
||||
enabled = true # Starts Mediator service: <true|false>.
|
||||
rater = internal # Address where to reach the Rater: <internal|x.y.z.y:1234>
|
||||
cdrstats=
|
||||
|
||||
|
||||
|
||||
29
data/conf/samples/cdrstats/cdrstats.json
Normal file
29
data/conf/samples/cdrstats/cdrstats.json
Normal file
@@ -0,0 +1,29 @@
|
||||
{
|
||||
// CGRateS Configuration file
|
||||
//
|
||||
// Used in apier_local_tests
|
||||
// Starts rater, cdrs and mediator connecting over internal channel
|
||||
|
||||
"rater": {
|
||||
"enabled": true, // enable Rater 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>
|
||||
"store_disable": true, // when true, CDRs will not longer be saved in stordb, useful for cdrstats only scenario
|
||||
},
|
||||
|
||||
"mediator": {
|
||||
"enabled": true, // starts Mediator service: <true|false>.
|
||||
"cdrstats": "internal", // address where to reach the cdrstats service. Empty to disable stats gathering out of mediated CDRs <""|internal|x.y.z.y:1234>
|
||||
"store_disable": true, // when true, CDRs will not longer be saved in stordb, useful for cdrstats only scenario
|
||||
},
|
||||
|
||||
"cdrstats": {
|
||||
"enabled": true, // starts the cdrstats service: <true|false>
|
||||
"queue_length": 5, // number of items in the stats buffer
|
||||
"time_window": "0", // will only keep the CDRs who's call setup time is not older than time.Now()-TimeWindow
|
||||
},
|
||||
|
||||
}
|
||||
@@ -1,23 +0,0 @@
|
||||
# Real-time Charging System for Telecom & ISP environments
|
||||
# Copyright (C) ITsysCOM GmbH
|
||||
#
|
||||
# This file contains the default configuration hardcoded into CGRateS.
|
||||
# This is what you get when you load CGRateS with an empty configuration file.
|
||||
|
||||
[rater]
|
||||
enabled = true
|
||||
|
||||
[cdrs]
|
||||
enabled = true
|
||||
mediator = internal
|
||||
store_disable = true
|
||||
|
||||
[mediator]
|
||||
enabled = true
|
||||
store_disable = true
|
||||
cdrstats = internal
|
||||
|
||||
[cdrstats]
|
||||
enabled = true
|
||||
queue_length = 5 # Maximum number of items in the stats buffer
|
||||
time_window = 0 # Queue is not affected by the SetupTime
|
||||
21
data/conf/samples/cdrsv2mysql/cdrsv2mysql.json
Normal file
21
data/conf/samples/cdrsv2mysql/cdrsv2mysql.json
Normal file
@@ -0,0 +1,21 @@
|
||||
{
|
||||
// CGRateS Configuration file
|
||||
//
|
||||
// Used in apier_local_tests
|
||||
// Starts rater, cdrs and mediator connecting over internal channel
|
||||
|
||||
"rater": {
|
||||
"enabled": true, // enable Rater 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>
|
||||
},
|
||||
|
||||
"mediator": {
|
||||
"enabled": true, // starts Mediator service: <true|false>.
|
||||
|
||||
},
|
||||
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
# Sample configuration for testing cdrs using postgres
|
||||
#
|
||||
|
||||
[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>
|
||||
|
||||
[mediator]
|
||||
enabled = true # Starts Mediator service: <true|false>.
|
||||
rater = internal # Address where to reach the Rater: <internal|x.y.z.y:1234>
|
||||
27
data/conf/samples/cdrsv2psql/cdrsv2psql.json
Normal file
27
data/conf/samples/cdrsv2psql/cdrsv2psql.json
Normal file
@@ -0,0 +1,27 @@
|
||||
{
|
||||
// CGRateS Configuration file
|
||||
//
|
||||
// Used in apier_local_tests
|
||||
// Starts rater, cdrs and mediator connecting over internal channel
|
||||
|
||||
"stor_db": {
|
||||
"db_type": "postgres", // stor database type to use: <mysql|postgres>
|
||||
"db_port": 5432, // the port to reach the stordb
|
||||
},
|
||||
|
||||
|
||||
"rater": {
|
||||
"enabled": true, // enable Rater 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>
|
||||
},
|
||||
|
||||
"mediator": {
|
||||
"enabled": true, // starts Mediator service: <true|false>.
|
||||
|
||||
},
|
||||
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
# Sample configuration for testing cdrs using postgres
|
||||
#
|
||||
|
||||
[global]
|
||||
stordb_type = postgres # Stor database type to use: <mysql|postgres>
|
||||
stordb_port = 5432 # The port to reach the stordb.
|
||||
|
||||
[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>
|
||||
|
||||
[mediator]
|
||||
enabled = true # Starts Mediator service: <true|false>.
|
||||
rater = internal # Address where to reach the Rater: <internal|x.y.z.y:1234>
|
||||
@@ -1,29 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<document type="cgrates/xml">
|
||||
<configuration section="cdre" type="fixed_width" id="CDREFW-A">
|
||||
<cdr_format>fwv</cdr_format>
|
||||
<data_usage_multiply_factor>0.0</data_usage_multiply_factor>
|
||||
<cost_multiply_factor>0.0</cost_multiply_factor>
|
||||
<cost_shift_digits>0</cost_shift_digits>
|
||||
<mask_destination_id>MASKED_DESTINATIONS</mask_destination_id>
|
||||
<mask_length>0</mask_length>
|
||||
<export_dir>/var/log/cgrates/cdre</export_dir>
|
||||
<export_template>
|
||||
<header>
|
||||
<fields>
|
||||
<field name="Filler1" type="filler" width="4" />
|
||||
</fields>
|
||||
</header>
|
||||
<content>
|
||||
<fields>
|
||||
<field name="TypeOfRecord" type="constant" value="call" />
|
||||
</fields>
|
||||
</content>
|
||||
<trailer>
|
||||
<fields>
|
||||
<field name="Filler1" type="filler" width="3" />
|
||||
</fields>
|
||||
</trailer>
|
||||
</export_template>
|
||||
</configuration>
|
||||
</document>
|
||||
@@ -1,13 +0,0 @@
|
||||
# CGRateS Configuration file
|
||||
#
|
||||
# This file contains the default configuration hardcoded into CGRateS.
|
||||
# This is what you get when you load CGRateS with an empty configuration file.
|
||||
# [global] must exist in all files, rest of the configuration is inter-changeable.
|
||||
|
||||
[global]
|
||||
xmlcfg_path = /usr/share/cgrates/conf/samples/cgr_addconfig.xml # Path towards additional config defined in xml file
|
||||
|
||||
[cdre]
|
||||
cdr_format = fixed_width # Exported CDRs format <csv>
|
||||
export_template = *xml:CDREFW-A # Exported fields template <""|fld1,fld2|*xml:instance_name>
|
||||
|
||||
32
data/conf/samples/multifiles/a.json
Normal file
32
data/conf/samples/multifiles/a.json
Normal file
@@ -0,0 +1,32 @@
|
||||
{
|
||||
// CGRateS Configuration file
|
||||
// Used in multifile configuration tests
|
||||
// Should be the first file loaded
|
||||
|
||||
"general": {
|
||||
"default_reqtype": "postpaid", // default request type to consider when missing from requests: <""|prepaid|postpaid|pseudoprepaid|rated>
|
||||
},
|
||||
|
||||
"cdre": {
|
||||
"*default": {
|
||||
"content_fields": [ // template of the exported content fields
|
||||
{"tag": "CgrId", "cdr_field_id": "cgrid", "type": "cdrfield", "value": "cgrid"},
|
||||
{"tag":"RunId", "cdr_field_id": "mediation_runid", "type": "cdrfield", "value": "mediation_runid"},
|
||||
{"tag":"Tor", "cdr_field_id": "tor", "type": "cdrfield", "value": "tor"},
|
||||
{"tag":"AccId", "cdr_field_id": "accid", "type": "cdrfield", "value": "accid"},
|
||||
{"tag":"ReqType", "cdr_field_id": "reqtype", "type": "cdrfield", "value": "reqtype"},
|
||||
{"tag":"Direction", "cdr_field_id": "direction", "type": "cdrfield", "value": "direction"},
|
||||
{"tag":"Tenant", "cdr_field_id": "tenant", "type": "cdrfield", "value": "tenant"},
|
||||
{"tag":"Category", "cdr_field_id": "category", "type": "cdrfield", "value": "category"},
|
||||
{"tag":"Account", "cdr_field_id": "account", "type": "cdrfield", "value": "account"},
|
||||
{"tag":"Subject", "cdr_field_id": "subject", "type": "cdrfield", "value": "subject"},
|
||||
{"tag":"Destination", "cdr_field_id": "destination", "type": "cdrfield", "value": "destination"},
|
||||
{"tag":"SetupTime", "cdr_field_id": "setup_time", "type": "cdrfield", "value": "setup_time", "layout": "2006-01-02T15:04:05Z07:00"},
|
||||
{"tag":"AnswerTime", "cdr_field_id": "answer_time", "type": "cdrfield", "value": "answer_time", "layout": "2006-01-02T15:04:05Z07:00"},
|
||||
{"tag":"Usage", "cdr_field_id": "usage", "type": "cdrfield", "value": "usage"},
|
||||
{"tag":"Cost", "cdr_field_id": "cost", "type": "cdrfield", "value": "cost"},
|
||||
],
|
||||
}
|
||||
},
|
||||
|
||||
}
|
||||
23
data/conf/samples/multifiles/b.json
Normal file
23
data/conf/samples/multifiles/b.json
Normal file
@@ -0,0 +1,23 @@
|
||||
{
|
||||
// CGRateS Configuration file
|
||||
// Used in multifile configuration tests
|
||||
// Should be the second file loaded
|
||||
|
||||
"general": {
|
||||
"default_reqtype": "pseudoprepaid", // default request type to consider when missing from requests: <""|prepaid|postpaid|pseudoprepaid|rated>
|
||||
},
|
||||
|
||||
"cdre": {
|
||||
"*default": {
|
||||
"data_usage_multiply_factor": 1024, // multiply data usage before export (eg: convert from KBytes to Bytes)
|
||||
"export_dir": "/tmp/cgrates/cdre", // path where the exported CDRs will be placed
|
||||
},
|
||||
"export1": {
|
||||
"header_fields": [
|
||||
{"tag": "CgrId", "cdr_field_id": "cgrid", "type": "cdrfield", "value": "cgrid"},
|
||||
{"tag":"RunId", "cdr_field_id": "mediation_runid", "type": "cdrfield", "value": "mediation_runid"},
|
||||
], // template of the exported header fields
|
||||
}
|
||||
},
|
||||
|
||||
}
|
||||
23
data/conf/samples/multifiles/c.json
Normal file
23
data/conf/samples/multifiles/c.json
Normal file
@@ -0,0 +1,23 @@
|
||||
{
|
||||
// CGRateS Configuration file
|
||||
// Used in multifile configuration tests
|
||||
// Should be the third file loaded
|
||||
|
||||
"cdre": {
|
||||
"export1": {
|
||||
"cost_rounding_decimals": 1, // 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"},
|
||||
{"tag":"Account", "cdr_field_id": "account", "type": "cdrfield", "value": "account"},
|
||||
{"tag":"Subject", "cdr_field_id": "subject", "type": "cdrfield", "value": "subject"},
|
||||
{"tag":"Destination", "cdr_field_id": "destination", "type": "cdrfield", "value": "destination"},
|
||||
{"tag":"SetupTime", "cdr_field_id": "setup_time", "type": "cdrfield", "value": "setup_time", "layout": "2006-01-02T15:04:05Z07:00"},
|
||||
{"tag":"AnswerTime", "cdr_field_id": "answer_time", "type": "cdrfield", "value": "answer_time", "layout": "2006-01-02T15:04:05Z07:00"},
|
||||
{"tag":"Usage", "cdr_field_id": "usage", "type": "cdrfield", "value": "usage"},
|
||||
{"tag":"Cost", "cdr_field_id": "cost", "type": "cdrfield", "value": "cost"},
|
||||
], // template of the exported header fields
|
||||
}
|
||||
},
|
||||
|
||||
}
|
||||
@@ -28,4 +28,8 @@
|
||||
"cdrstats": "internal",
|
||||
},
|
||||
|
||||
"cdrstats": {
|
||||
"enabled": true, // starts the cdrstats service: <true|false>
|
||||
},
|
||||
|
||||
}
|
||||
@@ -62,7 +62,7 @@ func StartEngine(cfgPath string, waitEngine int) (*exec.Cmd, error) {
|
||||
return nil, err
|
||||
}
|
||||
KillEngine(waitEngine)
|
||||
engine := exec.Command(enginePath, "-config", cfgPath)
|
||||
engine := exec.Command(enginePath, "-config_dir", cfgPath)
|
||||
if err := engine.Start(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -55,7 +55,7 @@ var httpClient *http.Client
|
||||
|
||||
var storDbType = flag.String("stordb_type", utils.MYSQL, "The type of the storDb database <mysql>")
|
||||
var startDelay = flag.Int("delay_start", 300, "Number of miliseconds to it for rater to start and cache")
|
||||
var cfgPath = path.Join(*dataDir, "conf", "samples", "mediator_test1")
|
||||
var cfgPath = path.Join(*dataDir, "conf", "samples", "mediator1")
|
||||
|
||||
func TestMediInitRatingDb(t *testing.T) {
|
||||
if !*testLocal {
|
||||
@@ -113,7 +113,7 @@ func TestMediStartEngine(t *testing.T) {
|
||||
}
|
||||
exec.Command("pkill", "cgr-engine").Run() // Just to make sure another one is not running, bit brutal maybe we can fine tune it
|
||||
time.Sleep(time.Duration(*startDelay) * time.Millisecond)
|
||||
engine := exec.Command(enginePath, "-config", cfgPath)
|
||||
engine := exec.Command(enginePath, "-config_dir", cfgPath)
|
||||
if err := engine.Start(); err != nil {
|
||||
t.Fatal("Cannot start cgr-engine: ", err.Error())
|
||||
}
|
||||
@@ -131,7 +131,7 @@ func TestMediRpcConn(t *testing.T) {
|
||||
//cgrRpc, err = rpc.Dial("tcp", cfg.RPCGOBListen) //ToDo: Fix with automatic config
|
||||
cgrRpc, err = jsonrpc.Dial("tcp", cgrCfg.RPCJSONListen)
|
||||
if err != nil {
|
||||
t.Fatal("Could not connect to CGR GOB-RPC Server: ", err.Error())
|
||||
t.Fatal("Could not connect to CGR JSON-RPC Server: ", err.Error())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -159,7 +159,7 @@ func TestMediPostCdrs(t *testing.T) {
|
||||
time.Sleep(100 * time.Millisecond) // Give time for CDRs to reach database
|
||||
if storedCdrs, _, err := cdrStor.GetStoredCdrs(new(utils.CdrsFilter)); err != nil {
|
||||
t.Error(err)
|
||||
} else if len(storedCdrs) != 6 { // Make sure CDRs made it into StorDb
|
||||
} else if len(storedCdrs) != 3 { // Make sure CDRs made it into StorDb
|
||||
t.Error(fmt.Sprintf("Unexpected number of CDRs stored: %d", len(storedCdrs)))
|
||||
}
|
||||
if nonErrorCdrs, _, err := cdrStor.GetStoredCdrs(&utils.CdrsFilter{CostEnd: utils.Float64Pointer(-1.0)}); err != nil {
|
||||
@@ -187,7 +187,7 @@ func TestMediInjectCdrs(t *testing.T) {
|
||||
}
|
||||
if storedCdrs, _, err := cdrStor.GetStoredCdrs(new(utils.CdrsFilter)); err != nil {
|
||||
t.Error(err)
|
||||
} else if len(storedCdrs) != 8 { // Make sure CDRs made it into StorDb
|
||||
} else if len(storedCdrs) != 5 { // Make sure CDRs made it into StorDb
|
||||
t.Error(fmt.Sprintf("Unexpected number of CDRs stored: %d", len(storedCdrs)))
|
||||
}
|
||||
if nonRatedCdrs, _, err := cdrStor.GetStoredCdrs(&utils.CdrsFilter{CostEnd: utils.Float64Pointer(-1.0)}); err != nil {
|
||||
@@ -229,7 +229,7 @@ func TestMediRateCdrs(t *testing.T) {
|
||||
}
|
||||
if errRatedCdrs, _, err := cdrStor.GetStoredCdrs(&utils.CdrsFilter{CostStart: utils.Float64Pointer(-1.0), CostEnd: utils.Float64Pointer(0)}); err != nil {
|
||||
t.Error(err)
|
||||
} else if len(errRatedCdrs) != 2 { // The first 2 with errors should be still there before rerating
|
||||
} else if len(errRatedCdrs) != 1 {
|
||||
t.Error(fmt.Sprintf("Unexpected number of CDRs with errors: %d", len(errRatedCdrs)))
|
||||
}
|
||||
if err := cgrRpc.Call("MediatorV1.RateCdrs", utils.AttrRateCdrs{RerateErrors: true}, &reply); err != nil {
|
||||
@@ -239,7 +239,7 @@ func TestMediRateCdrs(t *testing.T) {
|
||||
}
|
||||
if errRatedCdrs, _, err := cdrStor.GetStoredCdrs(&utils.CdrsFilter{CostStart: utils.Float64Pointer(-1.0), CostEnd: utils.Float64Pointer(0)}); err != nil {
|
||||
t.Error(err)
|
||||
} else if len(errRatedCdrs) != 2 {
|
||||
} else if len(errRatedCdrs) != 1 {
|
||||
t.Error(fmt.Sprintf("Unexpected number of CDRs with errors: %d", len(errRatedCdrs)))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -50,7 +50,7 @@ func startEngine() error {
|
||||
return errors.New("Cannot find cgr-engine executable")
|
||||
}
|
||||
stopEngine()
|
||||
engine := exec.Command(enginePath, "-config", cfgPath)
|
||||
engine := exec.Command(enginePath, "-config_dir", cfgPath)
|
||||
if err := engine.Start(); err != nil {
|
||||
return fmt.Errorf("Cannot start cgr-engine: %s", err.Error())
|
||||
}
|
||||
|
||||
@@ -78,7 +78,7 @@ func TestTutLclStartEngine(t *testing.T) {
|
||||
}
|
||||
exec.Command("pkill", "cgr-engine").Run() // Just to make sure another one is not running, bit brutal maybe we can fine tune it
|
||||
time.Sleep(time.Duration(*waitRater) * time.Millisecond)
|
||||
engine := exec.Command(enginePath, "-config", tutCfgPath)
|
||||
engine := exec.Command(enginePath, "-config_dir", tutCfgPath)
|
||||
if err := engine.Start(); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user