mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-15 13:19:53 +05:00
Add migrate TPSuppliers from one db to another
This commit is contained in:
committed by
Dan Christian Bogos
parent
46223299a8
commit
c6947dbb28
@@ -101,7 +101,7 @@ var sTestsOnStorIT = []func(t *testing.T){
|
||||
testOnStorITCRUDThresholdProfile,
|
||||
testOnStorITCRUDThreshold,
|
||||
testOnStorITCRUDFilter,
|
||||
testOnStorITCRUDLCRProfile,
|
||||
testOnStorITCRUDSupplierProfile,
|
||||
}
|
||||
|
||||
func TestOnStorITRedisConnect(t *testing.T) {
|
||||
@@ -2400,7 +2400,7 @@ func testOnStorITCRUDFilter(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func testOnStorITCRUDLCRProfile(t *testing.T) {
|
||||
func testOnStorITCRUDSupplierProfile(t *testing.T) {
|
||||
splProfile := &SupplierProfile{
|
||||
Tenant: "cgrates.org",
|
||||
ID: "SPRF_1",
|
||||
|
||||
@@ -131,8 +131,6 @@ func (m *Migrator) Migrate(taskIDs []string) (err error, stats map[string]int) {
|
||||
err = m.migrateStats()
|
||||
case utils.MetaThresholds:
|
||||
err = m.migrateThresholds()
|
||||
case utils.MetaSuppliers:
|
||||
err = m.migrateSupplierProfiles()
|
||||
//only Move
|
||||
case utils.MetaRatingPlans:
|
||||
err = m.migrateRatingPlans()
|
||||
@@ -162,6 +160,8 @@ func (m *Migrator) Migrate(taskIDs []string) (err error, stats map[string]int) {
|
||||
err = m.migrateSubscribers()
|
||||
case utils.MetaDerivedChargersV:
|
||||
err = m.migrateDerivedChargers()
|
||||
case utils.MetaSuppliers:
|
||||
err = m.migrateSupplierProfiles()
|
||||
//TPS
|
||||
case utils.MetaTpRatingPlans:
|
||||
err = m.migrateTPratingplans()
|
||||
|
||||
@@ -40,13 +40,16 @@ var (
|
||||
// subtests to be executed for each migrator
|
||||
var sTestsITMigrator = []func(t *testing.T){
|
||||
testFlush,
|
||||
testMigratorAccounts,
|
||||
testMigratorActionPlans,
|
||||
testMigratorActionTriggers,
|
||||
testMigratorActions,
|
||||
testMigratorSharedGroups,
|
||||
testMigratorStats,
|
||||
testMigratorTPRatingProfile,
|
||||
/*
|
||||
testMigratorAccounts,
|
||||
testMigratorActionPlans,
|
||||
testMigratorActionTriggers,
|
||||
testMigratorActions,
|
||||
testMigratorSharedGroups,
|
||||
testMigratorStats,
|
||||
testMigratorTPRatingProfile,
|
||||
*/
|
||||
testMigratorTPSuppliers,
|
||||
testFlush,
|
||||
}
|
||||
|
||||
@@ -1047,32 +1050,36 @@ func testMigratorTPRatingProfile(t *testing.T) {
|
||||
}
|
||||
|
||||
func testMigratorTPSuppliers(t *testing.T) {
|
||||
tpSplPr := &utils.TPSupplier{
|
||||
TPid: "TP1",
|
||||
Tenant: "cgrates.org",
|
||||
ID: "SUPL_1",
|
||||
FilterIDs: []string{"FLTR_ACNT_dan"},
|
||||
ActivationInterval: &utils.TPActivationInterval{
|
||||
ActivationTime: "2014-07-29T15:00:00Z",
|
||||
ExpiryTime: "",
|
||||
},
|
||||
Sorting: "*lowest_cost",
|
||||
SortingParams: []string{},
|
||||
Suppliers: []*utils.TPRequestSupplier{
|
||||
&utils.TPRequestSupplier{
|
||||
ID: "supplier1",
|
||||
FilterIDs: []string{"FLTR_1"},
|
||||
RatingPlanIDs: []string{"RPL_1"},
|
||||
ResourceIDs: []string{"ResGroup1"},
|
||||
StatIDs: []string{"Stat1"},
|
||||
tpSplPr := []*utils.TPSupplier{
|
||||
&utils.TPSupplier{
|
||||
TPid: "SupplierTPID12",
|
||||
Tenant: "cgrates.org",
|
||||
ID: "SUPL_1",
|
||||
FilterIDs: []string{"FLTR_ACNT_dan"},
|
||||
ActivationInterval: &utils.TPActivationInterval{
|
||||
ActivationTime: "2014-07-29T15:00:00Z",
|
||||
ExpiryTime: "",
|
||||
},
|
||||
Sorting: "*lowest_cost",
|
||||
SortingParams: []string{},
|
||||
Suppliers: []*utils.TPRequestSupplier{
|
||||
&utils.TPRequestSupplier{
|
||||
ID: "supplier1",
|
||||
AccountIDs: []string{"Account1"},
|
||||
FilterIDs: []string{"FLTR_1"},
|
||||
RatingPlanIDs: []string{"RPL_1"},
|
||||
ResourceIDs: []string{"ResGroup1"},
|
||||
StatIDs: []string{"Stat1"},
|
||||
Weight: 10,
|
||||
},
|
||||
},
|
||||
Blocker: false,
|
||||
Weight: 20,
|
||||
},
|
||||
Blocker: false,
|
||||
Weight: 20,
|
||||
}
|
||||
switch dbtype {
|
||||
case Move:
|
||||
if err := mig.InStorDB().SetTPSuppliers([]*utils.TPSupplier{tpSplPr}); err != nil {
|
||||
if err := mig.InStorDB().SetTPSuppliers(tpSplPr); err != nil {
|
||||
t.Error("Error when setting Stats ", err.Error())
|
||||
}
|
||||
currentVersion := engine.CurrentDataDBVersions()
|
||||
@@ -1084,12 +1091,12 @@ func testMigratorTPSuppliers(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Error("Error when migrating Stats ", err.Error())
|
||||
}
|
||||
result, err := mig.OutStorDB().GetTPSuppliers(tpSplPr.TPid, tpSplPr.ID)
|
||||
result, err := mig.OutStorDB().GetTPSuppliers(tpSplPr[0].TPid, tpSplPr[0].ID)
|
||||
if err != nil {
|
||||
t.Error("Error when getting Stats ", err.Error())
|
||||
t.Error("Error when getting TPSupplier ", err.Error())
|
||||
}
|
||||
if !reflect.DeepEqual(tpSplPr, result[0]) {
|
||||
t.Errorf("Expecting: %+v, received: %+v", tpSplPr, result[0])
|
||||
if !reflect.DeepEqual(tpSplPr, result) {
|
||||
t.Errorf("Expecting: %+v, received: %+v", tpSplPr, result)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user