Removed useless tests

This commit is contained in:
andronache98
2022-03-29 17:20:33 +03:00
committed by Dan Christian Bogos
parent 3de5f31954
commit 147546fb58
4 changed files with 104 additions and 608 deletions

View File

@@ -1,164 +0,0 @@
{
// CGRateS Configuration file
//
"general": {
"log_level": 7,
"reply_timeout": "50s"
},
"listen": {
"rpc_json": ":2012",
"rpc_gob": ":2013",
"http": ":2080"
},
"data_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"],
"admins_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"],
"admins_conns": ["*internal"]
},
"loaders": [
{
"id": "LoaderRatesTest",
"enabled": true,
"tenant": "cgrates.org",
"tp_in_dir": "/usr/share/cgrates/tariffplans/100_thousand_dest",
"tp_out_dir": "",
"run_delay": "0",
"data":[
{
"type": "*rate_profiles",
"file_name": "Rates.csv",
"fields": [
{"tag": "TenantID", "path": "Tenant", "type": "*variable", "value": "~*req.0", "mandatory": true},
{"tag": "ProfileID", "path": "ID", "type": "*variable", "value": "~*req.1", "mandatory": true},
{"tag": "FilterIDs", "path": "FilterIDs", "type": "*variable", "value": "~*req.2"},
{"tag": "Weights", "path": "Weights", "type": "*variable", "value": "~*req.3"},
{"tag": "MinCost", "path": "MinCost", "type": "*variable", "value": "~*req.4"},
{"tag": "MaxCost", "path": "MaxCost", "type": "*variable", "value": "~*req.5"},
{"tag": "MaxCostStrategy", "path": "MaxCostStrategy", "type": "*variable", "value": "~*req.6"},
{"tag": "RateID", "path": "RateID", "type": "*variable", "value": "~*req.7"},
{"tag": "RateFilterIDs", "path": "RateFilterIDs", "type": "*variable", "value": "~*req.8"},
{"tag": "RateActivationTimes", "path": "RateActivationTimes", "type": "*variable", "value": "~*req.9"},
{"tag": "RateWeights", "path": "RateWeights", "type": "*variable", "value": "~*req.10"},
{"tag": "RateBlocker", "path": "RateBlocker", "type": "*variable", "value": "~*req.11"},
{"tag": "RateIntervalStart", "path": "RateIntervalStart", "type": "*variable", "value": "~*req.12"},
{"tag": "RateFixedFee", "path": "RateFixedFee", "type": "*variable", "value": "~*req.13"},
{"tag": "RateRecurrentFee", "path": "RateRecurrentFee", "type": "*variable", "value": "~*req.14"},
{"tag": "RateUnit", "path": "RateUnit", "type": "*variable", "value": "~*req.15"},
{"tag": "RateIncrement", "path": "RateIncrement", "type": "*variable", "value": "~*req.16"},
],
},
],
},
],
}

View File

@@ -1,175 +0,0 @@
{
// 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,
},
"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"],
"admins_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",
"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"],
"admins_conns": ["*internal"],
},
"loaders": [
{
"id": "LoaderRatesTest",
"enabled": true,
"tenant": "cgrates.org",
"tp_in_dir": "/usr/share/cgrates/tariffplans/100_thousand_dest",
"tp_out_dir": "",
"run_delay": "0",
"data":[
{
"type": "*rate_profiles",
"file_name": "Rates.csv",
"fields": [
{"tag": "TenantID", "path": "Tenant", "type": "*variable", "value": "~*req.0", "mandatory": true},
{"tag": "ProfileID", "path": "ID", "type": "*variable", "value": "~*req.1", "mandatory": true},
{"tag": "FilterIDs", "path": "FilterIDs", "type": "*variable", "value": "~*req.2"},
{"tag": "Weights", "path": "Weights", "type": "*variable", "value": "~*req.3"},
{"tag": "MinCost", "path": "MinCost", "type": "*variable", "value": "~*req.4"},
{"tag": "MaxCost", "path": "MaxCost", "type": "*variable", "value": "~*req.5"},
{"tag": "MaxCostStrategy", "path": "MaxCostStrategy", "type": "*variable", "value": "~*req.6"},
{"tag": "RateID", "path": "RateID", "type": "*variable", "value": "~*req.7"},
{"tag": "RateFilterIDs", "path": "RateFilterIDs", "type": "*variable", "value": "~*req.8"},
{"tag": "RateActivationTimes", "path": "RateActivationTimes", "type": "*variable", "value": "~*req.9"},
{"tag": "RateWeights", "path": "RateWeights", "type": "*variable", "value": "~*req.10"},
{"tag": "RateBlocker", "path": "RateBlocker", "type": "*variable", "value": "~*req.11"},
{"tag": "RateIntervalStart", "path": "RateIntervalStart", "type": "*variable", "value": "~*req.12"},
{"tag": "RateFixedFee", "path": "RateFixedFee", "type": "*variable", "value": "~*req.13"},
{"tag": "RateRecurrentFee", "path": "RateRecurrentFee", "type": "*variable", "value": "~*req.14"},
{"tag": "RateUnit", "path": "RateUnit", "type": "*variable", "value": "~*req.15"},
{"tag": "RateIncrement", "path": "RateIncrement", "type": "*variable", "value": "~*req.16"},
],
},
],
},
],
}

View File

@@ -1,171 +0,0 @@
{
// 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
},
"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"],
"admins_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":{
"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"],
"admins_conns": ["*internal"],
},
"loaders": [
{
"id": "LoaderRatesTest",
"enabled": true,
"tenant": "cgrates.org",
"tp_in_dir": "/usr/share/cgrates/tariffplans/100_thousand_dest",
"tp_out_dir": "",
"run_delay": "0",
"data":[
{
"type": "*rate_profiles",
"file_name": "Rates.csv",
"fields": [
{"tag": "TenantID", "path": "Tenant", "type": "*variable", "value": "~*req.0", "mandatory": true},
{"tag": "ProfileID", "path": "ID", "type": "*variable", "value": "~*req.1", "mandatory": true},
{"tag": "FilterIDs", "path": "FilterIDs", "type": "*variable", "value": "~*req.2"},
{"tag": "Weights", "path": "Weights", "type": "*variable", "value": "~*req.3"},
{"tag": "MinCost", "path": "MinCost", "type": "*variable", "value": "~*req.4"},
{"tag": "MaxCost", "path": "MaxCost", "type": "*variable", "value": "~*req.5"},
{"tag": "MaxCostStrategy", "path": "MaxCostStrategy", "type": "*variable", "value": "~*req.6"},
{"tag": "RateID", "path": "RateID", "type": "*variable", "value": "~*req.7"},
{"tag": "RateFilterIDs", "path": "RateFilterIDs", "type": "*variable", "value": "~*req.8"},
{"tag": "RateActivationTimes", "path": "RateActivationTimes", "type": "*variable", "value": "~*req.9"},
{"tag": "RateWeights", "path": "RateWeights", "type": "*variable", "value": "~*req.10"},
{"tag": "RateBlocker", "path": "RateBlocker", "type": "*variable", "value": "~*req.11"},
{"tag": "RateIntervalStart", "path": "RateIntervalStart", "type": "*variable", "value": "~*req.12"},
{"tag": "RateFixedFee", "path": "RateFixedFee", "type": "*variable", "value": "~*req.13"},
{"tag": "RateRecurrentFee", "path": "RateRecurrentFee", "type": "*variable", "value": "~*req.14"},
{"tag": "RateUnit", "path": "RateUnit", "type": "*variable", "value": "~*req.15"},
{"tag": "RateIncrement", "path": "RateIncrement", "type": "*variable", "value": "~*req.16"},
],
},
],
},
],
}

View File

@@ -20,111 +20,117 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package general_tests
// import (
// "fmt"
// "os"
// "path"
// "testing"
import (
"fmt"
"os"
"path"
"testing"
// "github.com/cgrates/birpc"
// "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 (
// testDblTpDifDestDir string
// testDblTpDifDestPath string
// testDblTpDifDestCfg *config.CGRConfig
// testDblTpDifDestRPC *birpc.Client
var (
testDblTpDifDestDir string
testDblTpDifDestPath string
testDblTpDifDestCfg *config.CGRConfig
testDblTpDifDestRPC *birpc.Client
// testDblTpDifDestTests = []func(t *testing.T){
// //testGenerateCsv,
// // testDblTpDifDestLoadConfig,
// // testDblTpDifDestResetDataDB,
// // //testDblTpDifDestStartEngine,
// // testDblTpDifDestRPCConn,
// // testDblTpDifDestLoadersLoad,
// //testDblTpDifDestStopCgrEngine,
// }
// )
testDblTpDifDestTests = []func(t *testing.T){
testGenerateCsv,
testDblTpDifDestLoadConfig,
testDblTpDifDestResetDataDB,
testDblTpDifDestStartEngine,
testDblTpDifDestRPCConn,
testDblTpDifDestLoadersLoad,
testDblTpDifDestStopCgrEngine,
}
)
// func TestDblTpDifDest(t *testing.T) {
// switch *dbType {
// case utils.MetaInternal:
// testDblTpDifDestDir = "dblTpDifInternal"
// case utils.MetaMySQL:
// testDblTpDifDestDir = "dblTpDifMySql"
// case utils.MetaMongo:
// testDblTpDifDestDir = "dblTpDifInternalMongo"
// case utils.MetaPostgres:
// t.SkipNow()
// default:
// t.Fatal("Unknown Database type")
// }
// for _, testDblTpDifDest := range testDblTpDifDestTests {
// t.Run(testDblTpDifDestDir, testDblTpDifDest)
// }
// }
func TestDblTpDifDest(t *testing.T) {
switch *dbType {
case utils.MetaInternal:
testDblTpDifDestDir = "dblTpDifInternal"
case utils.MetaMySQL:
testDblTpDifDestDir = "dblTpDifMySql"
case utils.MetaMongo:
testDblTpDifDestDir = "dblTpDifInternalMongo"
case utils.MetaPostgres:
t.SkipNow()
default:
t.Fatal("Unknown Database type")
}
for _, testDblTpDifDest := range testDblTpDifDestTests {
t.Run(testDblTpDifDestDir, testDblTpDifDest)
}
}
// func testDblTpDifDestLoadConfig(t *testing.T) {
// var err error
// testDblTpDifDestPath = path.Join(*dataDir, "conf", "samples", testDblTpDifDestDir)
// if testDblTpDifDestCfg, err = config.NewCGRConfigFromPath(testDblTpDifDestPath); err != nil {
// t.Error(err)
// }
// }
func testDblTpDifDestLoadConfig(t *testing.T) {
var err error
testDblTpDifDestPath = path.Join(*dataDir, "conf", "samples", testDblTpDifDestDir)
if testDblTpDifDestCfg, err = config.NewCGRConfigFromPath(context.Background(), testDblTpDifDestPath); err != nil {
t.Error(err)
}
}
// func testDblTpDifDestResetDataDB(t *testing.T) {
// if err := engine.InitDataDB(testDblTpDifDestCfg); err != nil {
// t.Fatal(err)
// }
// }
func testDblTpDifDestResetDataDB(t *testing.T) {
if err := engine.InitDataDB(testDblTpDifDestCfg); err != nil {
t.Fatal(err)
}
}
// func testDblTpDifDestStartEngine(t *testing.T) {
// if _, err := engine.StopStartEngine(testDblTpDifDestPath, *waitRater); err != nil {
// t.Fatal(err)
// }
// }
func testDblTpDifDestStartEngine(t *testing.T) {
if _, err := engine.StopStartEngine(testDblTpDifDestPath, *waitRater); err != nil {
t.Fatal(err)
}
}
// func testDblTpDifDestRPCConn(t *testing.T) {
// var err error
// testDblTpDifDestRPC, err = newRPCClient(testDblTpDifDestCfg.ListenCfg())
// if err != nil {
// t.Fatal(err)
// }
// }
func testDblTpDifDestRPCConn(t *testing.T) {
var err error
testDblTpDifDestRPC, err = newRPCClient(testDblTpDifDestCfg.ListenCfg())
if err != nil {
t.Fatal(err)
}
}
// func testDblTpDifDestLoadersLoad(t *testing.T) {
// // var reply string
// // if err := testDblTpDifDestRPC.Call(context.Background(), utils.LoaderSv1Load,
// // &loaders.ArgsProcessFolder{
// // LoaderID: "LoaderRatesTest",
// // StopOnError: true,
// // Caching: utils.StringPointer(utils.MetaReload),
// // ForceLock: true,
// // }, &reply); err != nil {
// // t.Error(err)
// // } else if reply != utils.OK {
// // t.Error("Unexpected reply returned:", reply)
// // }
func testDblTpDifDestLoadersLoad(t *testing.T) {
// }
// func testGenerateCsv(t *testing.T) {
// filename := "/tmp/dat2"
// os.Remove(filename)
// f, _ := os.Create(filename)
// fmt.Fprintf(f, `#Tenant,ID,FilterIDs,Weights,MinCost,MaxCost,MaxCostStrategy,RateID,RateFilterIDs,RateActivationStart,RateWeights,RateBlocker,RateIntervalStart,RateFixedFee,RateRecurrentFee,RateUnit,RateIncrement`+"\n")
// n := 100000
// for i := 1; i <= n; i++ {
// fmt.Fprintf(f, `cgrates.org,RT_RETAIL%v,,,,,,RT_1,*prefix:~*req.Destination:%v,"* * * * *",,,0s,,0.4,1m,30s`, i, i)
// fmt.Fprintf(f, "\n")
// fmt.Fprintf(f, `cgrates.org,RT_RETAIL%v,,,,,,RT_1_CHRISTMAS,*prefix:~*req.Destination:%v,* * 24 12 *,;30,false,0s,,0.06,1m,1s`, i, i)
// fmt.Fprintf(f, "\n")
// }
// }
// func testDblTpDifDestStopCgrEngine(t *testing.T) {
// if err := engine.KillEngine(100); err != nil {
// t.Error(err)
// }
// }
// caching := utils.MetaReload
// if testLdPrMatchAcCfg.DataDbCfg().Type == utils.Internal {
// caching = utils.MetaNone
// }
// var reply string
// if err := testLdPrMatchAcRPC.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 testGenerateCsv(t *testing.T) {
filename := "/tmp/dat2"
os.Remove(filename)
f, _ := os.Create(filename)
fmt.Fprintf(f, `#Tenant,ID,FilterIDs,Weights,MinCost,MaxCost,MaxCostStrategy,RateID,RateFilterIDs,RateActivationStart,RateWeights,RateBlocker,RateIntervalStart,RateFixedFee,RateRecurrentFee,RateUnit,RateIncrement`+"\n")
n := 100000
for i := 1; i <= n; i++ {
fmt.Fprintf(f, `cgrates.org,RT_RETAIL%v,,,,,,RT_1,*prefix:~*req.Destination:%v,"* * * * *",,,0s,,0.4,1m,30s`, i, i)
fmt.Fprintf(f, "\n")
fmt.Fprintf(f, `cgrates.org,RT_RETAIL%v,,,,,,RT_1_CHRISTMAS,*prefix:~*req.Destination:%v,* * 24 12 *,;30,false,0s,,0.06,1m,1s`, i, i)
fmt.Fprintf(f, "\n")
}
}
func testDblTpDifDestStopCgrEngine(t *testing.T) {
if err := engine.KillEngine(100); err != nil {
t.Error(err)
}
}