Skip to content

Commit

Permalink
Renamed ERs *default folders
Browse files Browse the repository at this point in the history
  • Loading branch information
Trial97 authored and danbogos committed Jun 4, 2020
1 parent 3b4550a commit 4355b07
Show file tree
Hide file tree
Showing 26 changed files with 75 additions and 135 deletions.
2 changes: 1 addition & 1 deletion apier/v1/apier_it_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ func testApierLoadConfig(t *testing.T) {
}

func testApierCreateDirs(t *testing.T) {
for _, pathDir := range []string{cfg.CdreProfiles[utils.MetaDefault].ExportPath, "/var/log/cgrates/cdrc/in", "/var/log/cgrates/cdrc/out"} {
for _, pathDir := range []string{cfg.CdreProfiles[utils.MetaDefault].ExportPath, "/var/log/cgrates/ers/in", "/var/log/cgrates/ers/out"} {
if err := os.RemoveAll(pathDir); err != nil {
t.Fatal("Error removing folder: ", pathDir, err)
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/cgr-engine/cgr-engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -452,7 +452,7 @@ func main() {

dmService := services.NewDataDBService(cfg, connManager)
storDBService := services.NewStorDBService(cfg)
if dmService.ShouldRun() { // Some services can run without db, ie: CDRC
if dmService.ShouldRun() { // Some services can run without db, ie: ERs
if err = dmService.Start(); err != nil {
return
}
Expand Down
4 changes: 2 additions & 2 deletions config/config_defaults.go
Original file line number Diff line number Diff line change
Expand Up @@ -319,8 +319,8 @@ const CGRATES_CFG_JSON = `
"header_define_character": ":", // the starting character for header definition used in case of CSV files
"run_delay": "0", // sleep interval in seconds between consecutive runs, -1 to use automation via inotify or 0 to disable running all together
"concurrent_requests": 1024, // maximum simultaneous requests/files to process, 0 for unlimited
"source_path": "/var/spool/cgrates/cdrc/in", // read data from this path
"processed_path": "/var/spool/cgrates/cdrc/out", // move processed data here
"source_path": "/var/spool/cgrates/ers/in", // read data from this path
"processed_path": "/var/spool/cgrates/ers/out", // move processed data here
"xml_root_path": "", // path towards one event in case of XML CDRs
"tenant": "", // tenant used by import
"timezone": "", // timezone for timestamps where not specified <""|UTC|Local|$IANA_TZ_DB>
Expand Down
8 changes: 4 additions & 4 deletions config/config_it_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -465,8 +465,8 @@ func testCGRConfigReloadERs(t *testing.T) {
HeaderDefineChar: ":",
RunDelay: 0,
ConcurrentReqs: 1024,
SourcePath: "/var/spool/cgrates/cdrc/in",
ProcessedPath: "/var/spool/cgrates/cdrc/out",
SourcePath: "/var/spool/cgrates/ers/in",
ProcessedPath: "/var/spool/cgrates/ers/out",
Filters: []string{},
Flags: flagsDefault,
Fields: content,
Expand Down Expand Up @@ -858,10 +858,10 @@ func testCgrCfgV1ReloadConfigSection(t *testing.T) {
"Flags": map[string]interface{}{},
"FailedCallsPrefix": "",
"ID": "*default",
"ProcessedPath": "/var/spool/cgrates/cdrc/out",
"ProcessedPath": "/var/spool/cgrates/ers/out",
"RowLength": 0,
"RunDelay": 0,
"SourcePath": "/var/spool/cgrates/cdrc/in",
"SourcePath": "/var/spool/cgrates/ers/in",
"Tenant": nil,
"Timezone": "",
"Type": utils.META_NONE,
Expand Down
65 changes: 2 additions & 63 deletions config/config_json_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1638,67 +1638,6 @@ func TestDfSureTaxJsonCfg(t *testing.T) {
}
}

// func TestNewCgrJsonCfgFromFile(t *testing.T) {
// cgrJsonCfg, err := NewCgrJsonCfgFromFile("cfg_data.json")
// if err != nil {
// t.Error(err)
// }
// eCfg := &GeneralJsonCfg{Default_request_type: utils.StringPointer(utils.META_PSEUDOPREPAID)}
// if gCfg, err := cgrJsonCfg.GeneralJsonCfg(); err != nil {
// t.Error(err)
// } else if !reflect.DeepEqual(eCfg, gCfg) {
// t.Errorf("Expecting: %+v, received: %+v", eCfg, gCfg)
// }
// cdrFields := []*FcTemplateJsonCfg{
// {Path: utils.StringPointer(utils.ToR), Value: utils.StringPointer("~7:s/^(voice|data|sms|mms|generic)$/*$1/")},
// {Path: utils.StringPointer(utils.AnswerTime), Value: utils.StringPointer("~1")},
// {Path: utils.StringPointer(utils.Usage), Value: utils.StringPointer(`~9:s/^(\d+)$/${1}s/`)},
// }
// eCfgCdrc := []*CdrcJsonCfg{
// {
// Id: utils.StringPointer("CDRC-CSV1"),
// Enabled: utils.BoolPointer(true),
// Cdr_in_path: utils.StringPointer("/tmp/cgrates/cdrc1/in"),
// Cdr_out_path: utils.StringPointer("/tmp/cgrates/cdrc1/out"),
// Cdr_source_id: utils.StringPointer("csv1"),
// },
// {
// Id: utils.StringPointer("CDRC-CSV2"),
// Enabled: utils.BoolPointer(true),
// Run_delay: utils.IntPointer(1),
// Cdr_in_path: utils.StringPointer("/tmp/cgrates/cdrc2/in"),
// Cdr_out_path: utils.StringPointer("/tmp/cgrates/cdrc2/out"),
// Cdr_source_id: utils.StringPointer("csv2"),
// Fields: &cdrFields,
// },
// }
// if cfg, err := cgrJsonCfg.CdrcJsonCfg(); err != nil {
// t.Error(err)
// } else if !reflect.DeepEqual(eCfgCdrc, cfg) {
// t.Errorf("Expecting: %+v \n received: %+v", utils.ToIJSON(eCfgCdrc), utils.ToIJSON(cfg))
// }
// eCfgSmFs := &FreeswitchAgentJsonCfg{
// Enabled: utils.BoolPointer(true),
// Event_socket_conns: &[]*FsConnJsonCfg{
// {
// Address: utils.StringPointer("1.2.3.4:8021"),
// Password: utils.StringPointer("ClueCon"),
// Reconnects: utils.IntPointer(5),
// },
// {
// Address: utils.StringPointer("2.3.4.5:8021"),
// Password: utils.StringPointer("ClueCon"),
// Reconnects: utils.IntPointer(5),
// },
// },
// }
// if smFsCfg, err := cgrJsonCfg.FreeswitchAgentJsonCfg(); err != nil {
// t.Error(err)
// } else if !reflect.DeepEqual(eCfgSmFs, smFsCfg) {
// t.Error("Received: ", smFsCfg)
// }
// }

func TestDfHttpJsonCfg(t *testing.T) {
eCfg := &HTTPJsonCfg{
Json_rpc_url: utils.StringPointer("/jsonrpc"),
Expand Down Expand Up @@ -1854,8 +1793,8 @@ func TestDfEventReaderCfg(t *testing.T) {
Header_define_character: utils.StringPointer(":"),
Run_delay: utils.StringPointer("0"),
Concurrent_requests: utils.IntPointer(1024),
Source_path: utils.StringPointer("/var/spool/cgrates/cdrc/in"),
Processed_path: utils.StringPointer("/var/spool/cgrates/cdrc/out"),
Source_path: utils.StringPointer("/var/spool/cgrates/ers/in"),
Processed_path: utils.StringPointer("/var/spool/cgrates/ers/out"),
Xml_root_path: utils.StringPointer(utils.EmptyString),
Tenant: utils.StringPointer(utils.EmptyString),
Timezone: utils.StringPointer(utils.EmptyString),
Expand Down
8 changes: 4 additions & 4 deletions config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1816,8 +1816,8 @@ func TestCgrCdfEventReader(t *testing.T) {
HeaderDefineChar: ":",
RunDelay: time.Duration(0),
ConcurrentReqs: 1024,
SourcePath: "/var/spool/cgrates/cdrc/in",
ProcessedPath: "/var/spool/cgrates/cdrc/out",
SourcePath: "/var/spool/cgrates/ers/in",
ProcessedPath: "/var/spool/cgrates/ers/out",
XmlRootPath: utils.HierarchyPath{utils.EmptyString},
Tenant: nil,
Timezone: utils.EmptyString,
Expand Down Expand Up @@ -2110,8 +2110,8 @@ func TestCgrCfgEventReaderDefault(t *testing.T) {
HeaderDefineChar: ":",
RunDelay: time.Duration(0),
ConcurrentReqs: 1024,
SourcePath: "/var/spool/cgrates/cdrc/in",
ProcessedPath: "/var/spool/cgrates/cdrc/out",
SourcePath: "/var/spool/cgrates/ers/in",
ProcessedPath: "/var/spool/cgrates/ers/out",
XmlRootPath: utils.HierarchyPath{utils.EmptyString},
Tenant: nil,
Timezone: utils.EmptyString,
Expand Down
12 changes: 6 additions & 6 deletions config/erscfg_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,8 @@ func TestEventReaderLoadFromJSON(t *testing.T) {
HeaderDefineChar: ":",
RunDelay: time.Duration(0),
ConcurrentReqs: 1024,
SourcePath: "/var/spool/cgrates/cdrc/in",
ProcessedPath: "/var/spool/cgrates/cdrc/out",
SourcePath: "/var/spool/cgrates/ers/in",
ProcessedPath: "/var/spool/cgrates/ers/out",
XmlRootPath: utils.HierarchyPath{utils.EmptyString},
Tenant: nil,
Timezone: utils.EmptyString,
Expand Down Expand Up @@ -249,8 +249,8 @@ func TestEventReaderSameID(t *testing.T) {
HeaderDefineChar: ":",
RunDelay: time.Duration(0),
ConcurrentReqs: 1024,
SourcePath: "/var/spool/cgrates/cdrc/in",
ProcessedPath: "/var/spool/cgrates/cdrc/out",
SourcePath: "/var/spool/cgrates/ers/in",
ProcessedPath: "/var/spool/cgrates/ers/out",
XmlRootPath: utils.HierarchyPath{utils.EmptyString},
Tenant: nil,
Timezone: utils.EmptyString,
Expand Down Expand Up @@ -377,11 +377,11 @@ func TestERsCfgAsMapInterface(t *testing.T) {
"flags": map[string][]interface{}{},
"id": "*default",
"partial_record_cache": "0",
"processed_path": "/var/spool/cgrates/cdrc/out",
"processed_path": "/var/spool/cgrates/ers/out",
"row_length": 0,
"run_delay": "0",
"partial_cache_expiry_action": "",
"source_path": "/var/spool/cgrates/cdrc/in",
"source_path": "/var/spool/cgrates/ers/in",
"tenant": "",
"timezone": "",
"xml_root_path": []string{""},
Expand Down
2 changes: 1 addition & 1 deletion config/xmldp.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ func (xP *XmlProvider) RemoteHost() net.Addr {

// ElementText will process the node to extract the elementName's text out of it (only first one found)
// returns utils.ErrNotFound if the element is not found in the node
// Make the method exportable until we remove the cdrc
// Make the method exportable until we remove the ers
func ElementText(xmlElement *xmlquery.Node, elmntPath string) (string, error) {
elmnt := xmlquery.FindOne(xmlElement, elmntPath)
if elmnt == nil {
Expand Down
7 changes: 4 additions & 3 deletions data/conf/cgrates/cgrates.json
Original file line number Diff line number Diff line change
Expand Up @@ -295,10 +295,11 @@
// "type": "*none", // reader type <*file_csv>
// "row_length" : 0, // Number of fields from csv file
// "field_separator": ",", // separator used in case of csv files
// "header_define_character": ":", // the starting character for header definition used in case of CSV files
// "run_delay": "0", // sleep interval in seconds between consecutive runs, -1 to use automation via inotify or 0 to disable running all together
// "concurrent_requests": 1024, // maximum simultaneous requests/files to process, 0 for unlimited
// "source_path": "/var/spool/cgrates/cdrc/in", // read data from this path
// "processed_path": "/var/spool/cgrates/cdrc/out", // move processed data here
// "source_path": "/var/spool/cgrates/ers/in", // read data from this path
// "processed_path": "/var/spool/cgrates/ers/out", // move processed data here
// "xml_root_path": "", // path towards one event in case of XML CDRs
// "tenant": "", // tenant used by import
// "timezone": "", // timezone for timestamps where not specified <""|UTC|Local|$IANA_TZ_DB>
Expand Down Expand Up @@ -357,7 +358,7 @@
// {"tag": "SetupTime", "path": "*exp.SetupTime", "type": "*variable", "value": "~*req.SetupTime", "layout": "2006-01-02T15:04:05Z07:00"},
// {"tag": "AnswerTime", "path": "*exp.AnswerTime", "type": "*variable", "value": "~*req.AnswerTime", "layout": "2006-01-02T15:04:05Z07:00"},
// {"tag": "Usage", "path": "*exp.Usage", "type": "*variable", "value": "~*req.Usage"},
// {"tag": "Cost", "path": "*exp.Cost", "type": "*variable", "value": "~*req.Cost", "rounding_decimals": 4},
// {"tag": "Cost", "path": "*exp.Cost", "type": "*variable", "value": "~*req.Cost{*round:4}"},
// ],
// },
// ],
Expand Down
16 changes: 8 additions & 8 deletions data/tutorial_tests/asterisk_ari/cgrates/etc/init.d/cgrates
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ STACKTRACE=$RUNDIR/$NAME.strace
ENABLE=true
DAEMON_OPTS="-config_path=$TUTFOLDER/etc/cgrates"
CDREDIR=$TMP_DIR/cdre
CDRCINDIR=$TMP_DIR/cdrc/in
CDRCOUTDIR=$TMP_DIR/cdrc/out
ERSINDIR=$TMP_DIR/ers/in
ERSOUTDIR=$TMP_DIR/ers/out

# Exit if the package is not installed
[ -x "$DAEMON" ] || exit 0
Expand All @@ -55,12 +55,12 @@ if [ ! -d $RUNDIR ]; then
touch $STACKTRACE
chown -R $USER:$GROUP $RUNDIR
fi
# Install the cdrc folder
if [ ! -d $CDRCINDIR ]; then
mkdir -p $CDRCINDIR
chown $USER:$GROUP $CDRCINDIR
mkdir -p $CDRCOUTDIR
chown $USER:$GROUP $CDRCOUTDIR
# Install the ers folder
if [ ! -d $ERSINDIR ]; then
mkdir -p $ERSINDIR
chown $USER:$GROUP $ERSINDIR
mkdir -p $ERSOUTDIR
chown $USER:$GROUP $ERSOUTDIR
fi
# Install the cdre folder
if [ ! -d $CDREDIR ]; then
Expand Down
16 changes: 8 additions & 8 deletions data/tutorial_tests/fs_evsock/cgrates/etc/init.d/cgrates
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ STACKTRACE=$RUNDIR/$NAME.strace
ENABLE=true
DAEMON_OPTS="-config_path=$TUTFOLDER/etc/cgrates"
CDREDIR=$TMP_DIR/cdre
CDRCINDIR=$TMP_DIR/cdrc/in
CDRCOUTDIR=$TMP_DIR/cdrc/out
ERSINDIR=$TMP_DIR/ers/in
ERSOUTDIR=$TMP_DIR/ers/out

# Exit if the package is not installed
[ -x "$DAEMON" ] || exit 0
Expand All @@ -55,12 +55,12 @@ if [ ! -d $RUNDIR ]; then
touch $STACKTRACE
chown -R $USER:$GROUP $RUNDIR
fi
# Install the cdrc folder
if [ ! -d $CDRCINDIR ]; then
mkdir -p $CDRCINDIR
chown $USER:$GROUP $CDRCINDIR
mkdir -p $CDRCOUTDIR
chown $USER:$GROUP $CDRCOUTDIR
# Install the ers folder
if [ ! -d $ERSINDIR ]; then
mkdir -p $ERSINDIR
chown $USER:$GROUP $ERSINDIR
mkdir -p $ERSOUTDIR
chown $USER:$GROUP $ERSOUTDIR
fi
# Install the cdre folder
if [ ! -d $CDREDIR ]; then
Expand Down
16 changes: 8 additions & 8 deletions data/tutorials/asterisk_ari/cgrates/etc/init.d/cgrates
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ STACKTRACE=$RUNDIR/$NAME.strace
ENABLE=true
DAEMON_OPTS="-config_path=$TUTFOLDER/etc/cgrates"
CDREDIR=$TMP_DIR/cdre
CDRCINDIR=$TMP_DIR/cdrc/in
CDRCOUTDIR=$TMP_DIR/cdrc/out
ERSINDIR=$TMP_DIR/ers/in
ERSOUTDIR=$TMP_DIR/ers/out

# Exit if the package is not installed
[ -x "$DAEMON" ] || exit 0
Expand All @@ -55,12 +55,12 @@ if [ ! -d $RUNDIR ]; then
touch $STACKTRACE
chown -R $USER:$GROUP $RUNDIR
fi
# Install the cdrc folder
if [ ! -d $CDRCINDIR ]; then
mkdir -p $CDRCINDIR
chown $USER:$GROUP $CDRCINDIR
mkdir -p $CDRCOUTDIR
chown $USER:$GROUP $CDRCOUTDIR
# Install the ers folder
if [ ! -d $ERSINDIR ]; then
mkdir -p $ERSINDIR
chown $USER:$GROUP $ERSINDIR
mkdir -p $ERSOUTDIR
chown $USER:$GROUP $ERSOUTDIR
fi
# Install the cdre folder
if [ ! -d $CDREDIR ]; then
Expand Down
16 changes: 8 additions & 8 deletions data/tutorials/fs_evsock/cgrates/etc/init.d/cgrates
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ STACKTRACE=$RUNDIR/$NAME.strace
ENABLE=true
DAEMON_OPTS="-config_path=$TUTFOLDER/etc/cgrates"
CDREDIR=$TMP_DIR/cdre
CDRCINDIR=$TMP_DIR/cdrc/in
CDRCOUTDIR=$TMP_DIR/cdrc/out
ERSINDIR=$TMP_DIR/ers/in
ERSOUTDIR=$TMP_DIR/ers/out

# Exit if the package is not installed
[ -x "$DAEMON" ] || exit 0
Expand All @@ -55,12 +55,12 @@ if [ ! -d $RUNDIR ]; then
touch $STACKTRACE
chown -R $USER:$GROUP $RUNDIR
fi
# Install the cdrc folder
if [ ! -d $CDRCINDIR ]; then
mkdir -p $CDRCINDIR
chown $USER:$GROUP $CDRCINDIR
mkdir -p $CDRCOUTDIR
chown $USER:$GROUP $CDRCOUTDIR
# Install the ers folder
if [ ! -d $ERSINDIR ]; then
mkdir -p $ERSINDIR
chown $USER:$GROUP $ERSINDIR
mkdir -p $ERSOUTDIR
chown $USER:$GROUP $ERSOUTDIR
fi
# Install the cdre folder
if [ ! -d $CDREDIR ]; then
Expand Down
2 changes: 1 addition & 1 deletion engine/cdr.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ type CDR struct {
Usage time.Duration // event usage information (eg: in case of tor=*voice this will represent the total duration of a call)
ExtraFields map[string]string // Extra fields to be stored in CDR
ExtraInfo string // Container for extra information related to this CDR, eg: populated with error reason in case of error on calculation
Partial bool // Used for partial record processing by CDRC
Partial bool // Used for partial record processing by ERs
PreRated bool // Mark the CDR as rated so we do not process it during rating
CostSource string // The source of this cost
Cost float64 //
Expand Down
3 changes: 3 additions & 0 deletions ers/ers.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,9 @@ func (erS *ERService) ListenAndServe(cfgRldChan chan struct{}) (err error) {
continue
}
}
if erS.cfg.ERsCfg().Readers[rdrIdx].Type == utils.META_NONE { // ignore *default reader
continue
}
if err := erS.addReader(id, rdrIdx); err != nil {
utils.Logger.Crit(
fmt.Sprintf("<%s> adding reader <%s> got error: <%s>",
Expand Down
2 changes: 1 addition & 1 deletion ers/filecsv_it_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ func testCsvITLoadTPFromFolder(t *testing.T) {
time.Sleep(500 * time.Millisecond)
}

// The default scenario, out of cdrc defined in .cfg file
// The default scenario, out of ers defined in .cfg file
func testCsvITHandleCdr1File(t *testing.T) {
fileName := "file1.csv"
tmpFilePath := path.Join("/tmp", fileName)
Expand Down
2 changes: 1 addition & 1 deletion ers/filefwv_it_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ CDR0000330 0 20120710070434000123123458 0040123232350
TRL0001DDB ABC Some Connect A.B. DDB-Some-10022-20120711-309.CDR 0003090000003300000030550000000001000000000100Y
`

// The default scenario, out of cdrc defined in .cfg file
// The default scenario, out of ers defined in .cfg file
func testFWVITHandleCdr1File(t *testing.T) {
fileName := "file1.fwv"
tmpFilePath := path.Join("/tmp", fileName)
Expand Down
2 changes: 1 addition & 1 deletion ers/filejson_it_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ func testJSONAddData(t *testing.T) {
}
}

// The default scenario, out of cdrc defined in .cfg file
// The default scenario, out of ers defined in .cfg file
func testJSONHandleFile(t *testing.T) {
fileName := "file1.json"
tmpFilePath := path.Join("/tmp", fileName)
Expand Down
2 changes: 1 addition & 1 deletion ers/filexml_it_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ var cdrXmlBroadsoft = `<?xml version="1.0" encoding="ISO-8859-1"?>
</cdrData>
</broadWorksCDR>`

// The default scenario, out of cdrc defined in .cfg file
// The default scenario, out of ers defined in .cfg file
func testXMLITHandleCdr1File(t *testing.T) {
fileName := "file1.xml"
tmpFilePath := path.Join("/tmp", fileName)
Expand Down
Loading

0 comments on commit 4355b07

Please sign in to comment.