mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-25 00:58:45 +05:00
Add ees conns to coreS config and fix failing integration tests
This commit is contained in:
committed by
Dan Christian Bogos
parent
458d66d08f
commit
236f3ac2f0
@@ -60,6 +60,7 @@ const CGRATES_CFG_JSON = `
|
||||
"caps": 0, // maximum concurrent request allowed ( 0 to disabled )
|
||||
"caps_strategy": "*busy", // strategy in case in case of concurrent requests reached
|
||||
"caps_stats_interval": "0", // the interval we sample for caps stats ( 0 to disabled )
|
||||
"ees_conns": [], // connections to EventExporter
|
||||
"shutdown_timeout": "1s" // the duration to wait until all services are stopped
|
||||
},
|
||||
|
||||
|
||||
@@ -146,14 +146,16 @@ func testCGRConfigReloadAttributeS(t *testing.T) {
|
||||
t.Errorf("Expected OK received: %s", reply)
|
||||
}
|
||||
expAttr := &AttributeSCfg{
|
||||
Enabled: true,
|
||||
AccountSConns: []string{},
|
||||
ResourceSConns: []string{},
|
||||
StatSConns: []string{},
|
||||
StringIndexedFields: &[]string{utils.MetaReq + utils.NestingSep + utils.AccountField},
|
||||
PrefixIndexedFields: &[]string{},
|
||||
SuffixIndexedFields: &[]string{},
|
||||
IndexedSelects: true,
|
||||
Enabled: true,
|
||||
AccountSConns: []string{},
|
||||
ResourceSConns: []string{},
|
||||
StatSConns: []string{},
|
||||
StringIndexedFields: &[]string{utils.MetaReq + utils.NestingSep + utils.AccountField},
|
||||
PrefixIndexedFields: &[]string{},
|
||||
SuffixIndexedFields: &[]string{},
|
||||
ExistsIndexedFields: &[]string{},
|
||||
NotExistsIndexedFields: &[]string{},
|
||||
IndexedSelects: true,
|
||||
Opts: &AttributesOpts{
|
||||
ProfileIDs: []*utils.DynamicStringSliceOpt{},
|
||||
ProcessRuns: []*utils.DynamicIntOpt{},
|
||||
@@ -185,14 +187,16 @@ func testCGRConfigReloadAttributeSWithDB(t *testing.T) {
|
||||
t.Errorf("Expected OK received: %s", reply)
|
||||
}
|
||||
expAttr := &AttributeSCfg{
|
||||
Enabled: true,
|
||||
ResourceSConns: []string{},
|
||||
AccountSConns: []string{},
|
||||
StatSConns: []string{utils.MetaLocalHost},
|
||||
StringIndexedFields: &[]string{utils.MetaReq + utils.NestingSep + utils.AccountField},
|
||||
PrefixIndexedFields: &[]string{},
|
||||
SuffixIndexedFields: &[]string{},
|
||||
IndexedSelects: true,
|
||||
Enabled: true,
|
||||
ResourceSConns: []string{},
|
||||
AccountSConns: []string{},
|
||||
StatSConns: []string{utils.MetaLocalHost},
|
||||
StringIndexedFields: &[]string{utils.MetaReq + utils.NestingSep + utils.AccountField},
|
||||
PrefixIndexedFields: &[]string{},
|
||||
SuffixIndexedFields: &[]string{},
|
||||
ExistsIndexedFields: &[]string{},
|
||||
NotExistsIndexedFields: &[]string{},
|
||||
IndexedSelects: true,
|
||||
Opts: &AttributesOpts{
|
||||
ProfileIDs: []*utils.DynamicStringSliceOpt{},
|
||||
ProcessRuns: []*utils.DynamicIntOpt{},
|
||||
@@ -238,12 +242,14 @@ func testCGRConfigReloadChargerS(t *testing.T) {
|
||||
t.Errorf("Expected OK received: %s", reply)
|
||||
}
|
||||
expAttr := &ChargerSCfg{
|
||||
Enabled: true,
|
||||
StringIndexedFields: &[]string{utils.MetaReq + utils.NestingSep + utils.AccountField},
|
||||
PrefixIndexedFields: &[]string{},
|
||||
SuffixIndexedFields: &[]string{},
|
||||
IndexedSelects: true,
|
||||
AttributeSConns: []string{"*localhost"},
|
||||
Enabled: true,
|
||||
StringIndexedFields: &[]string{utils.MetaReq + utils.NestingSep + utils.AccountField},
|
||||
PrefixIndexedFields: &[]string{},
|
||||
SuffixIndexedFields: &[]string{},
|
||||
ExistsIndexedFields: &[]string{},
|
||||
NotExistsIndexedFields: &[]string{},
|
||||
IndexedSelects: true,
|
||||
AttributeSConns: []string{"*localhost"},
|
||||
}
|
||||
if !reflect.DeepEqual(expAttr, cfg.ChargerSCfg()) {
|
||||
t.Errorf("Expected %s , received: %s ", utils.ToJSON(expAttr), utils.ToJSON(cfg.ChargerSCfg()))
|
||||
@@ -261,12 +267,14 @@ func testCGRConfigReloadThresholdS(t *testing.T) {
|
||||
t.Errorf("Expected OK received: %s", reply)
|
||||
}
|
||||
expAttr := &ThresholdSCfg{
|
||||
Enabled: true,
|
||||
StringIndexedFields: &[]string{utils.MetaReq + utils.NestingSep + utils.AccountField},
|
||||
PrefixIndexedFields: &[]string{},
|
||||
SuffixIndexedFields: &[]string{},
|
||||
ActionSConns: []string{},
|
||||
IndexedSelects: true,
|
||||
Enabled: true,
|
||||
StringIndexedFields: &[]string{utils.MetaReq + utils.NestingSep + utils.AccountField},
|
||||
PrefixIndexedFields: &[]string{},
|
||||
SuffixIndexedFields: &[]string{},
|
||||
ExistsIndexedFields: &[]string{},
|
||||
NotExistsIndexedFields: &[]string{},
|
||||
ActionSConns: []string{},
|
||||
IndexedSelects: true,
|
||||
Opts: &ThresholdsOpts{
|
||||
ProfileIDs: []*utils.DynamicStringSliceOpt{},
|
||||
ProfileIgnoreFilters: []*utils.DynamicBoolOpt{},
|
||||
@@ -290,12 +298,14 @@ func testCGRConfigReloadStatS(t *testing.T) {
|
||||
t.Errorf("Expected OK received: %s", reply)
|
||||
}
|
||||
expAttr := &StatSCfg{
|
||||
Enabled: true,
|
||||
StringIndexedFields: &[]string{utils.MetaReq + utils.NestingSep + utils.AccountField},
|
||||
PrefixIndexedFields: &[]string{},
|
||||
SuffixIndexedFields: &[]string{},
|
||||
IndexedSelects: true,
|
||||
ThresholdSConns: []string{utils.MetaLocalHost},
|
||||
Enabled: true,
|
||||
StringIndexedFields: &[]string{utils.MetaReq + utils.NestingSep + utils.AccountField},
|
||||
PrefixIndexedFields: &[]string{},
|
||||
SuffixIndexedFields: &[]string{},
|
||||
ExistsIndexedFields: &[]string{},
|
||||
NotExistsIndexedFields: &[]string{},
|
||||
IndexedSelects: true,
|
||||
ThresholdSConns: []string{utils.MetaLocalHost},
|
||||
Opts: &StatsOpts{
|
||||
ProfileIDs: []*utils.DynamicStringSliceOpt{},
|
||||
ProfileIgnoreFilters: []*utils.DynamicBoolOpt{},
|
||||
@@ -320,12 +330,14 @@ func testCGRConfigReloadResourceS(t *testing.T) {
|
||||
t.Errorf("Expected OK received: %s", reply)
|
||||
}
|
||||
expAttr := &ResourceSConfig{
|
||||
Enabled: true,
|
||||
StringIndexedFields: &[]string{utils.MetaReq + utils.NestingSep + utils.AccountField},
|
||||
PrefixIndexedFields: &[]string{},
|
||||
SuffixIndexedFields: &[]string{},
|
||||
IndexedSelects: true,
|
||||
ThresholdSConns: []string{utils.MetaLocalHost},
|
||||
Enabled: true,
|
||||
StringIndexedFields: &[]string{utils.MetaReq + utils.NestingSep + utils.AccountField},
|
||||
PrefixIndexedFields: &[]string{},
|
||||
SuffixIndexedFields: &[]string{},
|
||||
ExistsIndexedFields: &[]string{},
|
||||
NotExistsIndexedFields: &[]string{},
|
||||
IndexedSelects: true,
|
||||
ThresholdSConns: []string{utils.MetaLocalHost},
|
||||
Opts: &ResourcesOpts{
|
||||
UsageID: []*utils.DynamicStringOpt{},
|
||||
UsageTTL: []*utils.DynamicDurationOpt{},
|
||||
@@ -350,17 +362,19 @@ func testCGRConfigReloadSupplierS(t *testing.T) {
|
||||
t.Errorf("Expected OK received: %s", reply)
|
||||
}
|
||||
expAttr := &RouteSCfg{
|
||||
Enabled: true,
|
||||
StringIndexedFields: &[]string{"*req.LCRProfile"},
|
||||
PrefixIndexedFields: &[]string{utils.MetaReq + utils.NestingSep + utils.Destination},
|
||||
SuffixIndexedFields: &[]string{},
|
||||
ResourceSConns: []string{},
|
||||
StatSConns: []string{},
|
||||
AttributeSConns: []string{},
|
||||
RateSConns: []string{},
|
||||
AccountSConns: []string{},
|
||||
IndexedSelects: true,
|
||||
DefaultRatio: 1,
|
||||
Enabled: true,
|
||||
StringIndexedFields: &[]string{"*req.LCRProfile"},
|
||||
PrefixIndexedFields: &[]string{utils.MetaReq + utils.NestingSep + utils.Destination},
|
||||
SuffixIndexedFields: &[]string{},
|
||||
ExistsIndexedFields: &[]string{},
|
||||
NotExistsIndexedFields: &[]string{},
|
||||
ResourceSConns: []string{},
|
||||
StatSConns: []string{},
|
||||
AttributeSConns: []string{},
|
||||
RateSConns: []string{},
|
||||
AccountSConns: []string{},
|
||||
IndexedSelects: true,
|
||||
DefaultRatio: 1,
|
||||
Opts: &RoutesOpts{
|
||||
Context: []*utils.DynamicStringOpt{},
|
||||
ProfileCount: []*utils.DynamicIntPointerOpt{},
|
||||
|
||||
@@ -72,6 +72,7 @@ func TestDfCoreSJsonCfg(t *testing.T) {
|
||||
Caps: utils.IntPointer(0),
|
||||
Caps_strategy: utils.StringPointer(utils.MetaBusy),
|
||||
Caps_stats_interval: utils.StringPointer("0"),
|
||||
Ees_conns: utils.SliceStringPointer([]string{}),
|
||||
Shutdown_timeout: utils.StringPointer("1s"),
|
||||
}
|
||||
dfCgrJSONCfg, err := NewCgrJsonCfgFromBytes([]byte(CGRATES_CFG_JSON))
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -30,6 +30,7 @@ type CoreSCfg struct {
|
||||
Caps int
|
||||
CapsStrategy string
|
||||
CapsStatsInterval time.Duration
|
||||
EEsConns []string
|
||||
ShutdownTimeout time.Duration
|
||||
}
|
||||
|
||||
@@ -57,6 +58,9 @@ func (cS *CoreSCfg) loadFromJSONCfg(jsnCfg *CoreSJsonCfg) (err error) {
|
||||
return
|
||||
}
|
||||
}
|
||||
if jsnCfg.Ees_conns != nil {
|
||||
cS.EEsConns = updateInternalConns(*jsnCfg.Ees_conns, utils.MetaEEs)
|
||||
}
|
||||
if jsnCfg.Shutdown_timeout != nil {
|
||||
if cS.ShutdownTimeout, err = utils.ParseDurationWithNanosecs(*jsnCfg.Shutdown_timeout); err != nil {
|
||||
return
|
||||
@@ -76,6 +80,9 @@ func (cS CoreSCfg) AsMapInterface(string) interface{} {
|
||||
if cS.CapsStatsInterval == 0 {
|
||||
mp[utils.CapsStatsIntervalCfg] = "0"
|
||||
}
|
||||
if cS.EEsConns != nil {
|
||||
mp[utils.EEsConnsCfg] = getInternalJSONConns(cS.EEsConns)
|
||||
}
|
||||
if cS.ShutdownTimeout == 0 {
|
||||
mp[utils.ShutdownTimeoutCfg] = "0"
|
||||
}
|
||||
@@ -86,19 +93,25 @@ func (CoreSCfg) SName() string { return CoreSJSON }
|
||||
func (cS CoreSCfg) CloneSection() Section { return cS.Clone() }
|
||||
|
||||
// Clone returns a deep copy of CoreSCfg
|
||||
func (cS CoreSCfg) Clone() *CoreSCfg {
|
||||
return &CoreSCfg{
|
||||
func (cS CoreSCfg) Clone() (cln *CoreSCfg) {
|
||||
cln = &CoreSCfg{
|
||||
Caps: cS.Caps,
|
||||
CapsStrategy: cS.CapsStrategy,
|
||||
CapsStatsInterval: cS.CapsStatsInterval,
|
||||
ShutdownTimeout: cS.ShutdownTimeout,
|
||||
}
|
||||
if cS.EEsConns != nil {
|
||||
cln.EEsConns = utils.CloneStringSlice(cS.EEsConns)
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
type CoreSJsonCfg struct {
|
||||
Caps *int
|
||||
Caps_strategy *string
|
||||
Caps_stats_interval *string
|
||||
Ees_conns *[]string
|
||||
Shutdown_timeout *string
|
||||
}
|
||||
|
||||
@@ -115,6 +128,9 @@ func diffCoreSJsonCfg(d *CoreSJsonCfg, v1, v2 *CoreSCfg) *CoreSJsonCfg {
|
||||
if v1.CapsStatsInterval != v2.CapsStatsInterval {
|
||||
d.Caps_stats_interval = utils.StringPointer(v2.CapsStatsInterval.String())
|
||||
}
|
||||
if !utils.SliceStringEqual(v1.EEsConns, v2.EEsConns) {
|
||||
d.Ees_conns = utils.SliceStringPointer(getInternalJSONConns(v2.EEsConns))
|
||||
}
|
||||
if v1.ShutdownTimeout != v2.ShutdownTimeout {
|
||||
d.Shutdown_timeout = utils.StringPointer(v2.ShutdownTimeout.String())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user