diff --git a/apier/v1/apier_it_test.go b/apier/v1/apier_it_test.go index 7fc13dd1a..ec53b0b93 100644 --- a/apier/v1/apier_it_test.go +++ b/apier/v1/apier_it_test.go @@ -1158,7 +1158,7 @@ func TestApierSetAccount(t *testing.T) { func TestApierGetAccountActionPlan(t *testing.T) { var reply []*AccountActionTiming req := utils.TenantAccount{Tenant: "cgrates.org", Account: "dan7"} - if err := rater.Call("ApierV1.GetAccountActionPlan", req, &reply); err != nil { + if err := rater.Call(utils.ApierV1GetAccountActionPlan, req, &reply); err != nil { t.Error("Got error on ApierV1.GetAccountActionPlan: ", err.Error()) } else if len(reply) != 1 { t.Error("Unexpected action plan received: ", utils.ToJSON(reply)) @@ -1193,7 +1193,7 @@ func TestApierRemUniqueIDActionTiming(t *testing.T) { } var reply []*AccountActionTiming req := utils.TenantAccount{Tenant: "cgrates.org", Account: "dan4"} - if err := rater.Call("ApierV1.GetAccountActionPlan", req, &reply); err != nil { + if err := rater.Call(utils.ApierV1GetAccountActionPlan, req, &reply); err != nil { t.Error("Got error on ApierV1.GetAccountActionPlan: ", err.Error()) } else if len(reply) != 0 { t.Error("Action timings was not removed") diff --git a/cmd/cgr-tester/parallel/parallel.go b/cmd/cgr-tester/parallel/parallel.go index 969c42546..1e83d902a 100644 --- a/cmd/cgr-tester/parallel/parallel.go +++ b/cmd/cgr-tester/parallel/parallel.go @@ -25,6 +25,8 @@ import ( "log" "net/http" "sync" + + "github.com/cgrates/cgrates/utils" ) func main() { @@ -47,7 +49,7 @@ func main() { } wg.Wait() for index := 1; index < 1002; index++ { - resp, err := http.Post("http://localhost:2080/jsonrpc", "application/json", bytes.NewBuffer([]byte(fmt.Sprintf(`{"method": "ApierV1.GetAccountActionPlan","params": [{"Tenant":"reglo","Account":"100%d"}], "id":%d}`, index, index)))) + resp, err := http.Post("http://localhost:2080/jsonrpc", "application/json", bytes.NewBuffer([]byte(fmt.Sprintf(`{"method": "%s","params": [{"Tenant":"reglo","Account":"100%d"}], "id":%d}`, utils.ApierV1GetAccountActionPlan, index, index)))) if err != nil { log.Print("Post error: ", err) } diff --git a/console/account_actionplan_get.go b/console/account_actionplan_get.go index 838eade51..cfdfdefab 100644 --- a/console/account_actionplan_get.go +++ b/console/account_actionplan_get.go @@ -26,7 +26,7 @@ import ( func init() { c := &CmdGetAccountActionPlan{ name: "account_actionplan_get", - rpcMethod: "ApierV1.GetAccountActionPlan", + rpcMethod: utils.ApierV1GetAccountActionPlan, rpcParams: &utils.TenantAccount{}, } commands[c.Name()] = c diff --git a/engine/storage_redis.go b/engine/storage_redis.go index 12eaba14a..9bcfde6d7 100644 --- a/engine/storage_redis.go +++ b/engine/storage_redis.go @@ -345,7 +345,7 @@ func (rs *RedisStorage) getKeysForFilterIndexesKeys(fkeys []string) (keys []stri func (rs *RedisStorage) GetKeysForPrefix(prefix string) ([]string, error) { var r *redis.Resp if prefix == utils.ACTION_PLAN_PREFIX { //so we can avoid the full scan on scheduler reloads - r = rs.Cmd("SMEMBERS", "indx"+utils.ACTION_PLAN_PREFIX) + r = rs.Cmd("SMEMBERS", utils.ActionPlanIndexes) } else { r = rs.Cmd("KEYS", prefix+"*") } @@ -891,7 +891,7 @@ func (rs *RedisStorage) GetActionPlan(key string, skipCache bool, func (rs *RedisStorage) RemoveActionPlan(key string, transactionID string) error { cCommit := cacheCommit(transactionID) - rs.Cmd("SREM", "indx"+utils.ACTION_PLAN_PREFIX, utils.ACTION_PLAN_PREFIX+key) // should handle the error here? + rs.Cmd("SREM", utils.ActionPlanIndexes, utils.ACTION_PLAN_PREFIX+key) // should handle the error here? err := rs.Cmd("DEL", utils.ACTION_PLAN_PREFIX+key).Err Cache.Remove(utils.CacheActionPlans, key, cCommit, transactionID) @@ -903,7 +903,7 @@ func (rs *RedisStorage) SetActionPlan(key string, ats *ActionPlan, cCommit := cacheCommit(transactionID) if len(ats.ActionTimings) == 0 { // delete the key - rs.Cmd("SREM", "indx"+utils.ACTION_PLAN_PREFIX, utils.ACTION_PLAN_PREFIX+key) // should handle the error here? + rs.Cmd("SREM", utils.ActionPlanIndexes, utils.ACTION_PLAN_PREFIX+key) // should handle the error here? err = rs.Cmd("DEL", utils.ACTION_PLAN_PREFIX+key).Err Cache.Remove(utils.CacheActionPlans, key, cCommit, transactionID) @@ -928,7 +928,7 @@ func (rs *RedisStorage) SetActionPlan(key string, ats *ActionPlan, w := zlib.NewWriter(&b) w.Write(result) w.Close() - rs.Cmd("SADD", "indx"+utils.ACTION_PLAN_PREFIX, utils.ACTION_PLAN_PREFIX+key) // should handle the error here? + rs.Cmd("SADD", utils.ActionPlanIndexes, utils.ACTION_PLAN_PREFIX+key) // should handle the error here? return rs.Cmd("SET", utils.ACTION_PLAN_PREFIX+key, b.Bytes()).Err } diff --git a/general_tests/a1_it_test.go b/general_tests/a1_it_test.go index 03b048c5c..bb22eeaad 100644 --- a/general_tests/a1_it_test.go +++ b/general_tests/a1_it_test.go @@ -317,7 +317,7 @@ func TestA1itConcurrentAPs(t *testing.T) { wg.Add(3) go func(acnt string) { var atms []*v1.AccountActionTiming - if err := a1rpc.Call("ApierV1.GetAccountActionPlan", + if err := a1rpc.Call(utils.ApierV1GetAccountActionPlan, utils.TenantAccount{Tenant: "cgrates.org", Account: acnt}, &atms); err != nil { t.Error(err) //} else if len(atms) != 2 || atms[0].ActionPlanId != "PACKAGE_1" { diff --git a/utils/consts.go b/utils/consts.go index c87c139a4..266ebf216 100755 --- a/utils/consts.go +++ b/utils/consts.go @@ -460,8 +460,8 @@ const ( MetaStorDB = "*stordb" MetaDataDB = "*datadb" MetaWeight = "*weight" - MetaLC = "*lc" - MetaHC = "*hc" + MetaLC = "*lc" + MetaHC = "*hc" MetaQOS = "*qos" MetaReas = "*reas" MetaReds = "*reds" @@ -805,6 +805,7 @@ const ( ApierV1GetRatingProfileIDs = "ApierV1.GetRatingProfileIDs" ApierV1SetDataDBVersions = "ApierV1.SetDataDBVersions" ApierV1SetStorDBVersions = "ApierV1.SetStorDBVersions" + ApierV1GetAccountActionPlan = "ApierV1.GetAccountActionPlan" ) const ( @@ -1149,6 +1150,7 @@ const ( AttributeFilterIndexes = "afi_" ChargerFilterIndexes = "cfi_" DispatcherFilterIndexes = "dfi_" + ActionPlanIndexes = "api_" ) // Agents