mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-21 07:08:45 +05:00
Updated generalcfg load tests
This commit is contained in:
committed by
Dan Christian Bogos
parent
b12510ee8b
commit
6df506e11a
@@ -26,71 +26,60 @@ import (
|
||||
)
|
||||
|
||||
func TestGeneralCfgloadFromJsonCfg(t *testing.T) {
|
||||
var gencfg, expected GeneralCfg
|
||||
if err := gencfg.loadFromJsonCfg(nil); err != nil {
|
||||
t.Error(err)
|
||||
} else if !reflect.DeepEqual(gencfg, expected) {
|
||||
t.Errorf("Expected: %+v ,recived: %+v", expected, gencfg)
|
||||
cfgJSON := &GeneralJsonCfg{
|
||||
Node_id: utils.StringPointer("randomID"),
|
||||
Logger: utils.StringPointer(utils.MetaSysLog),
|
||||
Log_level: utils.IntPointer(6),
|
||||
Http_skip_tls_verify: utils.BoolPointer(false),
|
||||
Rounding_decimals: utils.IntPointer(5),
|
||||
Dbdata_encoding: utils.StringPointer("msgpack"),
|
||||
Tpexport_dir: utils.StringPointer("/var/spool/cgrates/tpe"),
|
||||
|
||||
Default_request_type: utils.StringPointer(utils.META_RATED),
|
||||
Default_category: utils.StringPointer(utils.CALL),
|
||||
Default_tenant: utils.StringPointer("cgrates.org"),
|
||||
Default_timezone: utils.StringPointer("Local"),
|
||||
Connect_attempts: utils.IntPointer(3),
|
||||
Reconnects: utils.IntPointer(-1),
|
||||
Connect_timeout: utils.StringPointer("1s"),
|
||||
Reply_timeout: utils.StringPointer("2s"),
|
||||
Digest_separator: utils.StringPointer(","),
|
||||
Digest_equal: utils.StringPointer(":"),
|
||||
Failed_posts_ttl: utils.StringPointer("2"),
|
||||
}
|
||||
if err := gencfg.loadFromJsonCfg(new(GeneralJsonCfg)); err != nil {
|
||||
t.Error(err)
|
||||
} else if !reflect.DeepEqual(gencfg, expected) {
|
||||
t.Errorf("Expected: %+v ,recived: %+v", expected, gencfg)
|
||||
|
||||
expected := &GeneralCfg{
|
||||
NodeID: "randomID",
|
||||
Logger: utils.MetaSysLog,
|
||||
LogLevel: 6,
|
||||
HttpSkipTlsVerify: false,
|
||||
RoundingDecimals: 5,
|
||||
DBDataEncoding: "msgpack",
|
||||
TpExportPath: "/var/spool/cgrates/tpe",
|
||||
PosterAttempts: 3,
|
||||
FailedPostsDir: "/var/spool/cgrates/failed_posts",
|
||||
DefaultReqType: utils.META_RATED,
|
||||
DefaultCategory: utils.CALL,
|
||||
DefaultTenant: "cgrates.org",
|
||||
DefaultTimezone: "Local",
|
||||
ConnectAttempts: 3,
|
||||
Reconnects: -1,
|
||||
ConnectTimeout: time.Duration(1 * time.Second),
|
||||
ReplyTimeout: time.Duration(2 * time.Second),
|
||||
DigestSeparator: ",",
|
||||
DigestEqual: ":",
|
||||
ConcurrentStrategy: utils.MetaBusy,
|
||||
MaxParallelConns: 100,
|
||||
RSRSep: ";",
|
||||
DefaultCaching: utils.MetaReload,
|
||||
FailedPostsTTL: time.Duration(2),
|
||||
}
|
||||
cfgJSONStr := `{
|
||||
"general": {
|
||||
"node_id": "", // identifier of this instance in the cluster, if empty it will be autogenerated
|
||||
"logger":"*syslog", // controls the destination of logs <*syslog|*stdout>
|
||||
"log_level": 6, // control the level of messages logged (0-emerg to 7-debug)
|
||||
"http_skip_tls_verify": false, // if enabled Http Client will accept any TLS certificate
|
||||
"rounding_decimals": 5, // system level precision for floats
|
||||
"dbdata_encoding": "msgpack", // encoding used to store object data in strings: <msgpack|json>
|
||||
"tpexport_dir": "/var/spool/cgrates/tpe", // path towards export folder for offline Tariff Plans
|
||||
"poster_attempts": 3, // number of attempts before considering post request failed (eg: *http_post, CDR replication)
|
||||
"failed_posts_dir": "/var/spool/cgrates/failed_posts", // directory path where we store failed requests
|
||||
"default_request_type": "*rated", // default request type to consider when missing from requests: <""|*prepaid|*postpaid|*pseudoprepaid|*rated>
|
||||
"default_category": "call", // default category to consider when missing from requests
|
||||
"default_tenant": "cgrates.org", // default tenant to consider when missing from requests
|
||||
"default_timezone": "Local", // default timezone for timestamps where not specified <""|UTC|Local|$IANA_TZ_DB>
|
||||
"connect_attempts": 3, // initial server connect attempts
|
||||
"reconnects": -1, // number of retries in case of connection lost
|
||||
"connect_timeout": "1s", // consider connection unsuccessful on timeout, 0 to disable the feature
|
||||
"reply_timeout": "2s", // consider connection down for replies taking longer than this value
|
||||
"response_cache_ttl": "0s", // the life span of a cached response
|
||||
"locking_timeout": "0", // timeout internal locks to avoid deadlocks
|
||||
"digest_separator": ",",
|
||||
"digest_equal": ":",
|
||||
}
|
||||
}`
|
||||
expected = GeneralCfg{
|
||||
NodeID: "",
|
||||
Logger: "*syslog",
|
||||
LogLevel: 6,
|
||||
HttpSkipTlsVerify: false,
|
||||
RoundingDecimals: 5,
|
||||
DBDataEncoding: "msgpack",
|
||||
TpExportPath: "/var/spool/cgrates/tpe",
|
||||
PosterAttempts: 3,
|
||||
FailedPostsDir: "/var/spool/cgrates/failed_posts",
|
||||
DefaultReqType: "*rated",
|
||||
DefaultCategory: "call",
|
||||
DefaultTenant: "cgrates.org",
|
||||
DefaultTimezone: "Local",
|
||||
ConnectAttempts: 3,
|
||||
Reconnects: -1,
|
||||
ConnectTimeout: time.Duration(1 * time.Second),
|
||||
ReplyTimeout: time.Duration(2 * time.Second),
|
||||
DigestSeparator: ",",
|
||||
DigestEqual: ":",
|
||||
}
|
||||
if jsnCfg, err := NewCgrJsonCfgFromBytes([]byte(cfgJSONStr)); err != nil {
|
||||
if jsnCfg, err := NewDefaultCGRConfig(); err != nil {
|
||||
t.Error(err)
|
||||
} else if jsnGenCfg, err := jsnCfg.GeneralJsonCfg(); err != nil {
|
||||
} else if err = jsnCfg.generalCfg.loadFromJsonCfg(cfgJSON); err != nil {
|
||||
t.Error(err)
|
||||
} else if err = gencfg.loadFromJsonCfg(jsnGenCfg); err != nil {
|
||||
t.Error(err)
|
||||
} else if !reflect.DeepEqual(expected, gencfg) {
|
||||
t.Errorf("Expected: %+v , recived: %+v", expected, gencfg)
|
||||
} else if !reflect.DeepEqual(expected, jsnCfg.generalCfg) {
|
||||
t.Errorf("Expected %+v \n, received %+v", utils.ToJSON(expected), utils.ToJSON(jsnCfg.generalCfg))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user