mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-14 20:59:53 +05:00
Fixed varaibles for unit tests
This commit is contained in:
committed by
Dan Christian Bogos
parent
2cb978314e
commit
97eeadf8cc
@@ -57,7 +57,7 @@ func TestApierCfgAsMapInterface1(t *testing.T) {
|
||||
eMap := map[string]interface{}{
|
||||
utils.EnabledCfg: false,
|
||||
utils.CachesConnsCfg: sls,
|
||||
utils.ActionsConnsCfg: sls,
|
||||
utils.ActionSConnsCfg: sls,
|
||||
utils.AttributeSConnsCfg: sls,
|
||||
utils.EEsConnsCfg: sls,
|
||||
}
|
||||
@@ -81,7 +81,7 @@ func TestApierCfgAsMapInterface2(t *testing.T) {
|
||||
expectedMap := map[string]interface{}{
|
||||
utils.EnabledCfg: true,
|
||||
utils.CachesConnsCfg: []string{utils.MetaInternal, "*conn1"},
|
||||
utils.ActionsConnsCfg: []string{utils.MetaInternal, "*conn1"},
|
||||
utils.ActionSConnsCfg: []string{utils.MetaInternal, "*conn1"},
|
||||
utils.AttributeSConnsCfg: []string{utils.MetaInternal, "*conn1"},
|
||||
utils.EEsConnsCfg: []string{utils.MetaInternal, "*conn1"},
|
||||
}
|
||||
|
||||
@@ -149,7 +149,7 @@ func TestCdrsCfgClone(t *testing.T) {
|
||||
AttributeSConns: []string{utils.ConcatenatedKey(utils.MetaInternal, utils.MetaAttributes), "*conn1"},
|
||||
ThresholdSConns: []string{utils.ConcatenatedKey(utils.MetaInternal, utils.MetaThresholds), "*conn1"},
|
||||
StatSConns: []string{utils.ConcatenatedKey(utils.MetaInternal, utils.MetaStats), "*conn1"},
|
||||
ActionSConns: []string{utils.ConcatenatedKey(utils.MetaInternal, utils.MetaScheduler), "*conn1"},
|
||||
ActionsConns: []string{utils.ConcatenatedKey(utils.MetaInternal, utils.MetaActions), "*conn1"},
|
||||
EEsConns: []string{utils.ConcatenatedKey(utils.MetaInternal, utils.MetaEEs), "*conn1"},
|
||||
OnlineCDRExports: []string{"randomVal"},
|
||||
ExtraFields: RSRParsers{},
|
||||
@@ -173,7 +173,7 @@ func TestCdrsCfgClone(t *testing.T) {
|
||||
if rcv.StatSConns[1] = ""; ban.StatSConns[1] != "*conn1" {
|
||||
t.Errorf("Expected clone to not modify the cloned")
|
||||
}
|
||||
if rcv.ActionSConns[1] = ""; ban.ActionSConns[1] != "*conn1" {
|
||||
if rcv.ActionsConns[1] = ""; ban.ActionsConns[1] != "*conn1" {
|
||||
t.Errorf("Expected clone to not modify the cloned")
|
||||
}
|
||||
if rcv.EEsConns[1] = ""; ban.EEsConns[1] != "*conn1" {
|
||||
|
||||
@@ -91,9 +91,6 @@ func TestCacheJsonCfg(t *testing.T) {
|
||||
utils.CacheReverseDestinations: {Limit: utils.IntPointer(-1),
|
||||
Ttl: utils.StringPointer(""), Static_ttl: utils.BoolPointer(false),
|
||||
Precache: utils.BoolPointer(false), Replicate: utils.BoolPointer(false)},
|
||||
utils.CacheActions: {Limit: utils.IntPointer(-1),
|
||||
Ttl: utils.StringPointer(""), Static_ttl: utils.BoolPointer(false),
|
||||
Precache: utils.BoolPointer(false), Replicate: utils.BoolPointer(false)},
|
||||
utils.CacheTimings: {Limit: utils.IntPointer(-1),
|
||||
Ttl: utils.StringPointer(""), Static_ttl: utils.BoolPointer(false),
|
||||
Precache: utils.BoolPointer(false), Replicate: utils.BoolPointer(false)},
|
||||
@@ -232,9 +229,6 @@ func TestCacheJsonCfg(t *testing.T) {
|
||||
utils.CacheTBLTPDestinations: {Limit: utils.IntPointer(-1),
|
||||
Ttl: utils.StringPointer(""), Static_ttl: utils.BoolPointer(false),
|
||||
Replicate: utils.BoolPointer(false)},
|
||||
utils.CacheTBLTPActions: {Limit: utils.IntPointer(-1),
|
||||
Ttl: utils.StringPointer(""), Static_ttl: utils.BoolPointer(false),
|
||||
Replicate: utils.BoolPointer(false)},
|
||||
utils.CacheTBLTPResources: {Limit: utils.IntPointer(-1),
|
||||
Ttl: utils.StringPointer(""), Static_ttl: utils.BoolPointer(false),
|
||||
Replicate: utils.BoolPointer(false)},
|
||||
@@ -367,22 +361,10 @@ func TestDfDataDbJsonCfg(t *testing.T) {
|
||||
Replicate: utils.BoolPointer(false),
|
||||
Remote: utils.BoolPointer(false),
|
||||
},
|
||||
utils.MetaActionPlans: {
|
||||
Replicate: utils.BoolPointer(false),
|
||||
Remote: utils.BoolPointer(false),
|
||||
},
|
||||
utils.MetaAccountActionPlans: {
|
||||
Replicate: utils.BoolPointer(false),
|
||||
Remote: utils.BoolPointer(false),
|
||||
},
|
||||
utils.MetaActionTriggers: {
|
||||
Replicate: utils.BoolPointer(false),
|
||||
Remote: utils.BoolPointer(false),
|
||||
},
|
||||
utils.MetaSharedGroups: {
|
||||
Replicate: utils.BoolPointer(false),
|
||||
Remote: utils.BoolPointer(false),
|
||||
},
|
||||
utils.MetaTimings: {
|
||||
Replicate: utils.BoolPointer(false),
|
||||
Remote: utils.BoolPointer(false),
|
||||
@@ -495,10 +477,6 @@ func TestDfStorDBJsonCfg(t *testing.T) {
|
||||
Replicate: utils.BoolPointer(false),
|
||||
Remote: utils.BoolPointer(false),
|
||||
},
|
||||
utils.CacheTBLTPActions: {
|
||||
Replicate: utils.BoolPointer(false),
|
||||
Remote: utils.BoolPointer(false),
|
||||
},
|
||||
utils.CacheTBLTPResources: {
|
||||
Replicate: utils.BoolPointer(false),
|
||||
Remote: utils.BoolPointer(false),
|
||||
|
||||
@@ -424,19 +424,6 @@ func TestCgrCfgJSONDefaultsRALs(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestCgrCfgJSONDefaultsScheduler(t *testing.T) {
|
||||
eSchedulerCfg := &SchedulerCfg{
|
||||
Enabled: false,
|
||||
CDRsConns: []string{},
|
||||
ThreshSConns: []string{},
|
||||
StatSConns: []string{},
|
||||
Filters: []string{},
|
||||
}
|
||||
if !reflect.DeepEqual(cgrCfg.schedulerCfg, eSchedulerCfg) {
|
||||
t.Errorf("received: %+v, expecting: %+v", cgrCfg.schedulerCfg, eSchedulerCfg)
|
||||
}
|
||||
}
|
||||
|
||||
func TestCgrCfgJSONDefaultsCDRS(t *testing.T) {
|
||||
eCdrsCfg := &CdrsCfg{
|
||||
Enabled: false,
|
||||
@@ -447,7 +434,7 @@ func TestCgrCfgJSONDefaultsCDRS(t *testing.T) {
|
||||
AttributeSConns: []string{},
|
||||
ThresholdSConns: []string{},
|
||||
StatSConns: []string{},
|
||||
ActionSConns: []string{},
|
||||
ActionsConns: []string{},
|
||||
EEsConns: []string{},
|
||||
ExtraFields: RSRParsers{},
|
||||
}
|
||||
@@ -509,7 +496,7 @@ func TestCgrCfgJSONDefaultsSMGenericCfg(t *testing.T) {
|
||||
PayloadMaxduration: -1,
|
||||
DefaultAttest: "A",
|
||||
},
|
||||
SchedulerConns: []string{},
|
||||
ActionsConns: []string{},
|
||||
DefaultUsage: map[string]time.Duration{
|
||||
utils.MetaAny: 3 * time.Hour,
|
||||
utils.MetaVoice: 3 * time.Hour,
|
||||
@@ -530,20 +517,6 @@ func TestCgrCfgJSONDefaultsCacheCFG(t *testing.T) {
|
||||
TTL: 0, StaticTTL: false, Precache: false},
|
||||
utils.CacheReverseDestinations: {Limit: -1,
|
||||
TTL: 0, StaticTTL: false, Precache: false},
|
||||
utils.CacheRatingPlans: {Limit: -1,
|
||||
TTL: 0, StaticTTL: false, Precache: false},
|
||||
utils.CacheRatingProfiles: {Limit: -1,
|
||||
TTL: 0, StaticTTL: false, Precache: false},
|
||||
utils.CacheActions: {Limit: -1,
|
||||
TTL: 0, StaticTTL: false, Precache: false},
|
||||
utils.CacheActionPlans: {Limit: -1,
|
||||
TTL: 0, StaticTTL: false, Precache: false},
|
||||
utils.CacheAccountActionPlans: {Limit: -1,
|
||||
TTL: 0, StaticTTL: false, Precache: false},
|
||||
utils.CacheActionTriggers: {Limit: -1,
|
||||
TTL: 0, StaticTTL: false, Precache: false},
|
||||
utils.CacheSharedGroups: {Limit: -1,
|
||||
TTL: 0, StaticTTL: false, Precache: false},
|
||||
utils.CacheTimings: {Limit: -1,
|
||||
TTL: 0, StaticTTL: false, Precache: false},
|
||||
utils.CacheResourceProfiles: {Limit: -1,
|
||||
@@ -630,30 +603,10 @@ func TestCgrCfgJSONDefaultsCacheCFG(t *testing.T) {
|
||||
|
||||
utils.CacheVersions: {Limit: -1,
|
||||
TTL: 0, StaticTTL: false, Precache: false},
|
||||
utils.CacheAccounts: {Limit: -1,
|
||||
TTL: 0, StaticTTL: false, Precache: false},
|
||||
utils.CacheTBLTPTimings: {Limit: -1,
|
||||
TTL: 0, StaticTTL: false, Precache: false},
|
||||
utils.CacheTBLTPDestinations: {Limit: -1,
|
||||
TTL: 0, StaticTTL: false, Precache: false},
|
||||
utils.CacheTBLTPRates: {Limit: -1,
|
||||
TTL: 0, StaticTTL: false, Precache: false},
|
||||
utils.CacheTBLTPDestinationRates: {Limit: -1,
|
||||
TTL: 0, StaticTTL: false, Precache: false},
|
||||
utils.CacheTBLTPRatingPlans: {Limit: -1,
|
||||
TTL: 0, StaticTTL: false, Precache: false},
|
||||
utils.CacheTBLTPRatingProfiles: {Limit: -1,
|
||||
TTL: 0, StaticTTL: false, Precache: false},
|
||||
utils.CacheTBLTPSharedGroups: {Limit: -1,
|
||||
TTL: 0, StaticTTL: false, Precache: false},
|
||||
utils.CacheTBLTPActions: {Limit: -1,
|
||||
TTL: 0, StaticTTL: false, Precache: false},
|
||||
utils.CacheTBLTPActionPlans: {Limit: -1,
|
||||
TTL: 0, StaticTTL: false, Precache: false},
|
||||
utils.CacheTBLTPActionTriggers: {Limit: -1,
|
||||
TTL: 0, StaticTTL: false, Precache: false},
|
||||
utils.CacheTBLTPAccountActions: {Limit: -1,
|
||||
TTL: 0, StaticTTL: false, Precache: false},
|
||||
utils.CacheTBLTPResources: {Limit: -1,
|
||||
TTL: 0, StaticTTL: false, Precache: false},
|
||||
utils.CacheTBLTPStats: {Limit: -1,
|
||||
@@ -1280,24 +1233,6 @@ func TestLoadRalSCfgError(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestLoadSchedulerCfgError(t *testing.T) {
|
||||
cfgJSONStr := `{
|
||||
"schedulers": {
|
||||
"filters": "randomFilter",
|
||||
},
|
||||
}`
|
||||
expected := "json: cannot unmarshal string into Go struct field SchedulerJsonCfg.Filters of type []string"
|
||||
cgrConfig := NewDefaultCGRConfig()
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
if cgrCfgJSON, err := NewCgrJsonCfgFromBytes([]byte(cfgJSONStr)); err != nil {
|
||||
t.Error(err)
|
||||
} else if err := cgrConfig.loadSchedulerCfg(cgrCfgJSON); err == nil || err.Error() != expected {
|
||||
t.Errorf("Expected %+v, received %+v", expected, err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestLoadCdrsCfgError(t *testing.T) {
|
||||
cfgJSONStr := `{
|
||||
"cdrs": {
|
||||
@@ -2183,7 +2118,7 @@ func TestSessionSConfig(t *testing.T) {
|
||||
ChannelSyncInterval: 0,
|
||||
TerminateAttempts: 5,
|
||||
AlterableFields: utils.StringSet{},
|
||||
SchedulerConns: []string{},
|
||||
ActionsConns: []string{},
|
||||
STIRCfg: &STIRcfg{
|
||||
AllowedAttest: utils.StringSet{utils.MetaAny: {}},
|
||||
PayloadMaxduration: -1,
|
||||
@@ -2344,24 +2279,6 @@ func TestDispatcherSConfig(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestSchedulerConfig(t *testing.T) {
|
||||
expected := &SchedulerCfg{
|
||||
Enabled: false,
|
||||
CDRsConns: []string{},
|
||||
ThreshSConns: []string{},
|
||||
StatSConns: []string{},
|
||||
Filters: []string{},
|
||||
}
|
||||
cgrConfig := NewDefaultCGRConfig()
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
newConfig := cgrConfig.SchedulerCfg()
|
||||
if !reflect.DeepEqual(expected, newConfig) {
|
||||
t.Errorf("Expected %+v \n, received %+v", utils.ToJSON(expected), utils.ToJSON(newConfig))
|
||||
}
|
||||
}
|
||||
|
||||
func TestAnalyzerConfig(t *testing.T) {
|
||||
expected := &AnalyzerSCfg{
|
||||
Enabled: false,
|
||||
@@ -2384,7 +2301,7 @@ func TestApierConfig(t *testing.T) {
|
||||
expected := &ApierCfg{
|
||||
Enabled: false,
|
||||
CachesConns: []string{utils.ConcatenatedKey(utils.MetaInternal, utils.MetaCaches)},
|
||||
SchedulerConns: []string{},
|
||||
ActionsConns: []string{},
|
||||
AttributeSConns: []string{},
|
||||
EEsConns: []string{},
|
||||
}
|
||||
@@ -3748,7 +3665,7 @@ func TestCgrCfgJSONDefaultApierCfg(t *testing.T) {
|
||||
aCfg := &ApierCfg{
|
||||
Enabled: false,
|
||||
CachesConns: []string{utils.ConcatenatedKey(utils.MetaInternal, utils.MetaCaches)},
|
||||
SchedulerConns: []string{},
|
||||
ActionsConns: []string{},
|
||||
AttributeSConns: []string{},
|
||||
EEsConns: []string{},
|
||||
}
|
||||
@@ -4143,25 +4060,6 @@ func TestV1GetConfigRals(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestV1GetConfigScheduler(t *testing.T) {
|
||||
var reply map[string]interface{}
|
||||
expected := map[string]interface{}{
|
||||
SCHEDULER_JSN: map[string]interface{}{
|
||||
utils.EnabledCfg: false,
|
||||
utils.CDRsConnsCfg: []string{},
|
||||
utils.ThreshSConnsCfg: []string{},
|
||||
utils.StatSConnsCfg: []string{},
|
||||
utils.FiltersCfg: []string{},
|
||||
},
|
||||
}
|
||||
cfgCgr := NewDefaultCGRConfig()
|
||||
if err := cfgCgr.V1GetConfig(&SectionWithAPIOpts{Section: SCHEDULER_JSN}, &reply); err != nil {
|
||||
t.Error(err)
|
||||
} else if !reflect.DeepEqual(reply, expected) {
|
||||
t.Errorf("Expected %+v \n, received %+v", utils.ToJSON(expected), utils.ToJSON(reply))
|
||||
}
|
||||
}
|
||||
|
||||
func TestV1GetConfigCdrs(t *testing.T) {
|
||||
var reply map[string]interface{}
|
||||
expected := map[string]interface{}{
|
||||
@@ -5227,17 +5125,6 @@ func TestV1GetConfigAsJSONRals(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestV1GetConfigAsJSONScheduler(t *testing.T) {
|
||||
var reply string
|
||||
expected := `{"schedulers":{"cdrs_conns":[],"enabled":false,"filters":[],"stats_conns":[],"thresholds_conns":[]}}`
|
||||
cfgCgr := NewDefaultCGRConfig()
|
||||
if err := cfgCgr.V1GetConfigAsJSON(&SectionWithAPIOpts{Section: SCHEDULER_JSN}, &reply); err != nil {
|
||||
t.Error(err)
|
||||
} else if expected != reply {
|
||||
t.Errorf("Expected %+v \n, received %+v", expected, reply)
|
||||
}
|
||||
}
|
||||
|
||||
func TestV1GetConfigAsJSONCdrs(t *testing.T) {
|
||||
var reply string
|
||||
expected := `{"cdrs":{"attributes_conns":[],"chargers_conns":[],"ees_conns":[],"enabled":false,"extra_fields":[],"online_cdr_exports":[],"rals_conns":[],"scheduler_conns":[],"session_cost_retries":5,"stats_conns":[],"store_cdrs":true,"thresholds_conns":[]}}`
|
||||
@@ -5941,14 +5828,14 @@ func TestLoadConfigFromHTTP(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestReloadSections(t *testing.T) {
|
||||
subsystemsThatNeedDataDB := utils.NewStringSet([]string{SCHEDULER_JSN,
|
||||
subsystemsThatNeedDataDB := utils.NewStringSet([]string{
|
||||
RALS_JSN, CDRS_JSN, SessionSJson, ATTRIBUTE_JSN,
|
||||
ChargerSCfgJson, RESOURCES_JSON, STATS_JSON, THRESHOLDS_JSON,
|
||||
RouteSJson, LoaderJson, DispatcherSJson, RateSJson, ApierS})
|
||||
subsystemsThatNeedStorDB := utils.NewStringSet([]string{RALS_JSN, CDRS_JSN, ApierS})
|
||||
cfgCgr := NewDefaultCGRConfig()
|
||||
|
||||
for _, section := range []string{RPCConnsJsonName, HTTP_JSN, SCHEDULER_JSN, RALS_JSN, CDRS_JSN, ERsJson,
|
||||
for _, section := range []string{RPCConnsJsonName, HTTP_JSN, RALS_JSN, CDRS_JSN, ERsJson,
|
||||
SessionSJson, AsteriskAgentJSN, FreeSWITCHAgentJSN, KamailioAgentJSN, DA_JSN, RA_JSN, HttpAgentJson,
|
||||
DNSAgentJson, ATTRIBUTE_JSN, ChargerSCfgJson, RESOURCES_JSON, STATS_JSON, THRESHOLDS_JSON, RouteSJson,
|
||||
LoaderJson, DispatcherSJson, ApierS, EEsJson, SIPAgentJson, RateSJson, RegistrarCJson, AnalyzerCfgJson} {
|
||||
@@ -6107,9 +5994,6 @@ func TestCGRConfigClone(t *testing.T) {
|
||||
if !reflect.DeepEqual(cfg.ralsCfg, rcv.ralsCfg) {
|
||||
t.Errorf("Expected: %+v\nReceived: %+v", utils.ToJSON(cfg.ralsCfg), utils.ToJSON(rcv.ralsCfg))
|
||||
}
|
||||
if !reflect.DeepEqual(cfg.schedulerCfg, rcv.schedulerCfg) {
|
||||
t.Errorf("Expected: %+v\nReceived: %+v", utils.ToJSON(cfg.schedulerCfg), utils.ToJSON(rcv.schedulerCfg))
|
||||
}
|
||||
if !reflect.DeepEqual(cfg.cdrsCfg, rcv.cdrsCfg) {
|
||||
t.Errorf("Expected: %+v\nReceived: %+v", utils.ToJSON(cfg.cdrsCfg), utils.ToJSON(rcv.cdrsCfg))
|
||||
}
|
||||
|
||||
@@ -813,47 +813,6 @@ func TestConfigSanityRouteS(t *testing.T) {
|
||||
|
||||
}
|
||||
|
||||
func TestConfigSanityScheduler(t *testing.T) {
|
||||
cfg = NewDefaultCGRConfig()
|
||||
cfg.schedulerCfg.Enabled = true
|
||||
|
||||
cfg.schedulerCfg.CDRsConns = []string{utils.MetaInternal}
|
||||
expected := "<CDRs> not enabled but requested by <SchedulerS> component"
|
||||
if err := cfg.checkConfigSanity(); err == nil || err.Error() != expected {
|
||||
t.Errorf("Expecting: %+q received: %+q", expected, err)
|
||||
}
|
||||
cfg.schedulerCfg.CDRsConns = []string{"test"}
|
||||
expected = "<SchedulerS> connection with id: <test> not defined"
|
||||
if err := cfg.checkConfigSanity(); err == nil || err.Error() != expected {
|
||||
t.Errorf("Expecting: %+q received: %+q", expected, err)
|
||||
}
|
||||
cfg.schedulerCfg.CDRsConns = []string{}
|
||||
|
||||
cfg.schedulerCfg.ThreshSConns = []string{utils.MetaInternal}
|
||||
expected = "<ThresholdS> not enabled but requested by <SchedulerS> component"
|
||||
if err := cfg.checkConfigSanity(); err == nil || err.Error() != expected {
|
||||
t.Errorf("Expecting: %+q received: %+q", expected, err)
|
||||
}
|
||||
cfg.schedulerCfg.ThreshSConns = []string{"test"}
|
||||
expected = "<SchedulerS> connection with id: <test> not defined"
|
||||
if err := cfg.checkConfigSanity(); err == nil || err.Error() != expected {
|
||||
t.Errorf("Expecting: %+q received: %+q", expected, err)
|
||||
}
|
||||
cfg.schedulerCfg.ThreshSConns = []string{}
|
||||
|
||||
cfg.schedulerCfg.StatSConns = []string{utils.MetaInternal}
|
||||
expected = "<Stats> not enabled but requested by <SchedulerS> component"
|
||||
if err := cfg.checkConfigSanity(); err == nil || err.Error() != expected {
|
||||
t.Errorf("Expecting: %+q received: %+q", expected, err)
|
||||
}
|
||||
cfg.schedulerCfg.StatSConns = []string{"test"}
|
||||
expected = "<SchedulerS> connection with id: <test> not defined"
|
||||
if err := cfg.checkConfigSanity(); err == nil || err.Error() != expected {
|
||||
t.Errorf("Expecting: %+q received: %+q", expected, err)
|
||||
}
|
||||
cfg.schedulerCfg.StatSConns = []string{}
|
||||
}
|
||||
|
||||
func TestConfigSanityEventReader(t *testing.T) {
|
||||
cfg = NewDefaultCGRConfig()
|
||||
cfg.ersCfg = &ERsCfg{
|
||||
@@ -1248,13 +1207,13 @@ func TestConfigSanityDataDB(t *testing.T) {
|
||||
}
|
||||
cfg.cacheCfg = &CacheCfg{
|
||||
Partitions: map[string]*CacheParamCfg{
|
||||
utils.CacheAccounts: {
|
||||
utils.CacheRateProfiles: {
|
||||
Limit: 1,
|
||||
},
|
||||
},
|
||||
}
|
||||
expected := "<CacheS> *accounts needs to be 0 when DataBD is *internal, received : 1"
|
||||
cfg.cacheCfg.Partitions[utils.CacheAccounts].Limit = 0
|
||||
cfg.cacheCfg.Partitions[utils.CacheRateProfiles].Limit = 0
|
||||
cfg.resourceSCfg.Enabled = true
|
||||
expected = "<ResourceS> the StoreInterval field needs to be -1 when DataBD is *internal, received : 0"
|
||||
if err := cfg.checkConfigSanity(); err == nil || err.Error() != expected {
|
||||
@@ -1347,12 +1306,12 @@ func TestConfigSanityAPIer(t *testing.T) {
|
||||
}
|
||||
cfg.apier.AttributeSConns = []string{utils.MetaInternal}
|
||||
cfg.attributeSCfg.Enabled = true
|
||||
cfg.apier.SchedulerConns = []string{utils.MetaInternal}
|
||||
cfg.apier.ActionsConns = []string{utils.MetaInternal}
|
||||
|
||||
if err := cfg.checkConfigSanity(); err == nil || err.Error() != "<SchedulerS> not enabled but requested by <APIerSv1> component" {
|
||||
t.Error(err)
|
||||
}
|
||||
cfg.apier.SchedulerConns = []string{"test"}
|
||||
cfg.apier.ActionsConns = []string{"test"}
|
||||
expected = "<APIerSv1> connection with id: <test> not defined"
|
||||
if err := cfg.checkConfigSanity(); err == nil || err.Error() != expected {
|
||||
t.Errorf("Expecting: %+q received: %+q", expected, err)
|
||||
|
||||
@@ -23,7 +23,6 @@ import (
|
||||
|
||||
"github.com/cgrates/cgrates/config"
|
||||
"github.com/cgrates/cgrates/engine"
|
||||
"github.com/cgrates/cgrates/scheduler"
|
||||
"github.com/cgrates/cgrates/utils"
|
||||
)
|
||||
|
||||
@@ -129,9 +128,7 @@ TOPUP10_AT,TOPUP10_AC1,ASAP,10`
|
||||
}
|
||||
|
||||
func TestDZ1ExecuteActions(t *testing.T) {
|
||||
scheduler.NewScheduler(dataDB, config.CgrConfig(),
|
||||
engine.NewFilterS(config.CgrConfig(), nil, dataDB)).Reload()
|
||||
time.Sleep(10 * time.Millisecond) // Give time to scheduler to topup the account
|
||||
time.Sleep(10 * time.Millisecond)
|
||||
if acnt, err := dataDB.GetAccount("cgrates.org:12344"); err != nil {
|
||||
t.Error(err)
|
||||
} else if len(acnt.BalanceMap) != 2 {
|
||||
|
||||
@@ -28,7 +28,6 @@ import (
|
||||
)
|
||||
|
||||
func TestV1StatsAsStats(t *testing.T) {
|
||||
tim := time.Date(0001, time.January, 1, 2, 0, 0, 0, time.UTC)
|
||||
var filters []*engine.FilterRule
|
||||
v1Sts := &v1Stat{
|
||||
Id: "test", // Config id, unique per config instance
|
||||
@@ -55,22 +54,6 @@ func TestV1StatsAsStats(t *testing.T) {
|
||||
RatedAccount: []string{},
|
||||
RatedSubject: []string{},
|
||||
CostInterval: []float64{},
|
||||
Triggers: engine.ActionTriggers{&engine.ActionTrigger{
|
||||
ID: "TestB",
|
||||
Balance: &engine.BalanceFilter{
|
||||
ID: utils.StringPointer("TESTB"),
|
||||
Timings: []*engine.RITiming{},
|
||||
ExpirationDate: utils.TimePointer(tim),
|
||||
Type: utils.StringPointer(utils.MetaMonetary),
|
||||
},
|
||||
ExpirationDate: tim,
|
||||
LastExecutionTime: tim,
|
||||
ActivationDate: tim,
|
||||
ThresholdType: utils.TriggerMaxBalance,
|
||||
ThresholdValue: 2,
|
||||
ActionsID: "TEST_ACTIONS",
|
||||
Executed: true,
|
||||
}},
|
||||
}
|
||||
|
||||
x, _ := engine.NewFilterRule(utils.MetaGreaterOrEqual, "SetupInterval", []string{v1Sts.SetupInterval[0].String()})
|
||||
|
||||
@@ -1,106 +0,0 @@
|
||||
/*
|
||||
Real-time Online/Offline Charging System (OCS) for Telecom & ISP environments
|
||||
Copyright (C) ITsysCOM GmbH
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
*/
|
||||
package migrator
|
||||
|
||||
import (
|
||||
"reflect"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/cgrates/cgrates/config"
|
||||
"github.com/cgrates/cgrates/engine"
|
||||
"github.com/cgrates/cgrates/utils"
|
||||
)
|
||||
|
||||
func TestV2ActionTriggerAsThreshold(t *testing.T) {
|
||||
var filters []*engine.FilterRule
|
||||
v2ATR := &v2ActionTrigger{
|
||||
ID: "test2", // original csv tag
|
||||
UniqueID: "testUUID", // individual id
|
||||
ThresholdType: "*min_event_counter", //*min_event_counter, *max_event_counter, *min_balance_counter, *max_balance_counter, *min_balance, *max_balance, *balance_expired
|
||||
ThresholdValue: 5.32,
|
||||
Recurrent: false, // reset excuted flag each run
|
||||
MinSleep: 5 * time.Second, // Minimum duration between two executions in case of recurrent triggers
|
||||
ExpirationDate: time.Now(),
|
||||
ActivationDate: time.Now(),
|
||||
Balance: &engine.BalanceFilter{
|
||||
ID: utils.StringPointer(utils.MetaMonetary),
|
||||
DestinationIDs: &utils.StringMap{
|
||||
"1002": true,
|
||||
},
|
||||
RatingSubject: utils.StringPointer("1001"),
|
||||
Categories: &utils.StringMap{
|
||||
utils.MetaVoice: true,
|
||||
},
|
||||
SharedGroups: &utils.StringMap{
|
||||
"SHG1": true,
|
||||
},
|
||||
TimingIDs: &utils.StringMap{
|
||||
"TIMINGID": true,
|
||||
},
|
||||
},
|
||||
Weight: 0,
|
||||
ActionsID: "Action1",
|
||||
MinQueuedItems: 10, // Trigger actions only if this number is hit (stats only)
|
||||
Executed: false,
|
||||
LastExecutionTime: time.Now(),
|
||||
}
|
||||
x, _ := engine.NewFilterRule(utils.MetaDestinations, "DestinationIDs", v2ATR.Balance.DestinationIDs.Slice())
|
||||
filters = append(filters, x)
|
||||
x, _ = engine.NewFilterRule(utils.MetaPrefix, "RatingSubject", []string{*v2ATR.Balance.RatingSubject})
|
||||
filters = append(filters, x)
|
||||
x, _ = engine.NewFilterRule(utils.MetaPrefix, "Categories", v2ATR.Balance.Categories.Slice())
|
||||
filters = append(filters, x)
|
||||
x, _ = engine.NewFilterRule(utils.MetaPrefix, "SharedGroups", v2ATR.Balance.SharedGroups.Slice())
|
||||
filters = append(filters, x)
|
||||
x, _ = engine.NewFilterRule(utils.MetaPrefix, "TimingIDs", v2ATR.Balance.TimingIDs.Slice())
|
||||
filters = append(filters, x)
|
||||
|
||||
filter := &engine.Filter{
|
||||
Tenant: config.CgrConfig().GeneralCfg().DefaultTenant,
|
||||
ID: *v2ATR.Balance.ID,
|
||||
Rules: filters}
|
||||
|
||||
thp := &engine.ThresholdProfile{
|
||||
ID: v2ATR.ID,
|
||||
FilterIDs: make([]string, 0),
|
||||
Tenant: config.CgrConfig().GeneralCfg().DefaultTenant,
|
||||
Blocker: false,
|
||||
Weight: v2ATR.Weight,
|
||||
ActivationInterval: &utils.ActivationInterval{ExpiryTime: v2ATR.ExpirationDate, ActivationTime: v2ATR.ActivationDate},
|
||||
MinSleep: v2ATR.MinSleep,
|
||||
}
|
||||
th := &engine.Threshold{
|
||||
Tenant: config.CgrConfig().GeneralCfg().DefaultTenant,
|
||||
ID: v2ATR.ID,
|
||||
}
|
||||
|
||||
newthp, newth, fltr, err := v2ATR.AsThreshold()
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
if !reflect.DeepEqual(thp, newthp) {
|
||||
t.Errorf("Expecting: %+v, received: %+v", utils.ToJSON(thp), utils.ToJSON(newthp))
|
||||
}
|
||||
if !reflect.DeepEqual(th, newth) {
|
||||
t.Errorf("Expecting: %+v, received: %+v", th, newth)
|
||||
}
|
||||
if !reflect.DeepEqual(filter, fltr) {
|
||||
t.Errorf("Expecting: %+v, received: %+v", filter, fltr)
|
||||
}
|
||||
}
|
||||
@@ -41,15 +41,13 @@ func TestApiersCoverage(t *testing.T) {
|
||||
shdChan := utils.NewSyncedChan()
|
||||
chS := engine.NewCacheS(cfg, nil, nil)
|
||||
cfg.ThresholdSCfg().Enabled = true
|
||||
cfg.SchedulerCfg().Enabled = true
|
||||
server := cores.NewServer(nil)
|
||||
srvDep := map[string]*sync.WaitGroup{utils.DataDB: new(sync.WaitGroup)}
|
||||
db := NewDataDBService(cfg, nil, srvDep)
|
||||
cfg.StorDbCfg().Type = utils.INTERNAL
|
||||
stordb := NewStorDBService(cfg, srvDep)
|
||||
anz := NewAnalyzerService(cfg, server, filterSChan, shdChan, make(chan rpcclient.ClientConnector, 1), srvDep)
|
||||
schS := NewSchedulerService(cfg, db, chS, filterSChan, server, make(chan rpcclient.ClientConnector, 1), nil, anz, srvDep)
|
||||
apiSv1 := NewAPIerSv1Service(cfg, db, stordb, filterSChan, server, schS, new(ResponderService),
|
||||
apiSv1 := NewAPIerSv1Service(cfg, db, stordb, filterSChan, server,
|
||||
make(chan rpcclient.ClientConnector, 1), nil, anz, srvDep)
|
||||
apiSv2 := NewAPIerSv2Service(apiSv1, cfg, server, make(chan rpcclient.ClientConnector, 1), anz, srvDep)
|
||||
if apiSv1.IsRunning() {
|
||||
|
||||
@@ -84,18 +84,9 @@ func TestDataDBCoverage(t *testing.T) {
|
||||
utils.MetaActions: {
|
||||
Replicate: false,
|
||||
Remote: false},
|
||||
utils.MetaActionPlans: {
|
||||
Replicate: false,
|
||||
Remote: false},
|
||||
utils.MetaAccountActionPlans: {
|
||||
Replicate: false,
|
||||
Remote: false},
|
||||
utils.MetaActionTriggers: {
|
||||
Replicate: false,
|
||||
Remote: false},
|
||||
utils.MetaSharedGroups: {
|
||||
Replicate: false,
|
||||
Remote: false},
|
||||
utils.MetaTimings: {
|
||||
Replicate: false,
|
||||
Remote: false},
|
||||
|
||||
@@ -777,13 +777,6 @@ func TestNewAttrReloadCacheWithOpts(t *testing.T) {
|
||||
ArgsCache: map[string][]string{
|
||||
DestinationIDs: nil,
|
||||
ReverseDestinationIDs: nil,
|
||||
RatingPlanIDs: nil,
|
||||
RatingProfileIDs: nil,
|
||||
ActionIDs: nil,
|
||||
ActionPlanIDs: nil,
|
||||
AccountActionPlanIDs: nil,
|
||||
ActionTriggerIDs: nil,
|
||||
SharedGroupIDs: nil,
|
||||
ResourceProfileIDs: nil,
|
||||
ResourceIDs: nil,
|
||||
StatsQueueIDs: nil,
|
||||
|
||||
Reference in New Issue
Block a user