mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-11 18:16:24 +05:00
Updated unit index health tests
This commit is contained in:
committed by
Dan Christian Bogos
parent
5cd5822215
commit
4c90f78343
@@ -1081,8 +1081,8 @@ func TestHealthIndexDispatchers(t *testing.T) {
|
||||
|
||||
// we will set this dispatcherProfile but without indexing
|
||||
dspPrf := &DispatcherProfile{
|
||||
Tenant: "cgrates.org",
|
||||
ID: "Dsp1",
|
||||
Tenant: "cgrates.org",
|
||||
ID: "Dsp1",
|
||||
Subsystems: []string{utils.MetaAny, utils.MetaSessionS},
|
||||
FilterIDs: []string{
|
||||
"*string:~*opts.*apikey:dps1234|dsp9876",
|
||||
@@ -1094,7 +1094,7 @@ func TestHealthIndexDispatchers(t *testing.T) {
|
||||
Weight: 20,
|
||||
Hosts: DispatcherHostProfiles{
|
||||
{
|
||||
ID: "ALL",
|
||||
ID: "ALL",
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -1105,29 +1105,27 @@ func TestHealthIndexDispatchers(t *testing.T) {
|
||||
args := &IndexHealthArgsWith3Ch{}
|
||||
exp := &FilterIHReply{
|
||||
MissingIndexes: map[string][]string{
|
||||
"cgrates.org:*any:*string:*opts.*apikey:dps1234": {"Dsp1"},
|
||||
"cgrates.org:*any:*string:*opts.*apikey:dsp9876": {"Dsp1"},
|
||||
"cgrates.org:*any:*string:*req.AnswerTime:2013-11-07T08:42:26Z": {"Dsp1"},
|
||||
"cgrates.org:*sessions:*string:*opts.*apikey:dps1234": {"Dsp1"},
|
||||
"cgrates.org:*sessions:*string:*opts.*apikey:dsp9876": {"Dsp1"},
|
||||
"cgrates.org:*any:*string:*opts.*apikey:dps1234": {"Dsp1"},
|
||||
"cgrates.org:*any:*string:*opts.*apikey:dsp9876": {"Dsp1"},
|
||||
"cgrates.org:*any:*string:*req.AnswerTime:2013-11-07T08:42:26Z": {"Dsp1"},
|
||||
"cgrates.org:*sessions:*string:*opts.*apikey:dps1234": {"Dsp1"},
|
||||
"cgrates.org:*sessions:*string:*opts.*apikey:dsp9876": {"Dsp1"},
|
||||
"cgrates.org:*sessions:*string:*req.AnswerTime:2013-11-07T08:42:26Z": {"Dsp1"},
|
||||
},
|
||||
BrokenIndexes: map[string][]string{},
|
||||
MissingFilters: map[string][]string{},
|
||||
MissingObjects: []string{},
|
||||
}
|
||||
/*
|
||||
if rply, err := GetFltrIdxHealth(dm,
|
||||
ltcache.NewCache(args.FilterCacheLimit, args.FilterCacheTTL, args.FilterCacheStaticTTL, nil),
|
||||
ltcache.NewCache(args.IndexCacheLimit, args.IndexCacheTTL, args.IndexCacheStaticTTL, nil),
|
||||
ltcache.NewCache(args.ObjectCacheLimit, args.ObjectCacheTTL, args.ObjectCacheStaticTTL, nil),
|
||||
utils.CacheDispatcherFilterIndexes); err != nil {
|
||||
t.Error(err)
|
||||
} else if !reflect.DeepEqual(exp, rply) {
|
||||
t.Errorf("Expected %+v, received %+v", utils.ToJSON(exp), utils.ToJSON(rply))
|
||||
}
|
||||
|
||||
*/
|
||||
if rply, err := GetFltrIdxHealth(dm,
|
||||
ltcache.NewCache(args.FilterCacheLimit, args.FilterCacheTTL, args.FilterCacheStaticTTL, nil),
|
||||
ltcache.NewCache(args.IndexCacheLimit, args.IndexCacheTTL, args.IndexCacheStaticTTL, nil),
|
||||
ltcache.NewCache(args.ObjectCacheLimit, args.ObjectCacheTTL, args.ObjectCacheStaticTTL, nil),
|
||||
utils.CacheDispatcherFilterIndexes); err != nil {
|
||||
t.Error(err)
|
||||
} else if !reflect.DeepEqual(exp, rply) {
|
||||
t.Errorf("Expected %+v, received %+v", utils.ToJSON(exp), utils.ToJSON(rply))
|
||||
}
|
||||
|
||||
// we will set manually some indexes that points to an nil object or index is valid but the obj is missing
|
||||
indexes := map[string]utils.StringSet{
|
||||
@@ -1140,7 +1138,7 @@ func TestHealthIndexDispatchers(t *testing.T) {
|
||||
"Dsp2": {},
|
||||
},
|
||||
"*string:*req.ExtraField:Usage": { // index is valid but the obj does not exist
|
||||
"InexistingDispatcher": {},
|
||||
"InexistingDispatcher": {},
|
||||
"InexistingDispatcher2": {},
|
||||
},
|
||||
}
|
||||
@@ -1152,15 +1150,15 @@ func TestHealthIndexDispatchers(t *testing.T) {
|
||||
//get the newIdxHealth for dispatchersProfile
|
||||
exp = &FilterIHReply{
|
||||
MissingIndexes: map[string][]string{
|
||||
"cgrates.org:*any:*string:*opts.*apikey:dps1234": {"Dsp1"},
|
||||
"cgrates.org:*any:*string:*opts.*apikey:dsp9876": {"Dsp1"},
|
||||
"cgrates.org:*any:*string:*req.AnswerTime:2013-11-07T08:42:26Z": {"Dsp1"},
|
||||
"cgrates.org:*sessions:*string:*opts.*apikey:dps1234": {"Dsp1"},
|
||||
"cgrates.org:*sessions:*string:*opts.*apikey:dsp9876": {"Dsp1"},
|
||||
"cgrates.org:*any:*string:*opts.*apikey:dps1234": {"Dsp1"},
|
||||
"cgrates.org:*any:*string:*opts.*apikey:dsp9876": {"Dsp1"},
|
||||
"cgrates.org:*any:*string:*req.AnswerTime:2013-11-07T08:42:26Z": {"Dsp1"},
|
||||
"cgrates.org:*sessions:*string:*opts.*apikey:dps1234": {"Dsp1"},
|
||||
"cgrates.org:*sessions:*string:*opts.*apikey:dsp9876": {"Dsp1"},
|
||||
"cgrates.org:*sessions:*string:*req.AnswerTime:2013-11-07T08:42:26Z": {"Dsp1"},
|
||||
},
|
||||
BrokenIndexes: map[string][]string{
|
||||
"cgrates.org:*suffix:*opts.Destination:+100": {"Dsp1"},
|
||||
BrokenIndexes: map[string][]string{
|
||||
"cgrates.org:*suffix:*opts.Destination:+100": {"Dsp1"},
|
||||
"cgrates.org:*string:*req.RequestType:*rated": {"Dsp1"},
|
||||
},
|
||||
MissingFilters: map[string][]string{},
|
||||
@@ -1170,27 +1168,25 @@ func TestHealthIndexDispatchers(t *testing.T) {
|
||||
"cgrates.org:InexistingDispatcher2",
|
||||
},
|
||||
}
|
||||
/*
|
||||
if rply, err := GetFltrIdxHealth(dm,
|
||||
ltcache.NewCache(args.FilterCacheLimit, args.FilterCacheTTL, args.FilterCacheStaticTTL, nil),
|
||||
ltcache.NewCache(args.IndexCacheLimit, args.IndexCacheTTL, args.IndexCacheStaticTTL, nil),
|
||||
ltcache.NewCache(args.ObjectCacheLimit, args.ObjectCacheTTL, args.ObjectCacheStaticTTL, nil),
|
||||
utils.CacheDispatcherFilterIndexes); err != nil {
|
||||
t.Error(err)
|
||||
} else {
|
||||
sort.Strings(rply.MissingObjects)
|
||||
sort.Strings(exp.MissingObjects)
|
||||
if !reflect.DeepEqual(exp, rply) {
|
||||
t.Errorf("Expected %+v, received %+v", utils.ToJSON(exp), utils.ToJSON(rply))
|
||||
}
|
||||
}
|
||||
|
||||
*/
|
||||
if rply, err := GetFltrIdxHealth(dm,
|
||||
ltcache.NewCache(args.FilterCacheLimit, args.FilterCacheTTL, args.FilterCacheStaticTTL, nil),
|
||||
ltcache.NewCache(args.IndexCacheLimit, args.IndexCacheTTL, args.IndexCacheStaticTTL, nil),
|
||||
ltcache.NewCache(args.ObjectCacheLimit, args.ObjectCacheTTL, args.ObjectCacheStaticTTL, nil),
|
||||
utils.CacheDispatcherFilterIndexes); err != nil {
|
||||
t.Error(err)
|
||||
} else {
|
||||
sort.Strings(rply.MissingObjects)
|
||||
sort.Strings(exp.MissingObjects)
|
||||
if !reflect.DeepEqual(exp, rply) {
|
||||
t.Errorf("Expected %+v, received %+v", utils.ToJSON(exp), utils.ToJSON(rply))
|
||||
}
|
||||
}
|
||||
|
||||
//we will use an inexisting Filter(not inline) for the same DispatcherProfile
|
||||
dspPrf = &DispatcherProfile{
|
||||
Tenant: "cgrates.org",
|
||||
ID: "Dsp1",
|
||||
Tenant: "cgrates.org",
|
||||
ID: "Dsp1",
|
||||
Subsystems: []string{utils.MetaAny, utils.MetaSessionS},
|
||||
FilterIDs: []string{
|
||||
"*string:~*opts.*apikey:dps1234|dsp9876",
|
||||
@@ -1203,7 +1199,7 @@ func TestHealthIndexDispatchers(t *testing.T) {
|
||||
Weight: 20,
|
||||
Hosts: DispatcherHostProfiles{
|
||||
{
|
||||
ID: "ALL",
|
||||
ID: "ALL",
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -1214,15 +1210,15 @@ func TestHealthIndexDispatchers(t *testing.T) {
|
||||
//get the newIdxHealth for dispatchersProfile
|
||||
exp = &FilterIHReply{
|
||||
MissingIndexes: map[string][]string{
|
||||
"cgrates.org:*any:*string:*opts.*apikey:dps1234": {"Dsp1"},
|
||||
"cgrates.org:*any:*string:*opts.*apikey:dsp9876": {"Dsp1"},
|
||||
"cgrates.org:*any:*string:*req.AnswerTime:2013-11-07T08:42:26Z": {"Dsp1"},
|
||||
"cgrates.org:*sessions:*string:*opts.*apikey:dps1234": {"Dsp1"},
|
||||
"cgrates.org:*sessions:*string:*opts.*apikey:dsp9876": {"Dsp1"},
|
||||
"cgrates.org:*any:*string:*opts.*apikey:dps1234": {"Dsp1"},
|
||||
"cgrates.org:*any:*string:*opts.*apikey:dsp9876": {"Dsp1"},
|
||||
"cgrates.org:*any:*string:*req.AnswerTime:2013-11-07T08:42:26Z": {"Dsp1"},
|
||||
"cgrates.org:*sessions:*string:*opts.*apikey:dps1234": {"Dsp1"},
|
||||
"cgrates.org:*sessions:*string:*opts.*apikey:dsp9876": {"Dsp1"},
|
||||
"cgrates.org:*sessions:*string:*req.AnswerTime:2013-11-07T08:42:26Z": {"Dsp1"},
|
||||
},
|
||||
BrokenIndexes: map[string][]string{
|
||||
"cgrates.org:*suffix:*opts.Destination:+100": {"Dsp1"},
|
||||
BrokenIndexes: map[string][]string{
|
||||
"cgrates.org:*suffix:*opts.Destination:+100": {"Dsp1"},
|
||||
"cgrates.org:*string:*req.RequestType:*rated": {"Dsp1"},
|
||||
},
|
||||
MissingFilters: map[string][]string{
|
||||
@@ -1278,8 +1274,8 @@ func TestIndexHealthMultipleProfiles(t *testing.T) {
|
||||
"*string:~*req.Account:1234",
|
||||
"FLTR_1_NOT_EXIST2",
|
||||
},
|
||||
RunID: "*default",
|
||||
Weight: 10,
|
||||
RunID: "*default",
|
||||
Weight: 10,
|
||||
}
|
||||
chPrf3 := &ChargerProfile{
|
||||
Tenant: "cgrates.org",
|
||||
@@ -1309,14 +1305,14 @@ func TestIndexHealthMultipleProfiles(t *testing.T) {
|
||||
exp := &FilterIHReply{
|
||||
MissingIndexes: map[string][]string{
|
||||
"cgrates.org:*string:*opts.*eventType:ChargerAccountUpdate": {"Raw", "Default"},
|
||||
"cgrates.org:*string:*req.Account:1234": {"Raw", "Default", "Call_Attr1"},
|
||||
"cgrates.org:*prefix:*req.Destination:+2234": {"Default"},
|
||||
"cgrates.org:*suffix:*req.Usage:10": {"Default"},
|
||||
"cgrates.org:*string:*req.Account:1234": {"Raw", "Default", "Call_Attr1"},
|
||||
"cgrates.org:*prefix:*req.Destination:+2234": {"Default"},
|
||||
"cgrates.org:*suffix:*req.Usage:10":{"Default"},
|
||||
},
|
||||
BrokenIndexes: map[string][]string{},
|
||||
BrokenIndexes: map[string][]string{},
|
||||
MissingFilters: map[string][]string{
|
||||
"cgrates.org:FLTR_1_NOT_EXIST2": {"Default", "Call_Attr1"},
|
||||
"cgrates.org:FLTR_1_NOT_EXIST": {"Call_Attr1"},
|
||||
"cgrates.org:FLTR_1_NOT_EXIST": {"Call_Attr1"},
|
||||
},
|
||||
MissingObjects: []string{},
|
||||
}
|
||||
@@ -1369,12 +1365,12 @@ func TestIndexHealthReverseChecking(t *testing.T) {
|
||||
|
||||
// reverse indexes for charger
|
||||
exp := map[string]*ReverseFilterIHReply{
|
||||
utils.CacheChargerFilterIndexes: {
|
||||
MissingFilters: map[string][]string{
|
||||
"cgrates.org:FLTR_1": {"Raw"},
|
||||
utils.CacheChargerFilterIndexes: {
|
||||
MissingFilters: map[string][]string{
|
||||
"cgrates.org:FLTR_1": {"Raw"},
|
||||
"cgrates.org:FLTR_2": {"Raw"},
|
||||
},
|
||||
BrokenReverseIndexes: map[string][]string{},
|
||||
BrokenReverseIndexes: map[string][]string{},
|
||||
MissingReverseIndexes: map[string][]string{},
|
||||
},
|
||||
}
|
||||
@@ -1390,8 +1386,8 @@ func TestIndexHealthReverseChecking(t *testing.T) {
|
||||
// set reverse indexes for Raw that is already set and 2 that does not exist
|
||||
indexes := map[string]utils.StringSet{
|
||||
utils.CacheChargerFilterIndexes: {
|
||||
"Raw": {},
|
||||
"Default": {},
|
||||
"Raw": {},
|
||||
"Default": {},
|
||||
"Call_Attr1": {},
|
||||
},
|
||||
}
|
||||
@@ -1400,6 +1396,7 @@ func TestIndexHealthReverseChecking(t *testing.T) {
|
||||
t.Error(err)
|
||||
}
|
||||
|
||||
|
||||
// reverse indexes for charger with the changes
|
||||
exp = map[string]*ReverseFilterIHReply{
|
||||
utils.CacheChargerFilterIndexes: {
|
||||
@@ -1407,9 +1404,9 @@ func TestIndexHealthReverseChecking(t *testing.T) {
|
||||
"cgrates.org:FLTR_1": {"Raw"},
|
||||
"cgrates.org:FLTR_2": {"Raw"},
|
||||
},
|
||||
BrokenReverseIndexes: map[string][]string{},
|
||||
BrokenReverseIndexes: map[string][]string{},
|
||||
MissingReverseIndexes: map[string][]string{},
|
||||
MissingObjects: []string{"cgrates.org:Default", "cgrates.org:Call_Attr1"},
|
||||
MissingObjects: []string{"cgrates.org:Default","cgrates.org:Call_Attr1" },
|
||||
},
|
||||
}
|
||||
if rply, err := GetRevFltrIdxHealth(dm,
|
||||
@@ -1428,8 +1425,8 @@ func TestIndexHealthReverseChecking(t *testing.T) {
|
||||
// reverse for a filter present in PROFILE but does not exist for the same indexes
|
||||
indexes = map[string]utils.StringSet{
|
||||
utils.CacheChargerFilterIndexes: {
|
||||
"Raw": {},
|
||||
"Default": {},
|
||||
"Raw": {},
|
||||
"Default": {},
|
||||
"Call_Attr1": {},
|
||||
},
|
||||
}
|
||||
@@ -1449,7 +1446,7 @@ func TestIndexHealthReverseChecking(t *testing.T) {
|
||||
"cgrates.org:Raw": {"FLTR_NOT_IN_PROFILE"},
|
||||
},
|
||||
MissingReverseIndexes: map[string][]string{},
|
||||
MissingObjects: []string{"cgrates.org:Default", "cgrates.org:Call_Attr1"},
|
||||
MissingObjects: []string{"cgrates.org:Default","cgrates.org:Call_Attr1"},
|
||||
},
|
||||
}
|
||||
if rply, err := GetRevFltrIdxHealth(dm,
|
||||
@@ -1539,7 +1536,7 @@ func TestIndexHealthMissingReverseIndexes(t *testing.T) {
|
||||
|
||||
exp := map[string]*ReverseFilterIHReply{
|
||||
utils.CacheChargerFilterIndexes: {
|
||||
MissingFilters: map[string][]string{},
|
||||
MissingFilters: map[string][]string{},
|
||||
BrokenReverseIndexes: map[string][]string{},
|
||||
MissingReverseIndexes: map[string][]string{
|
||||
"cgrates.org:Raw": {"FLTR_1", "FLTR_3"},
|
||||
@@ -1556,19 +1553,19 @@ func TestIndexHealthMissingReverseIndexes(t *testing.T) {
|
||||
t.Errorf("Expecting: %+v,\n received: %+v", utils.ToJSON(exp), utils.ToJSON(rply))
|
||||
}
|
||||
}
|
||||
/*
|
||||
if err := dm.SetFilter(filter1, true); err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
if err := dm.SetFilter(filter2, true); err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
if err := dm.SetFilter(filter3, true); err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
|
||||
*/
|
||||
//Cache.Clear(nil)
|
||||
if err := dm.SetFilter(filter1, true); err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
if err := dm.SetFilter(filter2, true); err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
if err := dm.SetFilter(filter3, true); err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
|
||||
/*
|
||||
// Cache.Clear(nil)
|
||||
// we will set this multiple chargers but without indexing(same and different indexes)
|
||||
chPrf1 = &ChargerProfile{
|
||||
Tenant: "cgrates.org",
|
||||
@@ -1589,7 +1586,7 @@ func TestIndexHealthMissingReverseIndexes(t *testing.T) {
|
||||
}
|
||||
exp = map[string]*ReverseFilterIHReply{
|
||||
utils.CacheChargerFilterIndexes: {
|
||||
MissingFilters: map[string][]string{},
|
||||
MissingFilters: map[string][]string{},
|
||||
BrokenReverseIndexes: map[string][]string{},
|
||||
MissingReverseIndexes: map[string][]string{
|
||||
"cgrates.org:Raw": {"FLTR_1", "FLTR_3"}, // check for FLTR_2
|
||||
@@ -1608,4 +1605,8 @@ func TestIndexHealthMissingReverseIndexes(t *testing.T) {
|
||||
t.Errorf("Expecting: %+v,\n received: %+v", utils.ToJSON(exp), utils.ToJSON(rply))
|
||||
}
|
||||
}
|
||||
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user