Prevent deadlocks in file reader unit tests

This commit is contained in:
ionutboangiu
2025-01-22 17:26:18 +02:00
committed by Dan Christian Bogos
parent c171937c3d
commit 96c2a3acee
4 changed files with 0 additions and 38 deletions

View File

@@ -668,9 +668,7 @@ func TestFileCSV(t *testing.T) {
rdrEvents: make(chan *erEvent, 1),
rdrError: make(chan error, 1),
rdrExit: make(chan struct{}),
conReqs: make(chan struct{}, 1),
}
eR.conReqs <- struct{}{}
eR.Config().RunDelay = 1 * time.Millisecond
if err := eR.Serve(); err != nil {
t.Error(err)
@@ -688,10 +686,8 @@ func TestFileCSVServeDefault(t *testing.T) {
rdrEvents: make(chan *erEvent, 1),
rdrError: make(chan error, 1),
rdrExit: make(chan struct{}),
conReqs: make(chan struct{}, 1),
}
var err error
eR.conReqs <- struct{}{}
filePath := "/tmp/ers/out/"
err = os.MkdirAll(filePath, 0777)
if err != nil {
@@ -725,9 +721,7 @@ func TestFileCSVExit(t *testing.T) {
rdrEvents: make(chan *erEvent, 1),
rdrError: make(chan error, 1),
rdrExit: make(chan struct{}),
conReqs: make(chan struct{}, 1),
}
eR.conReqs <- struct{}{}
eR.Config().RunDelay = 1 * time.Millisecond
if err := eR.Serve(); err != nil {
t.Error(err)

View File

@@ -366,9 +366,7 @@ func TestFileFWV(t *testing.T) {
rdrEvents: make(chan *erEvent, 1),
rdrError: make(chan error, 1),
rdrExit: make(chan struct{}),
conReqs: make(chan struct{}, 1),
}
eR.conReqs <- struct{}{}
filePath := "/tmp/fwvErs/out"
err := os.MkdirAll(filePath, 0777)
if err != nil {
@@ -401,9 +399,7 @@ func TestFileFWVServeDefault(t *testing.T) {
rdrEvents: make(chan *erEvent, 1),
rdrError: make(chan error, 1),
rdrExit: make(chan struct{}),
conReqs: make(chan struct{}, 1),
}
eR.conReqs <- struct{}{}
filePath := "/tmp/fwvErs/out"
err := os.MkdirAll(filePath, 0777)
if err != nil {
@@ -437,9 +433,7 @@ func TestFileFWVExit(t *testing.T) {
rdrEvents: make(chan *erEvent, 1),
rdrError: make(chan error, 1),
rdrExit: make(chan struct{}),
conReqs: make(chan struct{}, 1),
}
eR.conReqs <- struct{}{}
eR.Config().RunDelay = 1 * time.Millisecond
if err := eR.Serve(); err != nil {
t.Error(err)
@@ -461,7 +455,6 @@ func TestFileFWVProcessTrailer(t *testing.T) {
rdrEvents: make(chan *erEvent, 1),
rdrError: make(chan error, 1),
rdrExit: make(chan struct{}),
conReqs: make(chan struct{}, 1),
}
expEvent := &utils.CGREvent{
Tenant: "cgrates.org",
@@ -470,7 +463,6 @@ func TestFileFWVProcessTrailer(t *testing.T) {
},
APIOpts: map[string]any{},
}
eR.conReqs <- struct{}{}
filePath := "/tmp/TestFileFWVProcessTrailer/"
if err := os.MkdirAll(filePath, 0777); err != nil {
t.Error(err)
@@ -521,9 +513,7 @@ func TestFileFWVProcessTrailerError1(t *testing.T) {
rdrEvents: make(chan *erEvent, 1),
rdrError: make(chan error, 1),
rdrExit: make(chan struct{}),
conReqs: make(chan struct{}, 1),
}
eR.conReqs <- struct{}{}
filePath := "/tmp/TestFileFWVProcessTrailer/"
if err := os.MkdirAll(filePath, 0777); err != nil {
t.Error(err)
@@ -557,9 +547,7 @@ func TestFileFWVProcessTrailerError2(t *testing.T) {
rdrEvents: make(chan *erEvent, 1),
rdrError: make(chan error, 1),
rdrExit: make(chan struct{}),
conReqs: make(chan struct{}, 1),
}
eR.conReqs <- struct{}{}
eR.Config().Tenant = config.RSRParsers{
{
Rules: "cgrates.org",
@@ -604,9 +592,7 @@ func TestFileFWVProcessTrailerError3(t *testing.T) {
rdrEvents: make(chan *erEvent, 1),
rdrError: make(chan error, 1),
rdrExit: make(chan struct{}),
conReqs: make(chan struct{}, 1),
}
eR.conReqs <- struct{}{}
trailerFields := []*config.FCTemplate{
{
Tag: "OriginId",
@@ -635,9 +621,7 @@ func TestFileFWVCreateHeaderMap(t *testing.T) {
rdrEvents: make(chan *erEvent, 1),
rdrError: make(chan error, 1),
rdrExit: make(chan struct{}),
conReqs: make(chan struct{}, 1),
}
eR.conReqs <- struct{}{}
expEvent := &utils.CGREvent{
Tenant: "cgrates.org",
Event: map[string]any{
@@ -684,9 +668,7 @@ func TestFileFWVCreateHeaderMapError1(t *testing.T) {
rdrEvents: make(chan *erEvent, 1),
rdrError: make(chan error, 1),
rdrExit: make(chan struct{}),
conReqs: make(chan struct{}, 1),
}
eR.conReqs <- struct{}{}
trailerFields := []*config.FCTemplate{
{},
}
@@ -710,9 +692,7 @@ func TestFileFWVCreateHeaderMapError2(t *testing.T) {
rdrEvents: make(chan *erEvent, 1),
rdrError: make(chan error, 1),
rdrExit: make(chan struct{}),
conReqs: make(chan struct{}, 1),
}
eR.conReqs <- struct{}{}
record := "testRecord"
trailerFields := []*config.FCTemplate{
{

View File

@@ -541,9 +541,7 @@ func TestFileJSON(t *testing.T) {
rdrEvents: make(chan *erEvent, 1),
rdrError: make(chan error, 1),
rdrExit: make(chan struct{}),
conReqs: make(chan struct{}, 1),
}
eR.conReqs <- struct{}{}
if err := eR.Serve(); err != nil {
t.Error(err)
}
@@ -560,9 +558,7 @@ func TestFileJSONServeDefault(t *testing.T) {
rdrEvents: make(chan *erEvent, 1),
rdrError: make(chan error, 1),
rdrExit: make(chan struct{}),
conReqs: make(chan struct{}, 1),
}
eR.conReqs <- struct{}{}
filePath := "/tmp/ErsJSON/out/"
err := os.MkdirAll(filePath, 0777)
if err != nil {
@@ -596,9 +592,7 @@ func TestFileJSONExit(t *testing.T) {
rdrEvents: make(chan *erEvent, 1),
rdrError: make(chan error, 1),
rdrExit: make(chan struct{}),
conReqs: make(chan struct{}, 1),
}
eR.conReqs <- struct{}{}
eR.Config().RunDelay = 1 * time.Millisecond
if err := eR.Serve(); err != nil {
t.Error(err)

View File

@@ -580,9 +580,7 @@ func TestFileXML(t *testing.T) {
rdrEvents: make(chan *erEvent, 1),
rdrError: make(chan error, 1),
rdrExit: make(chan struct{}),
conReqs: make(chan struct{}, 1),
}
eR.conReqs <- struct{}{}
err := os.MkdirAll(eR.sourceDir, 0777)
if err != nil {
t.Error(err)
@@ -633,9 +631,7 @@ func TestFileXMLError(t *testing.T) {
rdrEvents: make(chan *erEvent, 1),
rdrError: make(chan error, 1),
rdrExit: make(chan struct{}),
conReqs: make(chan struct{}, 1),
}
eR.conReqs <- struct{}{}
err := os.MkdirAll(eR.sourceDir, 0777)
if err != nil {
t.Error(err)
@@ -676,9 +672,7 @@ func TestFileXMLExit(t *testing.T) {
rdrEvents: make(chan *erEvent, 1),
rdrError: make(chan error, 1),
rdrExit: make(chan struct{}),
conReqs: make(chan struct{}, 1),
}
eR.conReqs <- struct{}{}
eR.Config().RunDelay = 1 * time.Millisecond
if err := eR.Serve(); err != nil {
t.Error(err)