diff --git a/apier/apier.go b/apier/apier.go index 4ff3b8693..8a20ece25 100644 --- a/apier/apier.go +++ b/apier/apier.go @@ -627,7 +627,7 @@ func (self *ApierV1) LoadTariffPlanFromFolder(attrs utils.AttrLoadTpFromFolder, if err := self.RatingDb.CacheRating(dstKeys, rpKeys, rpfKeys, rpAlsKeys); err != nil { return err } - if err := self.AccountDb.CacheAccounting(actKeys, shgKeys, accAliases); err != nil { + if err := self.AccountDb.CacheAccounting(actKeys, shgKeys, accAlsKeys); err != nil { return err } if self.Sched != nil { diff --git a/apier/tutfscsv_local_test.go b/apier/tutfscsv_local_test.go index bf66d3db7..d9264d144 100644 --- a/apier/tutfscsv_local_test.go +++ b/apier/tutfscsv_local_test.go @@ -104,9 +104,9 @@ func TestFsCsvStartFs(t *testing.T) { if !*testLocal { return } - exec.Command("pkill", "freeswitch").Run() // Just to make sure another one is not running, bit brutal maybe we can fine tune it + exec.Command("pkill", "freeswitch").Run() // Just to make sure no freeswitch is running go func() { - fs := exec.Command("/usr/share/cgrates/tutorials/fs_csv/freeswitch/etc/init.d/freeswitch", "start") + fs := exec.Command("sudo", "/usr/share/cgrates/tutorials/fs_csv/freeswitch/etc/init.d/freeswitch", "start") out, _ := fs.CombinedOutput() engine.Logger.Info(fmt.Sprintf("CgrEngine-TestFsCsv: %s", out)) }() @@ -120,7 +120,7 @@ func TestFsCsvStartEngine(t *testing.T) { } exec.Command("pkill", "cgr-engine").Run() // Just to make sure another one is not running, bit brutal maybe we can fine tune it go func() { - eng := exec.Command("/usr/share/cgrates/tutorials/fs_json/cgrates/etc/init.d/cgrates", "start") + eng := exec.Command("sudo", "/usr/share/cgrates/tutorials/fs_json/cgrates/etc/init.d/cgrates", "start") out, _ := eng.CombinedOutput() engine.Logger.Info(fmt.Sprintf("CgrEngine-TestFsCsv: %s", out)) }() @@ -144,14 +144,6 @@ func TestFsCsvEmptyCache(t *testing.T) { if !*testLocal { return } - reply := "" - arc := new(utils.ApiReloadCache) - // Simple test that command is executed without errors - if err := rater.Call("ApierV1.ReloadCache", arc, &reply); err != nil { - t.Error("Got error on ApierV1.ReloadCache: ", err.Error()) - } else if reply != "OK" { - t.Error("Calling ApierV1.ReloadCache got reply: ", reply) - } var rcvStats *utils.CacheStats expectedStats := &utils.CacheStats{Destinations: 0, RatingPlans: 0, RatingProfiles: 0, Actions: 0} var args utils.AttrCacheStats diff --git a/apier/tutfsjson_local_test.go b/apier/tutfsjson_local_test.go index 5219fb8ed..f262d11fd 100644 --- a/apier/tutfsjson_local_test.go +++ b/apier/tutfsjson_local_test.go @@ -109,7 +109,7 @@ func TestFsJsonStartFs(t *testing.T) { } exec.Command("pkill", "freeswitch").Run() // Just to make sure another one is not running, bit brutal maybe we can fine tune it go func() { - fs := exec.Command("/usr/share/cgrates/tutorials/fs_json/freeswitch/etc/init.d/freeswitch", "start") + fs := exec.Command("sudo", "/usr/share/cgrates/tutorials/fs_json/freeswitch/etc/init.d/freeswitch", "start") out, _ := fs.CombinedOutput() engine.Logger.Info(fmt.Sprintf("CgrEngine-TestFsJson: %s", out)) }() @@ -123,7 +123,7 @@ func TestFsJsonStartEngine(t *testing.T) { } exec.Command("pkill", "cgr-engine").Run() // Just to make sure another one is not running, bit brutal maybe we can fine tune it go func() { - eng := exec.Command("/usr/share/cgrates/tutorials/fs_json/cgrates/etc/init.d/cgrates", "start") + eng := exec.Command("sudo", "/usr/share/cgrates/tutorials/fs_json/cgrates/etc/init.d/cgrates", "start") out, _ := eng.CombinedOutput() engine.Logger.Info(fmt.Sprintf("CgrEngine-TestFsJson: %s", out)) }() @@ -147,14 +147,6 @@ func TestFsJsonEmptyCache(t *testing.T) { if !*testLocal { return } - reply := "" - arc := new(utils.ApiReloadCache) - // Simple test that command is executed without errors - if err := rater.Call("ApierV1.ReloadCache", arc, &reply); err != nil { - t.Error("Got error on ApierV1.ReloadCache: ", err.Error()) - } else if reply != "OK" { - t.Error("Calling ApierV1.ReloadCache got reply: ", reply) - } var rcvStats *utils.CacheStats expectedStats := &utils.CacheStats{Destinations: 0, RatingPlans: 0, RatingProfiles: 0, Actions: 0} var args utils.AttrCacheStats @@ -171,7 +163,7 @@ func TestFsJsonLoadTariffPlans(t *testing.T) { } reply := "" // Simple test that command is executed without errors - attrs := &utils.AttrLoadTpFromFolder{FolderPath: path.Join(*dataDir, "tutorials", "fs_csv", "cgrates", "tariffplans")} + attrs := &utils.AttrLoadTpFromFolder{FolderPath: path.Join(*dataDir, "tutorials", "fs_json", "cgrates", "tariffplans")} if err := rater.Call("ApierV1.LoadTariffPlanFromFolder", attrs, &reply); err != nil { t.Error("Got error on ApierV1.LoadTariffPlanFromFolder: ", err.Error()) } else if reply != "OK" { @@ -179,7 +171,7 @@ func TestFsJsonLoadTariffPlans(t *testing.T) { } time.Sleep(100 * time.Millisecond) // Give time for scheduler to execute topups var rcvStats *utils.CacheStats - expectedStats := &utils.CacheStats{Destinations: 3, RatingPlans: 1, RatingProfiles: 1, Actions: 2} + expectedStats := &utils.CacheStats{Destinations: 3, RatingPlans: 2, RatingProfiles: 2, Actions: 5} var args utils.AttrCacheStats if err := rater.Call("ApierV1.GetCacheStats", args, &rcvStats); err != nil { t.Error("Got error on ApierV1.GetCacheStats: ", err.Error()) diff --git a/data/tutorials/fs_json/cgrates/tariffplans/ActionPlans.csv b/data/tutorials/fs_json/cgrates/tariffplans/ActionPlans.csv index 16fe4024a..ca6e464e2 100644 --- a/data/tutorials/fs_json/cgrates/tariffplans/ActionPlans.csv +++ b/data/tutorials/fs_json/cgrates/tariffplans/ActionPlans.csv @@ -2,4 +2,4 @@ PACKAGE_10,TOPUP_RST_10,ASAP,10 PACKAGE_10_SHARED_A_5,TOPUP_RST_5,ASAP,10 PACKAGE_10_SHARED_A_5,TOPUP_RST_SHARED_5,ASAP,10 -USE_SHARED_A,SHARED_A_2,ASAP,10 +USE_SHARED_A,SHARED_A_0,ASAP,10 diff --git a/data/tutorials/fs_json/cgrates/tariffplans/Actions.csv b/data/tutorials/fs_json/cgrates/tariffplans/Actions.csv index ebb8e21fa..cc9d0d3e5 100644 --- a/data/tutorials/fs_json/cgrates/tariffplans/Actions.csv +++ b/data/tutorials/fs_json/cgrates/tariffplans/Actions.csv @@ -1,6 +1,6 @@ #ActionsTag,Action,BalanceType,Direction,Units,ExpiryTime,DestinationTag,RatingSubject,BalanceWeight,SharedGroup,ExtraParameters,Weight TOPUP_RST_10,*topup_reset,*monetary,*out,10,*unlimited,*any,,10,,,10 TOPUP_RST_5,*topup_reset,*monetary,*out,5,*unlimited,*any,,10,,,10 -TOPUP_RST_SHARED_5,*topup_reset,*monetary,*out,5,*unlimited,*any,,20,SHARED_A,,10 -SHARED_A_2,*topup_reset,*monetary,*out,2,*unlimited,*any,,10,SHARED_A,,10 +TOPUP_RST_SHARED_5,*topup,*monetary,*out,5,*unlimited,*any,,20,SHARED_A,,10 +SHARED_A_0,*topup_reset,*monetary,*out,0,*unlimited,*any,,10,SHARED_A,,10 LOG_WARNING,*log,,,,,,,,,,10 diff --git a/data/tutorials/fs_json/cgrates/tariffplans/SharedGroups.csv b/data/tutorials/fs_json/cgrates/tariffplans/SharedGroups.csv index d5713a194..c01defac4 100644 --- a/data/tutorials/fs_json/cgrates/tariffplans/SharedGroups.csv +++ b/data/tutorials/fs_json/cgrates/tariffplans/SharedGroups.csv @@ -1,2 +1,2 @@ #Id,Account,Strategy,RatingSubject -SHARED_A,*any,*highest_first, +SHARED_A,*any,*highest, diff --git a/engine/storage_redis.go b/engine/storage_redis.go index a04e271a3..a8ac83288 100644 --- a/engine/storage_redis.go +++ b/engine/storage_redis.go @@ -284,6 +284,7 @@ func (rs *RedisStorage) SetRatingProfile(rpf *RatingProfile) (err error) { } func (rs *RedisStorage) GetRpAlias(key string, checkDb bool) (alias string, err error) { + key = RP_ALIAS_PREFIX + key if x, err := cache2go.GetCached(key); err == nil { return x.(string), nil