diff --git a/apier/v1/dm_remote_it_test.go b/apier/v1/dm_remote_it_test.go index 7507fcffe..e8839aa98 100644 --- a/apier/v1/dm_remote_it_test.go +++ b/apier/v1/dm_remote_it_test.go @@ -57,22 +57,22 @@ var sTestsInternalRemoteIT = []func(t *testing.T){ testInternalRemoteITStartEngine, testInternalRemoteITRPCConn, testInternalRemoteLoadDataInEngineTwo, - //testInternalRemoteITGetAccount, - //testInternalRemoteITGetAttribute, - //testInternalRemoteITGetThreshold, - //testInternalRemoteITGetThresholdProfile, - //testInternalRemoteITGetResource, - //testInternalRemoteITGetResourceProfile, - //testInternalRemoteITGetStatQueueProfile, - //testInternalRemoteITGetSupplier, - //testInternalRemoteITGetFilter, - //testInternalRemoteITGetRatingPlan, - //testInternalRemoteITGetRatingProfile, - //testInternalRemoteITGetAction, - //testInternalRemoteITGetActionPlan, - //testInternalRemoteITGetAccountActionPlan, - //testInternalRemoteITGetDestination, - //testInternalRemoteITGetReverseDestination, + testInternalRemoteITGetAccount, + testInternalRemoteITGetAttribute, + testInternalRemoteITGetThreshold, + testInternalRemoteITGetThresholdProfile, + testInternalRemoteITGetResource, + testInternalRemoteITGetResourceProfile, + testInternalRemoteITGetStatQueueProfile, + testInternalRemoteITGetSupplier, + testInternalRemoteITGetFilter, + testInternalRemoteITGetRatingPlan, + testInternalRemoteITGetRatingProfile, + testInternalRemoteITGetAction, + testInternalRemoteITGetActionPlan, + testInternalRemoteITGetAccountActionPlan, + testInternalRemoteITGetDestination, + testInternalRemoteITGetReverseDestination, testInternalReplicationSetThreshold, testInternalMatchThreshold, testInternalRemoteITKillEngine, @@ -640,6 +640,7 @@ func testInternalReplicationSetThreshold(t *testing.T) { } else if result != utils.OK { t.Error("Unexpected reply returned", result) } + time.Sleep(50 * time.Millisecond) if err := internalRPC.Call("ApierV1.GetThresholdProfile", &utils.TenantID{Tenant: "cgrates.org", ID: "THD_Replication"}, &reply); err != nil { t.Error(err) @@ -742,10 +743,8 @@ func testInternalMatchThreshold(t *testing.T) { utils.Account: "1001", }, } - if err := internalRPC.Call(utils.ThresholdSv1ProcessEvent, ev2, &ids); err != nil { + if err := internalRPC.Call(utils.ThresholdSv1ProcessEvent, ev2, &ids); err == nil || err.Error() != utils.ErrNotFound.Error() { t.Error(err) - } else if !reflect.DeepEqual(ids, eIDs) { - t.Errorf("Expecting ids: %s, received: %s", eIDs, ids) } } diff --git a/apier/v1/replicator.go b/apier/v1/replicator.go index cd6bf64da..905725dab 100644 --- a/apier/v1/replicator.go +++ b/apier/v1/replicator.go @@ -494,6 +494,14 @@ func (rplSv1 *ReplicatorSv1) SetDispatcherHost(dpp *engine.DispatcherHost, reply return nil } +func (rplSv1 *ReplicatorSv1) RemoveThreshold(args *utils.TenantID, reply *string) error { + if err := rplSv1.dm.DataDB().RemoveThresholdDrv(args.Tenant, args.ID); err != nil { + return err + } + *reply = utils.OK + return nil +} + func (rplSv1 *ReplicatorSv1) SetLoadIDs(loadIDs map[string]int64, reply *string) error { if err := rplSv1.dm.DataDB().SetLoadIDsDrv(loadIDs); err != nil { return err diff --git a/engine/datamanager.go b/engine/datamanager.go index f51b37c0d..7c32f64b0 100644 --- a/engine/datamanager.go +++ b/engine/datamanager.go @@ -321,7 +321,9 @@ func (dm *DataManager) GetDestination(key string, skipCache bool, transactionID if err != nil { if err == utils.ErrNotFound && dm.rmtConns != nil && config.CgrConfig().DataDbCfg().Items[utils.MetaDestinations].Remote { - err = dm.rmtConns.Call(utils.ReplicatorSv1GetDestination, key, &dest) + if err = dm.rmtConns.Call(utils.ReplicatorSv1GetDestination, key, &dest); err == nil { + err = dm.dataDB.SetDestinationDrv(dest, utils.NonTransactional) + } } if err != nil { err = utils.CastRPCErr(err) @@ -558,15 +560,16 @@ func (dm *DataManager) GetThreshold(tenant, id string, if err != nil { if err == utils.ErrNotFound && config.CgrConfig().DataDbCfg().Items[utils.MetaThresholds].Remote { - err = dm.rmtConns.Call(utils.ReplicatorSv1GetThreshold, - &utils.TenantID{Tenant: tenant, ID: id}, &th) + if err = dm.rmtConns.Call(utils.ReplicatorSv1GetThreshold, + &utils.TenantID{Tenant: tenant, ID: id}, &th); err == nil { + err = dm.dataDB.SetThresholdDrv(th) + } } if err != nil { err = utils.CastRPCErr(err) if err == utils.ErrNotFound && cacheWrite { Cache.Set(utils.CacheThresholds, tntID, nil, nil, cacheCommit(transactionID), transactionID) - } return nil, err } @@ -596,6 +599,11 @@ func (dm *DataManager) RemoveThreshold(tenant, id, transactionID string) (err er if err = dm.DataDB().RemoveThresholdDrv(tenant, id); err != nil { return } + if config.CgrConfig().DataDbCfg().Items[utils.MetaThresholds].Replicate { + var reply string + dm.rplConns.Call(utils.ReplicatorSv1RemoveThreshold, + &utils.TenantID{Tenant: tenant, ID: id}, &reply) + } return } diff --git a/utils/consts.go b/utils/consts.go index 7f7debe25..aa38788d8 100755 --- a/utils/consts.go +++ b/utils/consts.go @@ -842,6 +842,7 @@ const ( ReplicatorSv1SetDispatcherProfile = "ReplicatorSv1.SetDispatcherProfile" ReplicatorSv1SetDispatcherHost = "ReplicatorSv1.SetDispatcherHost" ReplicatorSv1SetLoadIDs = "ReplicatorSv1.SetLoadIDs" + ReplicatorSv1RemoveThreshold = "ReplicatorSv1.RemoveThreshold" ) // ApierV1 APIs