Partially fixed cdrc integration tests

This commit is contained in:
Trial97
2018-11-27 17:42:06 +02:00
committed by Dan Christian Bogos
parent ca3d40e1c3
commit 41cd0ce29e
5 changed files with 46 additions and 4 deletions

View File

@@ -80,6 +80,13 @@ func TestCsvITInitCdrDb(t *testing.T) {
}
}
// Remove data in both rating and accounting db
func TestCsvITResetDataDb(t *testing.T) {
if err := engine.InitDataDb(csvCfg); err != nil {
t.Fatal(err)
}
}
func TestCsvITCreateCdrDirs(t *testing.T) {
for _, cdrcProfiles := range csvCfg.CdrcProfiles {
for _, cdrcInst := range cdrcProfiles {
@@ -149,10 +156,11 @@ func TestCsvITProcessedFiles(t *testing.T) {
}
func TestCsvITAnalyseCDRs(t *testing.T) {
time.Sleep(500 * time.Millisecond)
var reply []*engine.ExternalCDR
if err := cdrcRpc.Call("ApierV2.GetCdrs", utils.RPCCDRsFilter{}, &reply); err != nil {
t.Error("Unexpected error: ", err.Error())
} else if len(reply) != 6 { // 1 injected, 1 rated, 1 *raw and it's pair in *default run
} else if len(reply) != 5 { // 1 injected, 1 rated, 1 *raw and it's pair in *default run
t.Error("Unexpected number of CDRs returned: ", len(reply))
}
if err := cdrcRpc.Call("ApierV2.GetCdrs", utils.RPCCDRsFilter{DestinationPrefixes: []string{"08651"}}, &reply); err == nil || err.Error() != utils.NotFoundCaps {

View File

@@ -56,7 +56,7 @@ var part1 = `BYE|f9d3d5c3|c863a6e3|214d8f52b566e33a9349b184e72a4ccb@0:0:0:0:0:0:
`
var part2 = `INVITE|f9d3d5c3|c863a6e3|214d8f52b566e33a9349b184e72a4ccb@0:0:0:0:0:0:0:0|200|OK|1436454647|*postpaid|1002|1003||1877:893549742
INVITE|2daec40c|548625ac|dd0c4c617a9919d29a6175cdff223a9e@0:0:0:0:0:0:0:0|200|OK|1436454408|*prepaid|1001|1002||3401:2069362475`
INVITE|2daec40c|548625ac|dd0c4c617a9919d29a6175cdff223a9p@0:0:0:0:0:0:0:0|200|OK|1436454408|*prepaid|1001|1002||3401:2069362475`
func TestFlatstoreitInitCfg(t *testing.T) {
var err error
@@ -73,6 +73,13 @@ func TestFlatstoreitInitCdrDb(t *testing.T) {
}
}
// Remove data in both rating and accounting db
func TestFlatstoreitResetDataDb(t *testing.T) {
if err := engine.InitDataDb(flatstoreCfg); err != nil {
t.Fatal(err)
}
}
// Creates cdr files and moves them into processing folder
func TestFlatstoreitCreateCdrFiles(t *testing.T) {
if flatstoreCfg == nil {
@@ -140,10 +147,10 @@ func TestFlatstoreitProcessFiles(t *testing.T) {
if len(filesOutDir) != 5 {
t.Errorf("In CdrcOutDir, expecting 5 files, got: %d", len(filesOutDir))
}
ePartContent := "INVITE|2daec40c|548625ac|dd0c4c617a9919d29a6175cdff223a9e@0:0:0:0:0:0:0:0|200|OK|1436454408|*prepaid|1001|1002||3401:2069362475\n"
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 {
t.Error(err)
} else if len(ePartContent) != len(string(partContent)) {
} else if (ePartContent) != (string(partContent)) {
t.Errorf("Expecting:\n%s\nReceived:\n%s", ePartContent, string(partContent))
}
}
@@ -161,3 +168,9 @@ func TestFlatstoreitAnalyseCDRs(t *testing.T) {
t.Error("Unexpected number of CDRs returned: ", len(reply))
}
}
func TestFlatstoreitKillEngine(t *testing.T) {
if err := engine.KillEngine(*waitRater); err != nil {
t.Error(err)
}
}

View File

@@ -130,6 +130,13 @@ func TestFwvitInitCdrDb(t *testing.T) {
}
}
// Remove data in both rating and accounting db
func TestFwvitResetDataDb(t *testing.T) {
if err := engine.InitDataDb(fwvCfg); err != nil {
t.Fatal(err)
}
}
func TestFwvitProcessFiles(t *testing.T) {
fileName := "test1.fwv"
if err := ioutil.WriteFile(path.Join("/tmp", fileName), []byte(FW_CDR_FILE1), 0755); err != nil {

View File

@@ -65,6 +65,13 @@ func TestPartcsvITInitCdrDb(t *testing.T) {
}
}
// Remove data in both rating and accounting db
func TestPartcsvITResetDataDb(t *testing.T) {
if err := engine.InitDataDb(partcsvCfg); err != nil {
t.Fatal(err)
}
}
func TestPartcsvITCreateCdrDirs(t *testing.T) {
for path, cdrcProfiles := range partcsvCfg.CdrcProfiles {
for _, cdrcInst := range cdrcProfiles {

View File

@@ -55,6 +55,13 @@ func TestXmlITInitCdrDb(t *testing.T) {
}
}
// Remove data in both rating and accounting db
func TestXmlITResetDataDb(t *testing.T) {
if err := engine.InitDataDb(xmlCfg); err != nil {
t.Fatal(err)
}
}
func TestXmlITCreateCdrDirs(t *testing.T) {
for _, cdrcProfiles := range xmlCfg.CdrcProfiles {
for i, cdrcInst := range cdrcProfiles {