mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-11 18:16:24 +05:00
Added integration tests for filtered replication
This commit is contained in:
committed by
Dan Christian Bogos
parent
5f0150b639
commit
103c54ff50
@@ -61,10 +61,12 @@ func (rplSv1 *ReplicatorSv1) GetDestination(key *utils.StringWithOpts, reply *en
|
||||
|
||||
//GetDestination
|
||||
func (rplSv1 *ReplicatorSv1) GetReverseDestination(key *utils.StringWithOpts, reply *[]string) error {
|
||||
engine.SetReplicateHost(utils.ReverseDestinationPrefix, key.Arg, utils.IfaceAsString(key.Opts[utils.RemoteHostOpt]))
|
||||
if rcv, err := rplSv1.dm.DataDB().GetReverseDestinationDrv(key.Arg, utils.NonTransactional); err != nil {
|
||||
return err
|
||||
} else {
|
||||
for _, dstID := range rcv {
|
||||
engine.SetReplicateHost(utils.ReverseDestinationPrefix, dstID, utils.IfaceAsString(key.Opts[utils.RemoteHostOpt]))
|
||||
}
|
||||
*reply = rcv
|
||||
}
|
||||
return nil
|
||||
|
||||
@@ -0,0 +1,87 @@
|
||||
{
|
||||
"general": {
|
||||
"log_level": 7,
|
||||
"node_id" : "EngineMongo1",
|
||||
},
|
||||
|
||||
|
||||
"listen": {
|
||||
"rpc_json": ":2022",
|
||||
"rpc_gob": ":2023",
|
||||
"http": ":2280",
|
||||
},
|
||||
|
||||
|
||||
"rpc_conns": {
|
||||
"conn1": {
|
||||
"strategy": "*first",
|
||||
"conns": [{"address": "127.0.0.1:2012", "transport":"*json"}],
|
||||
},
|
||||
},
|
||||
|
||||
|
||||
"data_db": {
|
||||
"db_type": "mongo",
|
||||
"db_name": "10",
|
||||
"db_port": 27017,
|
||||
"remote_conns": ["conn1"],
|
||||
"remote_conn_id": "engine1",
|
||||
"items":{
|
||||
"*accounts":{"remote":true,"replicate":false},
|
||||
"*reverse_destinations": {"remote":true,"replicate":false},
|
||||
"*destinations": {"remote":true,"replicate":false},
|
||||
"*rating_plans": {"remote":true,"replicate":false},
|
||||
"*rating_profiles":{"remote":true,"replicate":false},
|
||||
"*actions":{"remote":true,"replicate":false},
|
||||
"*action_plans": {"remote":true,"replicate":false},
|
||||
"*account_action_plans":{"remote":true,"replicate":false},
|
||||
"*action_triggers":{"remote":true,"replicate":false},
|
||||
"*shared_groups":{"remote":true,"replicate":false},
|
||||
"*timings": {"remote":true,"replicate":false},
|
||||
"*resource_profiles":{"remote":true,"replicate":false},
|
||||
"*resources":{"remote":true,"replicate":false},
|
||||
"*statqueue_profiles": {"remote":true,"replicate":false},
|
||||
"*statqueues": {"remote":true,"replicate":false},
|
||||
"*threshold_profiles": {"remote":true,"replicate":false},
|
||||
"*thresholds": {"remote":true,"replicate":false},
|
||||
"*filters": {"remote":true,"replicate":false},
|
||||
"*route_profiles":{"remote":true,"replicate":false},
|
||||
"*attribute_profiles":{"remote":true,"replicate":false},
|
||||
"*charger_profiles": {"remote":true,"replicate":false},
|
||||
"*dispatcher_profiles":{"remote":true,"replicate":false},
|
||||
"*dispatcher_hosts":{"remote":true,"replicate":false},
|
||||
"*rate_profiles":{"remote":true,"replicate":false},
|
||||
"*load_ids":{"remote":true,"replicate":false},
|
||||
"*indexes":{"remote":true, "replicate":false},
|
||||
"*action_profiles":{"remote":true,"replicate":false},
|
||||
"*account_profiles":{"remote":true,"replicate":false},
|
||||
},
|
||||
},
|
||||
|
||||
|
||||
|
||||
"stor_db": {
|
||||
"db_type": "mongo",
|
||||
"db_name": "cgrates",
|
||||
"db_port": 27017,
|
||||
},
|
||||
|
||||
|
||||
"rals": {
|
||||
"enabled": true,
|
||||
},
|
||||
|
||||
|
||||
"schedulers": {
|
||||
"enabled": true,
|
||||
},
|
||||
|
||||
"apiers": {
|
||||
"enabled": true,
|
||||
"scheduler_conns": ["*internal"],
|
||||
},
|
||||
"thresholds": {
|
||||
"enabled": true,
|
||||
},
|
||||
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
{
|
||||
"general": {
|
||||
"log_level": 7,
|
||||
"node_id" : "EngineMongo1",
|
||||
},
|
||||
|
||||
|
||||
"listen": {
|
||||
"rpc_json": ":2022",
|
||||
"rpc_gob": ":2023",
|
||||
"http": ":2280",
|
||||
},
|
||||
|
||||
|
||||
"rpc_conns": {
|
||||
"conn1": {
|
||||
"strategy": "*first",
|
||||
"conns": [{"address": "127.0.0.1:2012", "transport":"*json"}],
|
||||
},
|
||||
},
|
||||
|
||||
"data_db": {
|
||||
"db_type": "redis",
|
||||
"db_port": 6379,
|
||||
"db_name": "10",
|
||||
"remote_conns": ["conn1"],
|
||||
"remote_conn_id": "engine1",
|
||||
"items":{
|
||||
"*accounts":{"remote":true,"replicate":false},
|
||||
"*reverse_destinations": {"remote":true,"replicate":false},
|
||||
"*destinations": {"remote":true,"replicate":false},
|
||||
"*rating_plans": {"remote":true,"replicate":false},
|
||||
"*rating_profiles":{"remote":true,"replicate":false},
|
||||
"*actions":{"remote":true,"replicate":false},
|
||||
"*action_plans": {"remote":true,"replicate":false},
|
||||
"*account_action_plans":{"remote":true,"replicate":false},
|
||||
"*action_triggers":{"remote":true,"replicate":false},
|
||||
"*shared_groups":{"remote":true,"replicate":false},
|
||||
"*timings": {"remote":true,"replicate":false},
|
||||
"*resource_profiles":{"remote":true,"replicate":false},
|
||||
"*resources":{"remote":true,"replicate":false},
|
||||
"*statqueue_profiles": {"remote":true,"replicate":false},
|
||||
"*statqueues": {"remote":true,"replicate":false},
|
||||
"*threshold_profiles": {"remote":true,"replicate":false},
|
||||
"*thresholds": {"remote":true,"replicate":false},
|
||||
"*filters": {"remote":true,"replicate":false},
|
||||
"*route_profiles":{"remote":true,"replicate":false},
|
||||
"*attribute_profiles":{"remote":true,"replicate":false},
|
||||
"*charger_profiles": {"remote":true,"replicate":false},
|
||||
"*dispatcher_profiles":{"remote":true,"replicate":false},
|
||||
"*dispatcher_hosts":{"remote":true,"replicate":false},
|
||||
"*rate_profiles":{"remote":true,"replicate":false},
|
||||
"*load_ids":{"remote":true,"replicate":false},
|
||||
"*indexes":{"remote":true, "replicate":false},
|
||||
"*action_profiles":{"remote":true,"replicate":false},
|
||||
"*account_profiles":{"remote":true,"replicate":false},
|
||||
},
|
||||
},
|
||||
|
||||
|
||||
"stor_db": {
|
||||
"db_password": "CGRateS.org",
|
||||
},
|
||||
|
||||
|
||||
"rals": {
|
||||
"enabled": true,
|
||||
},
|
||||
|
||||
|
||||
"schedulers": {
|
||||
"enabled": true,
|
||||
},
|
||||
|
||||
"apiers": {
|
||||
"enabled": true,
|
||||
"scheduler_conns": ["*internal"],
|
||||
},
|
||||
"thresholds": {
|
||||
"enabled": true,
|
||||
},
|
||||
|
||||
}
|
||||
@@ -0,0 +1,87 @@
|
||||
{
|
||||
"general": {
|
||||
"log_level": 7,
|
||||
"node_id" : "EngineMongo2",
|
||||
},
|
||||
|
||||
|
||||
"listen": {
|
||||
"rpc_json": ":2032",
|
||||
"rpc_gob": ":2033",
|
||||
"http": ":2380",
|
||||
},
|
||||
|
||||
|
||||
"rpc_conns": {
|
||||
"conn1": {
|
||||
"strategy": "*first",
|
||||
"conns": [{"address": "127.0.0.1:2012", "transport":"*json"}],
|
||||
},
|
||||
},
|
||||
|
||||
|
||||
"data_db": {
|
||||
"db_type": "mongo",
|
||||
"db_name": "11",
|
||||
"db_port": 27017,
|
||||
"remote_conns": ["conn1"],
|
||||
"remote_conn_id": "engine2",
|
||||
"items":{
|
||||
"*accounts":{"remote":true,"replicate":false},
|
||||
"*reverse_destinations": {"remote":true,"replicate":false},
|
||||
"*destinations": {"remote":true,"replicate":false},
|
||||
"*rating_plans": {"remote":true,"replicate":false},
|
||||
"*rating_profiles":{"remote":true,"replicate":false},
|
||||
"*actions":{"remote":true,"replicate":false},
|
||||
"*action_plans": {"remote":true,"replicate":false},
|
||||
"*account_action_plans":{"remote":true,"replicate":false},
|
||||
"*action_triggers":{"remote":true,"replicate":false},
|
||||
"*shared_groups":{"remote":true,"replicate":false},
|
||||
"*timings": {"remote":true,"replicate":false},
|
||||
"*resource_profiles":{"remote":true,"replicate":false},
|
||||
"*resources":{"remote":true,"replicate":false},
|
||||
"*statqueue_profiles": {"remote":true,"replicate":false},
|
||||
"*statqueues": {"remote":true,"replicate":false},
|
||||
"*threshold_profiles": {"remote":true,"replicate":false},
|
||||
"*thresholds": {"remote":true,"replicate":false},
|
||||
"*filters": {"remote":true,"replicate":false},
|
||||
"*route_profiles":{"remote":true,"replicate":false},
|
||||
"*attribute_profiles":{"remote":true,"replicate":false},
|
||||
"*charger_profiles": {"remote":true,"replicate":false},
|
||||
"*dispatcher_profiles":{"remote":true,"replicate":false},
|
||||
"*dispatcher_hosts":{"remote":true,"replicate":false},
|
||||
"*rate_profiles":{"remote":true,"replicate":false},
|
||||
"*load_ids":{"remote":true,"replicate":false},
|
||||
"*indexes":{"remote":true, "replicate":false},
|
||||
"*action_profiles":{"remote":true,"replicate":false},
|
||||
"*account_profiles":{"remote":true,"replicate":false},
|
||||
},
|
||||
},
|
||||
|
||||
"stor_db": {
|
||||
"db_type": "mongo",
|
||||
"db_name": "cgrates",
|
||||
"db_port": 27017,
|
||||
},
|
||||
|
||||
|
||||
"rals": {
|
||||
"enabled": true,
|
||||
},
|
||||
|
||||
|
||||
"schedulers": {
|
||||
"enabled": true,
|
||||
},
|
||||
|
||||
|
||||
"apiers": {
|
||||
"enabled": true,
|
||||
"scheduler_conns": ["*internal"],
|
||||
},
|
||||
|
||||
"thresholds": {
|
||||
"enabled": true,
|
||||
},
|
||||
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
{
|
||||
"general": {
|
||||
"log_level": 7,
|
||||
"node_id" : "EngineMongo2",
|
||||
},
|
||||
|
||||
|
||||
"listen": {
|
||||
"rpc_json": ":2032",
|
||||
"rpc_gob": ":2033",
|
||||
"http": ":2380",
|
||||
},
|
||||
|
||||
|
||||
"rpc_conns": {
|
||||
"conn1": {
|
||||
"strategy": "*first",
|
||||
"conns": [{"address": "127.0.0.1:2012", "transport":"*json"}],
|
||||
},
|
||||
},
|
||||
|
||||
|
||||
"data_db": {
|
||||
"db_type": "redis",
|
||||
"db_port": 6379,
|
||||
"db_name": "11",
|
||||
"remote_conns": ["conn1"],
|
||||
"remote_conn_id": "engine2",
|
||||
"items":{
|
||||
"*accounts":{"remote":true,"replicate":false},
|
||||
"*reverse_destinations": {"remote":true,"replicate":false},
|
||||
"*destinations": {"remote":true,"replicate":false},
|
||||
"*rating_plans": {"remote":true,"replicate":false},
|
||||
"*rating_profiles":{"remote":true,"replicate":false},
|
||||
"*actions":{"remote":true,"replicate":false},
|
||||
"*action_plans": {"remote":true,"replicate":false},
|
||||
"*account_action_plans":{"remote":true,"replicate":false},
|
||||
"*action_triggers":{"remote":true,"replicate":false},
|
||||
"*shared_groups":{"remote":true,"replicate":false},
|
||||
"*timings": {"remote":true,"replicate":false},
|
||||
"*resource_profiles":{"remote":true,"replicate":false},
|
||||
"*resources":{"remote":true,"replicate":false},
|
||||
"*statqueue_profiles": {"remote":true,"replicate":false},
|
||||
"*statqueues": {"remote":true,"replicate":false},
|
||||
"*threshold_profiles": {"remote":true,"replicate":false},
|
||||
"*thresholds": {"remote":true,"replicate":false},
|
||||
"*filters": {"remote":true,"replicate":false},
|
||||
"*route_profiles":{"remote":true,"replicate":false},
|
||||
"*attribute_profiles":{"remote":true,"replicate":false},
|
||||
"*charger_profiles": {"remote":true,"replicate":false},
|
||||
"*dispatcher_profiles":{"remote":true,"replicate":false},
|
||||
"*dispatcher_hosts":{"remote":true,"replicate":false},
|
||||
"*rate_profiles":{"remote":true,"replicate":false},
|
||||
"*load_ids":{"remote":true,"replicate":false},
|
||||
"*indexes":{"remote":true, "replicate":false},
|
||||
"*action_profiles":{"remote":true,"replicate":false},
|
||||
"*account_profiles":{"remote":true,"replicate":false},
|
||||
},
|
||||
},
|
||||
|
||||
|
||||
"stor_db": {
|
||||
"db_password": "CGRateS.org",
|
||||
},
|
||||
|
||||
"rals": {
|
||||
"enabled": true,
|
||||
},
|
||||
|
||||
|
||||
"schedulers": {
|
||||
"enabled": true,
|
||||
},
|
||||
|
||||
|
||||
"apiers": {
|
||||
"enabled": true,
|
||||
"scheduler_conns": ["*internal"],
|
||||
},
|
||||
|
||||
"thresholds": {
|
||||
"enabled": true,
|
||||
},
|
||||
|
||||
}
|
||||
103
data/conf/samples/filtered_replication/internal/cgrates.json
Normal file
103
data/conf/samples/filtered_replication/internal/cgrates.json
Normal file
@@ -0,0 +1,103 @@
|
||||
{
|
||||
"general": {
|
||||
"log_level": 7,
|
||||
"node_id": "InternalEngine",
|
||||
},
|
||||
|
||||
|
||||
"listen": {
|
||||
"rpc_json": ":2012",
|
||||
"rpc_gob": ":2013",
|
||||
"http": ":2080",
|
||||
},
|
||||
|
||||
|
||||
"rpc_conns": {
|
||||
"conn2": {
|
||||
"strategy": "*broadcast_sync",
|
||||
"conns": [
|
||||
{"id": "engine1", "address": "127.0.0.1:2022", "transport":"*json"},
|
||||
{"id": "engine2", "address": "127.0.0.1:2032", "transport":"*json"}
|
||||
],
|
||||
},
|
||||
},
|
||||
|
||||
|
||||
"data_db": {
|
||||
"db_type": "*internal",
|
||||
"replication_conns": ["conn2"],
|
||||
"filtered_replication": true,
|
||||
"items":{
|
||||
"*accounts":{"remote":false,"replicate":true},
|
||||
"*reverse_destinations": {"remote":false,"replicate":true},
|
||||
"*destinations": {"remote":false,"replicate":true},
|
||||
"*rating_plans": {"remote":false,"replicate":true},
|
||||
"*rating_profiles":{"remote":false,"replicate":true},
|
||||
"*actions":{"remote":false,"replicate":true},
|
||||
"*action_plans": {"remote":false,"replicate":true},
|
||||
"*account_action_plans":{"remote":false,"replicate":true},
|
||||
"*action_triggers":{"remote":false,"replicate":true},
|
||||
"*shared_groups":{"remote":false,"replicate":true},
|
||||
"*timings": {"remote":false,"replicate":true},
|
||||
"*resource_profiles":{"remote":false,"replicate":true},
|
||||
"*resources":{"remote":false,"replicate":true},
|
||||
"*statqueue_profiles": {"remote":false,"replicate":true},
|
||||
"*statqueues": {"remote":false,"replicate":true},
|
||||
"*threshold_profiles": {"remote":false,"replicate":true},
|
||||
"*thresholds": {"remote":false,"replicate":true},
|
||||
"*filters": {"remote":false,"replicate":true},
|
||||
"*route_profiles":{"remote":false,"replicate":true},
|
||||
"*attribute_profiles":{"remote":false,"replicate":true},
|
||||
"*charger_profiles": {"remote":false,"replicate":true},
|
||||
"*dispatcher_profiles":{"remote":false,"replicate":true},
|
||||
"*dispatcher_hosts":{"remote":false,"replicate":true},
|
||||
"*indexes" :{"remote":false,"replicate":true},
|
||||
"*rate_profiles":{"remote":false,"replicate":true},
|
||||
"*load_ids":{"remote":false,"replicate":true},
|
||||
"*action_profiles":{"remote":false,"replicate":true},
|
||||
"*account_profiles":{"remote":false,"replicate":true},
|
||||
},
|
||||
},
|
||||
|
||||
|
||||
"caches":{
|
||||
"partitions": {
|
||||
"*replication_hosts": {"limit": -1, "ttl": "", "static_ttl": false, "replicate": false},
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
"stor_db": {
|
||||
"db_type": "*internal",
|
||||
},
|
||||
|
||||
|
||||
"rals": {
|
||||
"enabled": true,
|
||||
},
|
||||
|
||||
|
||||
"thresholds": {
|
||||
"enabled": true,
|
||||
"store_interval": "-1",
|
||||
},
|
||||
|
||||
|
||||
"resources": {
|
||||
"enabled": true,
|
||||
"store_interval": "-1",
|
||||
"thresholds_conns": ["*internal"],
|
||||
},
|
||||
|
||||
|
||||
"schedulers": {
|
||||
"enabled": true,
|
||||
},
|
||||
|
||||
|
||||
"apiers": {
|
||||
"enabled": true,
|
||||
"scheduler_conns": ["*internal"],
|
||||
},
|
||||
|
||||
}
|
||||
@@ -491,12 +491,11 @@ func (dm *DataManager) SetReverseDestination(destID string, prefixes []string, t
|
||||
return
|
||||
}
|
||||
if config.CgrConfig().DataDbCfg().Items[utils.MetaReverseDestinations].Replicate {
|
||||
var reply string
|
||||
if err = dm.connMgr.Call(config.CgrConfig().DataDbCfg().RplConns, nil,
|
||||
utils.ReplicatorSv1SetReverseDestination, &Destination{Id: destID, Prefixes: prefixes}, &reply); err != nil {
|
||||
err = utils.CastRPCErr(err)
|
||||
return
|
||||
}
|
||||
err = replicate(dm.connMgr, config.CgrConfig().DataDbCfg().RplConns,
|
||||
config.CgrConfig().DataDbCfg().RplFiltered,
|
||||
utils.ReverseDestinationPrefix, destID, // this are used to get the host IDs from cache
|
||||
utils.ReplicatorSv1SetReverseDestination,
|
||||
&Destination{Id: destID, Prefixes: prefixes})
|
||||
}
|
||||
return
|
||||
}
|
||||
@@ -1442,9 +1441,11 @@ func (dm *DataManager) RemoveTiming(id, transactionID string) (err error) {
|
||||
return errCh
|
||||
}
|
||||
if config.CgrConfig().DataDbCfg().Items[utils.MetaTimings].Replicate {
|
||||
var reply string
|
||||
dm.connMgr.Call(config.CgrConfig().DataDbCfg().RplConns, nil,
|
||||
utils.ReplicatorSv1RemoveTiming, id, &reply)
|
||||
replicate(dm.connMgr, config.CgrConfig().DataDbCfg().RplConns,
|
||||
config.CgrConfig().DataDbCfg().RplFiltered,
|
||||
utils.TimingsPrefix, id, // this are used to get the host IDs from cache
|
||||
utils.ReplicatorSv1RemoveTiming,
|
||||
id)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
1709
general_tests/filtered_replication_it_test.go
Normal file
1709
general_tests/filtered_replication_it_test.go
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user