Updated ERS integration tests

This commit is contained in:
Trial97
2019-12-02 15:14:10 +02:00
parent 2d545a3cf2
commit ad559854f5
3 changed files with 34 additions and 28 deletions

View File

@@ -20,6 +20,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
package ers
import (
"errors"
"flag"
"net/rpc"
"net/rpc/jsonrpc"
"os"
@@ -47,8 +49,20 @@ var (
testReloadVerifyFirstReload,
testReloadITKillEngine,
}
encoding = flag.String("rpc", utils.MetaJSON, "what encoding whould be uused for rpc comunication")
)
func newRPCClient(cfg *config.ListenCfg) (c *rpc.Client, err error) {
switch *encoding {
case utils.MetaJSON:
return jsonrpc.Dial(utils.TCP, cfg.RPCJSONListen)
case utils.MetaGOB:
return rpc.Dial(utils.TCP, cfg.RPCGOBListen)
default:
return nil, errors.New("UNSUPPORTED_RPC")
}
}
func TestERsReload(t *testing.T) {
reloadCfgPath = path.Join(*dataDir, "conf", "samples", "ers_reload", "disabled")
for _, test := range reloadTests {
@@ -98,7 +112,7 @@ func testReloadITStartEngine(t *testing.T) {
// Connect rpc client to rater
func testReloadITRpcConn(t *testing.T) {
var err error
reloadRPC, err = jsonrpc.Dial("tcp", reloadCfg.ListenCfg().RPCJSONListen) // We connect over JSON so we can also troubleshoot if needed
reloadRPC, err = newRPCClient(reloadCfg.ListenCfg()) // We connect over JSON so we can also troubleshoot if needed
if err != nil {
t.Fatal("Could not connect to rater: ", err.Error())
}

View File

@@ -23,7 +23,6 @@ import (
"flag"
"io/ioutil"
"net/rpc"
"net/rpc/jsonrpc"
"os"
"path"
"testing"
@@ -132,7 +131,7 @@ func testCsvITStartEngine(t *testing.T) {
// Connect rpc client to rater
func testCsvITRpcConn(t *testing.T) {
var err error
csvRPC, err = jsonrpc.Dial("tcp", csvCfg.ListenCfg().RPCJSONListen) // We connect over JSON so we can also troubleshoot if needed
csvRPC, err = newRPCClient(csvCfg.ListenCfg()) // We connect over JSON so we can also troubleshoot if needed
if err != nil {
t.Fatal("Could not connect to rater: ", err.Error())
}
@@ -219,7 +218,7 @@ func testCsvITTerminateSession(t *testing.T) {
}
time.Sleep(100 * time.Millisecond)
aSessions := make([]*sessions.ExternalSession, 0)
if err := csvRPC.Call(utils.SessionSv1GetActiveSessions, nil, &aSessions); err == nil ||
if err := csvRPC.Call(utils.SessionSv1GetActiveSessions, new(utils.SessionFilter), &aSessions); err == nil ||
err.Error() != utils.ErrNotFound.Error() {
t.Error(err)
}
@@ -240,8 +239,12 @@ func testCsvITAnalyseCDRs(t *testing.T) {
time.Sleep(500 * time.Millisecond)
var cdrs []*engine.CDR
args := utils.RPCCDRsFilter{RunIDs: []string{"CustomerCharges"},
OriginIDs: []string{"SessionFromCsv"}}
args := &utils.RPCCDRsFilterWithArgDispatcher{
RPCCDRsFilter: &utils.RPCCDRsFilter{
RunIDs: []string{"CustomerCharges"},
OriginIDs: []string{"SessionFromCsv"},
},
}
if err := csvRPC.Call(utils.CDRsV1GetCDRs, args, &cdrs); err != nil {
t.Error("Unexpected error: ", err.Error())
} else if len(cdrs) != 1 {
@@ -251,7 +254,7 @@ func testCsvITAnalyseCDRs(t *testing.T) {
t.Errorf("Unexpected cost for CDR: %f", cdrs[0].Cost)
}
}
args = utils.RPCCDRsFilter{RunIDs: []string{"SupplierCharges"},
args.RPCCDRsFilter = &utils.RPCCDRsFilter{RunIDs: []string{"SupplierCharges"},
OriginIDs: []string{"SessionFromCsv"}}
if err := csvRPC.Call(utils.CDRsV1GetCDRs, args, &cdrs); err != nil {
t.Error("Unexpected error: ", err.Error())
@@ -288,8 +291,12 @@ func testCsvITAnalyzeFilteredCDR(t *testing.T) {
time.Sleep(500 * time.Millisecond)
var cdrs []*engine.CDR
args := utils.RPCCDRsFilter{NotRunIDs: []string{"CustomerCharges", "SupplierCharges"},
Sources: []string{"ers_csv"}}
args := &utils.RPCCDRsFilterWithArgDispatcher{
RPCCDRsFilter: &utils.RPCCDRsFilter{
NotRunIDs: []string{"CustomerCharges", "SupplierCharges"},
Sources: []string{"ers_csv"},
},
}
if err := csvRPC.Call(utils.CDRsV1GetCDRs, args, &cdrs); err != nil {
t.Error("Unexpected error: ", err.Error())
} else if len(cdrs) != 2 {

View File

@@ -14,15 +14,9 @@ en=$?
echo 'go test github.com/cgrates/cgrates/cdrc -tags=integration -rpc=*gob'
go test github.com/cgrates/cgrates/cdrc -tags=integration -rpc=*gob
cdrc=$?
# echo 'go test github.com/cgrates/cgrates/ers -tags=integration'
# go test github.com/cgrates/cgrates/ers -tags=integration
# ers=$?
# echo 'go test github.com/cgrates/cgrates/config -tags=integration'
# go test github.com/cgrates/cgrates/config -tags=integration
# cfg=$?
# echo 'go test github.com/cgrates/cgrates/utils -tags=integration'
# go test github.com/cgrates/cgrates/utils -tags=integration
# utl=$?
echo 'go test github.com/cgrates/cgrates/ers -tags=integration -rpc=*gob'
go test github.com/cgrates/cgrates/ers -tags=integration -rpc=*gob
ers=$?
# echo 'go test github.com/cgrates/cgrates/general_tests -tags=integration'
# go test github.com/cgrates/cgrates/general_tests -tags=integration
# gnr=$?
@@ -32,20 +26,11 @@ cdrc=$?
# echo 'go test github.com/cgrates/cgrates/sessions -tags=integration'
# go test github.com/cgrates/cgrates/sessions -tags=integration
# smg=$?
# echo 'go test github.com/cgrates/cgrates/migrator -tags=integration'
# go test github.com/cgrates/cgrates/migrator -tags=integration
# mgr=$?
# echo 'go test github.com/cgrates/cgrates/dispatchers -tags=integration'
# go test github.com/cgrates/cgrates/dispatchers -tags=integration
# dis=$?
# echo 'go test github.com/cgrates/cgrates/loaders -tags=integration'
# go test github.com/cgrates/cgrates/loaders -tags=integration
# lds=$?
# echo 'go test github.com/cgrates/cgrates/services -tags=integration'
# go test github.com/cgrates/cgrates/services -tags=integration
# srv=$?
# echo 'go test github.com/cgrates/cgrates/apier/v1 -tags=offline'
# go test github.com/cgrates/cgrates/apier/v1 -tags=offline
# offline=$?
exit $gen && $ap1 && $ap2 && $en && $cdrc #&& $cfg && $utl && $gnr && $agts && $smg && $mgr && $dis && $lds && $ers && $srv && $offline
exit $gen && $ap1 && $ap2 && $en && $cdrc #&& $gnr && $agts && $smg && $dis && $lds && $ers