diff --git a/apis/config_it_test.go b/apis/config_it_test.go index 79d98b1e6..f8b693d20 100644 --- a/apis/config_it_test.go +++ b/apis/config_it_test.go @@ -33,6 +33,7 @@ import ( ) var ( + connDb engine.DataDBDriver cfgPath string cfgCfg *config.CGRConfig cfgRPC *birpc.Client @@ -52,11 +53,14 @@ var ( testCfgKillEngine, //Store Cfg in Database Test testCfgInitCfgStore, - testCfgInitCfgStore, testCfgInitDataDbStore, testCfgResetStorDbStore, testCfgStartEngineStore, testCfgRPCConnStore, + testCfgResetConfigDBStore, + testCfgDataDBConnStore, + testCfgGetConfigStore, + testCfgStoreConfigStore, testCfgKillEngineStore, } ) @@ -64,7 +68,7 @@ var ( func TestCfgSIT(t *testing.T) { switch *dbType { case utils.MetaInternal: - cfgDIR = "apis_config_internal" + t.SkipNow() case utils.MetaMongo: cfgDIR = "apis_config_mongo" case utils.MetaMySQL: @@ -357,6 +361,39 @@ func testCfgRPCConnStore(t *testing.T) { } } +func testCfgDataDBConnStore(t *testing.T) { + var err error + connDb, err = engine.NewDataDBConn(cfgCfg.ConfigDBCfg().Type, + cfgCfg.ConfigDBCfg().Host, cfgCfg.ConfigDBCfg().Port, + cfgCfg.ConfigDBCfg().Name, cfgCfg.ConfigDBCfg().User, + cfgCfg.ConfigDBCfg().Password, cfgCfg.GeneralCfg().DBDataEncoding, + cfgCfg.ConfigDBCfg().Opts) + if err != nil { + t.Fatal(err) + } +} + +func testCfgGetConfigStore(t *testing.T) { + connDb.AttributeServJsonCfg() +} + +func testCfgStoreConfigStore(t *testing.T) { + var reply string + if err := cfgRPC.Call(context.Background(), utils.ConfigSv1StoreCfgInDB, + &config.SectionWithAPIOpts{ + APIOpts: nil, + Tenant: utils.CGRateSorg, + Sections: []string{"attributes"}, + }, + &reply); err != nil { + t.Error(err) + } + if !reflect.DeepEqual("OK", reply) { + t.Errorf("\nExpected <%+v>, \nReceived <%+v>", "OK", utils.ToJSON(reply)) + } + +} + func testCfgKillEngineStore(t *testing.T) { if err := engine.KillEngine(100); err != nil { t.Error(err) diff --git a/cmd/cgr-engine/cgr-engine.go b/cmd/cgr-engine/cgr-engine.go index 6d63ea2a7..bc4fe42fd 100644 --- a/cmd/cgr-engine/cgr-engine.go +++ b/cmd/cgr-engine/cgr-engine.go @@ -452,7 +452,7 @@ func main() { cfg.ConfigDBCfg().Password, cfg.GeneralCfg().DBDataEncoding, cfg.ConfigDBCfg().Opts) if err != nil { // Cannot configure getter database, show stopper - utils.Logger.Crit(fmt.Sprintf("Could not configure configDB: %s exiting!", err)) + log.Fatalf("Could not configure configDB: %s exiting!", err) return } if err = cfg.LoadFromDB(d); err != nil { diff --git a/config/config_defaults.go b/config/config_defaults.go index 3a2433d5b..39bbdeddf 100644 --- a/config/config_defaults.go +++ b/config/config_defaults.go @@ -1199,15 +1199,15 @@ const CGRATES_CFG_JSON = ` "db_user": "", // username to use when connecting to data_db "db_password": "", // password to use when connecting to data_db "opts":{ - "redis_sentinel": "", // the name of sentinel when used - "redis_cluster": false, // if enabled the datadb will try to connect to the redis cluster - "redis_cluster_sync": "5s", // the sync interval for the redis cluster - "redis_cluster_ondown_delay": "0", // the delay before executing the commands if the redis cluster is in the CLUSTERDOWN state - "query_timeout":"10s", - "redis_tls": false, // if true it will use a tls connection and use the redis_client_certificate certificate, redis_client_key and redis_ca_certificate for tls connection - "redis_client_certificate":"", // path to client certificate - "redis_client_key":"", // path to client key - "redis_ca_certificate":"", // path to CA certificate (populate for self-signed certificate otherwise let it empty) + "redisSentinel": "", // the name of sentinel when used + "redisCluster": false, // if enabled the datadb will try to connect to the redis cluster + "redisClusterSync": "5s", // the sync interval for the redis cluster + "redisClusterOndownDelay": "0", // the delay before executing the commands if the redis cluster is in the CLUSTERDOWN state + "mongoQueryTimeout":"10s", // timeout for query when mongo is used + "redisTLS": false, // if true it will use a tls connection and use the redisClientCertificate, redisClientKey and redisCACertificate for tls connection + "redisClientCertificate":"", // path to client certificate + "redisClientKey":"", // path to client key + "redisCACertificate":"", // path to CA certificate (populate for self-signed certificate otherwise let it empty) } }, diff --git a/data/conf/samples/apis_config_internal/cgrates.json b/data/conf/samples/apis_config_internal/cgrates.json deleted file mode 100644 index 01cc28e1d..000000000 --- a/data/conf/samples/apis_config_internal/cgrates.json +++ /dev/null @@ -1,132 +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" - }, - - - "stor_db": { - "db_type": "*internal" - }, - - - "rals": { - "enabled": true, - "thresholds_conns": ["*internal"], - "max_increments":3000000 - }, - - - "schedulers": { - "enabled": true, - "cdrs_conns": ["*internal"], - "stats_conns": ["*localhost"] - }, - - - "cdrs": { - "enabled": true, - "chargers_conns":["*internal"] - }, - - - "attributes": { - "enabled": true, - "stats_conns": ["*localhost"], - "resources_conns": ["*localhost"], - "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": false - }, - - - "actions": { - "enabled": true, - "accounts_conns": ["*localhost"] - }, - - - "accounts": { - "enabled": true - }, - - - "filters": { - "stats_conns": ["*internal"], - "resources_conns": ["*internal"], - "admins_conns": ["*internal"] - }, - - - -} diff --git a/data/conf/samples/apis_config_mongo/cgrates.json b/data/conf/samples/apis_config_mongo/cgrates.json index 97d3fadba..85ce24cc3 100644 --- a/data/conf/samples/apis_config_mongo/cgrates.json +++ b/data/conf/samples/apis_config_mongo/cgrates.json @@ -143,5 +143,9 @@ "admins_conns": ["*internal"], }, - + "config_db": { + "db_type": "mongo", + "db_name": "11", + "db_port": 27017, + } } diff --git a/data/conf/samples/apis_config_mysql/cgrates.json b/data/conf/samples/apis_config_mysql/cgrates.json index c7bbe8901..486bbe97f 100644 --- a/data/conf/samples/apis_config_mysql/cgrates.json +++ b/data/conf/samples/apis_config_mysql/cgrates.json @@ -134,5 +134,4 @@ "admins_conns": ["*internal"], }, - }, diff --git a/utils/consts.go b/utils/consts.go index 17e0dafc1..b54213e62 100644 --- a/utils/consts.go +++ b/utils/consts.go @@ -1265,6 +1265,7 @@ const ( ConfigSv1SetConfig = "ConfigSv1.SetConfig" ConfigSv1GetConfigAsJSON = "ConfigSv1.GetConfigAsJSON" ConfigSv1SetConfigFromJSON = "ConfigSv1.SetConfigFromJSON" + ConfigSv1StoreCfgInDB = "ConfigSv1.StoreCfgInDB" ) const (