From 23bd9721fd7145af218713d84b9a64c8e214b0b3 Mon Sep 17 00:00:00 2001 From: DanB Date: Mon, 10 Jun 2019 12:14:55 +0200 Subject: [PATCH] Updating cdrc integration tests with the new settings --- cdrc/cdrc.go | 5 +- cdrc/csv_it_test.go | 13 +++-- cdrc/flatstore_it_test.go | 26 ++++----- cdrc/fwv_it_test.go | 55 ++++++++++--------- cdrc/partialcsv_it_test.go | 13 +++-- cdrc/xml_it_test.go | 54 ++++++++++++------ config/config_defaults.go | 2 +- data/conf/samples/cdrc_partcsv/cgrates.json | 10 ++-- data/conf/samples/cdrccsv/cgrates.json | 24 ++++---- data/conf/samples/cdrcflatstore/cgrates.json | 6 +- data/conf/samples/cdrcfwv/cgrates.json | 6 +- .../samples/cdrcfwvwithfilter/cgrates.json | 10 ++-- data/conf/samples/cdrcxml/cgrates.json | 8 +-- .../samples/cdrcxmlwithfilter/cgrates.json | 38 ++++++------- .../conf/samples/fscsv/freeswitch_csvcdr.json | 4 +- .../multiplecdrc/multiplecdrc_fwexport.json | 12 ++-- utils/consts.go | 2 +- 17 files changed, 157 insertions(+), 131 deletions(-) diff --git a/cdrc/cdrc.go b/cdrc/cdrc.go index c6f7c2d30..4b17433c1 100644 --- a/cdrc/cdrc.go +++ b/cdrc/cdrc.go @@ -56,7 +56,6 @@ Parameters specific per config instance: func NewCdrc(cdrcCfgs []*config.CdrcCfg, httpSkipTlsCheck bool, cdrs rpcclient.RpcClientConnection, closeChan chan struct{}, dfltTimezone string, roundDecimals int, filterS *engine.FilterS) (*Cdrc, error) { cdrcCfg := cdrcCfgs[0] - cdrc := &Cdrc{ httpSkipTlsCheck: httpSkipTlsCheck, cdrcCfgs: cdrcCfgs, @@ -193,10 +192,10 @@ func (self *Cdrc) processFile(filePath string) error { recordsProcessor = NewCsvRecordsProcessor(csvReader, self.timezone, fn, self.dfltCdrcCfg, self.cdrcCfgs, self.httpSkipTlsCheck, self.unpairedRecordsCache, self.partialRecordsCache, self.dfltCdrcCfg.CacheDumpFields, self.filterS) - case utils.FWV: + case utils.MetaFileFWV: recordsProcessor = NewFwvRecordsProcessor(file, self.dfltCdrcCfg, self.cdrcCfgs, self.httpClient, self.httpSkipTlsCheck, self.timezone, self.filterS) - case utils.XML: + case utils.MetaFileXML: if recordsProcessor, err = NewXMLRecordsProcessor(file, self.dfltCdrcCfg.CDRRootPath, self.timezone, self.httpSkipTlsCheck, self.cdrcCfgs, self.filterS); err != nil { return err diff --git a/cdrc/csv_it_test.go b/cdrc/csv_it_test.go index 319c7049b..a7639cc7c 100644 --- a/cdrc/csv_it_test.go +++ b/cdrc/csv_it_test.go @@ -90,7 +90,10 @@ func TestCsvITResetDataDb(t *testing.T) { func TestCsvITCreateCdrDirs(t *testing.T) { for _, cdrcProfiles := range csvCfg.CdrcProfiles { for _, cdrcInst := range cdrcProfiles { - for _, dir := range []string{cdrcInst.CdrInDir, cdrcInst.CdrOutDir} { + if !cdrcInst.Enabled { + continue + } + for _, dir := range []string{cdrcInst.CDRInPath, cdrcInst.CDROutPath} { if err := os.RemoveAll(dir); err != nil { t.Fatal("Error removing folder: ", dir, err) } @@ -197,7 +200,7 @@ func TestCsvIT2InitCdrDb(t *testing.T) { func TestCsvIT2CreateCdrDirs(t *testing.T) { for _, cdrcProfiles := range csvCfg.CdrcProfiles { for _, cdrcInst := range cdrcProfiles { - for _, dir := range []string{cdrcInst.CdrInDir, cdrcInst.CdrOutDir} { + for _, dir := range []string{cdrcInst.CDRInPath, cdrcInst.CDROutPath} { if err := os.RemoveAll(dir); err != nil { t.Fatal("Error removing folder: ", dir, err) } @@ -289,7 +292,7 @@ func TestCsvIT3InitCdrDb(t *testing.T) { func TestCsvIT3CreateCdrDirs(t *testing.T) { for _, cdrcProfiles := range csvCfg.CdrcProfiles { for _, cdrcInst := range cdrcProfiles { - for _, dir := range []string{cdrcInst.CdrInDir, cdrcInst.CdrOutDir} { + for _, dir := range []string{cdrcInst.CDRInPath, cdrcInst.CDROutPath} { if err := os.RemoveAll(dir); err != nil { t.Fatal("Error removing folder: ", dir, err) } @@ -376,7 +379,7 @@ func TestCsvIT4InitCdrDb(t *testing.T) { func TestCsvIT4CreateCdrDirs(t *testing.T) { for _, cdrcProfiles := range csvCfg.CdrcProfiles { for _, cdrcInst := range cdrcProfiles { - for _, dir := range []string{cdrcInst.CdrInDir, cdrcInst.CdrOutDir} { + for _, dir := range []string{cdrcInst.CDRInPath, cdrcInst.CDROutPath} { if err := os.RemoveAll(dir); err != nil { t.Fatal("Error removing folder: ", dir, err) } @@ -463,7 +466,7 @@ func TestCsvIT5InitCdrDb(t *testing.T) { func TestCsvIT5CreateCdrDirs(t *testing.T) { for _, cdrcProfiles := range csvCfg.CdrcProfiles { for _, cdrcInst := range cdrcProfiles { - for _, dir := range []string{cdrcInst.CdrInDir, cdrcInst.CdrOutDir} { + for _, dir := range []string{cdrcInst.CDRInPath, cdrcInst.CDROutPath} { if err := os.RemoveAll(dir); err != nil { t.Fatal("Error removing folder: ", dir, err) } diff --git a/cdrc/flatstore_it_test.go b/cdrc/flatstore_it_test.go index 85a5ee9fa..94af7ee31 100644 --- a/cdrc/flatstore_it_test.go +++ b/cdrc/flatstore_it_test.go @@ -90,17 +90,17 @@ func TestFlatstoreitCreateCdrFiles(t *testing.T) { flatstoreCdrcCfg = cdrcCfg } } - if err := os.RemoveAll(flatstoreCdrcCfg.CdrInDir); err != nil { - t.Fatal("Error removing folder: ", flatstoreCdrcCfg.CdrInDir, err) + if err := os.RemoveAll(flatstoreCdrcCfg.CDRInPath); err != nil { + t.Fatal("Error removing folder: ", flatstoreCdrcCfg.CDRInPath, err) } - if err := os.MkdirAll(flatstoreCdrcCfg.CdrInDir, 0755); err != nil { - t.Fatal("Error creating folder: ", flatstoreCdrcCfg.CdrInDir, err) + if err := os.MkdirAll(flatstoreCdrcCfg.CDRInPath, 0755); err != nil { + t.Fatal("Error creating folder: ", flatstoreCdrcCfg.CDRInPath, err) } - if err := os.RemoveAll(flatstoreCdrcCfg.CdrOutDir); err != nil { - t.Fatal("Error removing folder: ", flatstoreCdrcCfg.CdrOutDir, err) + if err := os.RemoveAll(flatstoreCdrcCfg.CDROutPath); err != nil { + t.Fatal("Error removing folder: ", flatstoreCdrcCfg.CDROutPath, err) } - if err := os.MkdirAll(flatstoreCdrcCfg.CdrOutDir, 0755); err != nil { - t.Fatal("Error creating folder: ", flatstoreCdrcCfg.CdrOutDir, err) + if err := os.MkdirAll(flatstoreCdrcCfg.CDROutPath, 0755); err != nil { + t.Fatal("Error creating folder: ", flatstoreCdrcCfg.CDROutPath, err) } } @@ -134,22 +134,22 @@ func TestFlatstoreitProcessFiles(t *testing.T) { } //Rename(oldpath, newpath string) for _, fileName := range []string{"acc_1.log", "missed_calls_1.log", "acc_2.log", "acc_3.log"} { - if err := os.Rename(path.Join("/tmp", fileName), path.Join(flatstoreCdrcCfg.CdrInDir, fileName)); err != nil { + if err := os.Rename(path.Join("/tmp", fileName), path.Join(flatstoreCdrcCfg.CDRInPath, fileName)); err != nil { t.Fatal(err) } } time.Sleep(time.Duration(3) * time.Second) // Give time for processing to happen and the .unparired file to be written - filesInDir, _ := ioutil.ReadDir(flatstoreCdrcCfg.CdrInDir) + filesInDir, _ := ioutil.ReadDir(flatstoreCdrcCfg.CDRInPath) if len(filesInDir) != 0 { t.Errorf("Files in cdrcInDir: %+v", filesInDir) } - filesOutDir, _ := ioutil.ReadDir(flatstoreCdrcCfg.CdrOutDir) + filesOutDir, _ := ioutil.ReadDir(flatstoreCdrcCfg.CDROutPath) if len(filesOutDir) != 5 { f := []string{} for _, s := range filesOutDir { f = append(f, s.Name()) t.Errorf("File %s:", s.Name()) - if partContent, err := ioutil.ReadFile(path.Join(flatstoreCdrcCfg.CdrOutDir, s.Name())); err != nil { + if partContent, err := ioutil.ReadFile(path.Join(flatstoreCdrcCfg.CDROutPath, s.Name())); err != nil { t.Error(err) } else { t.Errorf("%s", partContent) @@ -160,7 +160,7 @@ func TestFlatstoreitProcessFiles(t *testing.T) { return } ePartContent := "INVITE|2daec40c|548625ac|dd0c4c617a9919d29a6175cdff223a9p@0:0:0:0:0:0:0:0|200|OK|1436454408|*prepaid|1001|1002||3401:2069362475\n" - if partContent, err := ioutil.ReadFile(path.Join(flatstoreCdrcCfg.CdrOutDir, "acc_3.log.unpaired")); err != nil { + if partContent, err := ioutil.ReadFile(path.Join(flatstoreCdrcCfg.CDROutPath, "acc_3.log.unpaired")); err != nil { t.Error(err) } else if (ePartContent) != (string(partContent)) { t.Errorf("Expecting:\n%s\nReceived:\n%s", ePartContent, string(partContent)) diff --git a/cdrc/fwv_it_test.go b/cdrc/fwv_it_test.go index 558e426f3..f0fa380c6 100644 --- a/cdrc/fwv_it_test.go +++ b/cdrc/fwv_it_test.go @@ -96,7 +96,10 @@ func TestFwvitCreateCdrFiles(t *testing.T) { } for _, cdrcProfiles := range fwvCfg.CdrcProfiles { for _, cdrcInst := range cdrcProfiles { - for _, dir := range []string{cdrcInst.CdrInDir, cdrcInst.CdrOutDir} { + if !cdrcInst.Enabled { + continue + } + for _, dir := range []string{cdrcInst.CDRInPath, cdrcInst.CDROutPath} { if err := os.RemoveAll(dir); err != nil { t.Fatal("Error removing folder: ", dir, err) } @@ -142,15 +145,15 @@ func TestFwvitProcessFiles(t *testing.T) { if err := ioutil.WriteFile(path.Join("/tmp", fileName), []byte(FW_CDR_FILE1), 0755); err != nil { t.Fatal(err.Error()) } - if err := os.Rename(path.Join("/tmp", fileName), path.Join(fwvCdrcCfg.CdrInDir, fileName)); err != nil { + if err := os.Rename(path.Join("/tmp", fileName), path.Join(fwvCdrcCfg.CDRInPath, fileName)); err != nil { t.Fatal(err) } time.Sleep(time.Duration(1) * time.Second) - filesInDir, _ := ioutil.ReadDir(fwvCdrcCfg.CdrInDir) + filesInDir, _ := ioutil.ReadDir(fwvCdrcCfg.CDRInPath) if len(filesInDir) != 0 { t.Errorf("Files in cdrcInDir: %d", len(filesInDir)) } - filesOutDir, _ := ioutil.ReadDir(fwvCdrcCfg.CdrOutDir) + filesOutDir, _ := ioutil.ReadDir(fwvCdrcCfg.CDROutPath) if len(filesOutDir) != 1 { t.Errorf("In CdrcOutDir, expecting 1 files, got: %d", len(filesOutDir)) } @@ -195,17 +198,17 @@ func TestFwvit2CreateCdrFiles(t *testing.T) { fwvCdrcCfg = cdrcCfg } } - if err := os.RemoveAll(fwvCdrcCfg.CdrInDir); err != nil { - t.Fatal("Error removing folder: ", fwvCdrcCfg.CdrInDir, err) + if err := os.RemoveAll(fwvCdrcCfg.CDRInPath); err != nil { + t.Fatal("Error removing folder: ", fwvCdrcCfg.CDRInPath, err) } - if err := os.MkdirAll(fwvCdrcCfg.CdrInDir, 0755); err != nil { - t.Fatal("Error creating folder: ", fwvCdrcCfg.CdrInDir, err) + if err := os.MkdirAll(fwvCdrcCfg.CDRInPath, 0755); err != nil { + t.Fatal("Error creating folder: ", fwvCdrcCfg.CDRInPath, err) } - if err := os.RemoveAll(fwvCdrcCfg.CdrOutDir); err != nil { - t.Fatal("Error removing folder: ", fwvCdrcCfg.CdrOutDir, err) + if err := os.RemoveAll(fwvCdrcCfg.CDROutPath); err != nil { + t.Fatal("Error removing folder: ", fwvCdrcCfg.CDROutPath, err) } - if err := os.MkdirAll(fwvCdrcCfg.CdrOutDir, 0755); err != nil { - t.Fatal("Error creating folder: ", fwvCdrcCfg.CdrOutDir, err) + if err := os.MkdirAll(fwvCdrcCfg.CDROutPath, 0755); err != nil { + t.Fatal("Error creating folder: ", fwvCdrcCfg.CDROutPath, err) } } @@ -236,15 +239,15 @@ func TestFwvit2ProcessFiles(t *testing.T) { if err := ioutil.WriteFile(path.Join("/tmp", fileName), []byte(FW_CDR_FILE1), 0644); err != nil { t.Fatal(err.Error()) } - if err := os.Rename(path.Join("/tmp", fileName), path.Join(fwvCdrcCfg.CdrInDir, fileName)); err != nil { + if err := os.Rename(path.Join("/tmp", fileName), path.Join(fwvCdrcCfg.CDRInPath, fileName)); err != nil { t.Fatal(err) } time.Sleep(time.Duration(1) * time.Second) - filesInDir, _ := ioutil.ReadDir(fwvCdrcCfg.CdrInDir) + filesInDir, _ := ioutil.ReadDir(fwvCdrcCfg.CDRInPath) if len(filesInDir) != 0 { t.Errorf("Files in cdrcInDir: %d", len(filesInDir)) } - filesOutDir, _ := ioutil.ReadDir(fwvCdrcCfg.CdrOutDir) + filesOutDir, _ := ioutil.ReadDir(fwvCdrcCfg.CDROutPath) if len(filesOutDir) != 1 { t.Errorf("In CdrcOutDir, expecting 1 files, got: %d", len(filesOutDir)) } @@ -291,17 +294,17 @@ func TestFwvit3CreateCdrFiles(t *testing.T) { fwvCdrcCfg = cdrcCfg } } - if err := os.RemoveAll(fwvCdrcCfg.CdrInDir); err != nil { - t.Fatal("Error removing folder: ", fwvCdrcCfg.CdrInDir, err) + if err := os.RemoveAll(fwvCdrcCfg.CDRInPath); err != nil { + t.Fatal("Error removing folder: ", fwvCdrcCfg.CDRInPath, err) } - if err := os.MkdirAll(fwvCdrcCfg.CdrInDir, 0755); err != nil { - t.Fatal("Error creating folder: ", fwvCdrcCfg.CdrInDir, err) + if err := os.MkdirAll(fwvCdrcCfg.CDRInPath, 0755); err != nil { + t.Fatal("Error creating folder: ", fwvCdrcCfg.CDRInPath, err) } - if err := os.RemoveAll(fwvCdrcCfg.CdrOutDir); err != nil { - t.Fatal("Error removing folder: ", fwvCdrcCfg.CdrOutDir, err) + if err := os.RemoveAll(fwvCdrcCfg.CDROutPath); err != nil { + t.Fatal("Error removing folder: ", fwvCdrcCfg.CDROutPath, err) } - if err := os.MkdirAll(fwvCdrcCfg.CdrOutDir, 0755); err != nil { - t.Fatal("Error creating folder: ", fwvCdrcCfg.CdrOutDir, err) + if err := os.MkdirAll(fwvCdrcCfg.CDROutPath, 0755); err != nil { + t.Fatal("Error creating folder: ", fwvCdrcCfg.CDROutPath, err) } } @@ -345,15 +348,15 @@ func TestFwvit3ProcessFiles(t *testing.T) { if err := ioutil.WriteFile(path.Join("/tmp", fileName), []byte(FW_CDR_FILE1), 0644); err != nil { t.Fatal(err.Error()) } - if err := os.Rename(path.Join("/tmp", fileName), path.Join(fwvCdrcCfg.CdrInDir, fileName)); err != nil { + if err := os.Rename(path.Join("/tmp", fileName), path.Join(fwvCdrcCfg.CDRInPath, fileName)); err != nil { t.Fatal(err) } time.Sleep(time.Duration(1) * time.Second) - filesInDir, _ := ioutil.ReadDir(fwvCdrcCfg.CdrInDir) + filesInDir, _ := ioutil.ReadDir(fwvCdrcCfg.CDRInPath) if len(filesInDir) != 0 { t.Errorf("Files in cdrcInDir: %d", len(filesInDir)) } - filesOutDir, _ := ioutil.ReadDir(fwvCdrcCfg.CdrOutDir) + filesOutDir, _ := ioutil.ReadDir(fwvCdrcCfg.CDROutPath) if len(filesOutDir) != 1 { t.Errorf("In CdrcOutDir, expecting 1 files, got: %d", len(filesOutDir)) } diff --git a/cdrc/partialcsv_it_test.go b/cdrc/partialcsv_it_test.go index 333bfae78..63bc4dc8d 100644 --- a/cdrc/partialcsv_it_test.go +++ b/cdrc/partialcsv_it_test.go @@ -75,12 +75,15 @@ func TestPartcsvITResetDataDb(t *testing.T) { func TestPartcsvITCreateCdrDirs(t *testing.T) { for path, cdrcProfiles := range partcsvCfg.CdrcProfiles { for _, cdrcInst := range cdrcProfiles { - if path == "/tmp/cdrctests/partcsv1/in" { - partcsvCDRCDirIn1, partcsvCDRCDirOut1 = cdrcInst.CdrInDir, cdrcInst.CdrOutDir - } else if path == "/tmp/cdrctests/partcsv2/in" { - partcsvCDRCDirIn2, partcsvCDRCDirOut2 = cdrcInst.CdrInDir, cdrcInst.CdrOutDir + if !cdrcInst.Enabled { + continue } - for _, dir := range []string{cdrcInst.CdrInDir, cdrcInst.CdrOutDir} { + if path == "/tmp/cdrctests/partcsv1/in" { + partcsvCDRCDirIn1, partcsvCDRCDirOut1 = cdrcInst.CDRInPath, cdrcInst.CDROutPath + } else if path == "/tmp/cdrctests/partcsv2/in" { + partcsvCDRCDirIn2, partcsvCDRCDirOut2 = cdrcInst.CDRInPath, cdrcInst.CDROutPath + } + for _, dir := range []string{cdrcInst.CDRInPath, cdrcInst.CDROutPath} { if err := os.RemoveAll(dir); err != nil { t.Fatal("Error removing folder: ", dir, err) } diff --git a/cdrc/xml_it_test.go b/cdrc/xml_it_test.go index 3179d9152..3b19c4800 100644 --- a/cdrc/xml_it_test.go +++ b/cdrc/xml_it_test.go @@ -65,7 +65,10 @@ func TestXmlITResetDataDb(t *testing.T) { func TestXmlITCreateCdrDirs(t *testing.T) { for _, cdrcProfiles := range xmlCfg.CdrcProfiles { for _, cdrcInst := range cdrcProfiles { - for _, dir := range []string{cdrcInst.CdrInDir, cdrcInst.CdrOutDir} { + if !cdrcInst.Enabled { + continue + } + for _, dir := range []string{cdrcInst.CDRInPath, cdrcInst.CDROutPath} { if err := os.RemoveAll(dir); err != nil { t.Fatal("Error removing folder: ", dir, err) } @@ -74,8 +77,8 @@ func TestXmlITCreateCdrDirs(t *testing.T) { } } if cdrcInst.ID == "XMLit1" { // Initialize the folders to check later - xmlPathIn1 = cdrcInst.CdrInDir - xmlPathOut1 = cdrcInst.CdrOutDir + xmlPathIn1 = cdrcInst.CDRInPath + xmlPathOut1 = cdrcInst.CDROutPath } } } @@ -157,7 +160,10 @@ func TestXmlIT2InitCdrDb(t *testing.T) { func TestXmlIT2CreateCdrDirs(t *testing.T) { for _, cdrcProfiles := range xmlCfg.CdrcProfiles { for _, cdrcInst := range cdrcProfiles { - for _, dir := range []string{cdrcInst.CdrInDir, cdrcInst.CdrOutDir} { + if !cdrcInst.Enabled { + continue + } + for _, dir := range []string{cdrcInst.CDRInPath, cdrcInst.CDROutPath} { if err := os.RemoveAll(dir); err != nil { t.Fatal("Error removing folder: ", dir, err) } @@ -166,8 +172,8 @@ func TestXmlIT2CreateCdrDirs(t *testing.T) { } } if cdrcInst.ID == "XMLWithFilter" { // Initialize the folders to check later - xmlPathIn1 = cdrcInst.CdrInDir - xmlPathOut1 = cdrcInst.CdrOutDir + xmlPathIn1 = cdrcInst.CDRInPath + xmlPathOut1 = cdrcInst.CDROutPath } } } @@ -243,7 +249,10 @@ func TestXmlIT3InitCdrDb(t *testing.T) { func TestXmlIT3CreateCdrDirs(t *testing.T) { for _, cdrcProfiles := range xmlCfg.CdrcProfiles { for _, cdrcInst := range cdrcProfiles { - for _, dir := range []string{cdrcInst.CdrInDir, cdrcInst.CdrOutDir} { + for _, dir := range []string{cdrcInst.CDRInPath, cdrcInst.CDROutPath} { + if !cdrcInst.Enabled { + continue + } if err := os.RemoveAll(dir); err != nil { t.Fatal("Error removing folder: ", dir, err) } @@ -252,8 +261,8 @@ func TestXmlIT3CreateCdrDirs(t *testing.T) { } } if cdrcInst.ID == "msw_xml" { // Initialize the folders to check later - xmlPathIn1 = cdrcInst.CdrInDir - xmlPathOut1 = cdrcInst.CdrOutDir + xmlPathIn1 = cdrcInst.CDRInPath + xmlPathOut1 = cdrcInst.CDROutPath } } } @@ -329,7 +338,10 @@ func TestXmlIT4InitCdrDb(t *testing.T) { func TestXmlIT4CreateCdrDirs(t *testing.T) { for _, cdrcProfiles := range xmlCfg.CdrcProfiles { for _, cdrcInst := range cdrcProfiles { - for _, dir := range []string{cdrcInst.CdrInDir, cdrcInst.CdrOutDir} { + if !cdrcInst.Enabled { + continue + } + for _, dir := range []string{cdrcInst.CDRInPath, cdrcInst.CDROutPath} { if err := os.RemoveAll(dir); err != nil { t.Fatal("Error removing folder: ", dir, err) } @@ -338,8 +350,8 @@ func TestXmlIT4CreateCdrDirs(t *testing.T) { } } if cdrcInst.ID == "msw_xml2" { // Initialize the folders to check later - xmlPathIn1 = cdrcInst.CdrInDir - xmlPathOut1 = cdrcInst.CdrOutDir + xmlPathIn1 = cdrcInst.CDRInPath + xmlPathOut1 = cdrcInst.CDROutPath } } } @@ -415,7 +427,10 @@ func TestXmlIT5InitCdrDb(t *testing.T) { func TestXmlIT5CreateCdrDirs(t *testing.T) { for _, cdrcProfiles := range xmlCfg.CdrcProfiles { for _, cdrcInst := range cdrcProfiles { - for _, dir := range []string{cdrcInst.CdrInDir, cdrcInst.CdrOutDir} { + if !cdrcInst.Enabled { + continue + } + for _, dir := range []string{cdrcInst.CDRInPath, cdrcInst.CDROutPath} { if err := os.RemoveAll(dir); err != nil { t.Fatal("Error removing folder: ", dir, err) } @@ -424,8 +439,8 @@ func TestXmlIT5CreateCdrDirs(t *testing.T) { } } if cdrcInst.ID == "XMLWithFilterID" { // Initialize the folders to check later - xmlPathIn1 = cdrcInst.CdrInDir - xmlPathOut1 = cdrcInst.CdrOutDir + xmlPathIn1 = cdrcInst.CDRInPath + xmlPathOut1 = cdrcInst.CDROutPath } } } @@ -526,7 +541,10 @@ func TestXmlIT6InitCdrDb(t *testing.T) { func TestXmlIT6CreateCdrDirs(t *testing.T) { for _, cdrcProfiles := range xmlCfg.CdrcProfiles { for _, cdrcInst := range cdrcProfiles { - for _, dir := range []string{cdrcInst.CdrInDir, cdrcInst.CdrOutDir} { + if !cdrcInst.Enabled { + continue + } + for _, dir := range []string{cdrcInst.CDRInPath, cdrcInst.CDROutPath} { if err := os.RemoveAll(dir); err != nil { t.Fatal("Error removing folder: ", dir, err) } @@ -535,8 +553,8 @@ func TestXmlIT6CreateCdrDirs(t *testing.T) { } } if cdrcInst.ID == "XMLWithIndex" { // Initialize the folders to check later - xmlPathIn1 = cdrcInst.CdrInDir - xmlPathOut1 = cdrcInst.CdrOutDir + xmlPathIn1 = cdrcInst.CDRInPath + xmlPathOut1 = cdrcInst.CDROutPath } } } diff --git a/config/config_defaults.go b/config/config_defaults.go index 44467676f..5c4e8adbd 100755 --- a/config/config_defaults.go +++ b/config/config_defaults.go @@ -242,7 +242,7 @@ const CGRATES_CFG_JSON = ` "cdrs_conns": [ // connections to CDRs. <*internal|x.y.z.y:1234> {"address": "*internal"} ], - "cdr_format": "*file_csv", // CDR file format <*file_csv|*freeswitch_csv|*fwv|*opensips_flatstore|*partial_csv> + "cdr_format": "*file_csv", // CDR file format <*file_csv|*freeswitch_csv|*file_fwv|*opensips_flatstore|*partial_csv|*file_xml> "field_separator": ",", // separator used in case of csv files "timezone": "", // timezone for timestamps where not specified <""|UTC|Local|$IANA_TZ_DB> "run_delay": 0, // sleep interval in seconds between consecutive runs, 0 to use automation via inotify diff --git a/data/conf/samples/cdrc_partcsv/cgrates.json b/data/conf/samples/cdrc_partcsv/cgrates.json index 13fa73ce0..853690799 100644 --- a/data/conf/samples/cdrc_partcsv/cgrates.json +++ b/data/conf/samples/cdrc_partcsv/cgrates.json @@ -29,9 +29,9 @@ { "id": "part1", "enabled": true, - "cdr_format": "partial_csv", - "cdr_in_dir": "/tmp/cdrctests/partcsv1/in", // absolute path towards the directory where the CDRs are stored - "cdr_out_dir": "/tmp/cdrctests/partcsv1/out", // absolute path towards the directory where processed CDRs will be moved + "cdr_format": "*partial_csv", + "cdr_in_path": "/tmp/cdrctests/partcsv1/in", // absolute path towards the directory where the CDRs are stored + "cdr_out_path": "/tmp/cdrctests/partcsv1/out", // absolute path towards the directory where processed CDRs will be moved "cdr_source_id": "partial_csv_test", // free form field, tag identifying the source of the CDRs within CDRS database "partial_record_cache": "1s", // duration to cache partial records when not pairing "partial_cache_expiry_action": "*dump_to_file", @@ -70,8 +70,8 @@ "id": "post_on_expiry", "enabled": true, "cdr_format": "partial_csv", - "cdr_in_dir": "/tmp/cdrctests/partcsv2/in", // absolute path towards the directory where the CDRs are stored - "cdr_out_dir": "/tmp/cdrctests/partcsv2/out", // absolute path towards the directory where processed CDRs will be moved + "cdr_in_path": "/tmp/cdrctests/partcsv2/in", // absolute path towards the directory where the CDRs are stored + "cdr_out_path": "/tmp/cdrctests/partcsv2/out", // absolute path towards the directory where processed CDRs will be moved "cdr_source_id": "partial_csv_test2", // free form field, tag identifying the source of the CDRs within CDRS database "partial_record_cache": "1s", // duration to cache partial records when not pairing "partial_cache_expiry_action": "*post_cdr", diff --git a/data/conf/samples/cdrccsv/cgrates.json b/data/conf/samples/cdrccsv/cgrates.json index 00f795cc3..3d26862b0 100644 --- a/data/conf/samples/cdrccsv/cgrates.json +++ b/data/conf/samples/cdrccsv/cgrates.json @@ -32,16 +32,16 @@ { "id": "*default", "enabled": true, - "cdr_in_dir": "/tmp/cdrctests/csvit1/in", - "cdr_out_dir": "/tmp/cdrctests/csvit1/out", + "cdr_in_path": "/tmp/cdrctests/csvit1/in", + "cdr_out_path": "/tmp/cdrctests/csvit1/out", "cdr_source_id": "csvit1", }, { "id": "*CSVit2", // identifier of the CDRC runner "enabled": true, // enable CDR client functionality "field_separator": ";", - "cdr_in_dir": "/tmp/cdrctests/csvit2/in", // absolute path towards the directory where the CDRs are stored - "cdr_out_dir": "/tmp/cdrctests/csvit2/out", // absolute path towards the directory where processed CDRs will be moved + "cdr_in_path": "/tmp/cdrctests/csvit2/in", // absolute path towards the directory where the CDRs are stored + "cdr_out_path": "/tmp/cdrctests/csvit2/out", // absolute path towards the directory where processed CDRs will be moved "cdr_source_id": "csvit2", // free form field, tag identifying the source of the CDRs within CDRS database "content_fields":[ // import content_fields template, tag will match internally CDR field, in case of .csv value will be represented by index of the field value {"tag": "TOR", "field_id": "ToR", "type": "*composed", "value": "*voice", "mandatory": true}, @@ -65,8 +65,8 @@ "id": "*CSVWithFilter1", // identifier of the CDRC runner "enabled": true, // enable CDR client functionality "field_separator": ";", - "cdr_in_dir": "/tmp/csvwithfilter1/csvit1/in", // absolute path towards the directory where the CDRs are stored - "cdr_out_dir": "/tmp/csvwithfilter1/csvit1/out", // absolute path towards the directory where processed CDRs will be moved + "cdr_in_path": "/tmp/csvwithfilter1/csvit1/in", // absolute path towards the directory where the CDRs are stored + "cdr_out_path": "/tmp/csvwithfilter1/csvit1/out", // absolute path towards the directory where processed CDRs will be moved "cdr_source_id": "csvit1", // free form field, tag identifying the source of the CDRs within CDRS database "filters":["*string:~3:1002"], //filter Account to be 1002 "content_fields":[ // import content_fields template, tag will match internally CDR field, in case of .csv value will be represented by index of the field value @@ -91,8 +91,8 @@ "id": "*CSVWithFilter2", // identifier of the CDRC runner "enabled": true, // enable CDR client functionality "field_separator": ";", - "cdr_in_dir": "/tmp/csvwithfilter2/csvit2/in", // absolute path towards the directory where the CDRs are stored - "cdr_out_dir": "/tmp/csvwithfilter2/csvit2/out", // absolute path towards the directory where processed CDRs will be moved + "cdr_in_path": "/tmp/csvwithfilter2/csvit2/in", // absolute path towards the directory where the CDRs are stored + "cdr_out_path": "/tmp/csvwithfilter2/csvit2/out", // absolute path towards the directory where processed CDRs will be moved "cdr_source_id": "csvit2", // free form field, tag identifying the source of the CDRs within CDRS database "filters":["*string:~3:1002","*string:~1:*prepaid","*gte:~6:70"], //filter Account to be 1002 and RequestType *prepaid "content_fields":[ // import content_fields template, tag will match internally CDR field, in case of .csv value will be represented by index of the field value @@ -117,8 +117,8 @@ "id": "*CSVit4", // identifier of the CDRC runner "enabled": true, // enable CDR client functionality "field_separator": ";", - "cdr_in_dir": "/tmp/csvwithfilter3/csvit3/in", // absolute path towards the directory where the CDRs are stored - "cdr_out_dir": "/tmp/csvwithfilter3/csvit3/out", // absolute path towards the directory where processed CDRs will be moved + "cdr_in_path": "/tmp/csvwithfilter3/csvit3/in", // absolute path towards the directory where the CDRs are stored + "cdr_out_path": "/tmp/csvwithfilter3/csvit3/out", // absolute path towards the directory where processed CDRs will be moved "cdr_source_id": "csvit4", // free form field, tag identifying the source of the CDRs within CDRS database "filters":["*string:~1:*postpaid"], //filter Account to be 1002 "content_fields":[ // import content_fields template, tag will match internally CDR field, in case of .csv value will be represented by index of the field value @@ -144,8 +144,8 @@ "id": "DifferentTenant", // identifier of the CDRC runner "enabled": true, // enable CDR client functionality "field_separator": ";", - "cdr_in_dir": "/tmp/csvwithfilter4/csvit4/in", // absolute path towards the directory where the CDRs are stored - "cdr_out_dir": "/tmp/csvwithfilter4/csvit4/out", // absolute path towards the directory where processed CDRs will be moved + "cdr_in_path": "/tmp/csvwithfilter4/csvit4/in", // absolute path towards the directory where the CDRs are stored + "cdr_out_path": "/tmp/csvwithfilter4/csvit4/out", // absolute path towards the directory where processed CDRs will be moved "tenant": "~2", // tenant used in filterS.Pass "filters":["FLTR_CDRC_ACC"], // if tenant is itsyscom.com will check if Account is 1001 and if tenant is cgrates.org will check if Account is 1002 "cdr_source_id": "diffTenant", // free form field, tag identifying the source of the CDRs within CDRS database diff --git a/data/conf/samples/cdrcflatstore/cgrates.json b/data/conf/samples/cdrcflatstore/cgrates.json index a518c5155..c5621a118 100644 --- a/data/conf/samples/cdrcflatstore/cgrates.json +++ b/data/conf/samples/cdrcflatstore/cgrates.json @@ -40,13 +40,13 @@ "cdrs_conns": [ {"address": "*internal"} // address where to reach CDR server. <*internal|x.y.z.y:1234> ], - "cdr_format": "opensips_flatstore", // CDR file format + "cdr_format": "*opensips_flatstore", // CDR file format "field_separator": "|", // separator used in case of csv files "run_delay": 0, // sleep interval in seconds between consecutive runs, 0 to use automation via inotify "max_open_files": 1024, // maximum simultaneous files to process "data_usage_multiply_factor": 1024, // conversion factor for data usage - "cdr_in_dir": "/tmp/cgr_flatstore/cdrc/in", // absolute path towards the directory where the CDRs are stored - "cdr_out_dir": "/tmp/cgr_flatstore/cdrc/out", // absolute path towards the directory where processed CDRs will be moved + "cdr_in_path": "/tmp/cgr_flatstore/cdrc/in", // absolute path towards the directory where the CDRs are stored + "cdr_out_path": "/tmp/cgr_flatstore/cdrc/out", // absolute path towards the directory where processed CDRs will be moved "failed_calls_prefix": "missed_calls", // used in case of flatstore CDRs to avoid searching for BYE records "cdr_source_id": "flatstore", // free form field, id identifying the source of the CDRs within CDRS database "partial_record_cache": "1s", // duration to cache partial records when not pairing diff --git a/data/conf/samples/cdrcfwv/cgrates.json b/data/conf/samples/cdrcfwv/cgrates.json index fa96b60ea..8b6c49004 100644 --- a/data/conf/samples/cdrcfwv/cgrates.json +++ b/data/conf/samples/cdrcfwv/cgrates.json @@ -40,9 +40,9 @@ "cdrs_conns": [ {"address": "*internal"} // address where to reach CDR server. <*internal|x.y.z.y:1234> ], - "cdr_format": "fwv", // CDR file format - "cdr_in_dir": "/tmp/cgr_fwv/cdrc/in", // absolute path towards the directory where the CDRs are stored - "cdr_out_dir": "/tmp/cgr_fwv/cdrc/out", // absolute path towards the directory where processed CDRs will be moved + "cdr_format": "*file_fwv", // CDR file format + "cdr_in_path": "/tmp/cgr_fwv/cdrc/in", // absolute path towards the directory where the CDRs are stored + "cdr_out_path": "/tmp/cgr_fwv/cdrc/out", // absolute path towards the directory where processed CDRs will be moved "cdr_source_id": "cdrc", // free form field, tag identifying the source of the CDRs within CDRS database "header_fields": [ {"tag": "FileName", "field_id": "CdrFileName", "type": "*composed", "value": "~95-135", "padding":"right"}, diff --git a/data/conf/samples/cdrcfwvwithfilter/cgrates.json b/data/conf/samples/cdrcfwvwithfilter/cgrates.json index 7b9ce166a..a7c3b4e74 100755 --- a/data/conf/samples/cdrcfwvwithfilter/cgrates.json +++ b/data/conf/samples/cdrcfwvwithfilter/cgrates.json @@ -41,9 +41,9 @@ "cdrs_conns": [ {"address": "*internal"} // address where to reach CDR server. <*internal|x.y.z.y:1234> ], - "cdr_format": "fwv", // CDR file format - "cdr_in_dir": "/tmp/cgr_fwv/cdrc/in", // absolute path towards the directory where the CDRs are stored - "cdr_out_dir": "/tmp/cgr_fwv/cdrc/out", // absolute path towards the directory where processed CDRs will be moved + "cdr_format": "*file_fwv", // CDR file format + "cdr_in_path": "/tmp/cgr_fwv/cdrc/in", // absolute path towards the directory where the CDRs are stored + "cdr_out_path": "/tmp/cgr_fwv/cdrc/out", // absolute path towards the directory where processed CDRs will be moved "cdr_source_id": "cdrc", // free form field, id identifying the source of the CDRs within CDRS database "filters":["*string:~0-10:CDR0000010"], "header_fields": [ @@ -84,8 +84,8 @@ {"address": "*internal"} // address where to reach CDR server. <*internal|x.y.z.y:1234> ], "cdr_format": "fwv", // CDR file format - "cdr_in_dir": "/tmp/cgr_fwv/cdrc/in", // absolute path towards the directory where the CDRs are stored - "cdr_out_dir": "/tmp/cgr_fwv/cdrc/out", // absolute path towards the directory where processed CDRs will be moved + "cdr_in_path": "/tmp/cgr_fwv/cdrc/in", // absolute path towards the directory where the CDRs are stored + "cdr_out_path": "/tmp/cgr_fwv/cdrc/out", // absolute path towards the directory where processed CDRs will be moved "cdr_source_id": "cdrc", // free form field, id identifying the source of the CDRs within CDRS database "filters":["FLTR_FWV"], "header_fields": [ diff --git a/data/conf/samples/cdrcxml/cgrates.json b/data/conf/samples/cdrcxml/cgrates.json index 1826916df..6c81b0a34 100644 --- a/data/conf/samples/cdrcxml/cgrates.json +++ b/data/conf/samples/cdrcxml/cgrates.json @@ -25,10 +25,10 @@ { "id": "XMLit1", "enabled": true, - "cdr_format": "xml", - "cdr_in_dir": "/tmp/cdrctests/xmlit1/in", - "cdr_out_dir": "/tmp/cdrctests/xmlit1/out", - "cdr_path": "broadWorksCDR.cdrData", + "cdr_format": "*file_xml", + "cdr_in_path": "/tmp/cdrctests/xmlit1/in", + "cdr_out_path": "/tmp/cdrctests/xmlit1/out", + "cdr_root_path": "broadWorksCDR.cdrData", "cdr_source_id": "xmlit1", "content_fields":[ // import content_fields template, id will match internally CDR field, in case of .csv value will be represented by index of the field value {"tag": "TOR", "field_id": "ToR", "type": "*composed", "value": "*voice", "mandatory": true}, diff --git a/data/conf/samples/cdrcxmlwithfilter/cgrates.json b/data/conf/samples/cdrcxmlwithfilter/cgrates.json index 620c2a29c..0e9761655 100755 --- a/data/conf/samples/cdrcxmlwithfilter/cgrates.json +++ b/data/conf/samples/cdrcxmlwithfilter/cgrates.json @@ -25,10 +25,10 @@ { "id": "XMLWithFilter", "enabled": true, - "cdr_format": "xml", - "cdr_in_dir": "/tmp/cdrcxmlwithfilters/xmlit1/in", - "cdr_out_dir": "/tmp/cdrcxmlwithfilters/xmlit1/out", - "cdr_path": "broadWorksCDR.cdrData", + "cdr_format": "*file_xml", + "cdr_in_path": "/tmp/cdrcxmlwithfilters/xmlit1/in", + "cdr_out_path": "/tmp/cdrcxmlwithfilters/xmlit1/out", + "cdr_root_path": "broadWorksCDR.cdrData", "cdr_source_id": "xmlit1", "filters": ["*string:~broadWorksCDR.cdrData.basicModule.userNumber:1002","*string:~broadWorksCDR.cdrData.headerModule.type:Normal"], "content_fields":[ // import content_fields template, id will match internally CDR field, in case of .csv value will be represented by index of the field value @@ -48,9 +48,9 @@ { "id": "msw_xml", // identifier of the CDRC runner "enabled": true, // enable CDR client functionality - "cdr_format": "xml", // CDR file format