mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-21 23:28:44 +05:00
Fixed processRuns test + indetation
This commit is contained in:
committed by
Dan Christian Bogos
parent
2f95a88ddc
commit
33084e33f4
@@ -858,20 +858,12 @@ func TestAttributesPorcessEventMatchingProcessRuns(t *testing.T) {
|
||||
fltrS := NewFilterS(cfg, nil, dm)
|
||||
fltr := &Filter{
|
||||
Tenant: "cgrates.org",
|
||||
ID: "Process_Runs_Fltr",
|
||||
ID: "Process_Runs_Fltr",
|
||||
Rules: []*FilterRule{
|
||||
/*
|
||||
{
|
||||
Type: utils.MetaString,
|
||||
Element: "~*req.Account",
|
||||
Values: []string{"pc_test"},
|
||||
},
|
||||
|
||||
*/
|
||||
{
|
||||
Type: utils.MetaGreaterThan,
|
||||
Type: utils.MetaGreaterThan,
|
||||
Element: "~*vars.*processRuns",
|
||||
Values: []string{"1"},
|
||||
Values: []string{"1"},
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -880,14 +872,13 @@ func TestAttributesPorcessEventMatchingProcessRuns(t *testing.T) {
|
||||
}
|
||||
|
||||
attrPfr := &AttributeProfile{
|
||||
Tenant: "cgrates.org",
|
||||
ID: "ATTR_ProcessRuns",
|
||||
Contexts: []string{"*any"},
|
||||
Tenant: "cgrates.org",
|
||||
ID: "ATTR_ProcessRuns",
|
||||
FilterIDs: []string{"Process_Runs_Fltr"},
|
||||
Attributes: []*Attribute{
|
||||
{
|
||||
Path: "*req.CompanyName",
|
||||
Type: utils.MetaVariable,
|
||||
Path: "*req.CompanyName",
|
||||
Type: utils.MetaVariable,
|
||||
Value: config.NewRSRParsersMustCompile("ITSYS COMMUNICATIONS SRL", utils.InfieldSep),
|
||||
},
|
||||
},
|
||||
@@ -896,12 +887,11 @@ func TestAttributesPorcessEventMatchingProcessRuns(t *testing.T) {
|
||||
// this I'll match first, no fltr and processRuns will be 1
|
||||
attrPfr2 := &AttributeProfile{
|
||||
Tenant: "cgrates.org",
|
||||
ID: "ATTR_MatchSecond",
|
||||
Contexts: []string{"*any"},
|
||||
ID: "ATTR_MatchSecond",
|
||||
Attributes: []*Attribute{
|
||||
{
|
||||
Path: "*req.Password",
|
||||
Type: utils.MetaVariable,
|
||||
Path: "*req.Password",
|
||||
Type: utils.MetaVariable,
|
||||
Value: config.NewRSRParsersMustCompile("CGRateS.org", utils.InfieldSep),
|
||||
},
|
||||
},
|
||||
@@ -911,22 +901,20 @@ func TestAttributesPorcessEventMatchingProcessRuns(t *testing.T) {
|
||||
attrPfr.Compile()
|
||||
fltr.Compile()
|
||||
attrPfr2.Compile()
|
||||
if err := dm.SetAttributeProfile(attrPfr, true); err != nil {
|
||||
if err := dm.SetAttributeProfile(context.Background(), attrPfr, true); err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
if err := dm.SetAttributeProfile(attrPfr2, true); err != nil {
|
||||
if err := dm.SetAttributeProfile(context.Background(), attrPfr2, true); err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
|
||||
|
||||
attr := NewAttributeService(dm, fltrS, cfg)
|
||||
|
||||
args := &AttrArgsProcessEvent{
|
||||
ProcessRuns: utils.IntPointer(2),
|
||||
Context: utils.StringPointer(utils.MetaAny),
|
||||
CGREvent: &utils.CGREvent{
|
||||
Event: map[string]interface{}{
|
||||
"Account": "pc_test",
|
||||
"Account": "pc_test",
|
||||
"CompanyName": "MY_company_will_be_changed",
|
||||
},
|
||||
},
|
||||
@@ -934,22 +922,20 @@ func TestAttributesPorcessEventMatchingProcessRuns(t *testing.T) {
|
||||
reply := &AttrSProcessEventReply{}
|
||||
expReply := &AttrSProcessEventReply{
|
||||
MatchedProfiles: []string{"cgrates.org:ATTR_MatchSecond", "cgrates.org:ATTR_ProcessRuns"},
|
||||
AlteredFields: []string{"*req.Password", "*req.CompanyName"},
|
||||
AlteredFields: []string{"*req.Password", "*req.CompanyName"},
|
||||
CGREvent: &utils.CGREvent{
|
||||
Tenant: "cgrates.org",
|
||||
Event: map[string]interface{}{
|
||||
"Account": "pc_test",
|
||||
"Account": "pc_test",
|
||||
"CompanyName": "ITSYS COMMUNICATIONS SRL",
|
||||
"Password": "CGRateS.org",
|
||||
"Password": "CGRateS.org",
|
||||
},
|
||||
APIOpts: map[string]interface{}{},
|
||||
},
|
||||
}
|
||||
if err := attr.V1ProcessEvent(args, reply); err != nil {
|
||||
if err := attr.V1ProcessEvent(context.Background(), args, reply); err != nil {
|
||||
t.Error(err)
|
||||
} else if !reflect.DeepEqual(expReply, reply){
|
||||
} else if !reflect.DeepEqual(expReply, reply) {
|
||||
t.Errorf("Expected %+v \n, received %+v", utils.ToJSON(expReply), utils.ToJSON(reply))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -837,8 +837,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",
|
||||
FilterIDs: []string{
|
||||
"*string:~*opts.*apikey:dps1234|dsp9876",
|
||||
"*string:~*req.AnswerTime:2013-11-07T08:42:26Z",
|
||||
@@ -859,25 +859,24 @@ func TestHealthIndexDispatchers(t *testing.T) {
|
||||
|
||||
exp := &FilterIHReply{
|
||||
MissingIndexes: map[string][]string{
|
||||
"cgrates.org:*string:*opts.*apikey:dps1234": {"Dsp1"},
|
||||
"cgrates.org:*string:*opts.*apikey:dsp9876": {"Dsp1"},
|
||||
"cgrates.org:*string:*req.AnswerTime:2013-11-07T08:42:26Z": {"Dsp1"},
|
||||
"cgrates.org:*string:*opts.*apikey:dps1234": {"Dsp1"},
|
||||
"cgrates.org:*string:*opts.*apikey:dsp9876": {"Dsp1"},
|
||||
"cgrates.org:*string:*req.AnswerTime:2013-11-07T08:42:26Z": {"Dsp1"},
|
||||
},
|
||||
BrokenIndexes: map[string][]string{},
|
||||
MissingFilters: map[string][]string{},
|
||||
MissingObjects: []string{},
|
||||
}
|
||||
|
||||
if rply, err := GetFltrIdxHealth(context.Background(), dm,
|
||||
ltcache.NewCache(0, 0, false, nil),
|
||||
ltcache.NewCache(0, 0, false, nil),
|
||||
ltcache.NewCache(0, 0, false, 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(context.Background(), dm,
|
||||
ltcache.NewCache(0, 0, false, nil),
|
||||
ltcache.NewCache(0, 0, false, nil),
|
||||
ltcache.NewCache(0, 0, false, 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{
|
||||
@@ -902,9 +901,9 @@ func TestHealthIndexDispatchers(t *testing.T) {
|
||||
//get the newIdxHealth for dispatchersProfile
|
||||
exp = &FilterIHReply{
|
||||
MissingIndexes: map[string][]string{
|
||||
"cgrates.org:*string:*opts.*apikey:dps1234": {"Dsp1"},
|
||||
"cgrates.org:*string:*opts.*apikey:dsp9876": {"Dsp1"},
|
||||
"cgrates.org:*string:*req.AnswerTime:2013-11-07T08:42:26Z": {"Dsp1"},
|
||||
"cgrates.org:*string:*opts.*apikey:dps1234": {"Dsp1"},
|
||||
"cgrates.org:*string:*opts.*apikey:dsp9876": {"Dsp1"},
|
||||
"cgrates.org:*string:*req.AnswerTime:2013-11-07T08:42:26Z": {"Dsp1"},
|
||||
},
|
||||
BrokenIndexes: map[string][]string{
|
||||
"cgrates.org:*suffix:*opts.Destination:+100": {"Dsp1"},
|
||||
@@ -918,25 +917,24 @@ func TestHealthIndexDispatchers(t *testing.T) {
|
||||
},
|
||||
}
|
||||
|
||||
if rply, err := GetFltrIdxHealth(context.Background(), dm,
|
||||
ltcache.NewCache(0, 0, false, nil),
|
||||
ltcache.NewCache(0, 0, false, nil),
|
||||
ltcache.NewCache(0, 0, false, 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(context.Background(), dm,
|
||||
ltcache.NewCache(0, 0, false, nil),
|
||||
ltcache.NewCache(0, 0, false, nil),
|
||||
ltcache.NewCache(0, 0, false, 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",
|
||||
FilterIDs: []string{
|
||||
"*string:~*opts.*apikey:dps1234|dsp9876",
|
||||
"*string:~*req.AnswerTime:2013-11-07T08:42:26Z",
|
||||
@@ -959,9 +957,9 @@ func TestHealthIndexDispatchers(t *testing.T) {
|
||||
//get the newIdxHealth for dispatchersProfile
|
||||
exp = &FilterIHReply{
|
||||
MissingIndexes: map[string][]string{
|
||||
"cgrates.org:*string:*opts.*apikey:dps1234": {"Dsp1"},
|
||||
"cgrates.org:*string:*opts.*apikey:dsp9876": {"Dsp1"},
|
||||
"cgrates.org:*string:*req.AnswerTime:2013-11-07T08:42:26Z": {"Dsp1"},
|
||||
"cgrates.org:*string:*opts.*apikey:dps1234": {"Dsp1"},
|
||||
"cgrates.org:*string:*opts.*apikey:dsp9876": {"Dsp1"},
|
||||
"cgrates.org:*string:*req.AnswerTime:2013-11-07T08:42:26Z": {"Dsp1"},
|
||||
},
|
||||
BrokenIndexes: map[string][]string{
|
||||
"cgrates.org:*suffix:*opts.Destination:+100": {"Dsp1"},
|
||||
@@ -1332,7 +1330,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_2", "FLTR_3"},
|
||||
@@ -1370,7 +1368,7 @@ func TestIndexHealthMissingReverseIndexes(t *testing.T) {
|
||||
"cgrates.org:FLTR_2": {"Raw"},
|
||||
"cgrates.org:FLTR_3": {"Raw"},
|
||||
},
|
||||
BrokenReverseIndexes: map[string][]string{},
|
||||
BrokenReverseIndexes: map[string][]string{},
|
||||
MissingReverseIndexes: map[string][]string{},
|
||||
},
|
||||
}
|
||||
@@ -1387,4 +1385,3 @@ func TestIndexHealthMissingReverseIndexes(t *testing.T) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user