Test for not indexing *libphnumber

This commit is contained in:
porosnicuadrian
2021-07-27 10:56:53 +03:00
committed by Dan Christian Bogos
parent ce70b8c581
commit acd9b527bd
2 changed files with 45 additions and 8 deletions

View File

@@ -127,3 +127,40 @@ func TestFilterIndexesCheckingDynamicPathToNotIndex(t *testing.T) {
t.Errorf("Expected %+v, received %+v", utils.ToJSON(expIDx), utils.ToJSON(fltrIDx))
}
}
func TestFilterIndexesCheckingDynamicPathToNotIndexLibphNmbr(t *testing.T) {
Cache.Clear(nil)
cfg := config.NewDefaultCGRConfig()
db := NewInternalDB(nil, nil, true)
dm := NewDataManager(db, cfg.CacheCfg(), nil)
// set 1 charger profile with different *libphonenumber filter to index
cghPfr := &ChargerProfile{
Tenant: "cgrates.org",
ID: "CHARGER_2",
FilterIDs: []string{
"*prefix:~*req.CGRID:TEST_ID",
"*string:~*opts.TotalCost:~*stats.STS_PRF1.*tcc",
"*string:~*libphonenumber.<~*req.Destination>:1233",
},
RunID: "RAW",
AttributeIDs: []string{"attr_1"},
Weight: 10,
}
if err := dm.SetChargerProfile(context.Background(), cghPfr, true); err != nil {
t.Error(err)
}
expIDx := map[string]utils.StringSet{
"*prefix:*req.CGRID:TEST_ID": {
"CHARGER_2": {},
},
}
if fltrIDx, err := dm.GetIndexes(context.Background(), utils.CacheChargerFilterIndexes,
"cgrates.org", utils.EmptyString, true, true); err != nil {
t.Error(err)
} else if !reflect.DeepEqual(expIDx, fltrIDx) {
t.Errorf("Expected %+v, received %+v", utils.ToJSON(expIDx), utils.ToJSON(fltrIDx))
}
}

View File

@@ -159,7 +159,7 @@ func TestHealthIndexThreshold(t *testing.T) {
Tenant: "cgrates.org",
ID: "TestHealthIndexThreshold",
FilterIDs: []string{"*string:~*opts.*eventType:AccountUpdate",
"*string:~*asm.ID:1002",
"*string:~*opts.ID:1002",
"*suffix:BrokenFilter:Invalid"},
MaxHits: 1,
},
@@ -170,7 +170,7 @@ func TestHealthIndexThreshold(t *testing.T) {
exp := &FilterIHReply{
MissingIndexes: map[string][]string{
"cgrates.org:*string:*asm.ID:1002": {"TestHealthIndexThreshold"},
"cgrates.org:*string:*opts.ID:1002": {"TestHealthIndexThreshold"},
"cgrates.org:*string:*opts.*eventType:AccountUpdate": {"TestHealthIndexThreshold"},
},
BrokenIndexes: map[string][]string{},
@@ -193,7 +193,7 @@ func TestHealthIndexThreshold(t *testing.T) {
"*string:*req.Destination:123": { // index is valid but the obj does not exist
"InexistingThreshold": {},
},
}
}
// we will set manually some indexes that points to an nil object or index is valid but the obj is missing
if err := dm.SetIndexes(context.Background(), utils.CacheThresholdFilterIndexes, "cgrates.org",
@@ -203,10 +203,10 @@ func TestHealthIndexThreshold(t *testing.T) {
exp = &FilterIHReply{
MissingObjects: []string{"cgrates.org:InexistingThreshold"},
MissingIndexes: map[string][]string{
"cgrates.org:*string:*asm.ID:1002": {"TestHealthIndexThreshold"},
"cgrates.org:*string:*opts.ID:1002": {"TestHealthIndexThreshold"},
"cgrates.org:*string:*opts.*eventType:AccountUpdate": {"TestHealthIndexThreshold"},
},
BrokenIndexes: map[string][]string{
BrokenIndexes: map[string][]string{
"cgrates.org:*prefix:req.InvalidIdx:10": {"TestHealthIndexThreshold"},
},
MissingFilters: map[string][]string{},
@@ -227,7 +227,7 @@ func TestHealthIndexThreshold(t *testing.T) {
Tenant: "cgrates.org",
ID: "TestHealthIndexThreshold",
FilterIDs: []string{"*string:~*opts.*eventType:AccountUpdate",
"*string:~*asm.ID:1002",
"*string:~*opts.ID:1002",
"FLTR_1_DOES_NOT_EXIST"},
MaxHits: 1,
},
@@ -238,10 +238,10 @@ func TestHealthIndexThreshold(t *testing.T) {
exp = &FilterIHReply{
MissingObjects: []string{"cgrates.org:InexistingThreshold"},
MissingIndexes: map[string][]string{
"cgrates.org:*string:*asm.ID:1002": {"TestHealthIndexThreshold"},
"cgrates.org:*string:*opts.ID:1002": {"TestHealthIndexThreshold"},
"cgrates.org:*string:*opts.*eventType:AccountUpdate": {"TestHealthIndexThreshold"},
},
BrokenIndexes: map[string][]string{
BrokenIndexes: map[string][]string{
"cgrates.org:*prefix:req.InvalidIdx:10": {"TestHealthIndexThreshold"},
},
MissingFilters: map[string][]string{