mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-11 18:16:24 +05:00
CDRS using goroutines for rating to release the CDR faster, tests improvements
This commit is contained in:
@@ -77,7 +77,7 @@ func TestApierLoadConfig(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestApierCreateDirs(t *testing.T) {
|
||||
for _, pathDir := range []string{cfg.CdreProfiles[utils.META_DEFAULT].ExportDirectory, "/var/log/cgrates/cdrc/in", "/var/log/cgrates/cdrc/out", cfg.HistoryDir} {
|
||||
for _, pathDir := range []string{cfg.CdreProfiles[utils.META_DEFAULT].ExportPath, "/var/log/cgrates/cdrc/in", "/var/log/cgrates/cdrc/out", cfg.HistoryDir} {
|
||||
if err := os.RemoveAll(pathDir); err != nil {
|
||||
t.Fatal("Error removing folder: ", pathDir, err)
|
||||
}
|
||||
|
||||
@@ -28,7 +28,6 @@ import (
|
||||
var mfCgrCfg *CGRConfig
|
||||
|
||||
func TestMfInitConfig(t *testing.T) {
|
||||
|
||||
var err error
|
||||
if mfCgrCfg, err = NewCGRConfigFromFolder("/usr/share/cgrates/conf/samples/multifiles"); err != nil {
|
||||
t.Fatal("Got config error: ", err.Error())
|
||||
@@ -36,7 +35,6 @@ func TestMfInitConfig(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestMfGeneralItems(t *testing.T) {
|
||||
|
||||
if mfCgrCfg.DefaultReqType != utils.META_PSEUDOPREPAID { // Twice reconfigured
|
||||
t.Error("DefaultReqType: ", mfCgrCfg.DefaultReqType)
|
||||
}
|
||||
@@ -46,18 +44,17 @@ func TestMfGeneralItems(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestMfCdreDefaultInstance(t *testing.T) {
|
||||
|
||||
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].ExportFormat != utils.MetaFileCSV {
|
||||
t.Error("Default instance has cdrFormat: ", mfCgrCfg.CdreProfiles[prfl].ExportFormat)
|
||||
}
|
||||
if mfCgrCfg.CdreProfiles[prfl].DataUsageMultiplyFactor != 1024.0 {
|
||||
t.Error("Default instance has cdrFormat: ", mfCgrCfg.CdreProfiles[prfl].DataUsageMultiplyFactor)
|
||||
if mfCgrCfg.CdreProfiles[prfl].CostMultiplyFactor != 1024.0 {
|
||||
t.Error("Default instance has cdrFormat: ", mfCgrCfg.CdreProfiles[prfl].CostMultiplyFactor)
|
||||
}
|
||||
if len(mfCgrCfg.CdreProfiles[prfl].HeaderFields) != 0 {
|
||||
t.Error("Default instance has number of header fields: ", len(mfCgrCfg.CdreProfiles[prfl].HeaderFields))
|
||||
@@ -71,13 +68,12 @@ func TestMfCdreDefaultInstance(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestMfCdreExport1Instance(t *testing.T) {
|
||||
|
||||
prfl := "export1"
|
||||
if mfCgrCfg.CdreProfiles[prfl].CdrFormat != "csv" {
|
||||
t.Error("Export1 instance has cdrFormat: ", mfCgrCfg.CdreProfiles[prfl].CdrFormat)
|
||||
if mfCgrCfg.CdreProfiles[prfl].ExportFormat != utils.MetaFileCSV {
|
||||
t.Error("Export1 instance has cdrFormat: ", mfCgrCfg.CdreProfiles[prfl].ExportFormat)
|
||||
}
|
||||
if mfCgrCfg.CdreProfiles[prfl].DataUsageMultiplyFactor != 1.0 {
|
||||
t.Error("Export1 instance has DataUsageMultiplyFormat: ", mfCgrCfg.CdreProfiles[prfl].DataUsageMultiplyFactor)
|
||||
if mfCgrCfg.CdreProfiles[prfl].CostMultiplyFactor != 1.0 {
|
||||
t.Error("Export1 instance has DataUsageMultiplyFormat: ", mfCgrCfg.CdreProfiles[prfl].CostMultiplyFactor)
|
||||
}
|
||||
if len(mfCgrCfg.CdreProfiles[prfl].HeaderFields) != 2 {
|
||||
t.Error("Export1 instance has number of header fields: ", len(mfCgrCfg.CdreProfiles[prfl].HeaderFields))
|
||||
|
||||
@@ -57,7 +57,7 @@
|
||||
|
||||
"cdre": {
|
||||
"*default": {
|
||||
"export_dir": "/tmp/cgrates/cdr/cdrexport/csv", // path where the exported CDRs will be placed
|
||||
"export_path": "/tmp/cgrates/cdr/cdrexport/csv", // path where the exported CDRs will be placed
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
@@ -4,6 +4,11 @@
|
||||
// Used in apier_local_tests
|
||||
// Starts rater, cdrs and mediator connecting over internal channel
|
||||
|
||||
"general": {
|
||||
"log_level": 7,
|
||||
},
|
||||
|
||||
|
||||
"rals": {
|
||||
"enabled": true, // enable Rater service: <true|false>
|
||||
},
|
||||
|
||||
@@ -9,8 +9,8 @@
|
||||
|
||||
"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
|
||||
"cost_multiply_factor": 1024, // multiply data usage before export (eg: convert from KBytes to Bytes)
|
||||
"export_path": "/tmp/cgrates/cdre", // path where the exported CDRs will be placed
|
||||
},
|
||||
"export1": {
|
||||
"header_fields": [
|
||||
|
||||
@@ -71,7 +71,7 @@
|
||||
|
||||
"cdre": {
|
||||
"CDRE-FW1": {
|
||||
"cdr_format": "fwv",
|
||||
"export_format": "*file_fwv",
|
||||
"field_separator": "",
|
||||
"header_fields": [
|
||||
{"tag": "ToR", "type": "constant", "value": "10", "width": 2},
|
||||
|
||||
@@ -194,9 +194,8 @@ func (self *CdrServer) processCdr(cdr *CDR) (err error) {
|
||||
if len(self.cgrCfg.CDRSOnlineCDRExports) != 0 { // Replicate raw CDR
|
||||
self.replicateCDRs([]*CDR{cdr})
|
||||
}
|
||||
|
||||
if self.rals != nil && !cdr.Rated { // CDRs not rated will be processed by Rating
|
||||
self.deriveRateStoreStatsReplicate(cdr, self.cgrCfg.CDRSStoreCdrs, self.stats != nil, len(self.cgrCfg.CDRSOnlineCDRExports) != 0)
|
||||
go self.deriveRateStoreStatsReplicate(cdr, self.cgrCfg.CDRSStoreCdrs, self.stats != nil, len(self.cgrCfg.CDRSOnlineCDRExports) != 0)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user