diff --git a/data/conf/samples/rpcexp_multiple_engines/rpcexp_opts_engine1_mongo/cgrates.json b/data/conf/samples/rpcexp_multiple_engines/rpcexp_opts_engine1_mongo/cgrates.json new file mode 100644 index 000000000..774d66b1b --- /dev/null +++ b/data/conf/samples/rpcexp_multiple_engines/rpcexp_opts_engine1_mongo/cgrates.json @@ -0,0 +1,81 @@ +{ + "general": { + "log_level": 7, + "reply_timeout": "50s" + }, + + "listen": { + "rpc_json": ":2012", + "rpc_gob": ":2013", + "http": ":2080" + }, + + "data_db": { + "db_type": "mongo", + "db_name": "10", + "db_port": 27017 + }, + + + "stor_db": { + "db_type": "mongo", + "db_name": "cgrates", + "db_port": 27017 + }, + + "ees": { + "enabled": true, + "exporters": [ + { + "id": "thProcessEv1", + "type": "*rpc", + "opts": { + "rpcCodec": "*json", + "connIDs": ["rplConn"], + "serviceMethod": "ThresholdSv1.ProcessEvent", + "keyPath": "" , + "certPath": "", + "caPath": "", + "tls": false, + "rpcConnTimeout" : "1s", + "rpcReplyTimeout":"5s" + } + }, + { + "id": "thProcessEv2", + "type": "*rpc", + "opts": { + "rpcCodec": "*json", + "connIDs": ["rplConn"], + "serviceMethod": "ThresholdSv1.ProcessEvent", + "keyPath": "" , + "certPath": "", + "caPath": "", + "tls": false, + "rpcConnTimeout" : "1s", + "rpcReplyTimeout":"5s", + "rpcAPIOpts": { + "*thdProfileIDs": ["THD_3"] + } + } + } + ] + }, + + + "rpc_conns": { + "rplConn": { + "strategy": "*broadcast_sync", + "conns": [{"address": "127.0.0.1:22012", "transport": "*json"}] + } + }, + + "sessions": { + "enabled": true, + "replication_conns": ["rplConn"] + }, + + "admins": { + "enabled": true + } +} \ No newline at end of file diff --git a/data/conf/samples/rpcexp_multiple_engines/rpcexp_opts_engine1_mysql/cgrates.json b/data/conf/samples/rpcexp_multiple_engines/rpcexp_opts_engine1_mysql/cgrates.json new file mode 100644 index 000000000..a1b2a0442 --- /dev/null +++ b/data/conf/samples/rpcexp_multiple_engines/rpcexp_opts_engine1_mysql/cgrates.json @@ -0,0 +1,78 @@ +{ + "general": { + "log_level": 7, + "reply_timeout": "50s" + }, + + "listen": { + "rpc_json": ":2012", + "rpc_gob": ":2013", + "http": ":2080" + }, + + "data_db": { + "db_type": "redis", + "db_port": 6379, + "db_name": "10" + }, + + "stor_db": { + "db_password": "CGRateS.org" + }, + + "ees": { + "enabled": true, + "exporters": [ + { + "id": "thProcessEv1", + "type": "*rpc", + "opts": { + "rpcCodec": "*json", + "connIDs": ["rplConn"], + "serviceMethod": "ThresholdSv1.ProcessEvent", + "keyPath": "" , + "certPath": "", + "caPath": "", + "tls": false, + "rpcConnTimeout" : "1s", + "rpcReplyTimeout":"5s" + } + }, + { + "id": "thProcessEv2", + "type": "*rpc", + "opts": { + "rpcCodec": "*json", + "connIDs": ["rplConn"], + "serviceMethod": "ThresholdSv1.ProcessEvent", + "keyPath": "" , + "certPath": "", + "caPath": "", + "tls": false, + "rpcConnTimeout" : "1s", + "rpcReplyTimeout":"5s", + "rpcAPIOpts": { + "*thdProfileIDs": ["THD_3"] + } + } + } + ] + }, + + + "rpc_conns": { + "rplConn": { + "strategy": "*broadcast_sync", + "conns": [{"address": "127.0.0.1:22012", "transport": "*json"}] + } + }, + + "sessions": { + "enabled": true, + "replication_conns": ["rplConn"] + }, + + "admins": { + "enabled": true + } +} \ No newline at end of file diff --git a/data/conf/samples/rpcexp_multiple_engines/rpcexp_opts_engine2_internal/cgrates.json b/data/conf/samples/rpcexp_multiple_engines/rpcexp_opts_engine2_internal/cgrates.json index ee2753e5c..e809cfca7 100644 --- a/data/conf/samples/rpcexp_multiple_engines/rpcexp_opts_engine2_internal/cgrates.json +++ b/data/conf/samples/rpcexp_multiple_engines/rpcexp_opts_engine2_internal/cgrates.json @@ -22,7 +22,7 @@ "enabled":true, "store_interval": "-1", "opts":{ - "*thresholdsIDs": [ + "*profileIDs": [ { "Tenant": "", "FilterIDs": [], diff --git a/data/conf/samples/rpcexp_multiple_engines/rpcexp_opts_engine2_mongo/cgrates.json b/data/conf/samples/rpcexp_multiple_engines/rpcexp_opts_engine2_mongo/cgrates.json new file mode 100644 index 000000000..73795cf50 --- /dev/null +++ b/data/conf/samples/rpcexp_multiple_engines/rpcexp_opts_engine2_mongo/cgrates.json @@ -0,0 +1,49 @@ +{ + "general": { + "log_level": 7, + "reply_timeout": "50s" + }, + + "listen": { + "rpc_json": ":22012", + "rpc_gob": ":22013", + "http": ":22080" + }, + + "data_db": { + "db_type": "mongo", + "db_name": "10", + "db_port": 27017 + }, + + + "stor_db": { + "db_type": "mongo", + "db_name": "cgrates", + "db_port": 27017 + }, + + "thresholds": { + "enabled":true, + "store_interval": "-1", + "opts":{ + "*profileIDs": [ + { + "Tenant": "", + "FilterIDs": [], + "Value": ["THD_1"] + } + ] + + } + }, + + "sessions": { + "enabled": true, + "listen_bijson": "127.0.0.1:22014" + }, + + "admins": { + "enabled": true + } +} \ No newline at end of file diff --git a/data/conf/samples/rpcexp_multiple_engines/rpcexp_opts_engine2_mysql/cgrates.json b/data/conf/samples/rpcexp_multiple_engines/rpcexp_opts_engine2_mysql/cgrates.json new file mode 100644 index 000000000..67017dc30 --- /dev/null +++ b/data/conf/samples/rpcexp_multiple_engines/rpcexp_opts_engine2_mysql/cgrates.json @@ -0,0 +1,46 @@ +{ + "general": { + "log_level": 7, + "reply_timeout": "50s" + }, + + "listen": { + "rpc_json": ":22012", + "rpc_gob": ":22013", + "http": ":22080" + }, + + "data_db": { + "db_type": "redis", + "db_port": 6379, + "db_name": "10" + }, + + "stor_db": { + "db_password": "CGRateS.org" + }, + + "thresholds": { + "enabled":true, + "store_interval": "-1", + "opts":{ + "*profileIDs": [ + { + "Tenant": "", + "FilterIDs": [], + "Value": ["THD_1"] + } + ] + + } + }, + + "sessions": { + "enabled": true, + "listen_bijson": "127.0.0.1:22014" + }, + + "admins": { + "enabled": true + } +} \ No newline at end of file diff --git a/general_tests/rpcexp_opts_it_test.go b/general_tests/rpcexp_opts_it_test.go index 4d9c71c28..82b737721 100644 --- a/general_tests/rpcexp_opts_it_test.go +++ b/general_tests/rpcexp_opts_it_test.go @@ -45,8 +45,8 @@ var ( testRPCExpStartEngine, testRPCExpRPCConn, testRPCExpSetThresholdProfilesBeforeProcessEv, - // testRPCExpProcessEventWithConfigOpts, - // testRPCExpGetThresholdsAfterFirstEvent, + testRPCExpProcessEventWithConfigOpts, + testRPCExpGetThresholdsAfterFirstEvent, testRPCExpProcessEventWithAPIOpts, testRPCExpGetThresholdsAfterSecondEvent, testRPCExpProcessEventWithRPCAPIOpts, @@ -61,13 +61,11 @@ func TestRPCExpIT(t *testing.T) { ng1ConfDIR = "rpcexp_opts_engine1_internal" ng2ConfDIR = "rpcexp_opts_engine2_internal" case utils.MetaMySQL: - t.SkipNow() - // ng1ConfDIR = "rpcexp_opts_engine1_mysql" - // ng2ConfDIR = "rpcexp_opts_engine2_mysql" + ng1ConfDIR = "rpcexp_opts_engine1_mysql" + ng2ConfDIR = "rpcexp_opts_engine2_mysql" case utils.MetaMongo: - t.SkipNow() - // ng1ConfDIR = "rpcexp_opts_engine1_mongo" - // ng2ConfDIR = "rpcexp_opts_engine2_mongo" + ng1ConfDIR = "rpcexp_opts_engine1_mongo" + ng2ConfDIR = "rpcexp_opts_engine2_mongo" case utils.MetaPostgres: t.SkipNow() default: @@ -205,72 +203,72 @@ func testRPCExpSetThresholdProfilesBeforeProcessEv(t *testing.T) { } } -// func testRPCExpProcessEventWithConfigOpts(t *testing.T) { -// args := utils.CGREventWithEeIDs{ -// EeIDs: []string{"thProcessEv1"}, -// CGREvent: &utils.CGREvent{ -// Tenant: "cgrates.org", -// ID: "ThresholdProcessEv1", -// Event: map[string]interface{}{ -// utils.AccountField: "1001", -// }, -// APIOpts: map[string]interface{}{}, -// }, -// } -// var reply map[string]map[string]interface{} -// if err := ng1RPC.Call(context.Background(), utils.EeSv1ProcessEvent, args, &reply); err != nil { -// t.Error(err) -// } -// time.Sleep(50 * time.Millisecond) +func testRPCExpProcessEventWithConfigOpts(t *testing.T) { + args := utils.CGREventWithEeIDs{ + EeIDs: []string{"thProcessEv1"}, + CGREvent: &utils.CGREvent{ + Tenant: "cgrates.org", + ID: "ThresholdProcessEv1", + Event: map[string]interface{}{ + utils.AccountField: "1001", + }, + APIOpts: map[string]interface{}{}, + }, + } + var reply map[string]map[string]interface{} + if err := ng1RPC.Call(context.Background(), utils.EeSv1ProcessEvent, args, &reply); err != nil { + t.Error(err) + } + time.Sleep(50 * time.Millisecond) -// } +} -// func testRPCExpGetThresholdsAfterFirstEvent(t *testing.T) { -// args := &utils.CGREvent{ -// Tenant: "cgrates.org", -// ID: "ThresholdEventTest1", -// Event: map[string]interface{}{ -// utils.AccountField: "1001", -// }, -// APIOpts: map[string]interface{}{ -// utils.OptsThresholdsProfileIDs: []string{"THD_1", "THD_2", "THD_3"}, -// }, -// } -// expThs := engine.Thresholds{ -// &engine.Threshold{ -// Tenant: "cgrates.org", -// ID: "THD_1", -// Hits: 1, -// }, -// &engine.Threshold{ -// Tenant: "cgrates.org", -// ID: "THD_2", -// Hits: 0, -// }, -// &engine.Threshold{ -// Tenant: "cgrates.org", -// ID: "THD_3", -// Hits: 0, -// }, -// } +func testRPCExpGetThresholdsAfterFirstEvent(t *testing.T) { + args := &utils.CGREvent{ + Tenant: "cgrates.org", + ID: "ThresholdEventTest1", + Event: map[string]interface{}{ + utils.AccountField: "1001", + }, + APIOpts: map[string]interface{}{ + utils.OptsThresholdsProfileIDs: []string{"THD_1", "THD_2", "THD_3"}, + }, + } + expThs := engine.Thresholds{ + &engine.Threshold{ + Tenant: "cgrates.org", + ID: "THD_1", + Hits: 1, + }, + &engine.Threshold{ + Tenant: "cgrates.org", + ID: "THD_2", + Hits: 0, + }, + &engine.Threshold{ + Tenant: "cgrates.org", + ID: "THD_3", + Hits: 0, + }, + } -// var rplyThs engine.Thresholds -// if err := ng2RPC.Call(context.Background(), utils.ThresholdSv1GetThresholdsForEvent, -// args, &rplyThs); err != nil { -// t.Error(err) -// } else { -// sort.Slice(rplyThs, func(i, j int) bool { -// return rplyThs[i].ID < rplyThs[j].ID -// }) -// for idx, thd := range rplyThs { -// thd.Snooze = expThs[idx].Snooze -// } -// if !reflect.DeepEqual(rplyThs, expThs) { -// t.Errorf("expected: <%+v>, \nreceived: <%+v>", -// utils.ToJSON(expThs), utils.ToJSON(rplyThs)) -// } -// } -// } + var rplyThs engine.Thresholds + if err := ng2RPC.Call(context.Background(), utils.ThresholdSv1GetThresholdsForEvent, + args, &rplyThs); err != nil { + t.Error(err) + } else { + sort.Slice(rplyThs, func(i, j int) bool { + return rplyThs[i].ID < rplyThs[j].ID + }) + for idx, thd := range rplyThs { + thd.Snooze = expThs[idx].Snooze + } + if !reflect.DeepEqual(rplyThs, expThs) { + t.Errorf("expected: <%+v>, \nreceived: <%+v>", + utils.ToJSON(expThs), utils.ToJSON(rplyThs)) + } + } +} func testRPCExpProcessEventWithAPIOpts(t *testing.T) { args := utils.CGREventWithEeIDs{ @@ -308,7 +306,7 @@ func testRPCExpGetThresholdsAfterSecondEvent(t *testing.T) { &engine.Threshold{ Tenant: "cgrates.org", ID: "THD_1", - // Hits: 1, + Hits: 1, }, &engine.Threshold{ Tenant: "cgrates.org", @@ -376,7 +374,7 @@ func testRPCExpGetThresholdsAfterThirdEvent(t *testing.T) { &engine.Threshold{ Tenant: "cgrates.org", ID: "THD_1", - // Hits: 1, + Hits: 1, }, &engine.Threshold{ Tenant: "cgrates.org",