From 7a135cb433d2ca72224fddd0a9ea91f3e159284f Mon Sep 17 00:00:00 2001 From: adragusin Date: Wed, 22 Jan 2020 17:56:50 +0200 Subject: [PATCH] Updated IT tests in dispatchers --- .../conf/samples/dispatchers/all/cgrates.json | 9 +- .../samples/dispatchers/all2/cgrates.json | 8 +- .../dispatchers/all2_mongo/cgrates.json | 95 ++++++++++++++++++ .../dispatchers/all2_mysql/cgrates.json | 92 +++++++++++++++++ .../dispatchers/all_mongo/cgrates.json | 98 ++++++++++++++++++ .../dispatchers/all_mysql/cgrates.json | 99 +++++++++++++++++++ dispatchers/attributes_it_test.go | 35 ++++--- dispatchers/caches_it_test.go | 30 ++++-- dispatchers/cdrs_it_test.go | 87 +++++++++------- dispatchers/chargers_it_test.go | 30 ++++-- dispatchers/config_it_test.go | 28 +++++- dispatchers/guardian_it_test.go | 28 +++++- dispatchers/lib_test.go | 5 +- dispatchers/rals_it_test.go | 28 +++++- dispatchers/resources_it_test.go | 30 ++++-- dispatchers/responder_it_test.go | 30 ++++-- dispatchers/scheduler_it_test.go | 29 +++++- dispatchers/sessions_it_test.go | 31 ++++-- dispatchers/stats_it_test.go | 30 ++++-- dispatchers/suppliers_it_test.go | 30 ++++-- dispatchers/thresholds_it_test.go | 30 ++++-- 21 files changed, 724 insertions(+), 158 deletions(-) create mode 100644 data/conf/samples/dispatchers/all2_mongo/cgrates.json create mode 100644 data/conf/samples/dispatchers/all2_mysql/cgrates.json create mode 100644 data/conf/samples/dispatchers/all_mongo/cgrates.json create mode 100644 data/conf/samples/dispatchers/all_mysql/cgrates.json diff --git a/data/conf/samples/dispatchers/all/cgrates.json b/data/conf/samples/dispatchers/all/cgrates.json index e57fda0ba..ec3d09ad6 100644 --- a/data/conf/samples/dispatchers/all/cgrates.json +++ b/data/conf/samples/dispatchers/all/cgrates.json @@ -21,6 +21,10 @@ "db_name": "11", // data_db database name to connect to }, +"stor_db": { + "db_password": "CGRateS.org", +}, + "rpc_conns": { "conn1": { @@ -33,11 +37,6 @@ } }, - -"stor_db": { - "db_password": "CGRateS.org", -}, - "attributes": { "enabled": true }, diff --git a/data/conf/samples/dispatchers/all2/cgrates.json b/data/conf/samples/dispatchers/all2/cgrates.json index 46665883d..5e25686f2 100644 --- a/data/conf/samples/dispatchers/all2/cgrates.json +++ b/data/conf/samples/dispatchers/all2/cgrates.json @@ -21,6 +21,9 @@ "db_name": "12", // data_db database name to connect to }, +"stor_db": { + "db_type":"*internal", +}, "rpc_conns": { "conn1": { @@ -29,11 +32,6 @@ }, }, - -"stor_db": { - "db_type":"*internal", -}, - "attributes": { "enabled": true }, diff --git a/data/conf/samples/dispatchers/all2_mongo/cgrates.json b/data/conf/samples/dispatchers/all2_mongo/cgrates.json new file mode 100644 index 000000000..878083285 --- /dev/null +++ b/data/conf/samples/dispatchers/all2_mongo/cgrates.json @@ -0,0 +1,95 @@ +{ +// CGRateS Configuration file +// + + +"general": { + "node_id": "ALL2", + "log_level": 7 +}, + + +"listen": { + "rpc_json": ":7012", + "rpc_gob": ":7013", + "http": ":7080", +}, + +"data_db": { + "db_type": "mongo", + "db_name": "10", + "db_port": 27017, +}, + + +"stor_db": { + "db_type": "mongo", + "db_name": "cgrates", + "db_port": 27017, +}, + + +"rpc_conns": { + "conn1": { + "strategy": "*first", + "conns": [{"address": "127.0.0.1:7012", "transport":"*json"}], + }, +}, + +"attributes": { + "enabled": true +}, + +"rals": { + "enabled": true, +}, + +"schedulers": { + "enabled": true, +}, + +"chargers": { + "enabled": true, + "attributes_conns": ["*internal"], +}, + +"thresholds": { + "enabled": true, +}, + +"suppliers": { + "enabled": true, +}, + +"stats": { + "enabled": true, +}, + +"resources": { + "enabled": true, +}, + +"cdrs": { + "enabled": true, + "chargers_conns":["*internal"], + "rals_conns": ["*internal"], +}, + +"sessions": { + "enabled": true, + "listen_bijson": ":7014", + "suppliers_conns": ["*internal"], + "resources_conns": ["*internal"], + "attributes_conns": ["*internal"], + "rals_conns": ["*internal"], + "cdrs_conns": ["*internal"], + "chargers_conns": ["*internal"], +}, + +"apier": { + "caches_conns":["conn1"], + "scheduler_conns": ["*internal"], +}, + + +} diff --git a/data/conf/samples/dispatchers/all2_mysql/cgrates.json b/data/conf/samples/dispatchers/all2_mysql/cgrates.json new file mode 100644 index 000000000..2c1b2905b --- /dev/null +++ b/data/conf/samples/dispatchers/all2_mysql/cgrates.json @@ -0,0 +1,92 @@ +{ +// CGRateS Configuration file +// + + +"general": { + "node_id": "ALL2", + "log_level": 7 +}, + + +"listen": { + "rpc_json": ":7012", + "rpc_gob": ":7013", + "http": ":7080", +}, + +"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": "12", // data_db database name to connect to +}, + +"stor_db": { + "db_type":"*internal", +}, + + +"rpc_conns": { + "conn1": { + "strategy": "*first", + "conns": [{"address": "127.0.0.1:7012", "transport":"*json"}], + }, +}, + +"attributes": { + "enabled": true +}, + +"rals": { + "enabled": true, +}, + +"schedulers": { + "enabled": true, +}, + +"chargers": { + "enabled": true, + "attributes_conns": ["*internal"], +}, + +"thresholds": { + "enabled": true, +}, + +"suppliers": { + "enabled": true, +}, + +"stats": { + "enabled": true, +}, + +"resources": { + "enabled": true, +}, + +"cdrs": { + "enabled": true, + "chargers_conns":["*internal"], + "rals_conns": ["*internal"], +}, + +"sessions": { + "enabled": true, + "listen_bijson": ":7014", + "suppliers_conns": ["*internal"], + "resources_conns": ["*internal"], + "attributes_conns": ["*internal"], + "rals_conns": ["*internal"], + "cdrs_conns": ["*internal"], + "chargers_conns": ["*internal"], +}, + +"apier": { + "caches_conns":["conn1"], + "scheduler_conns": ["*internal"], +}, + + +} diff --git a/data/conf/samples/dispatchers/all_mongo/cgrates.json b/data/conf/samples/dispatchers/all_mongo/cgrates.json new file mode 100644 index 000000000..b65afbf83 --- /dev/null +++ b/data/conf/samples/dispatchers/all_mongo/cgrates.json @@ -0,0 +1,98 @@ +{ +// CGRateS Configuration file +// + + +"general": { + "node_id": "ALL", + "log_level": 7 +}, + + +"listen": { + "rpc_json": ":6012", + "rpc_gob": ":6013", + "http": ":6080", +}, + +"data_db": { + "db_type": "mongo", + "db_name": "11", + "db_port": 27017, +}, + + +"stor_db": { + "db_type": "mongo", + "db_name": "cgrates", + "db_port": 27017, +}, + + +"rpc_conns": { + "conn1": { + "strategy": "*first", + "conns": [{"address": "127.0.0.1:6012", "transport":"*json"}], + }, + "rplConn": { + "strategy": "*broadcast_sync", + "conns": [{"address": "127.0.0.1:7012", "transport":"*json"}], + } +}, + +"attributes": { + "enabled": true +}, + +"rals": { + "enabled": true, +}, + +"schedulers": { + "enabled": true, +}, + +"chargers": { + "enabled": true, + "attributes_conns": ["*internal"], +}, + +"thresholds": { + "enabled": true, +}, + +"suppliers": { + "enabled": true, +}, + +"stats": { + "enabled": true, +}, + +"resources": { + "enabled": true, +}, + +"cdrs": { + "enabled": true, + "chargers_conns":["*internal"], + "rals_conns": ["*internal"], +}, + +"sessions": { + "enabled": true, + "listen_bijson": ":6014", + "suppliers_conns": ["*internal"], + "resources_conns": ["*internal"], + "attributes_conns": ["*internal"], + "rals_conns": ["*internal"], + "chargers_conns": ["*internal"], + "cdrs_conns": ["*internal"], +}, + +"apier": { + "caches_conns":["conn1"], + "scheduler_conns": ["*internal"], +}, + +} diff --git a/data/conf/samples/dispatchers/all_mysql/cgrates.json b/data/conf/samples/dispatchers/all_mysql/cgrates.json new file mode 100644 index 000000000..f97063220 --- /dev/null +++ b/data/conf/samples/dispatchers/all_mysql/cgrates.json @@ -0,0 +1,99 @@ +{ + // CGRateS Configuration file + // + + + "general": { + "node_id": "ALL", + "log_level": 7 + }, + + + "listen": { + "rpc_json": ":6012", + "rpc_gob": ":6013", + "http": ":6080", + }, + + "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": "11", // data_db database name to connect to + }, + + "stor_db": { + "db_password": "CGRateS.org", + }, + + + "rpc_conns": { + "conn1": { + "strategy": "*first", + "conns": [{"address": "127.0.0.1:6012", "transport":"*json"}], + }, + "rplConn": { + "strategy": "*broadcast_sync", + "conns": [{"address": "127.0.0.1:7012", "transport":"*json"}], + } + }, + + + + + "attributes": { + "enabled": true + }, + + "rals": { + "enabled": true, + }, + + "schedulers": { + "enabled": true, + }, + + "chargers": { + "enabled": true, + "attributes_conns": ["*internal"], + }, + + "thresholds": { + "enabled": true, + }, + + "suppliers": { + "enabled": true, + }, + + "stats": { + "enabled": true, + }, + + "resources": { + "enabled": true, + }, + + "cdrs": { + "enabled": true, + "chargers_conns":["*internal"], + "rals_conns": ["*internal"], + }, + + "sessions": { + "enabled": true, + "listen_bijson": ":6014", + "suppliers_conns": ["*internal"], + "resources_conns": ["*internal"], + "attributes_conns": ["*internal"], + "rals_conns": ["*internal"], + "chargers_conns": ["*internal"], + "cdrs_conns": ["*internal"], + }, + + "apier": { + "caches_conns":["conn1"], + "scheduler_conns": ["*internal"], + }, + +} + \ No newline at end of file diff --git a/dispatchers/attributes_it_test.go b/dispatchers/attributes_it_test.go index 77aa96f05..a8e3f68d2 100755 --- a/dispatchers/attributes_it_test.go +++ b/dispatchers/attributes_it_test.go @@ -46,28 +46,41 @@ var sTestsDspAttr = []func(t *testing.T){ } //Test start here -func TestDspAttributeSTMySQL(t *testing.T) { - if *encoding == utils.MetaGOB { - testDsp(t, sTestsDspAttr, "TestDspAttributeS", "all", "all2", "dispatchers_mysql", "tutorial", "oldtutorial", "dispatchers_gob") - } else { - testDsp(t, sTestsDspAttr, "TestDspAttributeS", "all", "all2", "dispatchers_mysql", "tutorial", "oldtutorial", "dispatchers") +func TestDspAttributeS(t *testing.T) { + var config1, config2, config3 string + switch *dbType { + case utils.MetaInternal: + t.SkipNow() + case utils.MetaSQL: + config1 = "all_mysql" + config2 = "all2_mysql" + config3 = "dispatchers_mysql" + case utils.MetaMongo: + config1 = "all_mongo" + config2 = "all2_mongo" + config3 = "dispatchers_mongo" + case utils.MetaPostgres: + t.SkipNow() + default: + t.Fatal("Unknown Database type") } -} -func TestDspAttributeSMongo(t *testing.T) { + dispDIR := "dispatchers" if *encoding == utils.MetaGOB { - testDsp(t, sTestsDspAttr, "TestDspAttributeS", "all", "all2", "dispatchers_mongo", "tutorial", "oldtutorial", "dispatchers_gob") - } else { - testDsp(t, sTestsDspAttr, "TestDspAttributeS", "all", "all2", "dispatchers_mongo", "tutorial", "oldtutorial", "dispatchers") + dispDIR += "_gob" } + testDsp(t, sTestsDspAttr, "TestDspAttributeS", config1, config2, config3, "tutorial", "oldtutorial", dispDIR) } func TestDspAttributeSNoConn(t *testing.T) { + if *dbType != utils.MetaSQL { + t.SkipNow() + } testDsp(t, []func(t *testing.T){ testDspAttrPingFailover, testDspAttrPing, testDspAttrPingNoArgDispatcher, - }, "TestDspAttributeS", "all", "all2", "dispatchers_no_attributes", "tutorial", "oldtutorial", "dispatchers") + }, "TestDspAttributeS", "all_mysql", "all2_mysql", "dispatchers_no_attributes", "tutorial", "oldtutorial", "dispatchers") } func testDspAttrPingFailover(t *testing.T) { diff --git a/dispatchers/caches_it_test.go b/dispatchers/caches_it_test.go index fd8166f55..8ed4f0dff 100644 --- a/dispatchers/caches_it_test.go +++ b/dispatchers/caches_it_test.go @@ -45,20 +45,30 @@ var sTestsDspChc = []func(t *testing.T){ } //Test start here -func TestDspCacheSv1TMySQL(t *testing.T) { - if *encoding == utils.MetaGOB { - testDsp(t, sTestsDspChc, "TestDspCacheSv1", "all", "all2", "dispatchers_mysql", "tutorial", "oldtutorial", "dispatchers_gob") - } else { - testDsp(t, sTestsDspChc, "TestDspCacheSv1", "all", "all2", "dispatchers_mysql", "tutorial", "oldtutorial", "dispatchers") +func TestDspCacheSv1(t *testing.T) { + var config1, config2, config3 string + switch *dbType { + case utils.MetaInternal: + t.SkipNow() + case utils.MetaSQL: + config1 = "all_mysql" + config2 = "all2_mysql" + config3 = "dispatchers_mysql" + case utils.MetaMongo: + config1 = "all_mongo" + config2 = "all2_mongo" + config3 = "dispatchers_mongo" + case utils.MetaPostgres: + t.SkipNow() + default: + t.Fatal("Unknown Database type") } -} -func TestDspCacheSv1Mongo(t *testing.T) { + dispDIR := "dispatchers" if *encoding == utils.MetaGOB { - testDsp(t, sTestsDspChc, "TestDspCacheSv1", "all", "all2", "dispatchers_mongo", "tutorial", "oldtutorial", "dispatchers_gob") - } else { - testDsp(t, sTestsDspChc, "TestDspCacheSv1", "all", "all2", "dispatchers_mongo", "tutorial", "oldtutorial", "dispatchers") + dispDIR += "_gob" } + testDsp(t, sTestsDspChc, "TestDspCacheSv1", config1, config2, config3, "tutorial", "oldtutorial", dispDIR) } func testDspChcPing(t *testing.T) { diff --git a/dispatchers/cdrs_it_test.go b/dispatchers/cdrs_it_test.go index 85f9bd2ce..91eb0b7ca 100644 --- a/dispatchers/cdrs_it_test.go +++ b/dispatchers/cdrs_it_test.go @@ -28,52 +28,67 @@ import ( "github.com/cgrates/cgrates/utils" ) -var sTestsDspCDRs = []func(t *testing.T){ - testDspCDRsPing, - testDspCDRsProcessEvent, - testDspCDRsCountCDR, - testDspCDRsGetCDR, - testDspCDRsGetCDRWithoutTenant, - testDspCDRsProcessCDR, - testDspCDRsGetCDR2, - testDspCDRsProcessExternalCDR, - testDspCDRsGetCDR3, -} +var ( + sTestsDspCDRs = []func(t *testing.T){ + testDspCDRsPing, + testDspCDRsProcessEvent, + testDspCDRsCountCDR, + testDspCDRsGetCDR, + testDspCDRsGetCDRWithoutTenant, + testDspCDRsProcessCDR, + testDspCDRsGetCDR2, + testDspCDRsProcessExternalCDR, + testDspCDRsGetCDR3, + } -var sTestsDspCDRsWithoutAuth = []func(t *testing.T){ - testDspCDRsPingNoAuth, - testDspCDRsProcessEventNoAuth, - testDspCDRsCountCDRNoAuth, - testDspCDRsGetCDRNoAuth, - testDspCDRsGetCDRNoAuthWithoutTenant, - testDspCDRsProcessCDRNoAuth, - testDspCDRsGetCDR2NoAuth, - testDspCDRsProcessExternalCDRNoAuth, - testDspCDRsGetCDR3NoAuth, -} + sTestsDspCDRsWithoutAuth = []func(t *testing.T){ + testDspCDRsPingNoAuth, + testDspCDRsProcessEventNoAuth, + testDspCDRsCountCDRNoAuth, + testDspCDRsGetCDRNoAuth, + testDspCDRsGetCDRNoAuthWithoutTenant, + testDspCDRsProcessCDRNoAuth, + testDspCDRsGetCDR2NoAuth, + testDspCDRsProcessExternalCDRNoAuth, + testDspCDRsGetCDR3NoAuth, + } +) //Test start here -func TestDspCDRsITMySQL(t *testing.T) { - if *encoding == utils.MetaGOB { - testDsp(t, sTestsDspCDRs, "TestDspCDRs", "all", "all2", "dispatchers_mysql", "tutorial", "oldtutorial", "dispatchers_gob") - } else { - testDsp(t, sTestsDspCDRs, "TestDspCDRs", "all", "all2", "dispatchers_mysql", "tutorial", "oldtutorial", "dispatchers") +func TestDspCDRsIT(t *testing.T) { + var config1, config2, config3 string + switch *dbType { + case utils.MetaInternal: + t.SkipNow() + case utils.MetaSQL: + config1 = "all_mysql" + config2 = "all2_mysql" + config3 = "dispatchers_mysql" + case utils.MetaMongo: + config1 = "all_mongo" + config2 = "all2_mongo" + config3 = "dispatchers_mongo" + case utils.MetaPostgres: + t.SkipNow() + default: + t.Fatal("Unknown Database type") } + + dispDIR := "dispatchers" + if *encoding == utils.MetaGOB { + dispDIR += "_gob" + } + testDsp(t, sTestsDspCDRs, "TestDspCDRs", config1, config2, config3, "tutorial", "oldtutorial", dispDIR) } func TestDspCDRsITMySQLWithoutAuth(t *testing.T) { - if *encoding == utils.MetaGOB { - testDsp(t, sTestsDspCDRsWithoutAuth, "TestDspCDRsWithoutAuth", "all", "all2", "dispatchers_no_attributes", "tutorial", "oldtutorial", "dispatchers_gob") - } else { - testDsp(t, sTestsDspCDRsWithoutAuth, "TestDspCDRsWithoutAuth", "all", "all2", "dispatchers_no_attributes", "tutorial", "oldtutorial", "dispatchers") + if *dbType != utils.MetaSQL { + t.SkipNow() } -} - -func TestDspCDRsITMongo(t *testing.T) { if *encoding == utils.MetaGOB { - testDsp(t, sTestsDspCDRs, "TestDspCDRs", "all", "all2", "dispatchers_mongo", "tutorial", "oldtutorial", "dispatchers_gob") + testDsp(t, sTestsDspCDRsWithoutAuth, "TestDspCDRsWithoutAuth", "all_mysql", "all2_mysql", "dispatchers_no_attributes", "tutorial", "oldtutorial", "dispatchers_gob") } else { - testDsp(t, sTestsDspCDRs, "TestDspCDRs", "all", "all2", "dispatchers_mongo", "tutorial", "oldtutorial", "dispatchers") + testDsp(t, sTestsDspCDRsWithoutAuth, "TestDspCDRsWithoutAuth", "all_mysql", "all2_mysql", "dispatchers_no_attributes", "tutorial", "oldtutorial", "dispatchers") } } diff --git a/dispatchers/chargers_it_test.go b/dispatchers/chargers_it_test.go index 2973afa1a..511d26955 100755 --- a/dispatchers/chargers_it_test.go +++ b/dispatchers/chargers_it_test.go @@ -41,20 +41,30 @@ var sTestsDspCpp = []func(t *testing.T){ } //Test start here -func TestDspChargerSTMySQL(t *testing.T) { - if *encoding == utils.MetaGOB { - testDsp(t, sTestsDspCpp, "TestDspChargerS", "all", "all2", "dispatchers_mysql", "tutorial", "oldtutorial", "dispatchers_gob") - } else { - testDsp(t, sTestsDspCpp, "TestDspChargerS", "all", "all2", "dispatchers_mysql", "tutorial", "oldtutorial", "dispatchers") +func TestDspChargerST(t *testing.T) { + var config1, config2, config3 string + switch *dbType { + case utils.MetaInternal: + t.SkipNow() + case utils.MetaSQL: + config1 = "all_mysql" + config2 = "all2_mysql" + config3 = "dispatchers_mysql" + case utils.MetaMongo: + config1 = "all_mongo" + config2 = "all2_mongo" + config3 = "dispatchers_mongo" + case utils.MetaPostgres: + t.SkipNow() + default: + t.Fatal("Unknown Database type") } -} -func TestDspChargerSMongo(t *testing.T) { + dispDIR := "dispatchers" if *encoding == utils.MetaGOB { - testDsp(t, sTestsDspCpp, "TestDspChargerS", "all", "all2", "dispatchers_mongo", "tutorial", "oldtutorial", "dispatchers_gob") - } else { - testDsp(t, sTestsDspCpp, "TestDspChargerS", "all", "all2", "dispatchers_mongo", "tutorial", "oldtutorial", "dispatchers") + dispDIR += "_gob" } + testDsp(t, sTestsDspCpp, "TestDspChargerS", config1, config2, config3, "tutorial", "oldtutorial", dispDIR) } func testDspCppPingFailover(t *testing.T) { diff --git a/dispatchers/config_it_test.go b/dispatchers/config_it_test.go index a2b2489c8..c45de7de1 100644 --- a/dispatchers/config_it_test.go +++ b/dispatchers/config_it_test.go @@ -33,12 +33,30 @@ var sTestsDspConfig = []func(t *testing.T){ } //Test start here -func TestDspConfigITMySQL(t *testing.T) { - if *encoding == utils.MetaGOB { - testDsp(t, sTestsDspConfig, "TestDspConfigITMySQL", "all", "all2", "dispatchers_mysql", "tutorial", "oldtutorial", "dispatchers_gob") - } else { - testDsp(t, sTestsDspConfig, "TestDspConfigITMySQL", "all", "all2", "dispatchers_mysql", "tutorial", "oldtutorial", "dispatchers") +func TestDspConfigIT(t *testing.T) { + var config1, config2, config3 string + switch *dbType { + case utils.MetaInternal: + t.SkipNow() + case utils.MetaSQL: + config1 = "all_mysql" + config2 = "all2_mysql" + config3 = "dispatchers_mysql" + case utils.MetaMongo: + config1 = "all_mongo" + config2 = "all2_mongo" + config3 = "dispatchers_mongo" + case utils.MetaPostgres: + t.SkipNow() + default: + t.Fatal("Unknown Database type") } + + dispDIR := "dispatchers" + if *encoding == utils.MetaGOB { + dispDIR += "_gob" + } + testDsp(t, sTestsDspConfig, "TestDspConfigIT", config1, config2, config3, "tutorial", "oldtutorial", dispDIR) } func testDspConfigSv1GetJSONSection(t *testing.T) { diff --git a/dispatchers/guardian_it_test.go b/dispatchers/guardian_it_test.go index 91b083dc5..e3770d5ab 100644 --- a/dispatchers/guardian_it_test.go +++ b/dispatchers/guardian_it_test.go @@ -34,12 +34,30 @@ var sTestsDspGrd = []func(t *testing.T){ } //Test start here -func TestDspGuardianSTMySQL(t *testing.T) { - if *encoding == utils.MetaGOB { - testDsp(t, sTestsDspGrd, "TestDspGuardianS", "all", "all2", "dispatchers_mysql", "tutorial", "oldtutorial", "dispatchers_gob") - } else { - testDsp(t, sTestsDspGrd, "TestDspGuardianS", "all", "all2", "dispatchers_mysql", "tutorial", "oldtutorial", "dispatchers") +func TestDspGuardianST(t *testing.T) { + var config1, config2, config3 string + switch *dbType { + case utils.MetaInternal: + t.SkipNow() + case utils.MetaSQL: + config1 = "all_mysql" + config2 = "all2_mysql" + config3 = "dispatchers_mysql" + case utils.MetaMongo: + config1 = "all_mongo" + config2 = "all2_mongo" + config3 = "dispatchers_mongo" + case utils.MetaPostgres: + t.SkipNow() + default: + t.Fatal("Unknown Database type") } + + dispDIR := "dispatchers" + if *encoding == utils.MetaGOB { + dispDIR += "_gob" + } + testDsp(t, sTestsDspGrd, "TestDspGuardianS", config1, config2, config3, "tutorial", "oldtutorial", dispDIR) } func testDspGrdPing(t *testing.T) { diff --git a/dispatchers/lib_test.go b/dispatchers/lib_test.go index 29d4e428c..450dabe16 100644 --- a/dispatchers/lib_test.go +++ b/dispatchers/lib_test.go @@ -40,7 +40,10 @@ var ( allEngine2 *testDispatcher ) var ( - encoding = flag.String("rpc", utils.MetaJSON, "what encoding whould be uused for rpc comunication") + waitRater = flag.Int("wait_rater", 100, "Number of miliseconds to wait for rater to start and cache") + dataDir = flag.String("data_dir", "/usr/share/cgrates", "CGR data dir path here") + encoding = flag.String("rpc", utils.MetaJSON, "what encoding whould be used 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) { diff --git a/dispatchers/rals_it_test.go b/dispatchers/rals_it_test.go index f17a2249d..4012ea36c 100644 --- a/dispatchers/rals_it_test.go +++ b/dispatchers/rals_it_test.go @@ -33,12 +33,30 @@ var sTestsDspRALs = []func(t *testing.T){ } //Test start here -func TestDspRALsITMySQL(t *testing.T) { - if *encoding == utils.MetaGOB { - testDsp(t, sTestsDspRALs, "TestDspRALsITMySQL", "all", "all2", "dispatchers_mysql", "tutorial", "oldtutorial", "dispatchers_gob") - } else { - testDsp(t, sTestsDspRALs, "TestDspRALsITMySQL", "all", "all2", "dispatchers_mysql", "tutorial", "oldtutorial", "dispatchers") +func TestDspRALsIT(t *testing.T) { + var config1, config2, config3 string + switch *dbType { + case utils.MetaInternal: + t.SkipNow() + case utils.MetaSQL: + config1 = "all_mysql" + config2 = "all2_mysql" + config3 = "dispatchers_mysql" + case utils.MetaMongo: + config1 = "all_mongo" + config2 = "all2_mongo" + config3 = "dispatchers_mongo" + case utils.MetaPostgres: + t.SkipNow() + default: + t.Fatal("Unknown Database type") } + + dispDIR := "dispatchers" + if *encoding == utils.MetaGOB { + dispDIR += "_gob" + } + testDsp(t, sTestsDspRALs, "TestDspRALsITMySQL", config1, config2, config3, "tutorial", "oldtutorial", dispDIR) } func testDspRALsPing(t *testing.T) { diff --git a/dispatchers/resources_it_test.go b/dispatchers/resources_it_test.go index a0a7f3ae7..b3ad0d0e7 100755 --- a/dispatchers/resources_it_test.go +++ b/dispatchers/resources_it_test.go @@ -38,20 +38,30 @@ var sTestsDspRes = []func(t *testing.T){ } //Test start here -func TestDspResourceSITMySQL(t *testing.T) { - if *encoding == utils.MetaGOB { - testDsp(t, sTestsDspRes, "TestDspResourceS", "all", "all2", "dispatchers_mysql", "tutorial", "oldtutorial", "dispatchers_gob") - } else { - testDsp(t, sTestsDspRes, "TestDspResourceS", "all", "all2", "dispatchers_mysql", "tutorial", "oldtutorial", "dispatchers") +func TestDspResourceSIT(t *testing.T) { + var config1, config2, config3 string + switch *dbType { + case utils.MetaInternal: + t.SkipNow() + case utils.MetaSQL: + config1 = "all_mysql" + config2 = "all2_mysql" + config3 = "dispatchers_mysql" + case utils.MetaMongo: + config1 = "all_mongo" + config2 = "all2_mongo" + config3 = "dispatchers_mongo" + case utils.MetaPostgres: + t.SkipNow() + default: + t.Fatal("Unknown Database type") } -} -func TestDspResourceSITMongo(t *testing.T) { + dispDIR := "dispatchers" if *encoding == utils.MetaGOB { - testDsp(t, sTestsDspRes, "TestDspResourceS", "all", "all2", "dispatchers_mongo", "tutorial", "oldtutorial", "dispatchers_gob") - } else { - testDsp(t, sTestsDspRes, "TestDspResourceS", "all", "all2", "dispatchers_mongo", "tutorial", "oldtutorial", "dispatchers") + dispDIR += "_gob" } + testDsp(t, sTestsDspRes, "TestDspResourceS", config1, config2, config3, "tutorial", "oldtutorial", dispDIR) } func testDspResPingFailover(t *testing.T) { diff --git a/dispatchers/responder_it_test.go b/dispatchers/responder_it_test.go index 30d949aa6..45d92289a 100644 --- a/dispatchers/responder_it_test.go +++ b/dispatchers/responder_it_test.go @@ -37,20 +37,30 @@ var sTestsDspRsp = []func(t *testing.T){ } //Test start here -func TestDspResponderTMySQL(t *testing.T) { - if *encoding == utils.MetaGOB { - testDsp(t, sTestsDspRsp, "TestDspResponder", "all", "all2", "dispatchers_mysql", "tutorial", "oldtutorial", "dispatchers_gob") - } else { - testDsp(t, sTestsDspRsp, "TestDspResponder", "all", "all2", "dispatchers_mysql", "tutorial", "oldtutorial", "dispatchers") +func TestDspResponder(t *testing.T) { + var config1, config2, config3 string + switch *dbType { + case utils.MetaInternal: + t.SkipNow() + case utils.MetaSQL: + config1 = "all_mysql" + config2 = "all2_mysql" + config3 = "dispatchers_mysql" + case utils.MetaMongo: + config1 = "all_mongo" + config2 = "all2_mongo" + config3 = "dispatchers_mongo" + case utils.MetaPostgres: + t.SkipNow() + default: + t.Fatal("Unknown Database type") } -} -func TestDspResponderMongo(t *testing.T) { + dispDIR := "dispatchers" if *encoding == utils.MetaGOB { - testDsp(t, sTestsDspRsp, "TestDspResponder", "all", "all2", "dispatchers_mongo", "tutorial", "oldtutorial", "dispatchers_gob") - } else { - testDsp(t, sTestsDspRsp, "TestDspResponder", "all", "all2", "dispatchers_mongo", "tutorial", "oldtutorial", "dispatchers") + dispDIR += "_gob" } + testDsp(t, sTestsDspRsp, "TestDspResponder", config1, config2, config3, "tutorial", "oldtutorial", dispDIR) } func testDspResponderStatus(t *testing.T) { diff --git a/dispatchers/scheduler_it_test.go b/dispatchers/scheduler_it_test.go index f71d9b5ea..bcd767d3c 100644 --- a/dispatchers/scheduler_it_test.go +++ b/dispatchers/scheduler_it_test.go @@ -31,12 +31,31 @@ var sTestsDspSched = []func(t *testing.T){ } //Test start here -func TestDspSchedulerSTMySQL(t *testing.T) { - if *encoding == utils.MetaGOB { - testDsp(t, sTestsDspSched, "TestDspSchedulerSTMySQL", "all", "all2", "dispatchers_mysql", "tutorial", "oldtutorial", "dispatchers_gob") - } else { - testDsp(t, sTestsDspSched, "TestDspSchedulerSTMySQL", "all", "all2", "dispatchers_mysql", "tutorial", "oldtutorial", "dispatchers") + +func TestDspSchedulerS(t *testing.T) { + var config1, config2, config3 string + switch *dbType { + case utils.MetaInternal: + t.SkipNow() + case utils.MetaSQL: + config1 = "all_mysql" + config2 = "all2_mysql" + config3 = "dispatchers_mysql" + case utils.MetaMongo: + config1 = "all_mongo" + config2 = "all2_mongo" + config3 = "dispatchers_mongo" + case utils.MetaPostgres: + t.SkipNow() + default: + t.Fatal("Unknown Database type") } + + dispDIR := "dispatchers" + if *encoding == utils.MetaGOB { + dispDIR += "_gob" + } + testDsp(t, sTestsDspSched, "TestDspSchedulerSTMySQL", config1, config2, config3, "tutorial", "oldtutorial", dispDIR) } func testDspSchedPing(t *testing.T) { diff --git a/dispatchers/sessions_it_test.go b/dispatchers/sessions_it_test.go index 6d6f560ae..79dc18dda 100755 --- a/dispatchers/sessions_it_test.go +++ b/dispatchers/sessions_it_test.go @@ -57,20 +57,31 @@ var sTestsDspSession = []func(t *testing.T){ } //Test start here -func TestDspSessionSTMySQL(t *testing.T) { - if *encoding == utils.MetaGOB { - testDsp(t, sTestsDspSession, "TestDspSessionS", "all", "all2", "dispatchers_mysql_gob", "testit", "tutorial", "dispatchers_gob") - } else { - testDsp(t, sTestsDspSession, "TestDspSessionS", "all", "all2", "dispatchers_mysql", "testit", "tutorial", "dispatchers") +func TestDspSessionS(t *testing.T) { + var config1, config2, config3 string + switch *dbType { + case utils.MetaInternal: + t.SkipNow() + case utils.MetaSQL: + config1 = "all_mysql" + config2 = "all2_mysql" + config3 = "dispatchers_mysql" + case utils.MetaMongo: + config1 = "all_mongo" + config2 = "all2_mongo" + config3 = "dispatchers_mongo" + case utils.MetaPostgres: + t.SkipNow() + default: + t.Fatal("Unknown Database type") } -} -func TestDspSessionSMongo(t *testing.T) { + dispDIR := "dispatchers" if *encoding == utils.MetaGOB { - testDsp(t, sTestsDspSession, "TestDspSessionS", "all", "all2", "dispatchers_mongo_gob", "testit", "tutorial", "dispatchers_gob") - } else { - testDsp(t, sTestsDspSession, "TestDspSessionS", "all", "all2", "dispatchers_mongo", "testit", "tutorial", "dispatchers") + dispDIR += "_gob" + config3 += "_gob" } + testDsp(t, sTestsDspSession, "TestDspSessionS", config1, config2, config3, "testit", "tutorial", dispDIR) } func testDspSessionAddBalacne(t *testing.T) { diff --git a/dispatchers/stats_it_test.go b/dispatchers/stats_it_test.go index 08457fd1f..7f4a0a83f 100755 --- a/dispatchers/stats_it_test.go +++ b/dispatchers/stats_it_test.go @@ -41,20 +41,30 @@ var sTestsDspSts = []func(t *testing.T){ } //Test start here -func TestDspStatSTMySQL(t *testing.T) { - if *encoding == utils.MetaGOB { - testDsp(t, sTestsDspSts, "TestDspStatS", "all", "all2", "dispatchers_mysql", "tutorial", "oldtutorial", "dispatchers_gob") - } else { - testDsp(t, sTestsDspSts, "TestDspStatS", "all", "all2", "dispatchers_mysql", "tutorial", "oldtutorial", "dispatchers") +func TestDspStatS(t *testing.T) { + var config1, config2, config3 string + switch *dbType { + case utils.MetaInternal: + t.SkipNow() + case utils.MetaSQL: + config1 = "all_mysql" + config2 = "all2_mysql" + config3 = "dispatchers_mysql" + case utils.MetaMongo: + config1 = "all_mongo" + config2 = "all2_mongo" + config3 = "dispatchers_mongo" + case utils.MetaPostgres: + t.SkipNow() + default: + t.Fatal("Unknown Database type") } -} -func TestDspStatSMongo(t *testing.T) { + dispDIR := "dispatchers" if *encoding == utils.MetaGOB { - testDsp(t, sTestsDspSts, "TestDspStatS", "all", "all2", "dispatchers_mongo", "tutorial", "oldtutorial", "dispatchers_gob") - } else { - testDsp(t, sTestsDspSts, "TestDspStatS", "all", "all2", "dispatchers_mongo", "tutorial", "oldtutorial", "dispatchers") + dispDIR += "_gob" } + testDsp(t, sTestsDspSts, "TestDspStatS", config1, config2, config3, "tutorial", "oldtutorial", dispDIR) } func testDspStsPingFailover(t *testing.T) { diff --git a/dispatchers/suppliers_it_test.go b/dispatchers/suppliers_it_test.go index a74ff90eb..8c48b0dbc 100755 --- a/dispatchers/suppliers_it_test.go +++ b/dispatchers/suppliers_it_test.go @@ -42,20 +42,30 @@ var sTestsDspSup = []func(t *testing.T){ } //Test start here -func TestDspSupplierSTMySQL(t *testing.T) { - if *encoding == utils.MetaGOB { - testDsp(t, sTestsDspSup, "TestDspSupplierS", "all", "all2", "dispatchers_mysql", "tutorial", "oldtutorial", "dispatchers_gob") - } else { - testDsp(t, sTestsDspSup, "TestDspSupplierS", "all", "all2", "dispatchers_mysql", "tutorial", "oldtutorial", "dispatchers") +func TestDspSupplierS(t *testing.T) { + var config1, config2, config3 string + switch *dbType { + case utils.MetaInternal: + t.SkipNow() + case utils.MetaSQL: + config1 = "all_mysql" + config2 = "all2_mysql" + config3 = "dispatchers_mysql" + case utils.MetaMongo: + config1 = "all_mongo" + config2 = "all2_mongo" + config3 = "dispatchers_mongo" + case utils.MetaPostgres: + t.SkipNow() + default: + t.Fatal("Unknown Database type") } -} -func TestDspSupplierSMongo(t *testing.T) { + dispDIR := "dispatchers" if *encoding == utils.MetaGOB { - testDsp(t, sTestsDspSup, "TestDspSupplierS", "all", "all2", "dispatchers_mongo", "tutorial", "oldtutorial", "dispatchers_gob") - } else { - testDsp(t, sTestsDspSup, "TestDspSupplierS", "all", "all2", "dispatchers_mongo", "tutorial", "oldtutorial", "dispatchers") + dispDIR += "_gob" } + testDsp(t, sTestsDspSup, "TestDspSupplierS", config1, config2, config3, "tutorial", "oldtutorial", dispDIR) } func testDspSupPing(t *testing.T) { diff --git a/dispatchers/thresholds_it_test.go b/dispatchers/thresholds_it_test.go index 99df87cd9..6b90f7041 100755 --- a/dispatchers/thresholds_it_test.go +++ b/dispatchers/thresholds_it_test.go @@ -41,20 +41,30 @@ var sTestsDspTh = []func(t *testing.T){ } //Test start here -func TestDspThresholdSTMySQL(t *testing.T) { - if *encoding == utils.MetaGOB { - testDsp(t, sTestsDspTh, "TestDspThresholdS", "all", "all2", "dispatchers_mysql", "tutorial", "oldtutorial", "dispatchers_gob") - } else { - testDsp(t, sTestsDspTh, "TestDspThresholdS", "all", "all2", "dispatchers_mysql", "tutorial", "oldtutorial", "dispatchers") +func TestDspThresholdS(t *testing.T) { + var config1, config2, config3 string + switch *dbType { + case utils.MetaInternal: + t.SkipNow() + case utils.MetaSQL: + config1 = "all_mysql" + config2 = "all2_mysql" + config3 = "dispatchers_mysql" + case utils.MetaMongo: + config1 = "all_mongo" + config2 = "all2_mongo" + config3 = "dispatchers_mongo" + case utils.MetaPostgres: + t.SkipNow() + default: + t.Fatal("Unknown Database type") } -} -func TestDspThresholdSMongo(t *testing.T) { + dispDIR := "dispatchers" if *encoding == utils.MetaGOB { - testDsp(t, sTestsDspTh, "TestDspThresholdS", "all", "all2", "dispatchers_mongo", "tutorial", "oldtutorial", "dispatchers_gob") - } else { - testDsp(t, sTestsDspTh, "TestDspThresholdS", "all", "all2", "dispatchers_mongo", "tutorial", "oldtutorial", "dispatchers") + dispDIR += "_gob" } + testDsp(t, sTestsDspTh, "TestDspThresholdS", config1, config2, config3, "tutorial", "oldtutorial", dispDIR) } func testDspThPingFailover(t *testing.T) {