From 9621cd2baf9c057baac9921ee9456ae73615410a Mon Sep 17 00:00:00 2001 From: Anevo Date: Thu, 17 May 2018 06:00:53 -0400 Subject: [PATCH] Migrator: Added missing .json config options, updated migrator integration tests. --- cmd/cgr-migrator/cgr-migrator.go | 88 +++++++++---------- config/config.go | 19 ++++ config/config_defaults.go | 14 +++ config/config_json.go | 13 +++ config/config_json_test.go | 22 +++++ config/config_test.go | 20 +++++ config/libconfig_json.go | 15 ++++ config/migratorcfg.go | 76 ++++++++++++++++ .../cgrmigratorconfig/cgr-migrator.cfg | 36 ++++++++ data/conf/samples/tutmongojson/cgrates.json | 2 +- .../conf/samples/tutmongomsgpack/cgrates.json | 69 --------------- data/conf/samples/tutmysqljson/cgrates.json | 2 +- .../conf/samples/tutmysqlmsgpack/cgrates.json | 67 -------------- migrator/accounts_it_test.go | 11 +-- migrator/action_it_test.go | 8 +- migrator/action_plan_it_test.go | 8 +- migrator/action_trigger_it_test.go | 8 +- migrator/sharedgroup_it_test.go | 8 +- migrator/thresholds_it_test.go | 8 +- 19 files changed, 286 insertions(+), 208 deletions(-) create mode 100644 config/migratorcfg.go create mode 100644 data/conf/samples/cgrmigratorconfig/cgr-migrator.cfg delete mode 100644 data/conf/samples/tutmongomsgpack/cgrates.json delete mode 100644 data/conf/samples/tutmysqlmsgpack/cgrates.json diff --git a/cmd/cgr-migrator/cgr-migrator.go b/cmd/cgr-migrator/cgr-migrator.go index d5a4e08ff..6596e2a2d 100755 --- a/cmd/cgr-migrator/cgr-migrator.go +++ b/cmd/cgr-migrator/cgr-migrator.go @@ -162,60 +162,58 @@ func main() { } // out settings - if *outDataDBType == utils.MetaDataDB { - *outDataDBType = mgrCfg.DataDbType - } else { - *outDataDBType = strings.TrimPrefix(*outDataDBType, "*") + if *outDataDBType != utils.MetaDataDB { + mgrCfg.MigratorCgrConfig.OutDataDBType = strings.TrimPrefix(*outDataDBType, "*") } - if *outDataDBHost == utils.MetaDataDB { - *outDataDBHost = mgrCfg.DataDbHost + if *outDataDBHost != utils.MetaDataDB { + mgrCfg.MigratorCgrConfig.OutDataDBHost = *outDataDBHost } - if *outDataDBPort == utils.MetaDataDB { - *outDataDBPort = mgrCfg.DataDbPort + if *outDataDBPort != utils.MetaDataDB { + mgrCfg.MigratorCgrConfig.OutDataDBPort = *outDataDBPort } - if *outDataDBName == utils.MetaDataDB { - *outDataDBName = mgrCfg.DataDbName + if *outDataDBName != utils.MetaDataDB { + mgrCfg.MigratorCgrConfig.OutDataDBName = *outDataDBName } - if *outDataDBUser == utils.MetaDataDB { - *outDataDBUser = mgrCfg.DataDbUser + if *outDataDBUser != utils.MetaDataDB { + mgrCfg.MigratorCgrConfig.OutDataDBUser = *outDataDBUser } - if *outDataDBPass == utils.MetaDataDB { - *outDataDBPass = mgrCfg.DataDbPass + if *outDataDBPass != utils.MetaDataDB { + mgrCfg.MigratorCgrConfig.OutDataDBPassword = *outDataDBPass } - if *outStorDBType == utils.MetaStorDB { - *outStorDBType = mgrCfg.StorDBType - } else { - *outStorDBType = strings.TrimPrefix(*outStorDBType, "*") + if *outStorDBType != utils.MetaStorDB { + mgrCfg.MigratorCgrConfig.OutStorDBType = strings.TrimPrefix(*outStorDBType, "*") } - if *outStorDBHost == utils.MetaStorDB { - *outStorDBHost = mgrCfg.StorDBHost + if *outStorDBHost != utils.MetaStorDB { + mgrCfg.MigratorCgrConfig.OutStorDBHost = *outStorDBHost } - if *outStorDBPort == utils.MetaStorDB { - *outStorDBPort = mgrCfg.StorDBPort + if *outStorDBPort != utils.MetaStorDB { + mgrCfg.MigratorCgrConfig.OutStorDBPort = *outStorDBPort } - if *outStorDBName == utils.MetaStorDB { - *outStorDBName = mgrCfg.StorDBName + if *outStorDBName != utils.MetaStorDB { + mgrCfg.MigratorCgrConfig.OutStorDBName = *outStorDBName } - if *outStorDBUser == utils.MetaStorDB { - *outStorDBUser = mgrCfg.StorDBUser + if *outStorDBUser != utils.MetaStorDB { + mgrCfg.MigratorCgrConfig.OutStorDBUser = *outStorDBUser } - if *outStorDBPass == utils.MetaStorDB { - *outStorDBPass = mgrCfg.StorDBPass + if *outStorDBPass != utils.MetaStorDB { + mgrCfg.MigratorCgrConfig.OutStorDBPassword = *outStorDBPass } - if *outDBDataEncoding == "" { + if *outDBDataEncoding != "" { *outDBDataEncoding = mgrCfg.DBDataEncoding } - sameDataDB = *outDataDBType == mgrCfg.DataDbType && - *outDataDBHost == mgrCfg.DataDbHost && - *outDataDBPort == mgrCfg.DataDbPort && - *outDataDBName == mgrCfg.DataDbName && + fmt.Printf("After change: %+v\n", utils.ToJSON(mgrCfg.MigratorCgrConfig)) + + sameDataDB = mgrCfg.MigratorCgrConfig.OutDataDBType == mgrCfg.DataDbType && + mgrCfg.MigratorCgrConfig.OutDataDBHost == mgrCfg.DataDbHost && + mgrCfg.MigratorCgrConfig.OutDataDBPort == mgrCfg.DataDbPort && + mgrCfg.MigratorCgrConfig.OutDataDBName == mgrCfg.DataDbName && *outDBDataEncoding == mgrCfg.DBDataEncoding - sameStorDB = *outStorDBType == mgrCfg.StorDBType && - *outStorDBHost == mgrCfg.StorDBHost && - *outStorDBPort == mgrCfg.StorDBPort && - *outStorDBName == mgrCfg.StorDBName && + sameStorDB = mgrCfg.MigratorCgrConfig.OutStorDBType == mgrCfg.StorDBType && + mgrCfg.MigratorCgrConfig.OutStorDBHost == mgrCfg.StorDBHost && + mgrCfg.MigratorCgrConfig.OutStorDBPort == mgrCfg.StorDBPort && + mgrCfg.MigratorCgrConfig.OutStorDBName == mgrCfg.StorDBName && *outDBDataEncoding == mgrCfg.DBDataEncoding if dmIN, err = migrator.NewMigratorDataDB(mgrCfg.DataDbType, @@ -228,10 +226,10 @@ func main() { if sameDataDB { dmOUT = dmIN - } else if dmOUT, err = migrator.NewMigratorDataDB(*outDataDBType, - *outDataDBHost, *outDataDBPort, - *outDataDBName, *outDataDBUser, - *outDataDBPass, *outDBDataEncoding, + } else if dmOUT, err = migrator.NewMigratorDataDB(mgrCfg.MigratorCgrConfig.OutDataDBType, + mgrCfg.MigratorCgrConfig.OutDataDBHost, mgrCfg.MigratorCgrConfig.OutDataDBPort, + mgrCfg.MigratorCgrConfig.OutDataDBName, mgrCfg.MigratorCgrConfig.OutDataDBUser, + mgrCfg.MigratorCgrConfig.OutDataDBPassword, *outDBDataEncoding, mgrCfg.CacheCfg(), 0); err != nil { log.Fatal(err) } @@ -248,10 +246,10 @@ func main() { if sameStorDB { storDBOut = storDBIn - } else if storDBOut, err = migrator.NewMigratorStorDB(*outStorDBType, - *outStorDBHost, *outStorDBPort, - *outStorDBName, *outStorDBUser, - *outStorDBPass, + } else if storDBOut, err = migrator.NewMigratorStorDB(mgrCfg.MigratorCgrConfig.OutStorDBType, + mgrCfg.MigratorCgrConfig.OutStorDBHost, mgrCfg.MigratorCgrConfig.OutStorDBPort, + mgrCfg.MigratorCgrConfig.OutStorDBName, mgrCfg.MigratorCgrConfig.OutStorDBUser, + mgrCfg.MigratorCgrConfig.OutStorDBPassword, mgrCfg.StorDBMaxOpenConns, mgrCfg.StorDBMaxIdleConns, mgrCfg.StorDBConnMaxLifetime, diff --git a/config/config.go b/config/config.go index e78e20058..924d6efa6 100755 --- a/config/config.go +++ b/config/config.go @@ -359,6 +359,7 @@ type CGRConfig struct { sureTaxCfg *SureTaxCfg // Load here SureTax configuration, as pointer so we can have runtime reloads in the future ConfigReloads map[string]chan struct{} // Signals to specific entities that a config reload should occur LoaderCgrConfig *LoaderCgrCfg + MigratorCgrConfig *MigratorCgrCfg // Cache defaults loaded from json and needing clones dfltCdreProfile *CdreConfig // Default cdreConfig profile dfltCdrcProfile *CdrcConfig // Default cdrcConfig profile @@ -835,6 +836,11 @@ func (self *CGRConfig) loadFromJsonCfg(jsnCfg *CgrJsonCfg) (err error) { return nil } + jsnMigratorCgrCfg, err := jsnCfg.MigratorCfgJson() + if err != nil { + return nil + } + if jsnDataDbCfg != nil { if jsnDataDbCfg.Db_type != nil { self.DataDbType = *jsnDataDbCfg.Db_type @@ -1384,6 +1390,15 @@ func (self *CGRConfig) loadFromJsonCfg(jsnCfg *CgrJsonCfg) (err error) { } } + if jsnMigratorCgrCfg != nil { + if self.MigratorCgrConfig == nil { + self.MigratorCgrConfig = new(MigratorCgrCfg) + } + if self.MigratorCgrConfig.loadFromJsonCfg(jsnMigratorCgrCfg); err != nil { + return err + } + } + return nil } @@ -1462,3 +1477,7 @@ func (cfg *CGRConfig) DispatcherSCfg() *DispatcherSCfg { func (cfg *CGRConfig) LoaderCgrCfg() *LoaderCgrCfg { return cfg.LoaderCgrConfig } + +func (cfg *CGRConfig) MigratorCgrCfg() *MigratorCgrCfg { + return cfg.MigratorCgrConfig +} diff --git a/config/config_defaults.go b/config/config_defaults.go index 374e02336..22b9b8203 100755 --- a/config/config_defaults.go +++ b/config/config_defaults.go @@ -624,5 +624,19 @@ const CGRATES_CFG_JSON = ` ], }, +"migrator": { + "out_datadb_type": "redis", + "out_datadb_host": "127.0.0.1", + "out_datadb_port": "6379", + "out_datadb_name": "10", + "out_datadb_user": "cgrates", + "out_datadb_password": "", + "out_stordb_type": "mysql", + "out_stordb_host": "127.0.0.1", + "out_stordb_port": "3306", + "out_stordb_name": "cgrates", + "out_stordb_user": "cgrates", + "out_stordb_password": "", +}, }` diff --git a/config/config_json.go b/config/config_json.go index 7eed53dc1..a62061f3a 100644 --- a/config/config_json.go +++ b/config/config_json.go @@ -65,6 +65,7 @@ const ( SURETAX_JSON = "suretax" DispatcherSJson = "dispatcher" CgrLoaderCfgJson = "loader" + CgrMigratorCfgJson = "migrator" ) // Loads the json config out of io.Reader, eg other sources than file, maybe over http @@ -461,3 +462,15 @@ func (self CgrJsonCfg) LoaderCfgJson() (*LoaderCfgJson, error) { } return cfg, nil } + +func (self CgrJsonCfg) MigratorCfgJson() (*MigratorCfgJson, error) { + rawCfg, hasKey := self[CgrMigratorCfgJson] + if !hasKey { + return nil, nil + } + cfg := new(MigratorCfgJson) + if err := json.Unmarshal(*rawCfg, cfg); err != nil { + return nil, err + } + return cfg, nil +} diff --git a/config/config_json_test.go b/config/config_json_test.go index cfa482c08..e46e329ac 100755 --- a/config/config_json_test.go +++ b/config/config_json_test.go @@ -1267,3 +1267,25 @@ func TestDfLoaderCfg(t *testing.T) { t.Errorf("Expected: %+v, received: %+v", utils.ToJSON(eCfg), utils.ToJSON(cfg)) } } + +func TestDfMigratorCfg(t *testing.T) { + eCfg := &MigratorCfgJson{ + Out_dataDB_type: utils.StringPointer("redis"), + Out_dataDB_host: utils.StringPointer("127.0.0.1"), + Out_dataDB_port: utils.StringPointer("6379"), + Out_dataDB_name: utils.StringPointer("10"), + Out_dataDB_user: utils.StringPointer("cgrates"), + Out_dataDB_password: utils.StringPointer(""), + Out_storDB_type: utils.StringPointer("mysql"), + Out_storDB_host: utils.StringPointer("127.0.0.1"), + Out_storDB_port: utils.StringPointer("3306"), + Out_storDB_name: utils.StringPointer("cgrates"), + Out_storDB_user: utils.StringPointer("cgrates"), + Out_storDB_password: utils.StringPointer(""), + } + if cfg, err := dfCgrJsonCfg.MigratorCfgJson(); err != nil { + t.Error(err) + } else if !reflect.DeepEqual(eCfg, cfg) { + t.Errorf("Expected: %+v, received: %+v", utils.ToJSON(eCfg), utils.ToJSON(cfg)) + } +} diff --git a/config/config_test.go b/config/config_test.go index faea43bea..c71694a90 100755 --- a/config/config_test.go +++ b/config/config_test.go @@ -1286,3 +1286,23 @@ func TestCgrLoaderCfgDefault(t *testing.T) { t.Errorf("received: %+v, expecting: %+v", utils.ToJSON(cgrCfg.LoaderCgrConfig), utils.ToJSON(eLdrCfg)) } } + +func TestCgrMigratorCfgDefault(t *testing.T) { + eMgrCfg := &MigratorCgrCfg{ + OutDataDBType: "redis", + OutDataDBHost: "127.0.0.1", + OutDataDBPort: "6379", + OutDataDBName: "10", + OutDataDBUser: "cgrates", + OutDataDBPassword: "", + OutStorDBType: "mysql", + OutStorDBHost: "127.0.0.1", + OutStorDBPort: "3306", + OutStorDBName: "cgrates", + OutStorDBUser: "cgrates", + OutStorDBPassword: "", + } + if !reflect.DeepEqual(cgrCfg.MigratorCgrConfig, eMgrCfg) { + t.Errorf("received: %+v, expecting: %+v", utils.ToJSON(cgrCfg.MigratorCgrConfig), utils.ToJSON(eMgrCfg)) + } +} diff --git a/config/libconfig_json.go b/config/libconfig_json.go index 75db5a272..3635bb997 100755 --- a/config/libconfig_json.go +++ b/config/libconfig_json.go @@ -498,3 +498,18 @@ type LoaderCfgJson struct { Caches_conns *[]*HaPoolJsonCfg Scheduler_conns *[]*HaPoolJsonCfg } + +type MigratorCfgJson struct { + Out_dataDB_type *string + Out_dataDB_host *string + Out_dataDB_port *string + Out_dataDB_name *string + Out_dataDB_user *string + Out_dataDB_password *string + Out_storDB_type *string + Out_storDB_host *string + Out_storDB_port *string + Out_storDB_name *string + Out_storDB_user *string + Out_storDB_password *string +} diff --git a/config/migratorcfg.go b/config/migratorcfg.go new file mode 100644 index 000000000..34b263577 --- /dev/null +++ b/config/migratorcfg.go @@ -0,0 +1,76 @@ +/* +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 +*/ + +package config + +type MigratorCgrCfg struct { + OutDataDBType string + OutDataDBHost string + OutDataDBPort string + OutDataDBName string + OutDataDBUser string + OutDataDBPassword string + OutStorDBType string + OutStorDBHost string + OutStorDBPort string + OutStorDBName string + OutStorDBUser string + OutStorDBPassword string +} + +func (mg *MigratorCgrCfg) loadFromJsonCfg(jsnCfg *MigratorCfgJson) (err error) { + + if jsnCfg.Out_dataDB_type != nil { + mg.OutDataDBType = *jsnCfg.Out_dataDB_type + } + if jsnCfg.Out_dataDB_host != nil { + mg.OutDataDBHost = *jsnCfg.Out_dataDB_host + } + if jsnCfg.Out_dataDB_port != nil { + mg.OutDataDBPort = *jsnCfg.Out_dataDB_port + } + if jsnCfg.Out_dataDB_name != nil { + mg.OutDataDBName = *jsnCfg.Out_dataDB_name + } + if jsnCfg.Out_dataDB_user != nil { + mg.OutDataDBUser = *jsnCfg.Out_dataDB_user + } + if jsnCfg.Out_dataDB_password != nil { + mg.OutDataDBPassword = *jsnCfg.Out_dataDB_password + } + + if jsnCfg.Out_storDB_type != nil { + mg.OutStorDBType = *jsnCfg.Out_storDB_type + } + if jsnCfg.Out_storDB_host != nil { + mg.OutStorDBHost = *jsnCfg.Out_storDB_host + } + if jsnCfg.Out_storDB_port != nil { + mg.OutStorDBPort = *jsnCfg.Out_storDB_port + } + if jsnCfg.Out_storDB_name != nil { + mg.OutStorDBName = *jsnCfg.Out_storDB_name + } + if jsnCfg.Out_storDB_user != nil { + mg.OutStorDBUser = *jsnCfg.Out_storDB_user + } + if jsnCfg.Out_storDB_password != nil { + mg.OutStorDBPassword = *jsnCfg.Out_storDB_password + } + return nil +} diff --git a/data/conf/samples/cgrmigratorconfig/cgr-migrator.cfg b/data/conf/samples/cgrmigratorconfig/cgr-migrator.cfg new file mode 100644 index 000000000..2ebb9b818 --- /dev/null +++ b/data/conf/samples/cgrmigratorconfig/cgr-migrator.cfg @@ -0,0 +1,36 @@ +# cgr-migrator configuration file + +[general] + datadb_encoding = json + +[data_db] + db_type = redis + db_host = 127.0.0.1 + db_port = 6379 + db_name = 10 + db_user = cgrates + db_password = + +[stor_db] + db_type = mysql + db_host = 127.0.0.1 + db_port = 3306 + db_name = cgrates + db_user = cgrates + db_password = CGRateS.or + +[out_data_db] + db_type = redis + db_host = 127.0.0.1 + db_port = 6379 + db_name = 10 + db_user = cgrates + db_password = + +[out_stor_db] + db_type = mysql + db_host = 127.0.0.1 + db_port = 3306 + db_name = cgrates + db_user = cgrates + db_password = CGRateS.or \ No newline at end of file diff --git a/data/conf/samples/tutmongojson/cgrates.json b/data/conf/samples/tutmongojson/cgrates.json index ba8106486..c771a05e9 100644 --- a/data/conf/samples/tutmongojson/cgrates.json +++ b/data/conf/samples/tutmongojson/cgrates.json @@ -18,7 +18,7 @@ "data_db": { "db_type": "mongo", - "db_name": "10", + "db_name": "11", "db_port": 27017, }, diff --git a/data/conf/samples/tutmongomsgpack/cgrates.json b/data/conf/samples/tutmongomsgpack/cgrates.json deleted file mode 100644 index 5200fd05e..000000000 --- a/data/conf/samples/tutmongomsgpack/cgrates.json +++ /dev/null @@ -1,69 +0,0 @@ -{ -// CGRateS Configuration file - - -"general": { - "log_level": 7, - "reply_timeout": "30s", - "dbdata_encoding": "msgpack", -}, - - -"listen": { - "rpc_json": ":2012", - "rpc_gob": ":2013", - "http": ":2080", -}, - - -"data_db": { - "db_type": "mongo", - "db_name": "11", - "db_port": 27017, -}, - - -"stor_db": { - "db_type": "mongo", - "db_port": 27017, -}, - - -"cache":{ - "destinations": {"limit": 10000, "ttl":"0s", "precache": true}, - "reverse_destinations": {"limit": 10000, "ttl":"0s", "precache": true}, - "rating_plans": {"limit": 10000, "ttl":"0s","precache": true}, - "rating_profiles": {"limit": 10000, "ttl":"0s", "precache": true}, - "lcr_rules": {"limit": 10000, "ttl":"0s", "precache": true}, - "cdr_stats": {"limit": 10000, "ttl":"0s", "precache": true}, - "actions": {"limit": 10000, "ttl":"0s", "precache": true}, - "action_plans": {"limit": 10000, "ttl":"0s", "precache": true}, - "account_action_plans": {"limit": 10000, "ttl":"0s", "precache": true}, - "action_triggers": {"limit": 10000, "ttl":"0s", "precache": true}, - "shared_groups": {"limit": 10000, "ttl":"0s", "precache": true}, - "aliases": {"limit": 10000, "ttl":"0s", "precache": true}, - "reverse_aliases": {"limit": 10000, "ttl":"0s", "precache": true}, - "derived_chargers": {"limit": 10000, "ttl":"0s", "precache": true}, - "resource_profiles": {"limit": 10000, "ttl":"0s", "precache": true}, - "resources": {"limit": 10000, "ttl":"0s", "precache": true}, - "statqueues": {"limit": 10000, "ttl":"0s", "precache": true}, - "statqueue_profiles": {"limit": 10000, "ttl":"0s", "precache": true}, - "thresholds": {"limit": 10000, "ttl":"0s", "precache": true}, - "threshold_profiles": {"limit": 10000, "ttl":"0s", "precache": true}, - "filters": {"limit": 10000, "ttl":"0s", "precache": true}, - "supplier_profiles": {"limit": 10000, "ttl":"0s", "precache": true}, - "attribute_profiles": {"limit": 10000, "ttl":"0s", "precache": true}, - "resource_filter_indexes" :{"limit": 10000, "ttl":"0s"}, - "resource_filter_revindexes" : {"limit": 10000, "ttl":"0s"}, - "stat_filter_indexes" : {"limit": 10000, "ttl":"0s"}, - "stat_filter_revindexes" : {"limit": 10000, "ttl":"0s"}, - "threshold_filter_indexes" : {"limit": 10000, "ttl":"0s"}, - "threshold_filter_revindexes" : {"limit": 10000, "ttl":"0s"}, - "supplier_filter_indexes" : {"limit": 10000, "ttl":"0s"}, - "supplier_filter_revindexes" :{"limit": 10000, "ttl":"0s"}, - "attribute_filter_indexes" : {"limit": 10000, "ttl":"0s"}, - "attribute_filter_revindexes" : {"limit": 10000, "ttl":"0s"}, -}, - - -} \ No newline at end of file diff --git a/data/conf/samples/tutmysqljson/cgrates.json b/data/conf/samples/tutmysqljson/cgrates.json index 303bdf609..d97fd819d 100644 --- a/data/conf/samples/tutmysqljson/cgrates.json +++ b/data/conf/samples/tutmysqljson/cgrates.json @@ -18,7 +18,7 @@ "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 + "db_name": "11", // data_db database name to connect to }, diff --git a/data/conf/samples/tutmysqlmsgpack/cgrates.json b/data/conf/samples/tutmysqlmsgpack/cgrates.json deleted file mode 100644 index 3e0f8f411..000000000 --- a/data/conf/samples/tutmysqlmsgpack/cgrates.json +++ /dev/null @@ -1,67 +0,0 @@ -{ -// CGRateS Configuration file -// - - -"general": { - "log_level": 7, - "dbdata_encoding": "msgpack", // encoding used to store object data in strings: -}, - - -"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": "11", // data_db database name to connect to - -}, - -"stor_db": { - "db_password": "CGRateS.org", -}, - - -"cache":{ - "destinations": {"limit": 10000, "ttl":"0s", "precache": true}, - "reverse_destinations": {"limit": 10000, "ttl":"0s", "precache": true}, - "rating_plans": {"limit": 10000, "ttl":"0s","precache": true}, - "rating_profiles": {"limit": 10000, "ttl":"0s", "precache": true}, - "lcr_rules": {"limit": 10000, "ttl":"0s", "precache": true}, - "cdr_stats": {"limit": 10000, "ttl":"0s", "precache": true}, - "actions": {"limit": 10000, "ttl":"0s", "precache": true}, - "action_plans": {"limit": 10000, "ttl":"0s", "precache": true}, - "account_action_plans": {"limit": 10000, "ttl":"0s", "precache": true}, - "action_triggers": {"limit": 10000, "ttl":"0s", "precache": true}, - "shared_groups": {"limit": 10000, "ttl":"0s", "precache": true}, - "aliases": {"limit": 10000, "ttl":"0s", "precache": true}, - "reverse_aliases": {"limit": 10000, "ttl":"0s", "precache": true}, - "derived_chargers": {"limit": 10000, "ttl":"0s", "precache": true}, - "resource_profiles": {"limit": 10000, "ttl":"0s", "precache": true}, - "resources": {"limit": 10000, "ttl":"0s", "precache": true}, - "statqueues": {"limit": 10000, "ttl":"0s", "precache": true}, - "statqueue_profiles": {"limit": 10000, "ttl":"0s", "precache": true}, - "thresholds": {"limit": 10000, "ttl":"0s", "precache": true}, - "threshold_profiles": {"limit": 10000, "ttl":"0s", "precache": true}, - "filters": {"limit": 10000, "ttl":"0s", "precache": true}, - "supplier_profiles": {"limit": 10000, "ttl":"0s", "precache": true}, - "attribute_profiles": {"limit": 10000, "ttl":"0s", "precache": true}, - "resource_filter_indexes" :{"limit": 10000, "ttl":"0s"}, - "resource_filter_revindexes" : {"limit": 10000, "ttl":"0s"}, - "stat_filter_indexes" : {"limit": 10000, "ttl":"0s"}, - "stat_filter_revindexes" : {"limit": 10000, "ttl":"0s"}, - "threshold_filter_indexes" : {"limit": 10000, "ttl":"0s"}, - "threshold_filter_revindexes" : {"limit": 10000, "ttl":"0s"}, - "supplier_filter_indexes" : {"limit": 10000, "ttl":"0s"}, - "supplier_filter_revindexes" :{"limit": 10000, "ttl":"0s"}, - "attribute_filter_indexes" : {"limit": 10000, "ttl":"0s"}, - "attribute_filter_revindexes" : {"limit": 10000, "ttl":"0s"}, -}, - - -} \ No newline at end of file diff --git a/migrator/accounts_it_test.go b/migrator/accounts_it_test.go index 4c7b8b3a2..a4f33fef1 100755 --- a/migrator/accounts_it_test.go +++ b/migrator/accounts_it_test.go @@ -104,12 +104,12 @@ func TestAccountITMove(t *testing.T) { func TestAccountITMoveEncoding(t *testing.T) { var err error - accPathIn = path.Join(*dataDir, "conf", "samples", "tutmongojson") + accPathIn = path.Join(*dataDir, "conf", "samples", "tutmongo") accCfgIn, err = config.NewCGRConfigFromFolder(accPathIn) if err != nil { t.Fatal(err) } - accPathOut = path.Join(*dataDir, "conf", "samples", "tutmongomsgpack") + accPathOut = path.Join(*dataDir, "conf", "samples", "tutmongojson") accCfgOut, err = config.NewCGRConfigFromFolder(accPathOut) if err != nil { t.Fatal(err) @@ -122,12 +122,12 @@ func TestAccountITMoveEncoding(t *testing.T) { func TestAccountITMoveEncoding2(t *testing.T) { var err error - accPathIn = path.Join(*dataDir, "conf", "samples", "tutmysqljson") + accPathIn = path.Join(*dataDir, "conf", "samples", "tutmysql") accCfgIn, err = config.NewCGRConfigFromFolder(accPathIn) if err != nil { t.Fatal(err) } - accPathOut = path.Join(*dataDir, "conf", "samples", "tutmysqlmsgpack") + accPathOut = path.Join(*dataDir, "conf", "samples", "tutmysqljson") accCfgOut, err = config.NewCGRConfigFromFolder(accPathOut) if err != nil { t.Fatal(err) @@ -240,7 +240,8 @@ func testAccITMigrateAndMove(t *testing.T) { utils.VOICE: engine.Balances{v2b}, utils.MONETARY: engine.Balances{m2}}, UnitCounters: engine.UnitCounters{}, - ActionTriggers: engine.ActionTriggers{}} + ActionTriggers: engine.ActionTriggers{}, + } switch accAction { case utils.Migrate: err := accMigrator.dmIN.setV1Account(v1Acc) diff --git a/migrator/action_it_test.go b/migrator/action_it_test.go index 782d89504..837b2f1c4 100644 --- a/migrator/action_it_test.go +++ b/migrator/action_it_test.go @@ -100,12 +100,12 @@ func TestActionITMove(t *testing.T) { func TestActionITMoveEncoding(t *testing.T) { var err error - actPathIn = path.Join(*dataDir, "conf", "samples", "tutmongojson") + actPathIn = path.Join(*dataDir, "conf", "samples", "tutmongo") actCfgIn, err = config.NewCGRConfigFromFolder(actPathIn) if err != nil { t.Fatal(err) } - actPathOut = path.Join(*dataDir, "conf", "samples", "tutmongomsgpack") + actPathOut = path.Join(*dataDir, "conf", "samples", "tutmongojson") actCfgOut, err = config.NewCGRConfigFromFolder(actPathOut) if err != nil { t.Fatal(err) @@ -119,12 +119,12 @@ func TestActionITMoveEncoding(t *testing.T) { /* func TestActionITMoveEncoding2(t *testing.T) { var err error - actPathIn = path.Join(*dataDir, "conf", "samples", "tutmysqljson") + actPathIn = path.Join(*dataDir, "conf", "samples", "tutmysql") actCfgIn, err = config.NewCGRConfigFromFolder(actPathIn) if err != nil { t.Fatal(err) } - actPathOut = path.Join(*dataDir, "conf", "samples", "tutmysqlmsgpack") + actPathOut = path.Join(*dataDir, "conf", "samples", "tutmysqljson") actCfgOut, err = config.NewCGRConfigFromFolder(actPathOut) if err != nil { t.Fatal(err) diff --git a/migrator/action_plan_it_test.go b/migrator/action_plan_it_test.go index a0dc2d22a..12e57186c 100644 --- a/migrator/action_plan_it_test.go +++ b/migrator/action_plan_it_test.go @@ -100,12 +100,12 @@ func TestActionPlanITMove(t *testing.T) { func TestActionPlanITMoveEncoding(t *testing.T) { var err error - actPlnPathIn = path.Join(*dataDir, "conf", "samples", "tutmongojson") + actPlnPathIn = path.Join(*dataDir, "conf", "samples", "tutmongo") actPlnCfgIn, err = config.NewCGRConfigFromFolder(actPlnPathIn) if err != nil { t.Fatal(err) } - actPlnPathOut = path.Join(*dataDir, "conf", "samples", "tutmongomsgpack") + actPlnPathOut = path.Join(*dataDir, "conf", "samples", "tutmongojson") actPlnCfgOut, err = config.NewCGRConfigFromFolder(actPlnPathOut) if err != nil { t.Fatal(err) @@ -118,12 +118,12 @@ func TestActionPlanITMoveEncoding(t *testing.T) { func TestActionPlanITMoveEncoding2(t *testing.T) { var err error - actPlnPathIn = path.Join(*dataDir, "conf", "samples", "tutmysqljson") + actPlnPathIn = path.Join(*dataDir, "conf", "samples", "tutmysql") actPlnCfgIn, err = config.NewCGRConfigFromFolder(actPlnPathIn) if err != nil { t.Fatal(err) } - actPlnPathOut = path.Join(*dataDir, "conf", "samples", "tutmysqlmsgpack") + actPlnPathOut = path.Join(*dataDir, "conf", "samples", "tutmysqljson") actPlnCfgOut, err = config.NewCGRConfigFromFolder(actPlnPathOut) if err != nil { t.Fatal(err) diff --git a/migrator/action_trigger_it_test.go b/migrator/action_trigger_it_test.go index 7c7179776..aa55f3d11 100644 --- a/migrator/action_trigger_it_test.go +++ b/migrator/action_trigger_it_test.go @@ -103,12 +103,12 @@ func TestActionTriggerITMove(t *testing.T) { func TestActionTriggerITMoveEncoding(t *testing.T) { var err error - actTrgPathIn = path.Join(*dataDir, "conf", "samples", "tutmongojson") + actTrgPathIn = path.Join(*dataDir, "conf", "samples", "tutmongo") actTrgCfgIn, err = config.NewCGRConfigFromFolder(actTrgPathIn) if err != nil { t.Fatal(err) } - actTrgPathOut = path.Join(*dataDir, "conf", "samples", "tutmongomsgpack") + actTrgPathOut = path.Join(*dataDir, "conf", "samples", "tutmongojson") actTrgCfgOut, err = config.NewCGRConfigFromFolder(actTrgPathOut) if err != nil { t.Fatal(err) @@ -121,12 +121,12 @@ func TestActionTriggerITMoveEncoding(t *testing.T) { func TestActionTriggerITMoveEncoding2(t *testing.T) { var err error - actTrgPathIn = path.Join(*dataDir, "conf", "samples", "tutmysqljson") + actTrgPathIn = path.Join(*dataDir, "conf", "samples", "tutmysql") actTrgCfgIn, err = config.NewCGRConfigFromFolder(actTrgPathIn) if err != nil { t.Fatal(err) } - actTrgPathOut = path.Join(*dataDir, "conf", "samples", "tutmysqlmsgpack") + actTrgPathOut = path.Join(*dataDir, "conf", "samples", "tutmysqljson") actTrgCfgOut, err = config.NewCGRConfigFromFolder(actTrgPathOut) if err != nil { t.Fatal(err) diff --git a/migrator/sharedgroup_it_test.go b/migrator/sharedgroup_it_test.go index 66c344ff4..fd9c0f1d7 100644 --- a/migrator/sharedgroup_it_test.go +++ b/migrator/sharedgroup_it_test.go @@ -100,12 +100,12 @@ func TestSharedGroupITMove(t *testing.T) { func TestSharedGroupITMoveEncoding(t *testing.T) { var err error - shrGrpPathIn = path.Join(*dataDir, "conf", "samples", "tutmongojson") + shrGrpPathIn = path.Join(*dataDir, "conf", "samples", "tutmongo") shrGrpCfgIn, err = config.NewCGRConfigFromFolder(shrGrpPathIn) if err != nil { t.Fatal(err) } - shrGrpPathOut = path.Join(*dataDir, "conf", "samples", "tutmongomsgpack") + shrGrpPathOut = path.Join(*dataDir, "conf", "samples", "tutmongojson") shrGrpCfgOut, err = config.NewCGRConfigFromFolder(shrGrpPathOut) if err != nil { t.Fatal(err) @@ -118,12 +118,12 @@ func TestSharedGroupITMoveEncoding(t *testing.T) { func TestSharedGroupITMoveEncoding2(t *testing.T) { var err error - shrGrpPathIn = path.Join(*dataDir, "conf", "samples", "tutmysqljson") + shrGrpPathIn = path.Join(*dataDir, "conf", "samples", "tutmysql") shrGrpCfgIn, err = config.NewCGRConfigFromFolder(shrGrpPathIn) if err != nil { t.Fatal(err) } - shrGrpPathOut = path.Join(*dataDir, "conf", "samples", "tutmysqlmsgpack") + shrGrpPathOut = path.Join(*dataDir, "conf", "samples", "tutmysqljson") shrGrpCfgOut, err = config.NewCGRConfigFromFolder(shrGrpPathOut) if err != nil { t.Fatal(err) diff --git a/migrator/thresholds_it_test.go b/migrator/thresholds_it_test.go index 67144fd50..b45c5662f 100644 --- a/migrator/thresholds_it_test.go +++ b/migrator/thresholds_it_test.go @@ -101,12 +101,12 @@ func TestThresholdsITMove(t *testing.T) { func TestThresholdsITMoveEncoding(t *testing.T) { var err error - trsPathIn = path.Join(*dataDir, "conf", "samples", "tutmongojson") + trsPathIn = path.Join(*dataDir, "conf", "samples", "tutmongo") trsCfgIn, err = config.NewCGRConfigFromFolder(trsPathIn) if err != nil { t.Fatal(err) } - trsPathOut = path.Join(*dataDir, "conf", "samples", "tutmongomsgpack") + trsPathOut = path.Join(*dataDir, "conf", "samples", "tutmongojson") trsCfgOut, err = config.NewCGRConfigFromFolder(trsPathOut) if err != nil { t.Fatal(err) @@ -119,12 +119,12 @@ func TestThresholdsITMoveEncoding(t *testing.T) { func TestThresholdsITMoveEncoding2(t *testing.T) { var err error - trsPathIn = path.Join(*dataDir, "conf", "samples", "tutmysqljson") + trsPathIn = path.Join(*dataDir, "conf", "samples", "tutmysql") trsCfgIn, err = config.NewCGRConfigFromFolder(trsPathIn) if err != nil { t.Fatal(err) } - trsPathOut = path.Join(*dataDir, "conf", "samples", "tutmysqlmsgpack") + trsPathOut = path.Join(*dataDir, "conf", "samples", "tutmysqljson") trsCfgOut, err = config.NewCGRConfigFromFolder(trsPathOut) if err != nil { t.Fatal(err)