Updated sql ers config

This commit is contained in:
Trial97
2021-05-04 11:22:32 +03:00
committed by Dan Christian Bogos
parent 051028078d
commit 3b968b3dc7
5 changed files with 29 additions and 47 deletions

View File

@@ -53,27 +53,22 @@ func newDbDefaults() dbDefaults {
utils.MySQL: map[string]string{
"DbName": "cgrates",
"DbPort": "3306",
"DbPass": "CGRateS.org",
},
utils.Postgres: map[string]string{
"DbName": "cgrates",
"DbPort": "5432",
"DbPass": "CGRateS.org",
},
utils.Mongo: map[string]string{
"DbName": "cgrates",
"DbPort": "27017",
"DbPass": "",
},
utils.Redis: map[string]string{
"DbName": "10",
"DbPort": "6379",
"DbPass": "",
},
utils.INTERNAL: map[string]string{
"DbName": "internal",
"DbPort": "internal",
"DbPass": "internal",
},
}
return deflt
@@ -95,13 +90,6 @@ func (dbDflt dbDefaults) dbPort(dbType string, flagInput string) string {
return dbDflt[dbType]["DbPort"]
}
func (dbDflt dbDefaults) dbPass(dbType string, flagInput string) string {
if flagInput != utils.MetaDynamic {
return flagInput
}
return dbDflt[dbType]["DbPass"]
}
func init() {
cgrCfg = NewDefaultCGRConfig()
dbDefaultsCfg = newDbDefaults()

View File

@@ -409,13 +409,13 @@ const CGRATES_CFG_JSON = `
// "kafkaTopicProcessed": "", the topic were the events are sent after they are processed
// SQL
// "sqldbName": "cgrates", // the name of the database from were the events are read
// "sqltableName": "cdrs", // the name of the table from were the events are read
// "sslMode": "disable", // the postgresSSLMode for postgres db
// "sqlDBName": "cgrates", // the name of the database from were the events are read
// "sqlTableName": "cdrs", // the name of the table from were the events are read
// "sslMode": "disable", // the ssl mode for postgres db
// "sqldbNameProcessed": "", // the name of the database were the events are sent after they are processed
// "sqltableNameProcessed": "", // the name of the table were the events are sent after they are processed
// "sslModeProcessed": "", // the postgresSSLMode for postgres db
// "sqlDBNameProcessed": "", // the name of the database were the events are sent after they are processed
// "sqlTableNameProcessed": "", // the name of the table were the events are sent after they are processed
// "sslModeProcessed": "", // the ssl mode for postgres db
// SQS and S3
// "awsRegion": "",

View File

@@ -969,10 +969,6 @@ func TestDbDefaultsMetaDynamic(t *testing.T) {
if name != dbdf[dbtype]["DbName"] {
t.Errorf("received: %+v, expecting: %+v", name, dbdf[dbtype]["DbName"])
}
pass := dbdf.dbPass(dbtype, flagInput)
if pass != dbdf[dbtype]["DbPass"] {
t.Errorf("received: %+v, expecting: %+v", pass, dbdf[dbtype]["DbPass"])
}
}
}
@@ -988,10 +984,6 @@ func TestDbDefaults(t *testing.T) {
if name != utils.CGRateSLwr {
t.Errorf("Expected %+v, received %+v", utils.CGRateSLwr, name)
}
pass := dbdf.dbPass(dbtype, utils.EmptyString)
if pass != utils.EmptyString {
t.Errorf("Expected %+v, received %+v", utils.EmptyString, pass)
}
}
}

View File

@@ -41,13 +41,13 @@ func TestSQLSetURL(t *testing.T) {
inURL := "*mysql://cgrates:CGRateS.org@127.0.0.1:3306"
outURL := "*mysql://cgrates:CGRateS.org@127.0.0.1:3306"
if err := sql.setURL(inURL, outURL, map[string]interface{}{
"sqlDBName": "cgrates2",
"sqlTableName": "cdrs2",
"sslMode": "enabled",
utils.SQLDBName: "cgrates2",
utils.SQLTableName: "cdrs2",
"sslMode": "enabled",
"sqlDBNameProcessed": "cgrates3",
"sqlTableNameProcessed": "cdrs3",
"sslModeProcessed": "enabled",
utils.SQLDBName + utils.ProcessedOpt: "cgrates3",
utils.SQLTableName + utils.ProcessedOpt: "cdrs3",
"sslModeProcessed": "enabled",
}); err != nil {
t.Fatal(err)
} else if expsql.connString != sql.connString {
@@ -76,13 +76,13 @@ func TestSQLSetURL(t *testing.T) {
inURL = "*postgres://cgrates:CGRateS.org@127.0.0.1:3306"
outURL = "*postgres://cgrates:CGRateS.org@127.0.0.1:3306"
if err := sql.setURL(inURL, outURL, map[string]interface{}{
"sqlDBName": "cgrates2",
"sqlTableName": "cdrs2",
"sslMode": "enabled",
utils.SQLDBName: "cgrates2",
utils.SQLTableName: "cdrs2",
"sslMode": "enabled",
"sqlDBNameProcessed": "cgrates3",
"sqlTableNameProcessed": "cdrs3",
"sslModeProcessed": "enabled",
utils.SQLDBName + utils.ProcessedOpt: "cgrates3",
utils.SQLTableName + utils.ProcessedOpt: "cdrs3",
"sslModeProcessed": "enabled",
}); err != nil {
t.Fatal(err)
} else if expsql.connString != sql.connString {
@@ -111,13 +111,13 @@ func TestSQLSetURL(t *testing.T) {
inURL = "*postgres://cgrates:CGRateS.org@127.0.0.1:3306"
outURL = ""
if err := sql.setURL(inURL, outURL, map[string]interface{}{
"sqlDBName": "cgrates2",
"sqlTableName": "cdrs2",
"sslMode": "enabled",
utils.SQLDBName: "cgrates2",
utils.SQLTableName: "cdrs2",
"sslMode": "enabled",
"sqlDBNameProcessed": "cgrates2",
"sqlTableNameProcessed": "cdrs2",
"sslModeProcessed": "enabled",
utils.SQLDBName + utils.ProcessedOpt: "cgrates2",
utils.SQLTableName + utils.ProcessedOpt: "cdrs2",
"sslModeProcessed": "enabled",
}); err != nil {
t.Fatal(err)
} else if expsql.connString != sql.connString {

View File

@@ -2545,10 +2545,12 @@ const (
S3Bucket = "s3BucketID"
S3FolderPath = "s3FolderPath"
SQLDBName = "sqlDBName"
SQLTableName = "sqlTableName"
SQLDefaultSSLMode = "disable"
// sql
SQLDefaultDBName = "cgrates"
SQLDefaultSSLMode = "disable"
SQLDBName = "sqlDBName"
SQLTableName = "sqlTableName"
// fileCSV
RowLengthOpt = "RowLength"