diff --git a/data/conf/samples/dbinternal/cgrates.json b/data/conf/samples/dbinternal/cgrates.json deleted file mode 100755 index 775b0faf7..000000000 --- a/data/conf/samples/dbinternal/cgrates.json +++ /dev/null @@ -1,88 +0,0 @@ -{ -// CGRateS Configuration file - - -"general": { - "log_level": 7, - "reply_timeout": "30s", -}, - - -"listen": { - "rpc_json": ":2012", - "rpc_gob": ":2013", - "http": ":2080", -}, - - -"data_db": { - "db_type": "*internal", - }, - - -"stor_db": { - "db_type": "*internal", -}, - -"rals": { - "enabled": true, - "thresholds_conns": ["*internal"], -}, - - -"schedulers": { - "enabled": true, -}, - - -"cdrs": { - "enabled": true, -}, - - -"resources": { - "enabled": true, - "store_interval": "1s", - "thresholds_conns": ["*internal"] -}, - - -"stats": { - "enabled": true, - "store_interval": "1s", - "thresholds_conns": ["*internal"], -}, - - -"thresholds": { - "enabled": true, - "store_interval": "1s", -}, - - -"routes": { - "enabled": true, -}, - - -"attributes": { // Attribute service - "enabled": true, // starts Attribute service: . -}, - - -"sessions": { - "enabled": true, -}, - - -"migrator": { - "out_datadb_type": "internal", - "out_stordb_type": "internal", -}, - -"apiers": { - "enabled": true, - "scheduler_conns": ["*internal"], -}, - -} diff --git a/dispatchers/dispatchers.go b/dispatchers/dispatchers.go index 7b8f403fc..646f8efce 100755 --- a/dispatchers/dispatchers.go +++ b/dispatchers/dispatchers.go @@ -147,6 +147,10 @@ func (dS *DispatcherService) dispatcherProfileForEvent(ev *utils.CGREvent, } continue } + if !(len(prfl.Subsystems) == 1 && prfl.Subsystems[0] == utils.META_ANY) && + !utils.IsSliceMember(prfl.Subsystems, subsys) { + continue + } if prfl.ActivationInterval != nil && ev.Time != nil && !prfl.ActivationInterval.IsActiveAtTime(*ev.Time) { // not active continue diff --git a/engine/attributes.go b/engine/attributes.go index 415e6ac4d..860db40e1 100644 --- a/engine/attributes.go +++ b/engine/attributes.go @@ -107,6 +107,10 @@ func (alS *AttributeService) attributeProfileForEvent(args *AttrArgsProcessEvent } return nil, err } + if !(len(aPrfl.Contexts) == 1 && aPrfl.Contexts[0] == utils.META_ANY) && + !utils.IsSliceMember(aPrfl.Contexts, contextVal) { + continue + } if aPrfl.ActivationInterval != nil && args.Time != nil && !aPrfl.ActivationInterval.IsActiveAtTime(*args.Time) { // not active continue diff --git a/engine/z_attributes_test.go b/engine/z_attributes_test.go index 50364fa46..e57a81543 100644 --- a/engine/z_attributes_test.go +++ b/engine/z_attributes_test.go @@ -152,7 +152,6 @@ func TestAttributePopulateAttrService(t *testing.T) { defaultCfg.AttributeSCfg().ProcessRuns = 1 defaultCfg.AttributeSCfg().StringIndexedFields = nil defaultCfg.AttributeSCfg().PrefixIndexedFields = nil - defaultCfg.AttributeSCfg().PrefixIndexedFields = nil data := NewInternalDB(nil, nil, true, defaultCfg.DataDbCfg().Items) dmAtr = NewDataManager(data, config.CgrConfig().CacheCfg(), nil) attrService, err = NewAttributeService(dmAtr, &FilterS{dm: dmAtr, cfg: defaultCfg}, defaultCfg) @@ -2387,3 +2386,66 @@ func TestProcessAttributeUnixTimeStamp(t *testing.T) { t.Errorf("Expecting: %+v, received: %+v", utils.ToJSON(eRply), utils.ToJSON(rcv)) } } + +func TestAttributeIndexSelectsFalse(t *testing.T) { + // change the IndexedSelects to false + defaultCfg, _ := config.NewDefaultCGRConfig() + defaultCfg.AttributeSCfg().ProcessRuns = 1 + defaultCfg.AttributeSCfg().StringIndexedFields = nil + defaultCfg.AttributeSCfg().PrefixIndexedFields = nil + defaultCfg.AttributeSCfg().IndexedSelects = false + data := NewInternalDB(nil, nil, true, defaultCfg.DataDbCfg().Items) + dmAtr = NewDataManager(data, config.CgrConfig().CacheCfg(), nil) + attrService, err = NewAttributeService(dmAtr, &FilterS{dm: dmAtr, cfg: defaultCfg}, defaultCfg) + if err != nil { + t.Errorf("Error: %+v", err) + } + + //refresh the DM + if err := dmAtr.DataDB().Flush(""); err != nil { + t.Error(err) + } + if test, err := dmAtr.DataDB().IsDBEmpty(); err != nil { + t.Error(err) + } else if test != true { + t.Errorf("\nExpecting: true got :%+v", test) + } + attrPrf := &AttributeProfile{ + Tenant: "cgrates.org", + ID: "AttrPrf", + Contexts: []string{utils.MetaCDRs}, + FilterIDs: []string{"*string:~*req.Account:1007"}, + ActivationInterval: &utils.ActivationInterval{ + ActivationTime: time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC), + ExpiryTime: expTimeAttributes, + }, + Attributes: []*Attribute{ + { + Path: utils.MetaReq + utils.NestingSep + utils.Account, + Value: config.NewRSRParsersMustCompile("1010", utils.INFIELD_SEP), + }, + }, + Weight: 20, + } + if err := dmAtr.SetAttributeProfile(attrPrf, true); err != nil { + t.Error(err) + } + + attrArgs := &AttrArgsProcessEvent{ + Context: utils.StringPointer(utils.MetaSessionS), + ProcessRuns: utils.IntPointer(1), + CGREvent: &utils.CGREvent{ + Tenant: config.CgrConfig().GeneralCfg().DefaultTenant, + ID: utils.GenUUID(), + Event: map[string]interface{}{ + "Account": "1007", + }, + }, + } + + var reply AttrSProcessEventReply + if err := attrService.V1ProcessEvent(attrArgs, &reply); err == nil || err != utils.ErrNotFound { + t.Errorf("Expected not found, reveiced: %+v", err) + } + +}