mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-11 10:06:24 +05:00
Updated IT tests in apier/v2
This commit is contained in:
@@ -43,6 +43,7 @@ var (
|
||||
sSV1RequestType string
|
||||
|
||||
sTestSessionSv1 = []func(t *testing.T){
|
||||
testSSv1ItInitCfgDir,
|
||||
testSSv1ItInitCfg,
|
||||
testSSv1ItResetDataDb,
|
||||
testSSv1ItResetStorDb,
|
||||
@@ -68,7 +69,7 @@ var (
|
||||
}
|
||||
)
|
||||
|
||||
func TestSessionSv1ITtests(t *testing.T) {
|
||||
func testSSv1ItInitCfgDir(t *testing.T) {
|
||||
switch *dbType {
|
||||
case utils.MetaInternal:
|
||||
sessionsConfDIR = "sessions_internal"
|
||||
@@ -81,10 +82,6 @@ func TestSessionSv1ITtests(t *testing.T) {
|
||||
default:
|
||||
t.Fatal("Unknown Database type")
|
||||
}
|
||||
|
||||
for _, stest := range sTestSessionSv1 {
|
||||
t.Run(sessionsConfDIR, stest)
|
||||
}
|
||||
}
|
||||
|
||||
func handleDisconnectSession(clnt *rpc2.Client,
|
||||
|
||||
@@ -20,11 +20,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
package v2
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"flag"
|
||||
"fmt"
|
||||
"net/rpc"
|
||||
"net/rpc/jsonrpc"
|
||||
"path"
|
||||
"reflect"
|
||||
"strconv"
|
||||
@@ -38,47 +35,72 @@ import (
|
||||
)
|
||||
|
||||
var (
|
||||
dataDir = flag.String("data_dir", "/usr/share/cgrates", "CGR data dir path here")
|
||||
waitRater = flag.Int("wait_rater", 1500, "Number of miliseconds to wait for rater to start and cache")
|
||||
encoding = flag.String("rpc", utils.MetaJSON, "what encoding whould be uused for rpc comunication")
|
||||
apierCfgPath string
|
||||
apierCfg *config.CGRConfig
|
||||
apierRPC *rpc.Client
|
||||
dm *engine.DataManager // share db connection here so we can check data we set through APIs
|
||||
apierCfgPath string
|
||||
apierCfg *config.CGRConfig
|
||||
apierRPC *rpc.Client
|
||||
dm *engine.DataManager // share db connection here so we can check data we set through APIs
|
||||
apierv2ConfDIR string
|
||||
|
||||
sTestsv2it = []func(t *testing.T){
|
||||
testApierV2itLoadConfig,
|
||||
testApierV2itResetDataDb,
|
||||
testApierV2itResetStorDb,
|
||||
testApierV2itConnectDataDB,
|
||||
testApierV2itStartEngine,
|
||||
testApierV2itRpcConn,
|
||||
testApierV2itAddBalance,
|
||||
testApierV2itSetAction,
|
||||
testApierV2itSetAccountActionTriggers,
|
||||
testApierV2itFraudMitigation,
|
||||
testApierV2itSetAccountWithAP,
|
||||
testApierV2itSetActionWithCategory,
|
||||
testApierV2itSetActionPlanWithWrongTiming,
|
||||
testApierV2itSetActionPlanWithWrongTiming2,
|
||||
testApierV2itKillEngine,
|
||||
}
|
||||
)
|
||||
|
||||
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)
|
||||
func TestV2IT(t *testing.T) {
|
||||
switch *dbType {
|
||||
case utils.MetaInternal:
|
||||
apierv2ConfDIR = "tutinternal"
|
||||
case utils.MetaSQL:
|
||||
apierv2ConfDIR = "tutmysql"
|
||||
case utils.MetaMongo:
|
||||
apierv2ConfDIR = "tutmongo"
|
||||
case utils.MetaPostgres:
|
||||
t.SkipNow()
|
||||
default:
|
||||
return nil, errors.New("UNSUPPORTED_RPC")
|
||||
t.Fatal("Unknown Database type")
|
||||
}
|
||||
|
||||
for _, stest := range sTestsv2it {
|
||||
t.Run(apierv2ConfDIR, stest)
|
||||
}
|
||||
}
|
||||
func TestApierV2itLoadConfig(t *testing.T) {
|
||||
apierCfgPath = path.Join(*dataDir, "conf", "samples", "tutmysql")
|
||||
|
||||
func testApierV2itLoadConfig(t *testing.T) {
|
||||
apierCfgPath = path.Join(*dataDir, "conf", "samples", apierv2ConfDIR)
|
||||
if apierCfg, err = config.NewCGRConfigFromPath(apierCfgPath); err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
}
|
||||
|
||||
// Remove data in both rating and accounting db
|
||||
func TestApierV2itResetDataDb(t *testing.T) {
|
||||
func testApierV2itResetDataDb(t *testing.T) {
|
||||
if err := engine.InitDataDb(apierCfg); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
// Wipe out the cdr database
|
||||
func TestApierV2itResetStorDb(t *testing.T) {
|
||||
func testApierV2itResetStorDb(t *testing.T) {
|
||||
if err := engine.InitStorDb(apierCfg); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestApierV2itConnectDataDB(t *testing.T) {
|
||||
func testApierV2itConnectDataDB(t *testing.T) {
|
||||
rdsDb, _ := strconv.Atoi(apierCfg.DataDbCfg().DataDbName)
|
||||
if rdsITdb, err := engine.NewRedisStorage(
|
||||
fmt.Sprintf("%s:%s", apierCfg.DataDbCfg().DataDbHost, apierCfg.DataDbCfg().DataDbPort),
|
||||
@@ -91,21 +113,21 @@ func TestApierV2itConnectDataDB(t *testing.T) {
|
||||
}
|
||||
|
||||
// Start CGR Engine
|
||||
func TestApierV2itStartEngine(t *testing.T) {
|
||||
func testApierV2itStartEngine(t *testing.T) {
|
||||
if _, err := engine.StopStartEngine(apierCfgPath, 200); err != nil { // Mongo requires more time to start
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
// Connect rpc client to rater
|
||||
func TestApierV2itRpcConn(t *testing.T) {
|
||||
func testApierV2itRpcConn(t *testing.T) {
|
||||
apierRPC, err = newRPCClient(apierCfg.ListenCfg()) // We connect over JSON so we can also troubleshoot if needed
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestApierV2itAddBalance(t *testing.T) {
|
||||
func testApierV2itAddBalance(t *testing.T) {
|
||||
attrs := &utils.AttrSetBalance{
|
||||
Tenant: "cgrates.org",
|
||||
Account: "dan",
|
||||
@@ -128,7 +150,7 @@ func TestApierV2itAddBalance(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestApierV2itSetAction(t *testing.T) {
|
||||
func testApierV2itSetAction(t *testing.T) {
|
||||
attrs := utils.AttrSetActions{ActionsId: "DISABLE_ACCOUNT", Actions: []*utils.TPAction{
|
||||
{Identifier: utils.DISABLE_ACCOUNT, Weight: 10.0},
|
||||
}}
|
||||
@@ -144,7 +166,7 @@ func TestApierV2itSetAction(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestApierV2itSetAccountActionTriggers(t *testing.T) {
|
||||
func testApierV2itSetAccountActionTriggers(t *testing.T) {
|
||||
attrs := v1.AttrSetAccountActionTriggers{
|
||||
Tenant: "cgrates.org",
|
||||
Account: "dan",
|
||||
@@ -179,7 +201,7 @@ func TestApierV2itSetAccountActionTriggers(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestApierV2itFraudMitigation(t *testing.T) {
|
||||
func testApierV2itFraudMitigation(t *testing.T) {
|
||||
attrs := &utils.AttrSetBalance{
|
||||
Tenant: "cgrates.org",
|
||||
Account: "dan",
|
||||
@@ -222,7 +244,7 @@ func TestApierV2itFraudMitigation(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestApierV2itSetAccountWithAP(t *testing.T) {
|
||||
func testApierV2itSetAccountWithAP(t *testing.T) {
|
||||
argActs1 := utils.AttrSetActions{ActionsId: "TestApierV2itSetAccountWithAP_ACT_1",
|
||||
Actions: []*utils.TPAction{
|
||||
{Identifier: utils.TOPUP_RESET,
|
||||
@@ -334,7 +356,7 @@ func TestApierV2itSetAccountWithAP(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestApierV2itSetActionWithCategory(t *testing.T) {
|
||||
func testApierV2itSetActionWithCategory(t *testing.T) {
|
||||
var reply string
|
||||
attrsSetAccount := &utils.AttrSetAccount{Tenant: "cgrates.org", Account: "TestApierV2itSetActionWithCategory"}
|
||||
if err := apierRPC.Call(utils.ApierV1SetAccount, attrsSetAccount, &reply); err != nil {
|
||||
@@ -372,7 +394,7 @@ func TestApierV2itSetActionWithCategory(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestApierV2itSetActionPlanWithWrongTiming(t *testing.T) {
|
||||
func testApierV2itSetActionPlanWithWrongTiming(t *testing.T) {
|
||||
var reply string
|
||||
tNow := time.Now().Add(time.Duration(time.Minute)).String()
|
||||
argAP1 := &v1.AttrSetActionPlan{Id: "TestApierV2itSetAccountWithAPWithWrongTiming",
|
||||
@@ -391,7 +413,7 @@ func TestApierV2itSetActionPlanWithWrongTiming(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestApierV2itSetActionPlanWithWrongTiming2(t *testing.T) {
|
||||
func testApierV2itSetActionPlanWithWrongTiming2(t *testing.T) {
|
||||
var reply string
|
||||
argAP1 := &v1.AttrSetActionPlan{Id: "TestApierV2itSetAccountWithAPWithWrongTiming",
|
||||
ActionPlan: []*v1.AttrActionPlan{
|
||||
@@ -409,7 +431,7 @@ func TestApierV2itSetActionPlanWithWrongTiming2(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestApierV2itKillEngine(t *testing.T) {
|
||||
func testApierV2itKillEngine(t *testing.T) {
|
||||
if err := engine.KillEngine(delay); err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
|
||||
@@ -40,29 +40,34 @@ var (
|
||||
alsPrfDataDir = "/usr/share/cgrates"
|
||||
alsPrf *engine.AttributeProfile
|
||||
alsPrfConfigDIR string //run tests for specific configuration
|
||||
|
||||
sTestsAlsPrf = []func(t *testing.T){
|
||||
testAttributeSInitCfg,
|
||||
testAttributeSInitDataDb,
|
||||
testAttributeSResetStorDb,
|
||||
testAttributeSStartEngine,
|
||||
testAttributeSRPCConn,
|
||||
testAttributeSSetAlsPrf,
|
||||
testAttributeSUpdateAlsPrf,
|
||||
testAttributeSKillEngine,
|
||||
}
|
||||
)
|
||||
|
||||
var sTestsAlsPrf = []func(t *testing.T){
|
||||
testAttributeSInitCfg,
|
||||
testAttributeSInitDataDb,
|
||||
testAttributeSResetStorDb,
|
||||
testAttributeSStartEngine,
|
||||
testAttributeSRPCConn,
|
||||
testAttributeSSetAlsPrf,
|
||||
testAttributeSUpdateAlsPrf,
|
||||
testAttributeSKillEngine,
|
||||
}
|
||||
|
||||
//Test start here
|
||||
func TestAttributeSITMySql(t *testing.T) {
|
||||
alsPrfConfigDIR = "tutmysql"
|
||||
for _, stest := range sTestsAlsPrf {
|
||||
t.Run(alsPrfConfigDIR, stest)
|
||||
func TestAttributeSIT(t *testing.T) {
|
||||
switch *dbType {
|
||||
case utils.MetaInternal:
|
||||
alsPrfConfigDIR = "tutinternal"
|
||||
case utils.MetaSQL:
|
||||
alsPrfConfigDIR = "tutmysql"
|
||||
case utils.MetaMongo:
|
||||
alsPrfConfigDIR = "tutmongo"
|
||||
case utils.MetaPostgres:
|
||||
t.SkipNow()
|
||||
default:
|
||||
t.Fatal("Unknown Database type")
|
||||
}
|
||||
}
|
||||
|
||||
func TestAttributeSITMongo(t *testing.T) {
|
||||
alsPrfConfigDIR = "tutmongo"
|
||||
for _, stest := range sTestsAlsPrf {
|
||||
t.Run(alsPrfConfigDIR, stest)
|
||||
}
|
||||
|
||||
@@ -32,68 +32,62 @@ import (
|
||||
"github.com/cgrates/cgrates/utils"
|
||||
)
|
||||
|
||||
var cdrsCfgPath string
|
||||
var cdrsCfg *config.CGRConfig
|
||||
var cdrsRpc *rpc.Client
|
||||
var cdrsConfDIR string // run the tests for specific configuration
|
||||
var (
|
||||
cdrsCfgPath string
|
||||
cdrsCfg *config.CGRConfig
|
||||
cdrsRpc *rpc.Client
|
||||
cdrsConfDIR string // run the tests for specific configuration
|
||||
|
||||
// subtests to be executed for each confDIR
|
||||
var sTestsCDRsIT = []func(t *testing.T){
|
||||
testV2CDRsInitConfig,
|
||||
testV2CDRsInitDataDb,
|
||||
testV2CDRsInitCdrDb,
|
||||
testV2CDRsStartEngine,
|
||||
testV2CDRsRpcConn,
|
||||
testV2CDRsLoadTariffPlanFromFolder,
|
||||
testV2CDRsProcessCDR,
|
||||
testV2CDRsGetCdrs,
|
||||
testV2CDRsRateCDRs,
|
||||
testV2CDRsGetCdrs2,
|
||||
testV2CDRsUsageNegative,
|
||||
testV2CDRsDifferentTenants,
|
||||
// subtests to be executed for each confDIR
|
||||
sTestsCDRsIT = []func(t *testing.T){
|
||||
testV2CDRsInitConfig,
|
||||
testV2CDRsInitDataDb,
|
||||
testV2CDRsInitCdrDb,
|
||||
testV2CDRsStartEngine,
|
||||
testV2CDRsRpcConn,
|
||||
testV2CDRsLoadTariffPlanFromFolder,
|
||||
testV2CDRsProcessCDR,
|
||||
testV2CDRsGetCdrs,
|
||||
testV2CDRsRateCDRs,
|
||||
testV2CDRsGetCdrs2,
|
||||
testV2CDRsUsageNegative,
|
||||
testV2CDRsDifferentTenants,
|
||||
|
||||
testV2CDRsRemoveRatingProfiles,
|
||||
testV2CDRsProcessCDRNoRattingPlan,
|
||||
testV2CDRsGetCdrsNoRattingPlan,
|
||||
testV2CDRsRemoveRatingProfiles,
|
||||
testV2CDRsProcessCDRNoRattingPlan,
|
||||
testV2CDRsGetCdrsNoRattingPlan,
|
||||
|
||||
testV2CDRsRateCDRsWithRatingPlan,
|
||||
testV2CDRsGetCdrsWithRattingPlan,
|
||||
testV2CDRsRateCDRsWithRatingPlan,
|
||||
testV2CDRsGetCdrsWithRattingPlan,
|
||||
|
||||
testV2CDRsSetThreshold,
|
||||
testV2CDRsProcessCDRWithThreshold,
|
||||
testV2CDRsGetThreshold,
|
||||
testV2CDRsSetThreshold,
|
||||
testV2CDRsProcessCDRWithThreshold,
|
||||
testV2CDRsGetThreshold,
|
||||
|
||||
testV2CDRsKillEngine,
|
||||
}
|
||||
testV2CDRsKillEngine,
|
||||
}
|
||||
)
|
||||
|
||||
// Tests starting here
|
||||
func TestCDRsITMySQL(t *testing.T) {
|
||||
cdrsConfDIR = "cdrsv2mysql"
|
||||
func TestCDRsIT(t *testing.T) {
|
||||
switch *dbType {
|
||||
case utils.MetaInternal:
|
||||
cdrsConfDIR = "cdrsv2internal"
|
||||
case utils.MetaSQL:
|
||||
cdrsConfDIR = "cdrsv2mysql"
|
||||
case utils.MetaMongo:
|
||||
cdrsConfDIR = "cdrsv2mongo"
|
||||
case utils.MetaPostgres:
|
||||
cdrsConfDIR = "cdrsv2psql"
|
||||
default:
|
||||
t.Fatal("Unknown Database type")
|
||||
}
|
||||
|
||||
for _, stest := range sTestsCDRsIT {
|
||||
t.Run(cdrsConfDIR, stest)
|
||||
}
|
||||
}
|
||||
|
||||
func TestCDRsITpg(t *testing.T) {
|
||||
cdrsConfDIR = "cdrsv2psql"
|
||||
for _, stest := range sTestsCDRsIT {
|
||||
t.Run(cdrsConfDIR, stest)
|
||||
}
|
||||
}
|
||||
|
||||
func TestCDRsITMongo(t *testing.T) {
|
||||
cdrsConfDIR = "cdrsv2mongo"
|
||||
for _, stest := range sTestsCDRsIT {
|
||||
t.Run(cdrsConfDIR, stest)
|
||||
}
|
||||
}
|
||||
|
||||
func TestCDRsITInternal(t *testing.T) {
|
||||
cdrsConfDIR = "cdrsv2internal"
|
||||
for _, stest := range sTestsCDRsIT {
|
||||
t.Run(cdrsConfDIR, stest)
|
||||
}
|
||||
}
|
||||
func testV2CDRsInitConfig(t *testing.T) {
|
||||
var err error
|
||||
cdrsCfgPath = path.Join(*dataDir, "conf", "samples", cdrsConfDIR)
|
||||
|
||||
@@ -33,42 +33,41 @@ import (
|
||||
"github.com/cgrates/cgrates/utils"
|
||||
)
|
||||
|
||||
var cdrsOfflineCfgPath string
|
||||
var cdrsOfflineCfg *config.CGRConfig
|
||||
var cdrsOfflineRpc *rpc.Client
|
||||
var cdrsOfflineConfDIR string // run the tests for specific configuration
|
||||
var (
|
||||
cdrsOfflineCfgPath string
|
||||
cdrsOfflineCfg *config.CGRConfig
|
||||
cdrsOfflineRpc *rpc.Client
|
||||
cdrsOfflineConfDIR string // run the tests for specific configuration
|
||||
|
||||
// subtests to be executed for each confDIR
|
||||
var sTestsCDRsOfflineIT = []func(t *testing.T){
|
||||
testV2CDRsOfflineInitConfig,
|
||||
testV2CDRsOfflineInitDataDb,
|
||||
testV2CDRsOfflineInitCdrDb,
|
||||
testV2CDRsOfflineStartEngine,
|
||||
testV2cdrsOfflineRpcConn,
|
||||
testV2CDRsOfflineLoadData,
|
||||
testV2CDRsOfflineBalanceUpdate,
|
||||
testV2CDRsOfflineExpiryBalance,
|
||||
testV2CDRsBalancesWithSameWeight,
|
||||
testV2CDRsOfflineKillEngine,
|
||||
}
|
||||
// subtests to be executed for each confDIR
|
||||
sTestsCDRsOfflineIT = []func(t *testing.T){
|
||||
testV2CDRsOfflineInitConfig,
|
||||
testV2CDRsOfflineInitDataDb,
|
||||
testV2CDRsOfflineInitCdrDb,
|
||||
testV2CDRsOfflineStartEngine,
|
||||
testV2cdrsOfflineRpcConn,
|
||||
testV2CDRsOfflineLoadData,
|
||||
testV2CDRsOfflineBalanceUpdate,
|
||||
testV2CDRsOfflineExpiryBalance,
|
||||
testV2CDRsBalancesWithSameWeight,
|
||||
testV2CDRsOfflineKillEngine,
|
||||
}
|
||||
)
|
||||
|
||||
// Tests starting here
|
||||
func TestCDRsOfflineITMySQL(t *testing.T) {
|
||||
cdrsOfflineConfDIR = "cdrsv2mysql"
|
||||
for _, stest := range sTestsCDRsOfflineIT {
|
||||
t.Run(cdrsOfflineConfDIR, stest)
|
||||
func TestCDRsOfflineIT(t *testing.T) {
|
||||
switch *dbType {
|
||||
case utils.MetaInternal:
|
||||
cdrsOfflineConfDIR = "cdrsv2internal"
|
||||
case utils.MetaSQL:
|
||||
cdrsOfflineConfDIR = "cdrsv2mysql"
|
||||
case utils.MetaMongo:
|
||||
cdrsOfflineConfDIR = "cdrsv2mongo"
|
||||
case utils.MetaPostgres:
|
||||
cdrsOfflineConfDIR = "cdrsv2psql"
|
||||
default:
|
||||
t.Fatal("Unknown Database type")
|
||||
}
|
||||
}
|
||||
|
||||
func TestCDRsOfflineITpg(t *testing.T) {
|
||||
cdrsOfflineConfDIR = "cdrsv2psql"
|
||||
for _, stest := range sTestsCDRsOfflineIT {
|
||||
t.Run(cdrsOfflineConfDIR, stest)
|
||||
}
|
||||
}
|
||||
|
||||
func TestCDRsOfflineITMongo(t *testing.T) {
|
||||
cdrsOfflineConfDIR = "cdrsv2mongo"
|
||||
for _, stest := range sTestsCDRsOfflineIT {
|
||||
t.Run(cdrsOfflineConfDIR, stest)
|
||||
}
|
||||
|
||||
46
apier/v2/lib_test.go
Normal file
46
apier/v2/lib_test.go
Normal file
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
Real-time Online/Offline Charging System (OCS) for Telecom & ISP environments
|
||||
Copyright (C) ITsysCOM GmbH
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
*/
|
||||
|
||||
package v2
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"flag"
|
||||
"net/rpc"
|
||||
"net/rpc/jsonrpc"
|
||||
|
||||
"github.com/cgrates/cgrates/config"
|
||||
"github.com/cgrates/cgrates/utils"
|
||||
)
|
||||
|
||||
var (
|
||||
dataDir = flag.String("data_dir", "/usr/share/cgrates", "CGR data dir path here")
|
||||
waitRater = flag.Int("wait_rater", 500, "Number of miliseconds to wait for rater to start and cache")
|
||||
encoding = flag.String("rpc", utils.MetaJSON, "what encoding whould be uused for rpc comunication")
|
||||
dbType = flag.String("dbtype", utils.MetaInternal, "The type of DataBase (Internal/Mongo/mySql)")
|
||||
)
|
||||
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")
|
||||
}
|
||||
}
|
||||
@@ -32,47 +32,45 @@ import (
|
||||
"github.com/cgrates/cgrates/utils"
|
||||
)
|
||||
|
||||
var tpCfgPath string
|
||||
var tpCfg *config.CGRConfig
|
||||
var tpRPC *rpc.Client
|
||||
var err error
|
||||
var delay int
|
||||
var configDIR string // relative path towards a config directory under samples prefix
|
||||
|
||||
var (
|
||||
testTPid = "V2TestTPit"
|
||||
)
|
||||
tpCfgPath string
|
||||
tpCfg *config.CGRConfig
|
||||
tpRPC *rpc.Client
|
||||
err error
|
||||
delay int
|
||||
configDIR string // relative path towards a config directory under samples prefix
|
||||
testTPid = "V2TestTPit"
|
||||
|
||||
// subtests to be executed for each confDIR
|
||||
var sTestsTutIT = []func(t *testing.T){
|
||||
testTPitLoadConfig,
|
||||
testTPitResetDataDb,
|
||||
testTPitResetStorDb,
|
||||
testTPitStartEngine,
|
||||
testTPitRpcConn,
|
||||
testTPitTimings,
|
||||
testTPitDestinations,
|
||||
testTPitKillEngine,
|
||||
}
|
||||
// subtests to be executed for each confDIR
|
||||
sTestsTutIT = []func(t *testing.T){
|
||||
testTPitLoadConfig,
|
||||
testTPitResetDataDb,
|
||||
testTPitResetStorDb,
|
||||
testTPitStartEngine,
|
||||
testTPitRpcConn,
|
||||
testTPitTimings,
|
||||
testTPitDestinations,
|
||||
testTPitKillEngine,
|
||||
}
|
||||
)
|
||||
|
||||
// Tests starting here
|
||||
|
||||
func TestITMySQLTutorial(t *testing.T) {
|
||||
configDIR = "tutmysql"
|
||||
for _, stest := range sTestsTutIT {
|
||||
t.Run(configDIR, stest)
|
||||
}
|
||||
}
|
||||
func TestTPit(t *testing.T) {
|
||||
|
||||
func TestITpgTutorial(t *testing.T) {
|
||||
configDIR = "tutpostgres"
|
||||
for _, stest := range sTestsTutIT {
|
||||
t.Run(configDIR, stest)
|
||||
switch *dbType {
|
||||
case utils.MetaInternal:
|
||||
configDIR = "tutinternal"
|
||||
case utils.MetaSQL:
|
||||
configDIR = "tutmysql"
|
||||
case utils.MetaMongo:
|
||||
configDIR = "tutmongo"
|
||||
case utils.MetaPostgres:
|
||||
configDIR = "tutpostgres"
|
||||
default:
|
||||
t.Fatal("Unknown Database type")
|
||||
}
|
||||
}
|
||||
|
||||
func TestITMongoTutorial(t *testing.T) {
|
||||
configDIR = "tutmongo"
|
||||
for _, stest := range sTestsTutIT {
|
||||
t.Run(configDIR, stest)
|
||||
}
|
||||
|
||||
@@ -2,21 +2,38 @@
|
||||
go clean --cache
|
||||
./test.sh
|
||||
gen=$?
|
||||
# Internal
|
||||
echo 'go test github.com/cgrates/cgrates/apier/v1 -tags=integration -dbtype=*internal'
|
||||
go test github.com/cgrates/cgrates/apier/v1 -tags=integration -dbtype=*internal
|
||||
ap1_internal=$?
|
||||
echo 'go test github.com/cgrates/cgrates/apier/v2 -tags=integration -dbtype=*internal'
|
||||
go test github.com/cgrates/cgrates/apier/v2 -tags=integration -dbtype=*internal
|
||||
ap2_internal=$?
|
||||
|
||||
# echo 'go test github.com/cgrates/cgrates/apier/v1 -tags=integration -dbtype=*internal'
|
||||
# go test github.com/cgrates/cgrates/apier/v1 -tags=integration -dbtype=*internal
|
||||
# ap1_internal=$?
|
||||
# SQL
|
||||
echo 'go test github.com/cgrates/cgrates/apier/v1 -tags=integration -dbtype=*sql'
|
||||
go test github.com/cgrates/cgrates/apier/v1 -tags=integration -dbtype=*sql
|
||||
ap1_sql=$?
|
||||
echo 'go test github.com/cgrates/cgrates/apier/v2 -tags=integration -dbtype=*sql'
|
||||
go test github.com/cgrates/cgrates/apier/v2 -tags=integration -dbtype=*sql
|
||||
ap2_sql=$?
|
||||
|
||||
# Mongo
|
||||
echo 'go test github.com/cgrates/cgrates/apier/v1 -tags=integration -dbtype=*mongo'
|
||||
go test github.com/cgrates/cgrates/apier/v1 -tags=integration -dbtype=*mongo
|
||||
ap1_mongo=$?
|
||||
echo 'go test github.com/cgrates/cgrates/apier/v2 -tags=integration -dbtype=*mongo'
|
||||
go test github.com/cgrates/cgrates/apier/v2 -tags=integration -dbtype=*mongo
|
||||
ap2_mongo=$?
|
||||
|
||||
# Postgres
|
||||
echo 'go test github.com/cgrates/cgrates/apier/v1 -tags=integration -dbtype=*postgres'
|
||||
go test github.com/cgrates/cgrates/apier/v1 -tags=integration -dbtype=*postgres
|
||||
ap1_postgres=$?
|
||||
echo 'go test github.com/cgrates/cgrates/apier/v2 -tags=integration -dbtype=*postgres'
|
||||
go test github.com/cgrates/cgrates/apier/v2 -tags=integration -dbtype=*postgres
|
||||
ap2_postgres=$?
|
||||
|
||||
echo 'go test github.com/cgrates/cgrates/apier/v2 -tags=integration'
|
||||
go test github.com/cgrates/cgrates/apier/v2 -tags=integration
|
||||
ap2=$?
|
||||
echo 'go test github.com/cgrates/cgrates/engine -tags=integration'
|
||||
go test github.com/cgrates/cgrates/engine -tags=integration
|
||||
en=$?
|
||||
|
||||
Reference in New Issue
Block a user