Integration tests for storecfgindb in apis

This commit is contained in:
andronache
2021-06-08 13:28:18 +03:00
committed by Dan Christian Bogos
parent 323646602c
commit 44525fc3e1
7 changed files with 55 additions and 146 deletions

View File

@@ -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)

View File

@@ -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 {

View File

@@ -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)
}
},

View File

@@ -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"]
},
}

View File

@@ -143,5 +143,9 @@
"admins_conns": ["*internal"],
},
"config_db": {
"db_type": "mongo",
"db_name": "11",
"db_port": 27017,
}
}

View File

@@ -134,5 +134,4 @@
"admins_conns": ["*internal"],
},
},

View File

@@ -1265,6 +1265,7 @@ const (
ConfigSv1SetConfig = "ConfigSv1.SetConfig"
ConfigSv1GetConfigAsJSON = "ConfigSv1.GetConfigAsJSON"
ConfigSv1SetConfigFromJSON = "ConfigSv1.SetConfigFromJSON"
ConfigSv1StoreCfgInDB = "ConfigSv1.StoreCfgInDB"
)
const (