From 147546fb586671296d806e86e858f40ce2b379ad Mon Sep 17 00:00:00 2001 From: andronache98 Date: Tue, 29 Mar 2022 17:20:33 +0300 Subject: [PATCH] Removed useless tests --- .../samples/dblTpDifInternal/cgrates.json | 164 -------------- .../dblTpDifInternalMongo/cgrates.json | 175 --------------- data/conf/samples/dblTpDifMySql/cgrates.json | 171 --------------- general_tests/dbl_tp_dif_it_test.go | 202 +++++++++--------- 4 files changed, 104 insertions(+), 608 deletions(-) delete mode 100644 data/conf/samples/dblTpDifInternal/cgrates.json delete mode 100644 data/conf/samples/dblTpDifInternalMongo/cgrates.json delete mode 100644 data/conf/samples/dblTpDifMySql/cgrates.json diff --git a/data/conf/samples/dblTpDifInternal/cgrates.json b/data/conf/samples/dblTpDifInternal/cgrates.json deleted file mode 100644 index 48b1c1579..000000000 --- a/data/conf/samples/dblTpDifInternal/cgrates.json +++ /dev/null @@ -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"}, - ], - }, - ], - }, -], - -} diff --git a/data/conf/samples/dblTpDifInternalMongo/cgrates.json b/data/conf/samples/dblTpDifInternalMongo/cgrates.json deleted file mode 100644 index 39fa68f56..000000000 --- a/data/conf/samples/dblTpDifInternalMongo/cgrates.json +++ /dev/null @@ -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"}, - ], - }, - ], - }, -], - -} diff --git a/data/conf/samples/dblTpDifMySql/cgrates.json b/data/conf/samples/dblTpDifMySql/cgrates.json deleted file mode 100644 index e6b70c804..000000000 --- a/data/conf/samples/dblTpDifMySql/cgrates.json +++ /dev/null @@ -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: - "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"}, - ], - }, - ], - }, -], - -} diff --git a/general_tests/dbl_tp_dif_it_test.go b/general_tests/dbl_tp_dif_it_test.go index 6911df3b0..db81982b4 100644 --- a/general_tests/dbl_tp_dif_it_test.go +++ b/general_tests/dbl_tp_dif_it_test.go @@ -20,111 +20,117 @@ along with this program. If not, see */ 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) + } +}