mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-17 14:19:54 +05:00
Test for the Profile Ignore Filters opt for attributes in engine, also changed some values in stats test
This commit is contained in:
committed by
Dan Christian Bogos
parent
48590cd99b
commit
d1ef08cff1
@@ -3535,7 +3535,7 @@ func TestStatQueueProcessEventProfileIgnoreFilters(t *testing.T) {
|
||||
sqPrf := &StatQueueProfile{
|
||||
Tenant: "cgrates.org",
|
||||
ID: "SQ1",
|
||||
FilterIDs: []string{"*string:~*req.Account:1001"},
|
||||
FilterIDs: []string{"*string:~*req.Stat:testStatValue"},
|
||||
}
|
||||
sq := &StatQueue{
|
||||
sqPrfl: sqPrf,
|
||||
@@ -3559,7 +3559,7 @@ func TestStatQueueProcessEventProfileIgnoreFilters(t *testing.T) {
|
||||
Tenant: "cgrates.org",
|
||||
ID: "SqProcessEvent",
|
||||
Event: map[string]interface{}{
|
||||
utils.AccountField: "1001",
|
||||
"Stat": "testStatValue",
|
||||
},
|
||||
APIOpts: map[string]interface{}{
|
||||
utils.OptsStatsStatIDs: []string{"SQ1"},
|
||||
@@ -3578,7 +3578,7 @@ func TestStatQueueProcessEventProfileIgnoreFilters(t *testing.T) {
|
||||
Tenant: "cgrates.org",
|
||||
ID: "SqProcessEvent",
|
||||
Event: map[string]interface{}{
|
||||
utils.AccountField: "1002",
|
||||
"Stat": "testStatValue2",
|
||||
},
|
||||
APIOpts: map[string]interface{}{
|
||||
utils.OptsStatsStatIDs: []string{"SQ1"},
|
||||
|
||||
@@ -2974,3 +2974,69 @@ func TestThreholdsMatchingThresholdsForEventDoesNotPass(t *testing.T) {
|
||||
t.Errorf("expected: <%+v>, received: <%+v>", utils.ErrNotFound, err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestThresholdsProcessEventIgnoreFilters(t *testing.T) {
|
||||
cfg := config.NewDefaultCGRConfig()
|
||||
data := NewInternalDB(nil, nil, true)
|
||||
dm := NewDataManager(data, cfg.CacheCfg(), nil)
|
||||
filterS := NewFilterS(cfg, nil, dm)
|
||||
tS := NewThresholdService(dm, cfg, filterS, nil)
|
||||
cfg.StatSCfg().Opts.ProfileIgnoreFilters = []*utils.DynamicBoolOpt{
|
||||
{
|
||||
Value: true,
|
||||
},
|
||||
}
|
||||
thPrf := &ThresholdProfile{
|
||||
Tenant: "cgrates.org",
|
||||
ID: "TH",
|
||||
FilterIDs: []string{"*string:~*req.Threshold:testThresholdValue"},
|
||||
}
|
||||
th := &Threshold{
|
||||
Tenant: "cgrates.org",
|
||||
ID: "TH",
|
||||
tPrfl: thPrf,
|
||||
}
|
||||
|
||||
if err := dm.SetThresholdProfile(context.Background(), thPrf, true); err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
if err := dm.SetThreshold(context.Background(), th); err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
// testing if the profile matches wtih profile ignore filters on false
|
||||
args := &utils.CGREvent{
|
||||
Tenant: "cgrates.org",
|
||||
ID: "ThdProcessEvent",
|
||||
Event: map[string]interface{}{
|
||||
"Threshold": "testThresholdValue",
|
||||
},
|
||||
APIOpts: map[string]interface{}{
|
||||
utils.OptsThresholdsThresholdIDs: []string{"TH"},
|
||||
utils.MetaProfileIgnoreFilters: false,
|
||||
},
|
||||
}
|
||||
exp := []string{"TH"}
|
||||
if rcv, err := tS.processEvent(context.Background(), args.Tenant, args); err != nil {
|
||||
t.Errorf("expected: <%+v>, \nreceived: <%+v>", nil, err)
|
||||
} else if !reflect.DeepEqual(rcv, exp) {
|
||||
t.Errorf("expected: <%+v>, \nreceived: <%+v>", exp, rcv)
|
||||
}
|
||||
// testing if the profile matches with wtih profile ignore filters on true
|
||||
args2 := &utils.CGREvent{
|
||||
Tenant: "cgrates.org",
|
||||
ID: "ThdProcessEvent",
|
||||
Event: map[string]interface{}{
|
||||
"Threshold": "testThresholdValue2",
|
||||
},
|
||||
APIOpts: map[string]interface{}{
|
||||
utils.OptsThresholdsThresholdIDs: []string{"TH"},
|
||||
utils.MetaProfileIgnoreFilters: true,
|
||||
},
|
||||
}
|
||||
exp2 := []string{"TH"}
|
||||
if rcv2, err := tS.processEvent(context.Background(), args2.Tenant, args2); err != nil {
|
||||
t.Errorf("expected: <%+v>, \nreceived: <%+v>", nil, err)
|
||||
} else if !reflect.DeepEqual(rcv2, exp) {
|
||||
t.Errorf("expected: <%+v>, \nreceived: <%+v>", exp2, rcv2)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user