mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-17 22:29:55 +05:00
Repairing integration test
This commit is contained in:
committed by
Dan Christian Bogos
parent
ee9a00b44d
commit
ae798dafe3
141
data/conf/samples/tp_internal/cgrates.json
Normal file
141
data/conf/samples/tp_internal/cgrates.json
Normal file
@@ -0,0 +1,141 @@
|
||||
{
|
||||
// CGRateS Configuration file
|
||||
//
|
||||
|
||||
|
||||
"general": {
|
||||
"log_level": 7,
|
||||
"reply_timeout": "50s"
|
||||
},
|
||||
|
||||
|
||||
"listen": {
|
||||
"rpc_json": ":2012",
|
||||
"rpc_gob": ":2013",
|
||||
"http": ":2080"
|
||||
},
|
||||
|
||||
|
||||
"data_db": {
|
||||
"db_type": "*internal"
|
||||
},
|
||||
|
||||
|
||||
"stor_db": {
|
||||
"db_type": "*internal"
|
||||
},
|
||||
|
||||
|
||||
"rals": {
|
||||
"enabled": true,
|
||||
"thresholds_conns": ["*internal"],
|
||||
"max_increments":3000000
|
||||
},
|
||||
|
||||
|
||||
"schedulers": {
|
||||
"enabled": true,
|
||||
"cdrs_conns": ["*internal"],
|
||||
"stats_conns": ["*localhost"]
|
||||
},
|
||||
|
||||
|
||||
"cdrs": {
|
||||
"enabled": true,
|
||||
"chargers_conns":["*internal"]
|
||||
},
|
||||
|
||||
|
||||
"attributes": {
|
||||
"enabled": true,
|
||||
"stats_conns": ["*localhost"],
|
||||
"resources_conns": ["*localhost"],
|
||||
"accounts_conns": ["*localhost"]
|
||||
},
|
||||
|
||||
|
||||
"chargers": {
|
||||
"enabled": true,
|
||||
"attributes_conns": ["*internal"]
|
||||
},
|
||||
|
||||
|
||||
"resources": {
|
||||
"enabled": true,
|
||||
"store_interval": "-1",
|
||||
"thresholds_conns": ["*internal"]
|
||||
},
|
||||
|
||||
|
||||
"stats": {
|
||||
"enabled": true,
|
||||
"store_interval": "-1",
|
||||
"thresholds_conns": ["*internal"]
|
||||
},
|
||||
|
||||
"thresholds": {
|
||||
"enabled": true,
|
||||
"store_interval": "-1"
|
||||
},
|
||||
|
||||
|
||||
"routes": {
|
||||
"enabled": true,
|
||||
"prefix_indexed_fields":["*req.Destination"],
|
||||
"stats_conns": ["*internal"],
|
||||
"resources_conns": ["*internal"],
|
||||
"rals_conns": ["*internal"]
|
||||
},
|
||||
|
||||
|
||||
"sessions": {
|
||||
"enabled": true,
|
||||
"routes_conns": ["*internal"],
|
||||
"resources_conns": ["*internal"],
|
||||
"attributes_conns": ["*internal"],
|
||||
"rals_conns": ["*internal"],
|
||||
"cdrs_conns": ["*internal"],
|
||||
"chargers_conns": ["*internal"]
|
||||
},
|
||||
|
||||
|
||||
"admins": {
|
||||
"enabled": true,
|
||||
"scheduler_conns": ["*internal"]
|
||||
},
|
||||
|
||||
|
||||
"rates": {
|
||||
"enabled": true
|
||||
},
|
||||
|
||||
|
||||
"actions": {
|
||||
"enabled": true,
|
||||
"accounts_conns": ["*localhost"]
|
||||
},
|
||||
|
||||
|
||||
"accounts": {
|
||||
"enabled": true
|
||||
},
|
||||
|
||||
|
||||
"filters": {
|
||||
"stats_conns": ["*internal"],
|
||||
"resources_conns": ["*internal"],
|
||||
"accounts_conns": ["*internal"],
|
||||
},
|
||||
|
||||
"loaders": [
|
||||
{
|
||||
"id": "*default",
|
||||
"enabled": true,
|
||||
"tenant": "cgrates.org",
|
||||
"lockfile_path": ".cgr.lck",
|
||||
"tp_in_dir": "/usr/share/cgrates/tariffplans/testtp",
|
||||
"tp_out_dir": "",
|
||||
},
|
||||
],
|
||||
|
||||
}
|
||||
156
data/conf/samples/tp_mongo/cgrates.json
Normal file
156
data/conf/samples/tp_mongo/cgrates.json
Normal file
@@ -0,0 +1,156 @@
|
||||
{
|
||||
// CGRateS Configuration file
|
||||
|
||||
|
||||
"general": {
|
||||
"log_level": 7,
|
||||
"reply_timeout": "30s",
|
||||
},
|
||||
|
||||
|
||||
"listen": {
|
||||
"rpc_json": ":2012",
|
||||
"rpc_gob": ":2013",
|
||||
"http": ":2080",
|
||||
},
|
||||
|
||||
|
||||
"data_db": {
|
||||
"db_type": "mongo",
|
||||
"db_name": "10",
|
||||
"db_port": 27017,
|
||||
},
|
||||
|
||||
|
||||
"stor_db": {
|
||||
"db_type": "mongo",
|
||||
"db_name": "cgrates",
|
||||
"db_port": 27017,
|
||||
},
|
||||
|
||||
|
||||
"rals": {
|
||||
"enabled": true,
|
||||
"thresholds_conns": ["*internal"],
|
||||
"max_increments":3000000,
|
||||
},
|
||||
|
||||
|
||||
"schedulers": {
|
||||
"enabled": true,
|
||||
"cdrs_conns": ["*internal"],
|
||||
"stats_conns": ["*localhost"],
|
||||
},
|
||||
|
||||
|
||||
"cdrs": {
|
||||
"enabled": true,
|
||||
"chargers_conns":["*internal"],
|
||||
},
|
||||
|
||||
|
||||
"attributes": {
|
||||
"enabled": true,
|
||||
"stats_conns": ["*localhost"],
|
||||
"resources_conns": ["*localhost"],
|
||||
"accounts_conns": ["*localhost"]
|
||||
},
|
||||
|
||||
|
||||
"chargers": {
|
||||
"enabled": true,
|
||||
"attributes_conns": ["*internal"],
|
||||
},
|
||||
|
||||
|
||||
"resources": {
|
||||
"enabled": true,
|
||||
"store_interval": "1s",
|
||||
"thresholds_conns": ["*internal"]
|
||||
},
|
||||
|
||||
|
||||
"stats": {
|
||||
"enabled": true,
|
||||
"store_interval": "1s",
|
||||
"thresholds_conns": ["*internal"],
|
||||
},
|
||||
|
||||
|
||||
"thresholds": {
|
||||
"enabled": true,
|
||||
"store_interval": "1s",
|
||||
},
|
||||
|
||||
|
||||
"routes": {
|
||||
"enabled": true,
|
||||
"prefix_indexed_fields":["*req.Destination"],
|
||||
"stats_conns": ["*internal"],
|
||||
"resources_conns": ["*internal"],
|
||||
"rals_conns": ["*internal"],
|
||||
},
|
||||
|
||||
|
||||
"sessions": {
|
||||
"enabled": true,
|
||||
"routes_conns": ["*internal"],
|
||||
"resources_conns": ["*internal"],
|
||||
"attributes_conns": ["*internal"],
|
||||
"rals_conns": ["*internal"],
|
||||
"cdrs_conns": ["*internal"],
|
||||
"chargers_conns": ["*internal"],
|
||||
},
|
||||
|
||||
|
||||
"migrator": {
|
||||
"out_datadb_type": "mongo",
|
||||
"out_datadb_port": "27017",
|
||||
"out_datadb_name": "10",
|
||||
"out_stordb_type": "mongo",
|
||||
"out_stordb_port": "27017",
|
||||
"out_stordb_name": "cgrates",
|
||||
"users_filters":["Account"],
|
||||
},
|
||||
|
||||
|
||||
"admins": {
|
||||
"enabled": true,
|
||||
"scheduler_conns": ["*internal"],
|
||||
},
|
||||
|
||||
|
||||
"rates": {
|
||||
"enabled": true
|
||||
},
|
||||
|
||||
|
||||
"actions": {
|
||||
"enabled": true,
|
||||
"accounts_conns": ["*localhost"]
|
||||
},
|
||||
|
||||
|
||||
"accounts": {
|
||||
"enabled": true
|
||||
},
|
||||
|
||||
|
||||
"filters": {
|
||||
"stats_conns": ["*internal"],
|
||||
"resources_conns": ["*internal"],
|
||||
"accounts_conns": ["*internal"],
|
||||
},
|
||||
|
||||
"loaders": [
|
||||
{
|
||||
"id": "*default",
|
||||
"enabled": true,
|
||||
"tenant": "cgrates.org",
|
||||
"lockfile_path": ".cgr.lck",
|
||||
"tp_in_dir": "/usr/share/cgrates/tariffplans/testtp",
|
||||
"tp_out_dir": "",
|
||||
},
|
||||
],
|
||||
|
||||
}
|
||||
132
data/conf/samples/tp_mysql/cgrates.json
Normal file
132
data/conf/samples/tp_mysql/cgrates.json
Normal file
@@ -0,0 +1,132 @@
|
||||
{
|
||||
// CGRateS Configuration file
|
||||
//
|
||||
|
||||
|
||||
"general": {
|
||||
"log_level": 7,
|
||||
"reply_timeout": "50s",
|
||||
},
|
||||
|
||||
|
||||
"listen": {
|
||||
"rpc_json": ":2012",
|
||||
"rpc_gob": ":2013",
|
||||
"http": ":2080",
|
||||
},
|
||||
|
||||
"data_db": { // database used to store runtime data (eg: accounts, cdr stats)
|
||||
"db_type": "redis", // data_db type: <redis|mongo>
|
||||
"db_port": 6379, // data_db port to reach the database
|
||||
"db_name": "10", // data_db database name to connect to
|
||||
},
|
||||
|
||||
"stor_db": {
|
||||
"db_password": "CGRateS.org",
|
||||
},
|
||||
|
||||
"cdrs": {
|
||||
"enabled": true,
|
||||
"chargers_conns":["*internal"],
|
||||
},
|
||||
|
||||
|
||||
"attributes": {
|
||||
"enabled": true,
|
||||
"stats_conns": ["*localhost"],
|
||||
"resources_conns": ["*localhost"],
|
||||
"accounts_conns": ["*localhost"]
|
||||
},
|
||||
|
||||
"chargers": {
|
||||
"enabled": true,
|
||||
"attributes_conns": ["*internal"],
|
||||
},
|
||||
|
||||
|
||||
"resources": {
|
||||
"enabled": true,
|
||||
"store_interval": "1s",
|
||||
"thresholds_conns": ["*internal"]
|
||||
},
|
||||
|
||||
|
||||
"stats": {
|
||||
"enabled": true,
|
||||
"store_interval": "1s",
|
||||
"thresholds_conns": ["*internal"],
|
||||
},
|
||||
|
||||
|
||||
"thresholds": {
|
||||
"enabled": true,
|
||||
"store_interval": "1s",
|
||||
},
|
||||
|
||||
|
||||
"routes": {
|
||||
"enabled": true,
|
||||
"prefix_indexed_fields":["*req.Destination"],
|
||||
"stats_conns": ["*internal"],
|
||||
"resources_conns": ["*internal"],
|
||||
"rals_conns": ["*internal"],
|
||||
},
|
||||
|
||||
|
||||
"sessions": {
|
||||
"enabled": true,
|
||||
"routes_conns": ["*internal"],
|
||||
"resources_conns": ["*internal"],
|
||||
"attributes_conns": ["*internal"],
|
||||
"rals_conns": ["*internal"],
|
||||
"cdrs_conns": ["*internal"],
|
||||
"chargers_conns": ["*internal"],
|
||||
},
|
||||
|
||||
|
||||
"migrator":{
|
||||
"out_stordb_password": "CGRateS.org",
|
||||
"users_filters":["Account"],
|
||||
},
|
||||
|
||||
|
||||
"admins": {
|
||||
"enabled": true,
|
||||
"scheduler_conns": ["*internal"],
|
||||
},
|
||||
|
||||
|
||||
"rates": {
|
||||
"enabled": true
|
||||
},
|
||||
|
||||
|
||||
"actions": {
|
||||
"enabled": true,
|
||||
"accounts_conns": ["*localhost"]
|
||||
},
|
||||
|
||||
|
||||
"accounts": {
|
||||
"enabled": true
|
||||
},
|
||||
|
||||
|
||||
"filters": {
|
||||
"stats_conns": ["*internal"],
|
||||
"resources_conns": ["*internal"],
|
||||
"accounts_conns": ["*internal"],
|
||||
},
|
||||
|
||||
"loaders": [
|
||||
{
|
||||
"id": "*default",
|
||||
"enabled": true,
|
||||
"tenant": "cgrates.org",
|
||||
"lockfile_path": ".cgr.lck",
|
||||
"tp_in_dir": "/usr/share/cgrates/tariffplans/testtp",
|
||||
"tp_out_dir": "",
|
||||
},
|
||||
],
|
||||
|
||||
}
|
||||
0
data/tariffplans/testtp/Accounts.csv
Normal file
0
data/tariffplans/testtp/Accounts.csv
Normal file
|
|
0
data/tariffplans/testtp/Actions.csv
Normal file
0
data/tariffplans/testtp/Actions.csv
Normal file
|
|
0
data/tariffplans/testtp/Chargers.csv
Normal file
0
data/tariffplans/testtp/Chargers.csv
Normal file
|
|
0
data/tariffplans/testtp/DispatcherHosts.csv
Normal file
0
data/tariffplans/testtp/DispatcherHosts.csv
Normal file
|
|
0
data/tariffplans/testtp/DispatcherProfiles.csv
Normal file
0
data/tariffplans/testtp/DispatcherProfiles.csv
Normal file
|
|
0
data/tariffplans/testtp/Rates.csv
Normal file
0
data/tariffplans/testtp/Rates.csv
Normal file
|
|
@@ -21,111 +21,123 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
|
||||
package general_tests
|
||||
|
||||
// import (
|
||||
// "net/rpc"
|
||||
// "path"
|
||||
// "testing"
|
||||
// "time"
|
||||
import (
|
||||
"path"
|
||||
"testing"
|
||||
|
||||
// "github.com/cgrates/cgrates/config"
|
||||
// "github.com/cgrates/cgrates/engine"
|
||||
// "github.com/cgrates/cgrates/utils"
|
||||
// )
|
||||
"github.com/cgrates/birpc"
|
||||
"github.com/cgrates/birpc/context"
|
||||
"github.com/cgrates/cgrates/config"
|
||||
"github.com/cgrates/cgrates/engine"
|
||||
"github.com/cgrates/cgrates/loaders"
|
||||
"github.com/cgrates/cgrates/utils"
|
||||
)
|
||||
|
||||
// var (
|
||||
// tpCfgPath string
|
||||
// tpCfgDIR string
|
||||
// tpCfg *config.CGRConfig
|
||||
// tpRPC *rpc.Client
|
||||
// tpLoadInst utils.LoadInstance // Share load information between tests
|
||||
var (
|
||||
tpCfgPath string
|
||||
tpCfgDIR string
|
||||
tpCfg *config.CGRConfig
|
||||
tpRPC *birpc.Client
|
||||
tpLoadInst utils.LoadInstance // Share load information between tests
|
||||
|
||||
// sTestTp = []func(t *testing.T){
|
||||
// testTpInitCfg,
|
||||
// testTpResetDataDb,
|
||||
// testTpResetStorDb,
|
||||
// testTpStartEngine,
|
||||
// testTpRpcConn,
|
||||
// testTpLoadTariffPlanFromFolder,
|
||||
// testTpBalanceCounter,
|
||||
// testTpActionTriggers,
|
||||
// testTpZeroCost,
|
||||
// testTpZeroNegativeCost,
|
||||
// testTpExecuteActionCgrRpc,
|
||||
// testTpExecuteActionCgrRpcAcc,
|
||||
// //testTpExecuteActionCgrRpcCdrStats,
|
||||
// testTpCreateExecuteActionMatch,
|
||||
// testTpSetRemoveActions,
|
||||
// testTpRemoveActionsRefenced,
|
||||
// testTpApierResetAccountActionTriggers,
|
||||
// testTpStopCgrEngine,
|
||||
// }
|
||||
// )
|
||||
sTestTp = []func(t *testing.T){
|
||||
testTpInitCfg,
|
||||
testTpResetDataDb,
|
||||
testTpResetStorDb,
|
||||
testTpStartEngine,
|
||||
testTpRpcConn,
|
||||
testTpLoadTariffPlanFromFolder,
|
||||
// testTpBalanceCounter,
|
||||
// testTpActionTriggers,
|
||||
// testTpZeroCost,
|
||||
// testTpZeroNegativeCost,
|
||||
// testTpExecuteActionCgrRpc,
|
||||
// testTpExecuteActionCgrRpcAcc,
|
||||
//testTpExecuteActionCgrRpcCdrStats,
|
||||
// testTpCreateExecuteActionMatch,
|
||||
// testTpSetRemoveActions,
|
||||
// testTpRemoveActionsRefenced,
|
||||
// testTpApierResetAccountActionTriggers,
|
||||
testTpStopCgrEngine,
|
||||
}
|
||||
)
|
||||
|
||||
// func TestTp(t *testing.T) {
|
||||
// switch *dbType {
|
||||
// case utils.MetaInternal:
|
||||
// tpCfgDIR = "tutinternal"
|
||||
// case utils.MetaMySQL:
|
||||
// tpCfgDIR = "tutmysql"
|
||||
// case utils.MetaMongo:
|
||||
// tpCfgDIR = "tutmongo"
|
||||
// case utils.MetaPostgres:
|
||||
// t.SkipNow()
|
||||
// default:
|
||||
// t.Fatal("Unknown Database type")
|
||||
// }
|
||||
// for _, stest := range sTestTp {
|
||||
// t.Run(tpCfgDIR, stest)
|
||||
// }
|
||||
// }
|
||||
// func testTpInitCfg(t *testing.T) {
|
||||
// tpCfgPath = path.Join(*dataDir, "conf", "samples", tpCfgDIR)
|
||||
// // Init config first
|
||||
// var err error
|
||||
// tpCfg, err = config.NewCGRConfigFromPath(tpCfgPath)
|
||||
// if err != nil {
|
||||
// t.Error(err)
|
||||
// }
|
||||
// }
|
||||
func TestTp(t *testing.T) {
|
||||
switch *dbType {
|
||||
case utils.MetaInternal:
|
||||
tpCfgDIR = "tp_internal"
|
||||
case utils.MetaMySQL:
|
||||
tpCfgDIR = "tp_mysql"
|
||||
case utils.MetaMongo:
|
||||
tpCfgDIR = "tp_mongo"
|
||||
case utils.MetaPostgres:
|
||||
t.SkipNow()
|
||||
default:
|
||||
t.Fatal("Unknown Database type")
|
||||
}
|
||||
for _, stest := range sTestTp {
|
||||
t.Run(tpCfgDIR, stest)
|
||||
}
|
||||
}
|
||||
func testTpInitCfg(t *testing.T) {
|
||||
tpCfgPath = path.Join(*dataDir, "conf", "samples", tpCfgDIR)
|
||||
// Init config first
|
||||
var err error
|
||||
tpCfg, err = config.NewCGRConfigFromPath(context.Background(), tpCfgPath)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
}
|
||||
|
||||
// // Remove data in both rating and accounting db
|
||||
// func testTpResetDataDb(t *testing.T) {
|
||||
// if err := engine.InitDataDB(tpCfg); err != nil {
|
||||
// t.Fatal(err)
|
||||
// }
|
||||
// }
|
||||
// Remove data in both rating and accounting db
|
||||
func testTpResetDataDb(t *testing.T) {
|
||||
if err := engine.InitDataDB(tpCfg); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
// // Wipe out the cdr database
|
||||
// func testTpResetStorDb(t *testing.T) {
|
||||
// if err := engine.InitStorDB(tpCfg); err != nil {
|
||||
// t.Fatal(err)
|
||||
// }
|
||||
// }
|
||||
// Wipe out the cdr database
|
||||
func testTpResetStorDb(t *testing.T) {
|
||||
if err := engine.InitStorDB(tpCfg); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
// // Start CGR Engine
|
||||
// func testTpStartEngine(t *testing.T) {
|
||||
// if _, err := engine.StopStartEngine(tpCfgPath, 1000); err != nil {
|
||||
// t.Fatal(err)
|
||||
// }
|
||||
// }
|
||||
// Start CGR Engine
|
||||
func testTpStartEngine(t *testing.T) {
|
||||
if _, err := engine.StopStartEngine(tpCfgPath, 1000); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
// // Connect rpc client to rater
|
||||
// func testTpRpcConn(t *testing.T) {
|
||||
// var err error
|
||||
// tpRPC, err = newRPCClient(tpCfg.ListenCfg()) // We connect over JSON so we can also troubleshoot if needed
|
||||
// if err != nil {
|
||||
// t.Fatal(err)
|
||||
// }
|
||||
// }
|
||||
// Connect rpc client to rater
|
||||
func testTpRpcConn(t *testing.T) {
|
||||
var err error
|
||||
tpRPC, err = newRPCClient(tpCfg.ListenCfg()) // We connect over JSON so we can also troubleshoot if needed
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
// // Load the tariff plan, creating accounts and their balances
|
||||
// func testTpLoadTariffPlanFromFolder(t *testing.T) {
|
||||
// attrs := &utils.AttrLoadTpFromFolder{FolderPath: path.Join(*dataDir, "tariffplans", "testtp")}
|
||||
// if err := tpRPC.Call(utils.APIerSv2LoadTariffPlanFromFolder, attrs, &tpLoadInst); err != nil {
|
||||
// t.Error(err)
|
||||
// }
|
||||
// time.Sleep(time.Duration(*waitRater) * time.Millisecond) // Give time for scheduler to execute topups
|
||||
// }
|
||||
// Load the tariff plan, creating accounts and their balances
|
||||
func testTpLoadTariffPlanFromFolder(t *testing.T) {
|
||||
caching := utils.MetaReload
|
||||
if tpCfg.DataDbCfg().Type == utils.Internal {
|
||||
caching = utils.MetaNone
|
||||
}
|
||||
var reply string
|
||||
if err := tpRPC.Call(context.Background(), utils.LoaderSv1Run,
|
||||
&loaders.ArgsProcessFolder{
|
||||
APIOpts: map[string]interface{}{
|
||||
utils.MetaCache: caching,
|
||||
utils.MetaStopOnError: true,
|
||||
},
|
||||
}, &reply); err != nil {
|
||||
t.Error(err)
|
||||
} else if reply != utils.OK {
|
||||
t.Error("Unexpected reply returned:", reply)
|
||||
}
|
||||
}
|
||||
|
||||
// func testTpBalanceCounter(t *testing.T) {
|
||||
// tStart := time.Date(2016, 3, 31, 0, 0, 0, 0, time.UTC)
|
||||
@@ -439,8 +451,8 @@ package general_tests
|
||||
// }
|
||||
// }
|
||||
|
||||
// func testTpStopCgrEngine(t *testing.T) {
|
||||
// if err := engine.KillEngine(100); err != nil {
|
||||
// t.Error(err)
|
||||
// }
|
||||
// }
|
||||
func testTpStopCgrEngine(t *testing.T) {
|
||||
if err := engine.KillEngine(100); err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user