mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-12 02:26:26 +05:00
Repair tests in general_tests
This commit is contained in:
committed by
Dan Christian Bogos
parent
84a70e50c9
commit
91e2563a77
@@ -1,42 +1,36 @@
|
||||
{
|
||||
// CGRateS Configuration file
|
||||
//
|
||||
|
||||
|
||||
"general": {
|
||||
"log_level": 7,
|
||||
"node_id": "CGRFilterS",
|
||||
"node_id": "CGRFilterS"
|
||||
},
|
||||
|
||||
|
||||
"listen": {
|
||||
"rpc_json": ":2012",
|
||||
"rpc_gob": ":2013",
|
||||
"http": ":2080",
|
||||
"http": ":2080"
|
||||
},
|
||||
|
||||
|
||||
"data_db": {
|
||||
"db_type": "*internal",
|
||||
"db_type": "*internal"
|
||||
},
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
"rals": {
|
||||
"enabled": true,
|
||||
"thresholds_conns": ["*localhost"],
|
||||
"thresholds_conns": ["*localhost"]
|
||||
},
|
||||
|
||||
"schedulers": {
|
||||
"enabled": true,
|
||||
"enabled": true
|
||||
},
|
||||
|
||||
"filters": {
|
||||
"stats_conns": ["*localhost"],
|
||||
"resources_conns": ["*localhost"],
|
||||
"accounts_conns": ["*localhost"],
|
||||
"accounts_conns": ["*localhost"]
|
||||
},
|
||||
|
||||
"accounts": {
|
||||
@@ -46,42 +40,58 @@
|
||||
"resources": {
|
||||
"enabled": true,
|
||||
"indexed_selects":false,
|
||||
"store_interval": "-1",
|
||||
"store_interval": "-1"
|
||||
},
|
||||
|
||||
|
||||
"stats": {
|
||||
"enabled": true,
|
||||
"indexed_selects":false,
|
||||
"store_interval": "-1",
|
||||
"store_interval": "-1"
|
||||
},
|
||||
|
||||
|
||||
"thresholds": {
|
||||
"enabled": true,
|
||||
"indexed_selects":false,
|
||||
"store_interval": "-1",
|
||||
"actions_conns": ["*localhost"],
|
||||
"store_interval": "-1"
|
||||
},
|
||||
|
||||
"actions": {
|
||||
"enabled": true
|
||||
},
|
||||
|
||||
|
||||
"attributes": {
|
||||
"enabled": true,
|
||||
"prefix_indexed_fields": ["*req.CustomField"],
|
||||
"prefix_indexed_fields": ["*req.CustomField"]
|
||||
},
|
||||
|
||||
|
||||
"chargers": {
|
||||
"enabled": true,
|
||||
"suffix_indexed_fields": ["*req.Subject"],
|
||||
"attributes_conns": ["*internal"],
|
||||
"attributes_conns": ["*internal"]
|
||||
},
|
||||
|
||||
|
||||
"admins": {
|
||||
"enabled": true,
|
||||
"caches_conns":["*localhost"],
|
||||
"scheduler_conns": ["*internal"],
|
||||
"scheduler_conns": ["*internal"]
|
||||
},
|
||||
|
||||
"loaders": [
|
||||
{
|
||||
"id": "*default",
|
||||
"enabled": true,
|
||||
"tenant": "cgrates.org",
|
||||
"lockfile_path": ".cgr.lck",
|
||||
"tp_in_dir": "/usr/share/cgrates/tariffplans/testit",
|
||||
"tp_out_dir": ""
|
||||
}
|
||||
]
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -1,18 +1,15 @@
|
||||
{
|
||||
// CGRateS Configuration file
|
||||
//
|
||||
|
||||
|
||||
"general": {
|
||||
"log_level": 7,
|
||||
"node_id": "CGRFilterS",
|
||||
"node_id": "CGRFilterS"
|
||||
},
|
||||
|
||||
|
||||
"listen": {
|
||||
"rpc_json": ":2012",
|
||||
"rpc_gob": ":2013",
|
||||
"http": ":2080",
|
||||
"http": ":2080"
|
||||
},
|
||||
|
||||
|
||||
@@ -20,26 +17,25 @@
|
||||
"data_db": {
|
||||
"db_type": "mongo",
|
||||
"db_name": "10",
|
||||
"db_port": 27017,
|
||||
"db_port": 27017
|
||||
},
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
"rals": {
|
||||
"enabled": true,
|
||||
"thresholds_conns": ["*localhost"],
|
||||
"thresholds_conns": ["*localhost"]
|
||||
},
|
||||
|
||||
"schedulers": {
|
||||
"enabled": true,
|
||||
"enabled": true
|
||||
},
|
||||
|
||||
"filters": {
|
||||
"stats_conns": ["*localhost"],
|
||||
"resources_conns": ["*localhost"],
|
||||
"accounts_conns": ["*localhost"],
|
||||
"accounts_conns": ["*localhost"]
|
||||
},
|
||||
|
||||
"accounts": {
|
||||
@@ -50,42 +46,58 @@
|
||||
"resources": {
|
||||
"enabled": true,
|
||||
"indexed_selects":false,
|
||||
"store_interval": "1s",
|
||||
"store_interval": "1s"
|
||||
},
|
||||
|
||||
|
||||
"stats": {
|
||||
"enabled": true,
|
||||
"indexed_selects":false,
|
||||
"store_interval": "1s",
|
||||
"store_interval": "1s"
|
||||
},
|
||||
|
||||
|
||||
"thresholds": {
|
||||
"enabled": true,
|
||||
"indexed_selects":false,
|
||||
"store_interval": "1s",
|
||||
"actions_conns": ["*localhost"],
|
||||
"store_interval": "1s"
|
||||
},
|
||||
|
||||
|
||||
"attributes": {
|
||||
"enabled": true,
|
||||
"prefix_indexed_fields": ["*req.CustomField"],
|
||||
"prefix_indexed_fields": ["*req.CustomField"]
|
||||
},
|
||||
|
||||
|
||||
"chargers": {
|
||||
"enabled": true,
|
||||
"suffix_indexed_fields": ["*req.Subject"],
|
||||
"attributes_conns": ["*internal"],
|
||||
"attributes_conns": ["*internal"]
|
||||
},
|
||||
|
||||
|
||||
"admins": {
|
||||
"enabled": true,
|
||||
"caches_conns":["*localhost"],
|
||||
"scheduler_conns": ["*internal"],
|
||||
"scheduler_conns": ["*internal"]
|
||||
},
|
||||
|
||||
"loaders": [
|
||||
{
|
||||
"id": "*default",
|
||||
"enabled": true,
|
||||
"tenant": "cgrates.org",
|
||||
"lockfile_path": ".cgr.lck",
|
||||
"tp_in_dir": "/usr/share/cgrates/tariffplans/testit",
|
||||
"tp_out_dir": ""
|
||||
}
|
||||
],
|
||||
|
||||
"actions": {
|
||||
"enabled": true
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -1,25 +1,22 @@
|
||||
{
|
||||
// CGRateS Configuration file
|
||||
//
|
||||
|
||||
|
||||
"general": {
|
||||
"log_level": 7,
|
||||
"node_id": "CGRFilterS",
|
||||
"node_id": "CGRFilterS"
|
||||
},
|
||||
|
||||
|
||||
"listen": {
|
||||
"rpc_json": ":2012",
|
||||
"rpc_gob": ":2013",
|
||||
"http": ":2080",
|
||||
"http": ":2080"
|
||||
},
|
||||
|
||||
|
||||
"data_db": { // database used to store runtime data (eg: accounts, cdr stats)
|
||||
"db_type": "redis", // data_db type: <redis|mongo>
|
||||
"db_port": 6379, // data_db port to reach the database
|
||||
"db_name": "10", // data_db database name to connect to
|
||||
"data_db": {
|
||||
"db_type": "redis",
|
||||
"db_port": 6379,
|
||||
"db_name": "10"
|
||||
},
|
||||
|
||||
|
||||
@@ -27,17 +24,17 @@
|
||||
|
||||
"rals": {
|
||||
"enabled": true,
|
||||
"thresholds_conns": ["*localhost"],
|
||||
"thresholds_conns": ["*localhost"]
|
||||
},
|
||||
|
||||
"schedulers": {
|
||||
"enabled": true,
|
||||
"enabled": true
|
||||
},
|
||||
|
||||
"filters": {
|
||||
"stats_conns": ["*localhost"],
|
||||
"resources_conns": ["*localhost"],
|
||||
"accounts_conns": ["*localhost"],
|
||||
"accounts_conns": ["*localhost"]
|
||||
},
|
||||
|
||||
"accounts": {
|
||||
@@ -48,42 +45,58 @@
|
||||
"resources": {
|
||||
"enabled": true,
|
||||
"indexed_selects":false,
|
||||
"store_interval": "1s",
|
||||
"store_interval": "1s"
|
||||
},
|
||||
|
||||
|
||||
"stats": {
|
||||
"enabled": true,
|
||||
"indexed_selects":false,
|
||||
"store_interval": "1s",
|
||||
"store_interval": "1s"
|
||||
},
|
||||
|
||||
|
||||
"thresholds": {
|
||||
"enabled": true,
|
||||
"indexed_selects":false,
|
||||
"store_interval": "1s",
|
||||
"indexed_selects":false,
|
||||
"actions_conns": ["*localhost"],
|
||||
"store_interval": "1s"
|
||||
},
|
||||
|
||||
"actions": {
|
||||
"enabled": true
|
||||
},
|
||||
|
||||
|
||||
"attributes": {
|
||||
"enabled": true,
|
||||
"prefix_indexed_fields": ["*req.CustomField"],
|
||||
"prefix_indexed_fields": ["*req.CustomField"]
|
||||
},
|
||||
|
||||
|
||||
"chargers": {
|
||||
"enabled": true,
|
||||
"suffix_indexed_fields": ["*req.Subject"],
|
||||
"attributes_conns": ["*internal"],
|
||||
"attributes_conns": ["*internal"]
|
||||
},
|
||||
|
||||
|
||||
"admins": {
|
||||
"enabled": true,
|
||||
"caches_conns":["*localhost"],
|
||||
"scheduler_conns": ["*internal"],
|
||||
"scheduler_conns": ["*internal"]
|
||||
},
|
||||
|
||||
"loaders": [
|
||||
{
|
||||
"id": "*default",
|
||||
"enabled": true,
|
||||
"tenant": "cgrates.org",
|
||||
"lockfile_path": ".cgr.lck",
|
||||
"tp_in_dir": "/usr/share/cgrates/tariffplans/testit",
|
||||
"tp_out_dir": ""
|
||||
}
|
||||
]
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -21,361 +21,381 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
|
||||
package general_tests
|
||||
|
||||
// import (
|
||||
// "os/exec"
|
||||
// "path"
|
||||
// "reflect"
|
||||
// "testing"
|
||||
import (
|
||||
"os/exec"
|
||||
"path"
|
||||
"reflect"
|
||||
"testing"
|
||||
|
||||
// "github.com/cgrates/birpc"
|
||||
// "github.com/cgrates/birpc/context"
|
||||
// "github.com/cgrates/cgrates/config"
|
||||
// "github.com/cgrates/cgrates/engine"
|
||||
// "github.com/cgrates/cgrates/utils"
|
||||
// )
|
||||
"github.com/cgrates/birpc"
|
||||
"github.com/cgrates/birpc/context"
|
||||
"github.com/cgrates/cgrates/config"
|
||||
"github.com/cgrates/cgrates/engine"
|
||||
"github.com/cgrates/cgrates/utils"
|
||||
)
|
||||
|
||||
// var (
|
||||
// fltrUpdateCfgPath1, fltrUpdateCfgPath2 string
|
||||
// fltrUpdateCfgDIR1, fltrUpdateCfgDIR2 string
|
||||
// fltrUpdateCfg1, fltrUpdateCfg2 *config.CGRConfig
|
||||
// fltrUpdateRPC1, fltrUpdateRPC2 *birpc.Client
|
||||
// testEng1 *exec.Cmd
|
||||
// sTestsFilterUpdate = []func(t *testing.T){
|
||||
// testFilterUpdateInitCfg,
|
||||
// testFilterUpdateResetDB,
|
||||
// testFilterUpdateStartEngine,
|
||||
// testFilterUpdateRpcConn,
|
||||
// testFilterUpdateSetFilterE1,
|
||||
// testFilterUpdateSetAttrProfileE1,
|
||||
// testFilterUpdateGetAttrProfileForEventEv1E1,
|
||||
// testFilterUpdateGetAttrProfileForEventEv1E2,
|
||||
// testFilterUpdateGetAttrProfileForEventEv2E1NotMatching,
|
||||
// testFilterUpdateGetAttrProfileForEventEv2E2NotMatching,
|
||||
// testFilterUpdateSetFilterAfterAttrE1,
|
||||
// testFilterUpdateGetAttrProfileForEventEv1E1NotMatching,
|
||||
// testFilterUpdateGetAttrProfileForEventEv1E2NotMatching,
|
||||
// testFilterUpdateGetAttrProfileForEventEv2E1,
|
||||
// testFilterUpdateGetAttrProfileForEventEv2E2,
|
||||
// testFilterUpdateStopEngine,
|
||||
// }
|
||||
// ev1 = &utils.CGREvent{
|
||||
// Tenant: "cgrates.org",
|
||||
// ID: "Event1",
|
||||
// Event: map[string]interface{}{
|
||||
// utils.AccountField: "1001",
|
||||
// },
|
||||
// }
|
||||
// ev2 = &utils.CGREvent{
|
||||
// Tenant: "cgrates.org",
|
||||
// ID: "Event2",
|
||||
// Event: map[string]interface{}{
|
||||
// utils.AccountField: "1002",
|
||||
// },
|
||||
// }
|
||||
// )
|
||||
var (
|
||||
fltrUpdateCfgPath1, fltrUpdateCfgPath2 string
|
||||
fltrUpdateCfgDIR1, fltrUpdateCfgDIR2 string
|
||||
fltrUpdateCfg1, fltrUpdateCfg2 *config.CGRConfig
|
||||
fltrUpdateRPC1, fltrUpdateRPC2 *birpc.Client
|
||||
testEng1 *exec.Cmd
|
||||
sTestsFilterUpdate = []func(t *testing.T){
|
||||
testFilterUpdateInitCfg,
|
||||
testFilterUpdateResetDB,
|
||||
testFilterUpdateStartEngine,
|
||||
testFilterUpdateRpcConn,
|
||||
testFilterUpdateSetFilterE1,
|
||||
testFilterUpdateSetAttrProfileE1,
|
||||
testFilterUpdateGetAttrProfileForEventEv1E1,
|
||||
testFilterUpdateGetAttrProfileForEventEv1E2,
|
||||
testFilterUpdateGetAttrProfileForEventEv2E1NotMatching,
|
||||
testFilterUpdateGetAttrProfileForEventEv2E2NotMatching,
|
||||
testFilterUpdateSetFilterAfterAttrE1,
|
||||
testFilterUpdateGetAttrProfileForEventEv1E1NotMatching,
|
||||
testFilterUpdateGetAttrProfileForEventEv1E2NotMatching,
|
||||
testFilterUpdateGetAttrProfileForEventEv2E1,
|
||||
testFilterUpdateGetAttrProfileForEventEv2E2,
|
||||
testFilterUpdateStopEngine,
|
||||
}
|
||||
ev1 = &utils.CGREvent{
|
||||
Tenant: "cgrates.org",
|
||||
ID: "Event1",
|
||||
Event: map[string]interface{}{
|
||||
utils.AccountField: "1001",
|
||||
},
|
||||
}
|
||||
ev2 = &utils.CGREvent{
|
||||
Tenant: "cgrates.org",
|
||||
ID: "Event2",
|
||||
Event: map[string]interface{}{
|
||||
utils.AccountField: "1002",
|
||||
},
|
||||
}
|
||||
)
|
||||
|
||||
// func TestFilterUpdateIT(t *testing.T) {
|
||||
// switch *dbType {
|
||||
// case utils.MetaInternal:
|
||||
// t.SkipNow()
|
||||
// case utils.MetaMySQL:
|
||||
// fltrUpdateCfgDIR1 = "fltr_update_e1_mysql"
|
||||
// fltrUpdateCfgDIR2 = "tutmysql"
|
||||
// case utils.MetaMongo:
|
||||
// fltrUpdateCfgDIR1 = "fltr_update_e1_mongo"
|
||||
// fltrUpdateCfgDIR2 = "tutmongo"
|
||||
// case utils.MetaPostgres:
|
||||
// t.SkipNow()
|
||||
// default:
|
||||
// t.Fatal("Unknown Database type")
|
||||
// }
|
||||
func TestFilterUpdateIT(t *testing.T) {
|
||||
switch *dbType {
|
||||
case utils.MetaInternal:
|
||||
t.SkipNow()
|
||||
case utils.MetaMySQL:
|
||||
fltrUpdateCfgDIR1 = "fltr_update_e1_mysql"
|
||||
fltrUpdateCfgDIR2 = "tutmysql"
|
||||
case utils.MetaMongo:
|
||||
fltrUpdateCfgDIR1 = "fltr_update_e1_mongo"
|
||||
fltrUpdateCfgDIR2 = "tutmongo"
|
||||
case utils.MetaPostgres:
|
||||
t.SkipNow()
|
||||
default:
|
||||
t.Fatal("Unknown Database type")
|
||||
}
|
||||
|
||||
// for _, stest1 := range sTestsFilterUpdate {
|
||||
// t.Run(*dbType, stest1)
|
||||
// }
|
||||
// }
|
||||
for _, stest1 := range sTestsFilterUpdate {
|
||||
t.Run(*dbType, stest1)
|
||||
}
|
||||
}
|
||||
|
||||
// //Init Config
|
||||
// func testFilterUpdateInitCfg(t *testing.T) {
|
||||
// var err error
|
||||
// fltrUpdateCfgPath1 = path.Join(*dataDir, "conf", "samples", "cache_replicate", fltrUpdateCfgDIR1)
|
||||
// if fltrUpdateCfg1, err = config.NewCGRConfigFromPath(fltrUpdateCfgPath1); err != nil {
|
||||
// t.Fatal(err)
|
||||
// }
|
||||
// fltrUpdateCfgPath2 = path.Join(*dataDir, "conf", "samples", fltrUpdateCfgDIR2)
|
||||
// if fltrUpdateCfg2, err = config.NewCGRConfigFromPath(fltrUpdateCfgPath2); err != nil {
|
||||
// t.Fatal(err)
|
||||
// }
|
||||
// }
|
||||
//Init Config
|
||||
func testFilterUpdateInitCfg(t *testing.T) {
|
||||
var err error
|
||||
fltrUpdateCfgPath1 = path.Join(*dataDir, "conf", "samples", "cache_replicate", fltrUpdateCfgDIR1)
|
||||
if fltrUpdateCfg1, err = config.NewCGRConfigFromPath(context.Background(), fltrUpdateCfgPath1); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
fltrUpdateCfgPath2 = path.Join(*dataDir, "conf", "samples", fltrUpdateCfgDIR2)
|
||||
if fltrUpdateCfg2, err = config.NewCGRConfigFromPath(context.Background(), fltrUpdateCfgPath2); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
// // Remove data in both rating and accounting db
|
||||
// func testFilterUpdateResetDB(t *testing.T) {
|
||||
// if err := engine.InitDataDB(fltrUpdateCfg1); err != nil {
|
||||
// t.Fatal(err)
|
||||
// }
|
||||
// }
|
||||
// Remove data in both rating and accounting db
|
||||
func testFilterUpdateResetDB(t *testing.T) {
|
||||
if err := engine.InitDataDB(fltrUpdateCfg1); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
// // Start CGR Engine
|
||||
// func testFilterUpdateStartEngine(t *testing.T) {
|
||||
// var err error
|
||||
// if _, err = engine.StopStartEngine(fltrUpdateCfgPath1, *waitRater); err != nil {
|
||||
// t.Fatal(err)
|
||||
// }
|
||||
// if testEng1, err = engine.StartEngine(fltrUpdateCfgPath2, *waitRater); err != nil {
|
||||
// t.Fatal(err)
|
||||
// }
|
||||
// Start CGR Engine
|
||||
func testFilterUpdateStartEngine(t *testing.T) {
|
||||
var err error
|
||||
if _, err = engine.StopStartEngine(fltrUpdateCfgPath1, *waitRater); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if testEng1, err = engine.StartEngine(fltrUpdateCfgPath2, *waitRater); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
// }
|
||||
}
|
||||
|
||||
// // Connect rpc client to rater
|
||||
// func testFilterUpdateRpcConn(t *testing.T) {
|
||||
// var err error
|
||||
// if fltrUpdateRPC1, err = newRPCClient(fltrUpdateCfg1.ListenCfg()); err != nil {
|
||||
// t.Fatal(err)
|
||||
// }
|
||||
// if fltrUpdateRPC2, err = newRPCClient(fltrUpdateCfg2.ListenCfg()); err != nil {
|
||||
// t.Fatal(err)
|
||||
// }
|
||||
// }
|
||||
// Connect rpc client to rater
|
||||
func testFilterUpdateRpcConn(t *testing.T) {
|
||||
var err error
|
||||
if fltrUpdateRPC1, err = newRPCClient(fltrUpdateCfg1.ListenCfg()); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if fltrUpdateRPC2, err = newRPCClient(fltrUpdateCfg2.ListenCfg()); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
// func testFilterUpdateStopEngine(t *testing.T) {
|
||||
// if err := engine.KillEngine(100); err != nil {
|
||||
// t.Error(err)
|
||||
// }
|
||||
// }
|
||||
func testFilterUpdateStopEngine(t *testing.T) {
|
||||
if err := engine.KillEngine(100); err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
}
|
||||
|
||||
// func testFilterUpdateSetFilterE1(t *testing.T) {
|
||||
// fltr := &engine.FilterWithAPIOpts{
|
||||
// Filter: &engine.Filter{
|
||||
// ID: "FLTR_ID",
|
||||
// Tenant: "cgrates.org",
|
||||
// Rules: []*engine.FilterRule{
|
||||
// {
|
||||
// Type: utils.MetaString,
|
||||
// Element: "~*req.Account",
|
||||
// Values: []string{"1001"},
|
||||
// },
|
||||
// },
|
||||
// },
|
||||
// APIOpts: map[string]interface{}{
|
||||
// utils.CacheOpt: utils.MetaLoad,
|
||||
// },
|
||||
// }
|
||||
func testFilterUpdateSetFilterE1(t *testing.T) {
|
||||
fltr := &engine.FilterWithAPIOpts{
|
||||
Filter: &engine.Filter{
|
||||
ID: "FLTR_ID",
|
||||
Tenant: "cgrates.org",
|
||||
Rules: []*engine.FilterRule{
|
||||
{
|
||||
Type: utils.MetaString,
|
||||
Element: "~*req.Account",
|
||||
Values: []string{"1001"},
|
||||
},
|
||||
},
|
||||
},
|
||||
APIOpts: map[string]interface{}{
|
||||
utils.MetaCache: utils.MetaLoad,
|
||||
},
|
||||
}
|
||||
|
||||
// var reply string
|
||||
// if err := fltrUpdateRPC1.Call(context.Background(), utils.AdminSv1SetFilter, fltr, &reply); err != nil {
|
||||
// t.Error(err)
|
||||
// } else if reply != utils.OK {
|
||||
// t.Error("Unexpected reply returned", reply)
|
||||
// }
|
||||
var reply string
|
||||
if err := fltrUpdateRPC1.Call(context.Background(), utils.AdminSv1SetFilter, fltr, &reply); err != nil {
|
||||
t.Error(err)
|
||||
} else if reply != utils.OK {
|
||||
t.Error("Unexpected reply returned", reply)
|
||||
}
|
||||
|
||||
// var result *engine.Filter
|
||||
// if err := fltrUpdateRPC1.Call(context.Background(), utils.AdminSv1GetFilter,
|
||||
// &utils.TenantID{Tenant: "cgrates.org", ID: "FLTR_ID"}, &result); err != nil {
|
||||
// t.Error(err)
|
||||
// } else if !reflect.DeepEqual(fltr.Filter, result) {
|
||||
// t.Errorf("expected: <%+v>, \nreceived: <%+v>", utils.ToJSON(fltr.Filter), utils.ToJSON(result))
|
||||
// }
|
||||
// }
|
||||
var result *engine.Filter
|
||||
if err := fltrUpdateRPC1.Call(context.Background(), utils.AdminSv1GetFilter,
|
||||
&utils.TenantID{Tenant: "cgrates.org", ID: "FLTR_ID"}, &result); err != nil {
|
||||
t.Error(err)
|
||||
} else if !reflect.DeepEqual(fltr.Filter, result) {
|
||||
t.Errorf("expected: <%+v>, \nreceived: <%+v>", utils.ToJSON(fltr.Filter), utils.ToJSON(result))
|
||||
}
|
||||
}
|
||||
|
||||
// func testFilterUpdateSetAttrProfileE1(t *testing.T) {
|
||||
// attrPrf := &engine.APIAttributeProfileWithAPIOpts{
|
||||
// APIAttributeProfile: &engine.APIAttributeProfile{
|
||||
// FilterIDs: []string{"FLTR_ID"},
|
||||
// ID: "ATTR_ID",
|
||||
// Tenant: "cgrates.org",
|
||||
// Weight: 10,
|
||||
// Attributes: []*engine.ExternalAttribute{
|
||||
// {
|
||||
// Path: "*req.Account",
|
||||
// Value: "1003",
|
||||
// Type: utils.MetaConstant,
|
||||
// },
|
||||
// },
|
||||
// },
|
||||
// APIOpts: map[string]interface{}{
|
||||
// utils.CacheOpt: utils.MetaNone,
|
||||
// },
|
||||
// }
|
||||
func testFilterUpdateSetAttrProfileE1(t *testing.T) {
|
||||
attrPrf := &engine.APIAttributeProfileWithAPIOpts{
|
||||
APIAttributeProfile: &engine.APIAttributeProfile{
|
||||
FilterIDs: []string{"FLTR_ID"},
|
||||
ID: "ATTR_ID",
|
||||
Tenant: "cgrates.org",
|
||||
Weights: utils.DynamicWeights{
|
||||
{
|
||||
Weight: 10,
|
||||
},
|
||||
},
|
||||
Attributes: []*engine.ExternalAttribute{
|
||||
{
|
||||
Path: "*req.Account",
|
||||
Value: "1003",
|
||||
Type: utils.MetaConstant,
|
||||
},
|
||||
},
|
||||
},
|
||||
APIOpts: map[string]interface{}{
|
||||
utils.MetaCache: utils.MetaNone,
|
||||
},
|
||||
}
|
||||
|
||||
// var reply string
|
||||
// if err := fltrUpdateRPC1.Call(context.Background(), utils.AdminSv1SetAttributeProfile, attrPrf, &reply); err != nil {
|
||||
// t.Error(err)
|
||||
// } else if reply != utils.OK {
|
||||
// t.Error("Unexpected reply returned", reply)
|
||||
// }
|
||||
// var result *engine.APIAttributeProfile
|
||||
// if err := fltrUpdateRPC1.Call(context.Background(), utils.AdminSv1GetAttributeProfile,
|
||||
// utils.TenantIDWithAPIOpts{TenantID: &utils.TenantID{Tenant: "cgrates.org", ID: "ATTR_ID"}}, &result); err != nil {
|
||||
// t.Fatal(err)
|
||||
// }
|
||||
// if !reflect.DeepEqual(attrPrf.APIAttributeProfile, result) {
|
||||
// t.Errorf("expected: <%+v>, \nreceived: <%+v>", utils.ToJSON(attrPrf.APIAttributeProfile), utils.ToJSON(result))
|
||||
// }
|
||||
// }
|
||||
var reply string
|
||||
if err := fltrUpdateRPC1.Call(context.Background(), utils.AdminSv1SetAttributeProfile, attrPrf, &reply); err != nil {
|
||||
t.Error(err)
|
||||
} else if reply != utils.OK {
|
||||
t.Error("Unexpected reply returned", reply)
|
||||
}
|
||||
var result *engine.APIAttributeProfile
|
||||
if err := fltrUpdateRPC1.Call(context.Background(), utils.AdminSv1GetAttributeProfile,
|
||||
utils.TenantIDWithAPIOpts{TenantID: &utils.TenantID{Tenant: "cgrates.org", ID: "ATTR_ID"}}, &result); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if !reflect.DeepEqual(attrPrf.APIAttributeProfile, result) {
|
||||
t.Errorf("expected: <%+v>, \nreceived: <%+v>", utils.ToJSON(attrPrf.APIAttributeProfile), utils.ToJSON(result))
|
||||
}
|
||||
}
|
||||
|
||||
// func testFilterUpdateGetAttrProfileForEventEv1E1(t *testing.T) {
|
||||
// eAttrPrf := &engine.APIAttributeProfile{
|
||||
// Tenant: "cgrates.org",
|
||||
// FilterIDs: []string{"FLTR_ID"},
|
||||
// ID: "ATTR_ID",
|
||||
// Weight: 10,
|
||||
// Attributes: []*engine.ExternalAttribute{
|
||||
// {
|
||||
// Path: "*req.Account",
|
||||
// Value: "1003",
|
||||
// Type: utils.MetaConstant,
|
||||
// },
|
||||
// },
|
||||
// }
|
||||
func testFilterUpdateGetAttrProfileForEventEv1E1(t *testing.T) {
|
||||
eAttrPrf := &engine.APIAttributeProfile{
|
||||
Tenant: "cgrates.org",
|
||||
FilterIDs: []string{"FLTR_ID"},
|
||||
ID: "ATTR_ID",
|
||||
Weights: utils.DynamicWeights{
|
||||
{
|
||||
Weight: 10,
|
||||
},
|
||||
},
|
||||
Attributes: []*engine.ExternalAttribute{
|
||||
{
|
||||
Path: "*req.Account",
|
||||
Value: "1003",
|
||||
Type: utils.MetaConstant,
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
// var attrReply *engine.APIAttributeProfile
|
||||
// if err := fltrUpdateRPC1.Call(context.Background(), utils.AttributeSv1GetAttributeForEvent,
|
||||
// ev1, &attrReply); err != nil {
|
||||
// t.Fatal(err)
|
||||
// }
|
||||
// if !reflect.DeepEqual(eAttrPrf, attrReply) {
|
||||
// t.Errorf("expected: <%+v>, \nreceived: <%+v>", utils.ToJSON(eAttrPrf), utils.ToJSON(attrReply))
|
||||
// }
|
||||
// }
|
||||
var attrReply *engine.APIAttributeProfile
|
||||
if err := fltrUpdateRPC1.Call(context.Background(), utils.AttributeSv1GetAttributeForEvent,
|
||||
ev1, &attrReply); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if !reflect.DeepEqual(eAttrPrf, attrReply) {
|
||||
t.Errorf("expected: <%+v>, \nreceived: <%+v>", utils.ToJSON(eAttrPrf), utils.ToJSON(attrReply))
|
||||
}
|
||||
}
|
||||
|
||||
// func testFilterUpdateGetAttrProfileForEventEv1E2(t *testing.T) {
|
||||
// eAttrPrf := &engine.APIAttributeProfile{
|
||||
// Tenant: "cgrates.org",
|
||||
// FilterIDs: []string{"FLTR_ID"},
|
||||
// ID: "ATTR_ID",
|
||||
// Weight: 10,
|
||||
// Attributes: []*engine.ExternalAttribute{
|
||||
// {
|
||||
// Path: "*req.Account",
|
||||
// Value: "1003",
|
||||
// Type: utils.MetaConstant,
|
||||
// },
|
||||
// },
|
||||
// }
|
||||
func testFilterUpdateGetAttrProfileForEventEv1E2(t *testing.T) {
|
||||
eAttrPrf := &engine.APIAttributeProfile{
|
||||
Tenant: "cgrates.org",
|
||||
FilterIDs: []string{"FLTR_ID"},
|
||||
ID: "ATTR_ID",
|
||||
Weights: utils.DynamicWeights{
|
||||
{
|
||||
Weight: 10,
|
||||
},
|
||||
},
|
||||
Attributes: []*engine.ExternalAttribute{
|
||||
{
|
||||
Path: "*req.Account",
|
||||
Value: "1003",
|
||||
Type: utils.MetaConstant,
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
// var attrReply *engine.APIAttributeProfile
|
||||
// if err := fltrUpdateRPC2.Call(context.Background(), utils.AttributeSv1GetAttributeForEvent,
|
||||
// ev1, &attrReply); err != nil {
|
||||
// t.Fatal(err)
|
||||
// }
|
||||
// if !reflect.DeepEqual(eAttrPrf, attrReply) {
|
||||
// t.Errorf("expected: <%+v>, \nreceived: <%+v>", utils.ToJSON(eAttrPrf), utils.ToJSON(attrReply))
|
||||
// }
|
||||
// }
|
||||
var attrReply *engine.APIAttributeProfile
|
||||
if err := fltrUpdateRPC2.Call(context.Background(), utils.AttributeSv1GetAttributeForEvent,
|
||||
ev1, &attrReply); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if !reflect.DeepEqual(eAttrPrf, attrReply) {
|
||||
t.Errorf("expected: <%+v>, \nreceived: <%+v>", utils.ToJSON(eAttrPrf), utils.ToJSON(attrReply))
|
||||
}
|
||||
}
|
||||
|
||||
// func testFilterUpdateGetAttrProfileForEventEv2E1(t *testing.T) {
|
||||
// eAttrPrf := &engine.APIAttributeProfile{
|
||||
// Tenant: "cgrates.org",
|
||||
// FilterIDs: []string{"FLTR_ID"},
|
||||
// ID: "ATTR_ID",
|
||||
// Weight: 10,
|
||||
// Attributes: []*engine.ExternalAttribute{
|
||||
// {
|
||||
// Path: "*req.Account",
|
||||
// Value: "1003",
|
||||
// Type: utils.MetaConstant,
|
||||
// },
|
||||
// },
|
||||
// }
|
||||
func testFilterUpdateGetAttrProfileForEventEv2E1(t *testing.T) {
|
||||
eAttrPrf := &engine.APIAttributeProfile{
|
||||
Tenant: "cgrates.org",
|
||||
FilterIDs: []string{"FLTR_ID"},
|
||||
ID: "ATTR_ID",
|
||||
Weights: utils.DynamicWeights{
|
||||
{
|
||||
Weight: 10,
|
||||
},
|
||||
},
|
||||
Attributes: []*engine.ExternalAttribute{
|
||||
{
|
||||
Path: "*req.Account",
|
||||
Value: "1003",
|
||||
Type: utils.MetaConstant,
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
// var attrReply *engine.APIAttributeProfile
|
||||
// if err := fltrUpdateRPC1.Call(context.Background(), utils.AttributeSv1GetAttributeForEvent,
|
||||
// ev2, &attrReply); err != nil {
|
||||
// t.Fatal(err)
|
||||
// }
|
||||
// if !reflect.DeepEqual(eAttrPrf, attrReply) {
|
||||
// t.Errorf("expected: <%+v>, \nreceived: <%+v>", utils.ToJSON(eAttrPrf), utils.ToJSON(attrReply))
|
||||
// }
|
||||
// }
|
||||
var attrReply *engine.APIAttributeProfile
|
||||
if err := fltrUpdateRPC1.Call(context.Background(), utils.AttributeSv1GetAttributeForEvent,
|
||||
ev2, &attrReply); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if !reflect.DeepEqual(eAttrPrf, attrReply) {
|
||||
t.Errorf("expected: <%+v>, \nreceived: <%+v>", utils.ToJSON(eAttrPrf), utils.ToJSON(attrReply))
|
||||
}
|
||||
}
|
||||
|
||||
// func testFilterUpdateGetAttrProfileForEventEv2E2(t *testing.T) {
|
||||
// eAttrPrf := &engine.APIAttributeProfile{
|
||||
// Tenant: "cgrates.org",
|
||||
// FilterIDs: []string{"FLTR_ID"},
|
||||
// ID: "ATTR_ID",
|
||||
// Weight: 10,
|
||||
// Attributes: []*engine.ExternalAttribute{
|
||||
// {
|
||||
// Path: "*req.Account",
|
||||
// Value: "1003",
|
||||
// Type: utils.MetaConstant,
|
||||
// },
|
||||
// },
|
||||
// }
|
||||
func testFilterUpdateGetAttrProfileForEventEv2E2(t *testing.T) {
|
||||
eAttrPrf := &engine.APIAttributeProfile{
|
||||
Tenant: "cgrates.org",
|
||||
FilterIDs: []string{"FLTR_ID"},
|
||||
ID: "ATTR_ID",
|
||||
Weights: utils.DynamicWeights{
|
||||
{
|
||||
Weight: 10,
|
||||
},
|
||||
},
|
||||
Attributes: []*engine.ExternalAttribute{
|
||||
{
|
||||
Path: "*req.Account",
|
||||
Value: "1003",
|
||||
Type: utils.MetaConstant,
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
// var attrReply *engine.APIAttributeProfile
|
||||
// if err := fltrUpdateRPC2.Call(context.Background(), utils.AttributeSv1GetAttributeForEvent,
|
||||
// ev2, &attrReply); err != nil {
|
||||
// t.Fatal(err)
|
||||
// }
|
||||
// if !reflect.DeepEqual(eAttrPrf, attrReply) {
|
||||
// t.Errorf("expected: <%+v>, \nreceived: <%+v>", utils.ToJSON(eAttrPrf), utils.ToJSON(attrReply))
|
||||
// }
|
||||
// }
|
||||
var attrReply *engine.APIAttributeProfile
|
||||
if err := fltrUpdateRPC2.Call(context.Background(), utils.AttributeSv1GetAttributeForEvent,
|
||||
ev2, &attrReply); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if !reflect.DeepEqual(eAttrPrf, attrReply) {
|
||||
t.Errorf("expected: <%+v>, \nreceived: <%+v>", utils.ToJSON(eAttrPrf), utils.ToJSON(attrReply))
|
||||
}
|
||||
}
|
||||
|
||||
// func testFilterUpdateSetFilterAfterAttrE1(t *testing.T) {
|
||||
// fltr := &engine.FilterWithAPIOpts{
|
||||
// Filter: &engine.Filter{
|
||||
// ID: "FLTR_ID",
|
||||
// Tenant: "cgrates.org",
|
||||
// Rules: []*engine.FilterRule{
|
||||
// {
|
||||
// Type: utils.MetaString,
|
||||
// Element: "~*req.Account",
|
||||
// Values: []string{"1002"},
|
||||
// },
|
||||
// },
|
||||
// },
|
||||
// APIOpts: map[string]interface{}{
|
||||
// utils.CacheOpt: utils.MetaLoad,
|
||||
// },
|
||||
// }
|
||||
func testFilterUpdateSetFilterAfterAttrE1(t *testing.T) {
|
||||
fltr := &engine.FilterWithAPIOpts{
|
||||
Filter: &engine.Filter{
|
||||
ID: "FLTR_ID",
|
||||
Tenant: "cgrates.org",
|
||||
Rules: []*engine.FilterRule{
|
||||
{
|
||||
Type: utils.MetaString,
|
||||
Element: "~*req.Account",
|
||||
Values: []string{"1002"},
|
||||
},
|
||||
},
|
||||
},
|
||||
APIOpts: map[string]interface{}{
|
||||
utils.MetaCache: utils.MetaLoad,
|
||||
},
|
||||
}
|
||||
|
||||
// var reply string
|
||||
// if err := fltrUpdateRPC1.Call(context.Background(), utils.AdminSv1SetFilter, fltr, &reply); err != nil {
|
||||
// t.Error(err)
|
||||
// } else if reply != utils.OK {
|
||||
// t.Error("Unexpected reply returned", reply)
|
||||
// }
|
||||
var reply string
|
||||
if err := fltrUpdateRPC1.Call(context.Background(), utils.AdminSv1SetFilter, fltr, &reply); err != nil {
|
||||
t.Error(err)
|
||||
} else if reply != utils.OK {
|
||||
t.Error("Unexpected reply returned", reply)
|
||||
}
|
||||
|
||||
// var result *engine.Filter
|
||||
// if err := fltrUpdateRPC1.Call(context.Background(), utils.AdminSv1GetFilter,
|
||||
// &utils.TenantID{Tenant: "cgrates.org", ID: "FLTR_ID"}, &result); err != nil {
|
||||
// t.Error(err)
|
||||
// } else if !reflect.DeepEqual(fltr.Filter, result) {
|
||||
// t.Errorf("expected: <%+v>, \nreceived: <%+v>", utils.ToJSON(fltr.Filter), utils.ToJSON(result))
|
||||
// }
|
||||
// }
|
||||
var result *engine.Filter
|
||||
if err := fltrUpdateRPC1.Call(context.Background(), utils.AdminSv1GetFilter,
|
||||
&utils.TenantID{Tenant: "cgrates.org", ID: "FLTR_ID"}, &result); err != nil {
|
||||
t.Error(err)
|
||||
} else if !reflect.DeepEqual(fltr.Filter, result) {
|
||||
t.Errorf("expected: <%+v>, \nreceived: <%+v>", utils.ToJSON(fltr.Filter), utils.ToJSON(result))
|
||||
}
|
||||
}
|
||||
|
||||
// func testFilterUpdateGetAttrProfileForEventEv1E1NotMatching(t *testing.T) {
|
||||
// var attrReply *engine.APIAttributeProfile
|
||||
// if err := fltrUpdateRPC1.Call(context.Background(), utils.AttributeSv1GetAttributeForEvent,
|
||||
// ev1, &attrReply); err == nil || err.Error() != utils.ErrNotFound.Error() {
|
||||
// t.Errorf("expected: <%+v>, \nreceived: <%+v>", utils.ErrNotFound, err)
|
||||
// }
|
||||
// }
|
||||
func testFilterUpdateGetAttrProfileForEventEv1E1NotMatching(t *testing.T) {
|
||||
var attrReply *engine.APIAttributeProfile
|
||||
if err := fltrUpdateRPC1.Call(context.Background(), utils.AttributeSv1GetAttributeForEvent,
|
||||
ev1, &attrReply); err == nil || err.Error() != utils.ErrNotFound.Error() {
|
||||
t.Errorf("expected: <%+v>, \nreceived: <%+v>", utils.ErrNotFound, err)
|
||||
}
|
||||
}
|
||||
|
||||
// func testFilterUpdateGetAttrProfileForEventEv1E2NotMatching(t *testing.T) {
|
||||
// var attrReply *engine.APIAttributeProfile
|
||||
// if err := fltrUpdateRPC2.Call(context.Background(), utils.AttributeSv1GetAttributeForEvent,
|
||||
// ev1, &attrReply); err == nil || err.Error() != utils.ErrNotFound.Error() {
|
||||
// t.Errorf("expected: <%+v>, \nreceived: <%+v>", utils.ErrNotFound, err)
|
||||
// }
|
||||
// }
|
||||
func testFilterUpdateGetAttrProfileForEventEv1E2NotMatching(t *testing.T) {
|
||||
var attrReply *engine.APIAttributeProfile
|
||||
if err := fltrUpdateRPC2.Call(context.Background(), utils.AttributeSv1GetAttributeForEvent,
|
||||
ev1, &attrReply); err == nil || err.Error() != utils.ErrNotFound.Error() {
|
||||
t.Errorf("expected: <%+v>, \nreceived: <%+v>", utils.ErrNotFound, err)
|
||||
}
|
||||
}
|
||||
|
||||
// func testFilterUpdateGetAttrProfileForEventEv2E1NotMatching(t *testing.T) {
|
||||
// var attrReply *engine.APIAttributeProfile
|
||||
// if err := fltrUpdateRPC1.Call(context.Background(), utils.AttributeSv1GetAttributeForEvent,
|
||||
// ev2, &attrReply); err == nil || err.Error() != utils.ErrNotFound.Error() {
|
||||
// t.Errorf("expected: <%+v>, \nreceived: <%+v>", utils.ErrNotFound, err)
|
||||
// }
|
||||
// }
|
||||
func testFilterUpdateGetAttrProfileForEventEv2E1NotMatching(t *testing.T) {
|
||||
var attrReply *engine.APIAttributeProfile
|
||||
if err := fltrUpdateRPC1.Call(context.Background(), utils.AttributeSv1GetAttributeForEvent,
|
||||
ev2, &attrReply); err == nil || err.Error() != utils.ErrNotFound.Error() {
|
||||
t.Errorf("expected: <%+v>, \nreceived: <%+v>", utils.ErrNotFound, err)
|
||||
}
|
||||
}
|
||||
|
||||
// func testFilterUpdateGetAttrProfileForEventEv2E2NotMatching(t *testing.T) {
|
||||
// var attrReply *engine.APIAttributeProfile
|
||||
// if err := fltrUpdateRPC2.Call(context.Background(), utils.AttributeSv1GetAttributeForEvent,
|
||||
// ev2, &attrReply); err == nil || err.Error() != utils.ErrNotFound.Error() {
|
||||
// t.Errorf("expected: <%+v>, \nreceived: <%+v>", utils.ErrNotFound, err)
|
||||
// }
|
||||
// }
|
||||
func testFilterUpdateGetAttrProfileForEventEv2E2NotMatching(t *testing.T) {
|
||||
var attrReply *engine.APIAttributeProfile
|
||||
if err := fltrUpdateRPC2.Call(context.Background(), utils.AttributeSv1GetAttributeForEvent,
|
||||
ev2, &attrReply); err == nil || err.Error() != utils.ErrNotFound.Error() {
|
||||
t.Errorf("expected: <%+v>, \nreceived: <%+v>", utils.ErrNotFound, err)
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user