diff --git a/data/conf/samples/dispatchers/attributes/cgrates.json b/data/conf/samples/dispatchers/attributes/cgrates.json index 323f60d47..17dfe8bb6 100644 --- a/data/conf/samples/dispatchers/attributes/cgrates.json +++ b/data/conf/samples/dispatchers/attributes/cgrates.json @@ -10,9 +10,20 @@ "listen": { - "rpc_json": "127.0.0.2:2012" + "rpc_json": ":5012", + "rpc_gob": ":5013", + "http": ":5080", }, +"data_db": { // database used to store runtime data (eg: accounts, cdr stats) + "db_type": "redis", // data_db type: + "db_port": 6379, // data_db port to reach the database + "db_name": "10", // data_db database name to connect to +}, + +"stor_db": { + "db_password": "CGRateS.org", +}, "attributes": { @@ -20,4 +31,8 @@ }, +"rals": { + "enabled": true, +}, + } diff --git a/data/conf/samples/dispatchers/dispatchers/cgrates.json b/data/conf/samples/dispatchers/dispatchers/cgrates.json index 53f7f9e72..b75a12581 100755 --- a/data/conf/samples/dispatchers/dispatchers/cgrates.json +++ b/data/conf/samples/dispatchers/dispatchers/cgrates.json @@ -12,9 +12,20 @@ "listen": { - "rpc_json": "127.0.0.1:2012" + "rpc_json": ":2012", + "rpc_gob": ":2013", + "http": ":2080", }, +"data_db": { // database used to store runtime data (eg: accounts, cdr stats) + "db_type": "redis", // data_db type: + "db_port": 6379, // data_db port to reach the database + "db_name": "10", // data_db database name to connect to +}, + +"stor_db": { + "db_password": "CGRateS.org", +}, "cache":{ "dispatcher_routes": {"limit": -1, "ttl": "2s"} @@ -22,21 +33,22 @@ "attributes": { - "enabled": true + "enabled": false }, "dispatchers":{ - "enabled": false, // starts DispatcherS service: . + "enabled": true, // starts DispatcherS service: . "attributes_conns": [ - {"address": "*internal"} + {"address": "127.0.0.1:5012", "transport": "*json"}, + // {"address": "*internal"} ], "conns": { - "AttributeS1": [ - {"address": "127.0.0.2:2012", "transport": "*json"}, - ], + // "AttributeS1": [ + // {"address": "127.0.0.1:2012", "transport": "*json"}, + // ], "ALL": [ - {"address": "127.0.0.100:2012", "transport": "*json"}, + {"address": "127.0.0.1:5012", "transport": "*json"}, ], }, }, diff --git a/dispatchers/attributes_it_test.go b/dispatchers/attributes_it_test.go index 1f50a1ae6..175677cf7 100755 --- a/dispatchers/attributes_it_test.go +++ b/dispatchers/attributes_it_test.go @@ -46,17 +46,15 @@ var sTestsDspAttr = []func(t *testing.T){ testDspAttrInitCfg, testDspAttrInitDataDb, testDspAttrResetStorDb, - // testDspAttrStartEngine, + testDspAttrStartEngine, testDspAttrRPCConn, testDspAttrLoadData, testDspAttrPing, - testDspAttrAddAttributesWithPermision, testDspAttrTestMissingApiKey, testDspAttrTestUnknownApiKey, testDspAttrTestAuthKey, - testDspAttrAddAttributesWithPermision2, testDspAttrTestAuthKey2, - // testDspAttrKillEngine, + testDspAttrKillEngine, } //Test start here @@ -68,14 +66,14 @@ func TestDspAttributeS(t *testing.T) { func testDspAttrInitCfg(t *testing.T) { var err error - dspAttrCfgPath = path.Join(dspDataDir, "conf", "samples", "dispatchers") + dspAttrCfgPath = path.Join(dspDataDir, "conf", "samples", "dispatchers", "dispatchers") dspAttrCfg, err = config.NewCGRConfigFromFolder(dspAttrCfgPath) if err != nil { t.Error(err) } dspAttrCfg.DataFolderPath = dspDataDir // Share DataFolderPath through config towards StoreDb for Flush() config.SetCgrConfig(dspAttrCfg) - instAttrCfgPath = path.Join(dspDataDir, "conf", "samples", "tutmysql") + instAttrCfgPath = path.Join(dspDataDir, "conf", "samples", "dispatchers", "attributes") instAttrCfg, err = config.NewCGRConfigFromFolder(instAttrCfgPath) if err != nil { t.Error(err) @@ -152,44 +150,6 @@ func testDspAttrPing(t *testing.T) { } } -func testDspAttrAddAttributesWithPermision(t *testing.T) { - alsPrf := &engine.AttributeProfile{ - Tenant: "cgrates.org", - ID: "AuthKey", - Contexts: []string{utils.MetaAuth}, - FilterIDs: []string{"*string:APIKey:12345"}, - ActivationInterval: &utils.ActivationInterval{ - ActivationTime: time.Date(2014, 7, 14, 14, 35, 0, 0, time.UTC), - ExpiryTime: time.Date(2014, 7, 14, 14, 35, 0, 0, time.UTC), - }, - Attributes: []*engine.Attribute{ - { - FieldName: utils.APIMethods, - Initial: utils.META_ANY, - Substitute: config.NewRSRParsersMustCompile("ThresholdSv1.GetThAttrholdsForEvent", true, utils.INFIELD_SEP), - Append: true, - }, - }, - Weight: 20, - } - alsPrf.Compile() - var Attrult string - if err := instAttrRPC.Call("ApierV1.SetAttributeProfile", alsPrf, &Attrult); err != nil { - t.Error(err) - } else if Attrult != utils.OK { - t.Error("Unexpected reply returned", Attrult) - } - var reply *engine.AttributeProfile - if err := instAttrRPC.Call("ApierV1.GetAttributeProfile", - &utils.TenantID{Tenant: "cgrates.org", ID: "AuthKey"}, &reply); err != nil { - t.Error(err) - } - reply.Compile() - if !reflect.DeepEqual(alsPrf, reply) { - t.Errorf("Expecting : %+v, received: %+v", alsPrf, reply) - } -} - func testDspAttrTestMissingApiKey(t *testing.T) { args := &CGREvWithApiKey{ CGREvent: utils.CGREvent{ @@ -246,49 +206,9 @@ func testDspAttrTestAuthKey(t *testing.T) { } } -func testDspAttrAddAttributesWithPermision2(t *testing.T) { - alsPrf := &engine.AttributeProfile{ - Tenant: "cgrates.org", - ID: "AuthKey", - Contexts: []string{utils.MetaAuth}, - FilterIDs: []string{"*string:APIKey:12345"}, - ActivationInterval: &utils.ActivationInterval{ - ActivationTime: time.Date(2014, 7, 14, 14, 35, 0, 0, time.UTC), - ExpiryTime: time.Date(2014, 7, 14, 14, 35, 0, 0, time.UTC), - }, - Attributes: []*engine.Attribute{ - { - FieldName: utils.APIMethods, - Initial: utils.META_ANY, - Substitute: config.NewRSRParsersMustCompile("AttributeSv1.GetAttributeForEvent&AttributeSv1.ProcessEvent", true, utils.INFIELD_SEP), - Append: true, - }, - }, - Weight: 20, - } - var result string - alsPrf.Compile() - if err := instAttrRPC.Call("ApierV1.SetAttributeProfile", alsPrf, &result); err != nil { - t.Error(err) - } else if result != utils.OK { - t.Error("Unexpected reply returned", result) - } - var reply *engine.AttributeProfile - if err := instAttrRPC.Call("ApierV1.GetAttributeProfile", - &utils.TenantID{Tenant: "cgrates.org", ID: "AuthKey"}, &reply); err != nil { - t.Error(err) - } - if reply != nil { - reply.Compile() - } - if !reflect.DeepEqual(alsPrf, reply) { - t.Errorf("Expecting : %+v, received: %+v", alsPrf, reply) - } -} - func testDspAttrTestAuthKey2(t *testing.T) { args := &CGREvWithApiKey{ - APIKey: "12345", + APIKey: "attr12345", CGREvent: utils.CGREvent{ Tenant: "cgrates.org", ID: "testAttributeSGetAttributeForEvent",