mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-11 18:16:24 +05:00
Changed format %s to %q for IDs in tpreader.go and currently testing versions on datadb/stordb
This commit is contained in:
committed by
Dan Christian Bogos
parent
49fdef7e09
commit
cc7296bdb2
@@ -64,7 +64,7 @@ var (
|
||||
testConsoleItRPCConn,
|
||||
testConsoleItLoadTP,
|
||||
testConsoleItCacheClear,
|
||||
// testConsoleItDebitMax,
|
||||
testConsoleItDebitMax,
|
||||
testConsoleItThreshold,
|
||||
testConsoleItThresholdsProfileIds,
|
||||
testConsoleItThresholdsProfileSet,
|
||||
@@ -75,7 +75,6 @@ var (
|
||||
testConsoleItThresholdsProfileRemove,
|
||||
testConsoleItTriggersSet,
|
||||
testConsoleItTriggers,
|
||||
|
||||
testConsoleItSchedulerReload,
|
||||
testConsoleItSchedulerExecute,
|
||||
testConsoleItActionExecute,
|
||||
@@ -180,7 +179,7 @@ var (
|
||||
testConsoleItDispatchersHostRemove,
|
||||
testConsoleItAccountActionPlanGet,
|
||||
testConsoleItCacheItemIds,
|
||||
// testConsoleItCacheItemExpiryTime,
|
||||
testConsoleItCacheItemExpiryTime,
|
||||
testConsoleItSessionProcessMessage,
|
||||
testConsoleItSessionUpdate,
|
||||
testConsoleItSessionInitiate,
|
||||
@@ -190,7 +189,7 @@ var (
|
||||
testConsoleItCacheRemoveGroup,
|
||||
testConsoleItParse,
|
||||
testConsoleItSchedulerQueue,
|
||||
// testConsoleItCacheStats,
|
||||
testConsoleItCacheStats,
|
||||
testConsoleItReloadConfig,
|
||||
testConsoleItKillEngine,
|
||||
}
|
||||
@@ -4550,7 +4549,7 @@ func testConsoleItDebitMax(t *testing.T) {
|
||||
rcv.Timespans[0].Increments[0].BalanceInfo.Monetary.UUID = ""
|
||||
rcv.Timespans[0].Increments[1].BalanceInfo.Monetary.UUID = ""
|
||||
rcv.AccountSummary.BalanceSummaries[0].UUID = ""
|
||||
if !reflect.DeepEqual(&rcv, expected) {
|
||||
if !reflect.DeepEqual(rcv, expected) {
|
||||
t.Fatalf("Expected %v \n but received \n %v", utils.ToJSON(expected), utils.ToJSON(rcv))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -178,7 +178,7 @@ func (tpr *TpReader) LoadDestinationRates() (err error) {
|
||||
for _, dr := range drs.DestinationRates {
|
||||
rate, exists := tpr.rates[dr.RateId]
|
||||
if !exists {
|
||||
return fmt.Errorf("could not find rate for tag %v", dr.RateId)
|
||||
return fmt.Errorf("could not find rate for tag %q", dr.RateId)
|
||||
}
|
||||
dr.Rate = rate
|
||||
destinationExists := dr.DestinationId == utils.MetaAny
|
||||
@@ -191,7 +191,7 @@ func (tpr *TpReader) LoadDestinationRates() (err error) {
|
||||
}
|
||||
}
|
||||
if !destinationExists {
|
||||
return fmt.Errorf("could not get destination for tag %v", dr.DestinationId)
|
||||
return fmt.Errorf("could not get destination for tag %q", dr.DestinationId)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -217,7 +217,7 @@ func (tpr *TpReader) LoadRatingPlansFiltered(tag string) (bool, error) {
|
||||
if !exists {
|
||||
tptm, err := tpr.lr.GetTPTimings(tpr.tpid, rp.TimingId)
|
||||
if err != nil || len(tptm) == 0 {
|
||||
return false, fmt.Errorf("no timing with id %s: %v", rp.TimingId, err)
|
||||
return false, fmt.Errorf("no timing with id %q: %v", rp.TimingId, err)
|
||||
}
|
||||
tm, err = MapTPTimings(tptm)
|
||||
if err != nil {
|
||||
@@ -228,7 +228,7 @@ func (tpr *TpReader) LoadRatingPlansFiltered(tag string) (bool, error) {
|
||||
rp.SetTiming(tm[rp.TimingId])
|
||||
tpdrm, err := tpr.lr.GetTPDestinationRates(tpr.tpid, rp.DestinationRatesId, nil)
|
||||
if err != nil || len(tpdrm) == 0 {
|
||||
return false, fmt.Errorf("no DestinationRates profile with id %s: %v", rp.DestinationRatesId, err)
|
||||
return false, fmt.Errorf("no DestinationRates profile with id %q: %v", rp.DestinationRatesId, err)
|
||||
}
|
||||
drm, err := MapTPDestinationRates(tpdrm)
|
||||
if err != nil {
|
||||
@@ -237,7 +237,7 @@ func (tpr *TpReader) LoadRatingPlansFiltered(tag string) (bool, error) {
|
||||
for _, drate := range drm[rp.DestinationRatesId].DestinationRates {
|
||||
tprt, err := tpr.lr.GetTPRates(tpr.tpid, drate.RateId)
|
||||
if err != nil || len(tprt) == 0 {
|
||||
return false, fmt.Errorf("no Rates profile with id %s: %v", drate.RateId, err)
|
||||
return false, fmt.Errorf("no Rates profile with id %q: %v", drate.RateId, err)
|
||||
}
|
||||
rt, err := MapTPRates(tprt)
|
||||
if err != nil {
|
||||
@@ -259,7 +259,7 @@ func (tpr *TpReader) LoadRatingPlansFiltered(tag string) (bool, error) {
|
||||
} else if dbExists {
|
||||
continue
|
||||
} else if !dbExists { // if the error doesn't exists in datadb return error
|
||||
return false, fmt.Errorf("could not get destination for tag %v", drate.DestinationId)
|
||||
return false, fmt.Errorf("could not get destination for tag %q", drate.DestinationId)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@@ -291,12 +291,12 @@ func (tpr *TpReader) LoadRatingPlans() (err error) {
|
||||
for _, rplBnd := range rplBnds {
|
||||
t, exists := tpr.timings[rplBnd.TimingId]
|
||||
if !exists {
|
||||
return fmt.Errorf("could not get timing for tag %v", rplBnd.TimingId)
|
||||
return fmt.Errorf("could not get timing for tag %q", rplBnd.TimingId)
|
||||
}
|
||||
rplBnd.SetTiming(t)
|
||||
drs, exists := tpr.destinationRates[rplBnd.DestinationRatesId]
|
||||
if !exists {
|
||||
return fmt.Errorf("could not find destination rate for tag %v", rplBnd.DestinationRatesId)
|
||||
return fmt.Errorf("could not find destination rate for tag %q", rplBnd.DestinationRatesId)
|
||||
}
|
||||
plan, exists := tpr.ratingPlans[tag]
|
||||
if !exists {
|
||||
@@ -336,7 +336,7 @@ func (tpr *TpReader) LoadRatingProfilesFiltered(qriedRpf *utils.TPRatingProfile)
|
||||
}
|
||||
}
|
||||
if !exists {
|
||||
return fmt.Errorf("could not load rating plans for tag: %v", tpRa.RatingPlanId)
|
||||
return fmt.Errorf("could not load rating plans for tag: %q", tpRa.RatingPlanId)
|
||||
}
|
||||
resultRatingProfile.RatingPlanActivations = append(resultRatingProfile.RatingPlanActivations,
|
||||
&RatingPlanActivation{
|
||||
@@ -377,7 +377,7 @@ func (tpr *TpReader) LoadRatingProfiles() (err error) {
|
||||
}
|
||||
}
|
||||
if !exists {
|
||||
return fmt.Errorf("could not load rating plans for tag: %v", tpRa.RatingPlanId)
|
||||
return fmt.Errorf("could not load rating plans for tag: %q", tpRa.RatingPlanId)
|
||||
}
|
||||
rpf.RatingPlanActivations = append(rpf.RatingPlanActivations,
|
||||
&RatingPlanActivation{
|
||||
@@ -515,7 +515,7 @@ func (tpr *TpReader) LoadActions() (err error) {
|
||||
if !found {
|
||||
if timing, err = tpr.dm.GetTiming(timingID, false,
|
||||
utils.NonTransactional); err != nil {
|
||||
return fmt.Errorf("error: <%s> querying timing with id: <%s>",
|
||||
return fmt.Errorf("error: %v querying timing with id: %q",
|
||||
err.Error(), timingID)
|
||||
}
|
||||
}
|
||||
@@ -548,15 +548,15 @@ func (tpr *TpReader) LoadActionPlans() (err error) {
|
||||
_, exists := tpr.actions[at.ActionsId]
|
||||
if !exists && tpr.dm.dataDB != nil {
|
||||
if exists, err = tpr.dm.HasData(utils.ActionPrefix, at.ActionsId, ""); err != nil {
|
||||
return fmt.Errorf("[ActionPlans] Error querying actions: %v - %s", at.ActionsId, err.Error())
|
||||
return fmt.Errorf("[ActionPlans] Error querying actions: %q - %s", at.ActionsId, err.Error())
|
||||
}
|
||||
}
|
||||
if !exists {
|
||||
return fmt.Errorf("[ActionPlans] Could not load the action for tag: %v", at.ActionsId)
|
||||
return fmt.Errorf("[ActionPlans] Could not load the action for tag: %q", at.ActionsId)
|
||||
}
|
||||
t, exists := tpr.timings[at.TimingId]
|
||||
if !exists {
|
||||
return fmt.Errorf("[ActionPlans] Could not load the timing for tag: %v", at.TimingId)
|
||||
return fmt.Errorf("[ActionPlans] Could not load the timing for tag: %q", at.TimingId)
|
||||
}
|
||||
var actPln *ActionPlan
|
||||
if actPln, exists = tpr.actionPlans[atID]; !exists {
|
||||
@@ -707,7 +707,7 @@ func (tpr *TpReader) LoadAccountActionsFiltered(qriedAA *utils.TPAccountActions)
|
||||
if err != nil {
|
||||
return errors.New(err.Error() + " (ActionPlan): " + accountAction.ActionPlanId)
|
||||
} else if len(tpap) == 0 {
|
||||
return fmt.Errorf("no action plan with id <%s>", accountAction.ActionPlanId)
|
||||
return fmt.Errorf("no action plan with id %q", accountAction.ActionPlanId)
|
||||
}
|
||||
aps := MapTPActionTimings(tpap)
|
||||
var actionPlan *ActionPlan
|
||||
@@ -718,7 +718,7 @@ func (tpr *TpReader) LoadAccountActionsFiltered(qriedAA *utils.TPAccountActions)
|
||||
if actions, err := tpr.lr.GetTPActions(tpr.tpid, at.ActionsId); err != nil {
|
||||
return errors.New(err.Error() + " (Actions): " + at.ActionsId)
|
||||
} else if len(actions) == 0 {
|
||||
return fmt.Errorf("no action with id <%s>", at.ActionsId)
|
||||
return fmt.Errorf("no action with id %q", at.ActionsId)
|
||||
}
|
||||
var t *utils.TPTiming
|
||||
if at.TimingId != utils.MetaASAP {
|
||||
@@ -726,7 +726,7 @@ func (tpr *TpReader) LoadAccountActionsFiltered(qriedAA *utils.TPAccountActions)
|
||||
if err != nil {
|
||||
return errors.New(err.Error() + " (Timing): " + at.TimingId)
|
||||
} else if len(tptm) == 0 {
|
||||
return fmt.Errorf("no timing with id <%s>", at.TimingId)
|
||||
return fmt.Errorf("no timing with id %q", at.TimingId)
|
||||
}
|
||||
tm, err := MapTPTimings(tptm)
|
||||
if err != nil {
|
||||
@@ -996,7 +996,7 @@ func (tpr *TpReader) LoadAccountActionsFiltered(qriedAA *utils.TPAccountActions)
|
||||
EndTime: timing.EndTime,
|
||||
})
|
||||
} else {
|
||||
return fmt.Errorf("could not find timing: %v", timingID)
|
||||
return fmt.Errorf("could not find timing: %q", timingID)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1048,13 +1048,13 @@ func (tpr *TpReader) LoadAccountActions() (err error) {
|
||||
for _, aa := range storAts {
|
||||
aaKeyID := aa.KeyId()
|
||||
if _, alreadyDefined := tpr.accountActions[aa.KeyId()]; alreadyDefined {
|
||||
return fmt.Errorf("duplicate account action found: %s", aaKeyID)
|
||||
return fmt.Errorf("duplicate account action found: %q", aaKeyID)
|
||||
}
|
||||
var aTriggers ActionTriggers
|
||||
if aa.ActionTriggersId != "" {
|
||||
var exists bool
|
||||
if aTriggers, exists = tpr.actionsTriggers[aa.ActionTriggersId]; !exists {
|
||||
return fmt.Errorf("could not get action triggers for tag %s", aa.ActionTriggersId)
|
||||
return fmt.Errorf("could not get action triggers for tag %q", aa.ActionTriggersId)
|
||||
}
|
||||
}
|
||||
ub := &Account{
|
||||
@@ -1071,7 +1071,7 @@ func (tpr *TpReader) LoadAccountActions() (err error) {
|
||||
if tpr.dm.dataDB != nil {
|
||||
if actionPlan, err = tpr.dm.GetActionPlan(aa.ActionPlanId, false, true, utils.NonTransactional); err != nil {
|
||||
if err.Error() == utils.ErrNotFound.Error() {
|
||||
return fmt.Errorf("could not get action plan for tag %v", aa.ActionPlanId)
|
||||
return fmt.Errorf("could not get action plan for tag %q", aa.ActionPlanId)
|
||||
}
|
||||
return err
|
||||
}
|
||||
@@ -1079,7 +1079,7 @@ func (tpr *TpReader) LoadAccountActions() (err error) {
|
||||
tpr.actionPlans[aa.ActionPlanId] = actionPlan
|
||||
}
|
||||
if !exists {
|
||||
return fmt.Errorf("could not get action plan for tag %v", aa.ActionPlanId)
|
||||
return fmt.Errorf("could not get action plan for tag %q", aa.ActionPlanId)
|
||||
}
|
||||
}
|
||||
if actionPlan.AccountIDs == nil {
|
||||
@@ -1205,7 +1205,7 @@ func (tpr *TpReader) LoadAttributeProfilesFiltered(tag string) (err error) {
|
||||
}
|
||||
for _, at := range attr.Attributes {
|
||||
if at.Path == utils.EmptyString { // we do not suppot empty Path in Attributes
|
||||
err = fmt.Errorf("empty path in AttributeProfile <%s>", utils.ConcatenatedKey(attr.Tenant, attr.ID))
|
||||
err = fmt.Errorf("empty path in AttributeProfile %q", utils.ConcatenatedKey(attr.Tenant, attr.ID))
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,8 +20,11 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
package engine
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"log"
|
||||
"os/exec"
|
||||
"path"
|
||||
"reflect"
|
||||
"testing"
|
||||
|
||||
"github.com/cgrates/cgrates/config"
|
||||
@@ -39,6 +42,27 @@ var (
|
||||
testVersionsFlush,
|
||||
testVersion,
|
||||
testVersionsFlush,
|
||||
testVersionsWithEngine,
|
||||
testUpdateVersionsAccounts,
|
||||
testUpdateVersionsActionPlans,
|
||||
testUpdateVersionsActionTriggers,
|
||||
testUpdateVersionsActions,
|
||||
testUpdateVersionsAttributes,
|
||||
testUpdateVersionsChargers,
|
||||
testUpdateVersionsDestinations,
|
||||
testUpdateVersionsDispatchers,
|
||||
testUpdateVersionsLoadIDs,
|
||||
testUpdateVersionsRQF,
|
||||
testUpdateVersionsRatingPlan,
|
||||
testUpdateVersionsRatingProfile,
|
||||
testUpdateVersionsResource,
|
||||
testUpdateVersionsReverseDestinations,
|
||||
testUpdateVersionsRoutes,
|
||||
testUpdateVersionsSharedGroups,
|
||||
testUpdateVersionsStats,
|
||||
testUpdateVersionsSubscribers,
|
||||
testUpdateVersionsThresholds,
|
||||
testUpdateVersionsTiming,
|
||||
}
|
||||
)
|
||||
|
||||
@@ -197,3 +221,492 @@ func testVersion(t *testing.T) {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func testVersionsWithEngine(t *testing.T) {
|
||||
cmd := exec.Command("cgr-engine", `-config_path=/usr/share/cgrates/conf/samples/tutmysql`, `-scheduled_shutdown=4ms`)
|
||||
output := bytes.NewBuffer(nil)
|
||||
cmd.Stdout = output
|
||||
if err := cmd.Run(); err != nil {
|
||||
t.Log(cmd.Args)
|
||||
t.Log(output.String())
|
||||
t.Fatal(err)
|
||||
}
|
||||
if output.String() != utils.EmptyString {
|
||||
t.Fatalf("Expected empty but received: %q", output.String())
|
||||
}
|
||||
dataDbQueryVersions, err := dm3.DataDB().GetVersions("")
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
storDbQueryVersions, err := storageDb.GetVersions("")
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
expectDataDb := Versions{
|
||||
"Accounts": 3,
|
||||
"ActionProfiles": 1,
|
||||
"Actions": 2,
|
||||
"Attributes": 7,
|
||||
"Chargers": 2,
|
||||
"Dispatchers": 2,
|
||||
"LoadIDs": 1,
|
||||
"RQF": 5,
|
||||
"RateProfiles": 1,
|
||||
"Resource": 1,
|
||||
"Routes": 2,
|
||||
"Stats": 4,
|
||||
"Subscribers": 1,
|
||||
"Thresholds": 4,
|
||||
}
|
||||
expectStorDb := Versions{
|
||||
"CDRs": 2,
|
||||
"CostDetails": 2,
|
||||
"SessionSCosts": 3,
|
||||
"TpAccountActions": 1,
|
||||
"TpActionPlans": 1,
|
||||
"TpActionTriggers": 1,
|
||||
"TpActions": 1,
|
||||
"TpChargers": 1,
|
||||
"TpDestinationRates": 1,
|
||||
"TpDestinations": 1,
|
||||
"TpDispatchers": 1,
|
||||
"TpFilters": 1,
|
||||
"TpRates": 1,
|
||||
"TpRatingPlan": 1,
|
||||
"TpRatingPlans": 1,
|
||||
"TpRatingProfile": 1,
|
||||
"TpRatingProfiles": 1,
|
||||
"TpResource": 1,
|
||||
"TpResources": 1,
|
||||
"TpRoutes": 1,
|
||||
"TpSharedGroups": 1,
|
||||
"TpStats": 1,
|
||||
"TpThresholds": 1,
|
||||
"TpTiming": 1,
|
||||
}
|
||||
if !reflect.DeepEqual(dataDbQueryVersions, expectDataDb) {
|
||||
t.Fatalf("Expected %v \n but received \n %v", utils.ToJSON(expectDataDb), utils.ToJSON(dataDbQueryVersions))
|
||||
} else if !reflect.DeepEqual(storDbQueryVersions, expectStorDb) {
|
||||
t.Fatalf("Expected %v \n but received \n %v", utils.ToJSON(expectStorDb), utils.ToJSON(storDbQueryVersions))
|
||||
}
|
||||
}
|
||||
|
||||
func testUpdateVersionsAccounts(t *testing.T) {
|
||||
newVersions := Versions{
|
||||
"Accounts": 2.,
|
||||
}
|
||||
if err := dm3.DataDB().SetVersions(newVersions, true); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
cmd := exec.Command("cgr-engine", `-config_path=/usr/share/cgrates/conf/samples/tutmysql`, `-scheduled_shutdown=4ms`)
|
||||
output := bytes.NewBuffer(nil)
|
||||
cmd.Stdout = output
|
||||
if err := cmd.Run(); err != nil {
|
||||
t.Log(cmd.Args)
|
||||
t.Log(output.String())
|
||||
t.Fatal(err)
|
||||
}
|
||||
errExpect := "Migration needed: please backup cgr data and run : <cgr-migrator -exec=*accounts>\n"
|
||||
if output.String() != errExpect {
|
||||
t.Fatalf("Expected %q \n but received: \n %q", errExpect, output.String())
|
||||
}
|
||||
}
|
||||
|
||||
func testUpdateVersionsActionPlans(t *testing.T) {
|
||||
newVersions := Versions{
|
||||
"ActionPlans": 5.,
|
||||
}
|
||||
if err := dm3.DataDB().SetVersions(newVersions, true); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
cmd := exec.Command("cgr-engine", `-config_path=/usr/share/cgrates/conf/samples/tutmysql`, `-scheduled_shutdown=4ms`)
|
||||
output := bytes.NewBuffer(nil)
|
||||
cmd.Stdout = output
|
||||
if err := cmd.Run(); err != nil {
|
||||
t.Log(cmd.Args)
|
||||
t.Log(output.String())
|
||||
t.Fatal(err)
|
||||
}
|
||||
errExpect := "Migration needed: please backup cgr data and run : <cgr-migrator -exec=*action_plans>\n"
|
||||
if output.String() != errExpect {
|
||||
t.Fatalf("Expected %q \n but received: \n %q", errExpect, output.String())
|
||||
}
|
||||
}
|
||||
|
||||
func testUpdateVersionsActionTriggers(t *testing.T) {
|
||||
newVersions := Versions{
|
||||
"ActionTriggers": 5.,
|
||||
}
|
||||
if err := dm3.DataDB().SetVersions(newVersions, true); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
cmd := exec.Command("cgr-engine", `-config_path=/usr/share/cgrates/conf/samples/tutmysql`, `-scheduled_shutdown=4ms`)
|
||||
output := bytes.NewBuffer(nil)
|
||||
cmd.Stdout = output
|
||||
if err := cmd.Run(); err != nil {
|
||||
t.Log(cmd.Args)
|
||||
t.Log(output.String())
|
||||
t.Fatal(err)
|
||||
}
|
||||
errExpect := "Migration needed: please backup cgr data and run : <cgr-migrator -exec=*action_triggers>\n"
|
||||
if output.String() != errExpect {
|
||||
t.Fatalf("Expected %q \n but received: \n %q", errExpect, output.String())
|
||||
}
|
||||
}
|
||||
|
||||
func testUpdateVersionsActions(t *testing.T) {
|
||||
newVersions := Versions{
|
||||
"Actions": 5.,
|
||||
}
|
||||
if err := dm3.DataDB().SetVersions(newVersions, true); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
cmd := exec.Command("cgr-engine", `-config_path=/usr/share/cgrates/conf/samples/tutmysql`, `-scheduled_shutdown=4ms`)
|
||||
output := bytes.NewBuffer(nil)
|
||||
cmd.Stdout = output
|
||||
if err := cmd.Run(); err != nil {
|
||||
t.Log(cmd.Args)
|
||||
t.Log(output.String())
|
||||
t.Fatal(err)
|
||||
}
|
||||
errExpect := "Migration needed: please backup cgr data and run : <cgr-migrator -exec=*actions>\n"
|
||||
if output.String() != errExpect {
|
||||
t.Fatalf("Expected %q \n but received: \n %q", errExpect, output.String())
|
||||
}
|
||||
}
|
||||
|
||||
func testUpdateVersionsChargers(t *testing.T) {
|
||||
newVersions := Versions{
|
||||
"Chargers": 5.,
|
||||
}
|
||||
if err := dm3.DataDB().SetVersions(newVersions, true); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
cmd := exec.Command("cgr-engine", `-config_path=/usr/share/cgrates/conf/samples/tutmysql`, `-scheduled_shutdown=4ms`)
|
||||
output := bytes.NewBuffer(nil)
|
||||
cmd.Stdout = output
|
||||
if err := cmd.Run(); err != nil {
|
||||
t.Log(cmd.Args)
|
||||
t.Log(output.String())
|
||||
t.Fatal(err)
|
||||
}
|
||||
errExpect := "Migration needed: please backup cgr data and run : <cgr-migrator -exec=*chargers>\n"
|
||||
if output.String() != errExpect {
|
||||
t.Fatalf("Expected %q \n but received: \n %q", errExpect, output.String())
|
||||
}
|
||||
}
|
||||
|
||||
func testUpdateVersionsDestinations(t *testing.T) {
|
||||
newVersions := Versions{
|
||||
"Destinations": 5.,
|
||||
}
|
||||
if err := dm3.DataDB().SetVersions(newVersions, true); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
cmd := exec.Command("cgr-engine", `-config_path=/usr/share/cgrates/conf/samples/tutmysql`, `-scheduled_shutdown=4ms`)
|
||||
output := bytes.NewBuffer(nil)
|
||||
cmd.Stdout = output
|
||||
if err := cmd.Run(); err != nil {
|
||||
t.Log(cmd.Args)
|
||||
t.Log(output.String())
|
||||
t.Fatal(err)
|
||||
}
|
||||
errExpect := "Migration needed: please backup cgr data and run : <cgr-migrator -exec=*destinations>\n"
|
||||
if output.String() != errExpect {
|
||||
t.Fatalf("Expected %q \n but received: \n %q", errExpect, output.String())
|
||||
}
|
||||
}
|
||||
|
||||
func testUpdateVersionsDispatchers(t *testing.T) {
|
||||
newVersions := Versions{
|
||||
"Dispatchers": 5.,
|
||||
}
|
||||
if err := dm3.DataDB().SetVersions(newVersions, true); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
cmd := exec.Command("cgr-engine", `-config_path=/usr/share/cgrates/conf/samples/tutmysql`, `-scheduled_shutdown=4ms`)
|
||||
output := bytes.NewBuffer(nil)
|
||||
cmd.Stdout = output
|
||||
if err := cmd.Run(); err != nil {
|
||||
t.Log(cmd.Args)
|
||||
t.Log(output.String())
|
||||
t.Fatal(err)
|
||||
}
|
||||
errExpect := "Migration needed: please backup cgr data and run : <cgr-migrator -exec=*dispatchers>\n"
|
||||
if output.String() != errExpect {
|
||||
t.Fatalf("Expected %q \n but received: \n %q", errExpect, output.String())
|
||||
}
|
||||
}
|
||||
|
||||
func testUpdateVersionsLoadIDs(t *testing.T) {
|
||||
newVersions := Versions{
|
||||
"LoadIDs": 5.,
|
||||
}
|
||||
if err := dm3.DataDB().SetVersions(newVersions, true); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
cmd := exec.Command("cgr-engine", `-config_path=/usr/share/cgrates/conf/samples/tutmysql`, `-scheduled_shutdown=4ms`)
|
||||
output := bytes.NewBuffer(nil)
|
||||
cmd.Stdout = output
|
||||
if err := cmd.Run(); err != nil {
|
||||
t.Log(cmd.Args)
|
||||
t.Log(output.String())
|
||||
t.Fatal(err)
|
||||
}
|
||||
errExpect := "Migration needed: please backup cgr data and run : <cgr-migrator -exec=*load_ids>\n"
|
||||
if output.String() != errExpect {
|
||||
t.Fatalf("Expected %q \n but received: \n %q", errExpect, output.String())
|
||||
}
|
||||
}
|
||||
|
||||
func testUpdateVersionsAttributes(t *testing.T) {
|
||||
newVersions := Versions{
|
||||
"Attributes": 2.,
|
||||
}
|
||||
if err := dm3.DataDB().SetVersions(newVersions, true); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
cmd := exec.Command("cgr-engine", `-config_path=/usr/share/cgrates/conf/samples/tutmysql`, `-scheduled_shutdown=4ms`)
|
||||
output := bytes.NewBuffer(nil)
|
||||
cmd.Stdout = output
|
||||
if err := cmd.Run(); err != nil {
|
||||
t.Log(cmd.Args)
|
||||
t.Log(output.String())
|
||||
t.Fatal(err)
|
||||
}
|
||||
errExpect := "Migration needed: please backup cgr data and run : <cgr-migrator -exec=*attributes>\n"
|
||||
if output.String() != errExpect {
|
||||
t.Fatalf("Expected %q \n but received: \n %q", errExpect, output.String())
|
||||
}
|
||||
}
|
||||
|
||||
func testUpdateVersionsRQF(t *testing.T) {
|
||||
newVersions := Versions{
|
||||
"RQF": 8.,
|
||||
}
|
||||
if err := dm3.DataDB().SetVersions(newVersions, true); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
cmd := exec.Command("cgr-engine", `-config_path=/usr/share/cgrates/conf/samples/tutmysql`, `-scheduled_shutdown=4ms`)
|
||||
output := bytes.NewBuffer(nil)
|
||||
cmd.Stdout = output
|
||||
if err := cmd.Run(); err != nil {
|
||||
t.Log(cmd.Args)
|
||||
t.Log(output.String())
|
||||
t.Fatal(err)
|
||||
}
|
||||
errExpect := "Migration needed: please backup cgr data and run : <cgr-migrator -exec=*filters>\n"
|
||||
if output.String() != errExpect {
|
||||
t.Fatalf("Expected %q \n but received: \n %q", errExpect, output.String())
|
||||
}
|
||||
}
|
||||
|
||||
func testUpdateVersionsRatingPlan(t *testing.T) {
|
||||
newVersions := Versions{
|
||||
"RatingPlan": 5.,
|
||||
}
|
||||
if err := dm3.DataDB().SetVersions(newVersions, true); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
cmd := exec.Command("cgr-engine", `-config_path=/usr/share/cgrates/conf/samples/tutmysql`, `-scheduled_shutdown=4ms`)
|
||||
output := bytes.NewBuffer(nil)
|
||||
cmd.Stdout = output
|
||||
if err := cmd.Run(); err != nil {
|
||||
t.Log(cmd.Args)
|
||||
t.Log(output.String())
|
||||
t.Fatal(err)
|
||||
}
|
||||
errExpect := "Migration needed: please backup cgr data and run : <cgr-migrator -exec=*rating_plan>\n"
|
||||
if output.String() != errExpect {
|
||||
t.Fatalf("Expected %q \n but received: \n %q", errExpect, output.String())
|
||||
}
|
||||
}
|
||||
|
||||
func testUpdateVersionsRatingProfile(t *testing.T) {
|
||||
newVersions := Versions{
|
||||
"RatingProfile": 5.,
|
||||
}
|
||||
if err := dm3.DataDB().SetVersions(newVersions, true); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
cmd := exec.Command("cgr-engine", `-config_path=/usr/share/cgrates/conf/samples/tutmysql`, `-scheduled_shutdown=4ms`)
|
||||
output := bytes.NewBuffer(nil)
|
||||
cmd.Stdout = output
|
||||
if err := cmd.Run(); err != nil {
|
||||
t.Log(cmd.Args)
|
||||
t.Log(output.String())
|
||||
t.Fatal(err)
|
||||
}
|
||||
errExpect := "Migration needed: please backup cgr data and run : <cgr-migrator -exec=*rating_profile>\n"
|
||||
if output.String() != errExpect {
|
||||
t.Fatalf("Expected %q \n but received: \n %q", errExpect, output.String())
|
||||
}
|
||||
}
|
||||
|
||||
func testUpdateVersionsResource(t *testing.T) {
|
||||
newVersions := Versions{
|
||||
"Resource": 5.,
|
||||
}
|
||||
if err := dm3.DataDB().SetVersions(newVersions, true); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
cmd := exec.Command("cgr-engine", `-config_path=/usr/share/cgrates/conf/samples/tutmysql`, `-scheduled_shutdown=4ms`)
|
||||
output := bytes.NewBuffer(nil)
|
||||
cmd.Stdout = output
|
||||
if err := cmd.Run(); err != nil {
|
||||
t.Log(cmd.Args)
|
||||
t.Log(output.String())
|
||||
t.Fatal(err)
|
||||
}
|
||||
errExpect := "Migration needed: please backup cgr data and run : <cgr-migrator -exec=*resource>\n"
|
||||
if output.String() != errExpect {
|
||||
t.Fatalf("Expected %q \n but received: \n %q", errExpect, output.String())
|
||||
}
|
||||
}
|
||||
|
||||
func testUpdateVersionsReverseDestinations(t *testing.T) {
|
||||
newVersions := Versions{
|
||||
"ReverseDestinations": 5.,
|
||||
}
|
||||
if err := dm3.DataDB().SetVersions(newVersions, true); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
cmd := exec.Command("cgr-engine", `-config_path=/usr/share/cgrates/conf/samples/tutmysql`, `-scheduled_shutdown=4ms`)
|
||||
output := bytes.NewBuffer(nil)
|
||||
cmd.Stdout = output
|
||||
if err := cmd.Run(); err != nil {
|
||||
t.Log(cmd.Args)
|
||||
t.Log(output.String())
|
||||
t.Fatal(err)
|
||||
}
|
||||
errExpect := "Migration needed: please backup cgr data and run : <cgr-migrator -exec=*reverse_destinations>\n"
|
||||
if output.String() != errExpect {
|
||||
t.Fatalf("Expected %q \n but received: \n %q", errExpect, output.String())
|
||||
}
|
||||
}
|
||||
|
||||
func testUpdateVersionsRoutes(t *testing.T) {
|
||||
newVersions := Versions{
|
||||
"Routes": 5.,
|
||||
}
|
||||
if err := dm3.DataDB().SetVersions(newVersions, true); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
cmd := exec.Command("cgr-engine", `-config_path=/usr/share/cgrates/conf/samples/tutmysql`, `-scheduled_shutdown=4ms`)
|
||||
output := bytes.NewBuffer(nil)
|
||||
cmd.Stdout = output
|
||||
if err := cmd.Run(); err != nil {
|
||||
t.Log(cmd.Args)
|
||||
t.Log(output.String())
|
||||
t.Fatal(err)
|
||||
}
|
||||
errExpect := "Migration needed: please backup cgr data and run : <cgr-migrator -exec=*routes>\n"
|
||||
if output.String() != errExpect {
|
||||
t.Fatalf("Expected %q \n but received: \n %q", errExpect, output.String())
|
||||
}
|
||||
}
|
||||
|
||||
func testUpdateVersionsSharedGroups(t *testing.T) {
|
||||
newVersions := Versions{
|
||||
"SharedGroups": 5.,
|
||||
}
|
||||
if err := dm3.DataDB().SetVersions(newVersions, true); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
cmd := exec.Command("cgr-engine", `-config_path=/usr/share/cgrates/conf/samples/tutmysql`, `-scheduled_shutdown=4ms`)
|
||||
output := bytes.NewBuffer(nil)
|
||||
cmd.Stdout = output
|
||||
if err := cmd.Run(); err != nil {
|
||||
t.Log(cmd.Args)
|
||||
t.Log(output.String())
|
||||
t.Fatal(err)
|
||||
}
|
||||
errExpect := "Migration needed: please backup cgr data and run : <cgr-migrator -exec=*shared_groups>\n"
|
||||
if output.String() != errExpect {
|
||||
t.Fatalf("Expected %q \n but received: \n %q", errExpect, output.String())
|
||||
}
|
||||
}
|
||||
|
||||
func testUpdateVersionsStats(t *testing.T) {
|
||||
newVersions := Versions{
|
||||
"Stats": 5.,
|
||||
}
|
||||
if err := dm3.DataDB().SetVersions(newVersions, true); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
cmd := exec.Command("cgr-engine", `-config_path=/usr/share/cgrates/conf/samples/tutmysql`, `-scheduled_shutdown=4ms`)
|
||||
output := bytes.NewBuffer(nil)
|
||||
cmd.Stdout = output
|
||||
if err := cmd.Run(); err != nil {
|
||||
t.Log(cmd.Args)
|
||||
t.Log(output.String())
|
||||
t.Fatal(err)
|
||||
}
|
||||
errExpect := "Migration needed: please backup cgr data and run : <cgr-migrator -exec=*stats>\n"
|
||||
if output.String() != errExpect {
|
||||
t.Fatalf("Expected %q \n but received: \n %q", errExpect, output.String())
|
||||
}
|
||||
}
|
||||
|
||||
func testUpdateVersionsSubscribers(t *testing.T) {
|
||||
newVersions := Versions{
|
||||
"Subscribers": 5.,
|
||||
}
|
||||
if err := dm3.DataDB().SetVersions(newVersions, true); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
cmd := exec.Command("cgr-engine", `-config_path=/usr/share/cgrates/conf/samples/tutmysql`, `-scheduled_shutdown=4ms`)
|
||||
output := bytes.NewBuffer(nil)
|
||||
cmd.Stdout = output
|
||||
if err := cmd.Run(); err != nil {
|
||||
t.Log(cmd.Args)
|
||||
t.Log(output.String())
|
||||
t.Fatal(err)
|
||||
}
|
||||
errExpect := "Migration needed: please backup cgr data and run : <cgr-migrator -exec=*subscribers>\n"
|
||||
if output.String() != errExpect {
|
||||
t.Fatalf("Expected %q \n but received: \n %q", errExpect, output.String())
|
||||
}
|
||||
}
|
||||
|
||||
func testUpdateVersionsThresholds(t *testing.T) {
|
||||
newVersions := Versions{
|
||||
"Thresholds": 5.,
|
||||
}
|
||||
if err := dm3.DataDB().SetVersions(newVersions, true); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
cmd := exec.Command("cgr-engine", `-config_path=/usr/share/cgrates/conf/samples/tutmysql`, `-scheduled_shutdown=4ms`)
|
||||
output := bytes.NewBuffer(nil)
|
||||
cmd.Stdout = output
|
||||
if err := cmd.Run(); err != nil {
|
||||
t.Log(cmd.Args)
|
||||
t.Log(output.String())
|
||||
t.Fatal(err)
|
||||
}
|
||||
errExpect := "Migration needed: please backup cgr data and run : <cgr-migrator -exec=*thresholds>\n"
|
||||
if output.String() != errExpect {
|
||||
t.Fatalf("Expected %q \n but received: \n %q", errExpect, output.String())
|
||||
}
|
||||
}
|
||||
|
||||
func testUpdateVersionsTiming(t *testing.T) {
|
||||
newVersions := Versions{
|
||||
"Timing": 5.,
|
||||
}
|
||||
if err := dm3.DataDB().SetVersions(newVersions, true); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
cmd := exec.Command("cgr-engine", `-config_path=/usr/share/cgrates/conf/samples/tutmysql`, `-scheduled_shutdown=4ms`)
|
||||
output := bytes.NewBuffer(nil)
|
||||
cmd.Stdout = output
|
||||
if err := cmd.Run(); err != nil {
|
||||
t.Log(cmd.Args)
|
||||
t.Log(output.String())
|
||||
t.Fatal(err)
|
||||
}
|
||||
errExpect := "Migration needed: please backup cgr data and run : <cgr-migrator -exec=*timing>\n"
|
||||
if output.String() != errExpect {
|
||||
t.Fatalf("Expected %q \n but received: \n %q", errExpect, output.String())
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user