mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-11 18:16:24 +05:00
revising integration tests
This commit is contained in:
committed by
Dan Christian Bogos
parent
3ff0e6e5a1
commit
009895f92a
@@ -22,7 +22,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
package dispatchers
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"reflect"
|
||||
"testing"
|
||||
|
||||
@@ -344,7 +343,7 @@ func testDspRplDispatcherProfile(t *testing.T) {
|
||||
allEngine.stopEngine(t)
|
||||
|
||||
// Get DispatcherProfile
|
||||
if err := dispEngine.RPC.Call(utils.ReplicatorSv1GetDispatcherProfile, argsDispatcherProfile, &reply); err == nil || !errors.Is(err, utils.ErrDSPProfileNotFound) {
|
||||
if err := dispEngine.RPC.Call(utils.ReplicatorSv1GetDispatcherProfile, argsDispatcherProfile, &reply); err == nil || err.Error() != utils.ErrDSPProfileNotFound.Error() {
|
||||
t.Errorf("Expecting: %+v, received: %+v, ", utils.ErrDSPProfileNotFound, err)
|
||||
}
|
||||
|
||||
@@ -359,7 +358,7 @@ func testDspRplDispatcherProfile(t *testing.T) {
|
||||
}
|
||||
|
||||
// Get DispatcherProfile
|
||||
if err := dispEngine.RPC.Call(utils.ReplicatorSv1GetDispatcherProfile, argsDispatcherProfile, &reply); err == nil || err.Error() != utils.ErrNotFound.Error() {
|
||||
if err := dispEngine.RPC.Call(utils.ReplicatorSv1GetDispatcherProfile, argsDispatcherProfile, &reply); err == nil || err.Error() != utils.ErrDSPProfileNotFound.Error() {
|
||||
t.Errorf("Expecting: %+v, received: %+v, ", utils.ErrDSPProfileNotFound, err)
|
||||
}
|
||||
}
|
||||
@@ -405,7 +404,7 @@ func testDspRplDispatcherHost(t *testing.T) {
|
||||
allEngine.stopEngine(t)
|
||||
|
||||
// Get DispatcherHost
|
||||
if err := dispEngine.RPC.Call(utils.ReplicatorSv1GetDispatcherHost, argsDispatcherHost, &reply); err == nil || err.Error() != utils.ErrNotFound.Error() {
|
||||
if err := dispEngine.RPC.Call(utils.ReplicatorSv1GetDispatcherHost, argsDispatcherHost, &reply); err == nil || err.Error() != utils.ErrDSPHostNotFound.Error() {
|
||||
t.Errorf("Expecting: %+v, received: %+v, ", utils.ErrDSPHostNotFound, err)
|
||||
}
|
||||
|
||||
@@ -420,7 +419,7 @@ func testDspRplDispatcherHost(t *testing.T) {
|
||||
}
|
||||
|
||||
// Get DispatcherHost
|
||||
if err := dispEngine.RPC.Call(utils.ReplicatorSv1GetDispatcherHost, argsDispatcherHost, &reply); err == nil || err.Error() != utils.ErrNotFound.Error() {
|
||||
if err := dispEngine.RPC.Call(utils.ReplicatorSv1GetDispatcherHost, argsDispatcherHost, &reply); err == nil || err.Error() != utils.ErrDSPHostNotFound.Error() {
|
||||
t.Errorf("Expecting: %+v, received: %+v, ", utils.ErrDSPHostNotFound, err)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,11 +21,13 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
package ers
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"net/rpc"
|
||||
"os"
|
||||
"path"
|
||||
"reflect"
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
@@ -593,11 +595,18 @@ func TestFileXMLProcessEVentError3(t *testing.T) {
|
||||
Mandatory: true,
|
||||
},
|
||||
}
|
||||
tmpLogger := utils.Logger
|
||||
defer func() {
|
||||
utils.Logger = tmpLogger
|
||||
}()
|
||||
var buf bytes.Buffer
|
||||
utils.Logger = utils.NewStdLoggerWithWriter(&buf, "", 7)
|
||||
|
||||
eR.Config().Fields[0].ComputePath()
|
||||
errExpect := "Empty source value for fieldID: <OriginID>"
|
||||
if err := eR.processFile(filePath, fname); err == nil || err.Error() != errExpect {
|
||||
t.Errorf("Expected %v but received %v", errExpect, err)
|
||||
eR.processFile(filePath, fname)
|
||||
if !strings.Contains(buf.String(), errExpect) {
|
||||
t.Errorf("Expected to contain %s", errExpect)
|
||||
}
|
||||
if err := os.RemoveAll(filePath); err != nil {
|
||||
t.Error(err)
|
||||
|
||||
@@ -636,7 +636,7 @@ func testAnzDocQueryWithContentFiltersFilters(t *testing.T) {
|
||||
// Query results for API calls with with an execution duration longer than 30ms
|
||||
if err := anzDocRPC.Call(context.Background(), utils.AnalyzerSv1StringQuery, &analyzers.QueryArgs{
|
||||
HeaderFilters: "",
|
||||
ContentFilters: []string{"*gt:~*hdr.RequestDuration:30ms"},
|
||||
ContentFilters: []string{"*gt:~*hdr.RequestDuration:10ms"},
|
||||
}, &result); err != nil {
|
||||
t.Error(err)
|
||||
} else if len(result) == 0 {
|
||||
|
||||
@@ -550,12 +550,12 @@ func testdoubleRemoveDispatcherProfile(t *testing.T) {
|
||||
}
|
||||
if err := doubleRemoveRPC.Call(context.Background(), utils.AdminSv1RemoveDispatcherProfile,
|
||||
&utils.TenantID{Tenant: doubleRemoveTenant, ID: "DSP_PRF"}, &result); err == nil ||
|
||||
err.Error() != utils.ErrDSPProfileNotFound.Error() {
|
||||
err.Error() != utils.ErrNotFound.Error() {
|
||||
t.Error(err)
|
||||
}
|
||||
if err := doubleRemoveRPC.Call(context.Background(), utils.AdminSv1RemoveDispatcherProfile,
|
||||
&utils.TenantID{Tenant: doubleRemoveTenant, ID: "DSP_PRF"}, &result); err == nil ||
|
||||
err.Error() != utils.ErrDSPProfileNotFound.Error() {
|
||||
err.Error() != utils.ErrNotFound.Error() {
|
||||
t.Error(err)
|
||||
}
|
||||
// check
|
||||
|
||||
@@ -49,6 +49,7 @@ var (
|
||||
expRpc *birpc.Client
|
||||
|
||||
sTestsExp = []func(t *testing.T){
|
||||
testExpCreateFiles,
|
||||
testExpLoadConfig,
|
||||
testExpFlushDBs,
|
||||
testExpStartEngine,
|
||||
@@ -93,6 +94,16 @@ func TestExport(t *testing.T) {
|
||||
t.Run(expCfgDir, stest)
|
||||
}
|
||||
}
|
||||
func testExpCreateFiles(t *testing.T) {
|
||||
for _, dir := range eeSBlockerFiles {
|
||||
if err := os.RemoveAll("/tmp/archivesTP"); err != nil {
|
||||
t.Fatal("Error removing folder: ", dir, err)
|
||||
}
|
||||
if err := os.MkdirAll("/tmp/archivesTP", os.ModePerm); err != nil {
|
||||
t.Fatal("Error creating folder: ", dir, err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func testExpLoadConfig(t *testing.T) {
|
||||
expCfgPath = path.Join(*dataDir, "conf", "samples", expCfgDir)
|
||||
|
||||
Reference in New Issue
Block a user