diff --git a/cmd/cgr-migrator/cgr-migrator.go b/cmd/cgr-migrator/cgr-migrator.go
index d012a2672..bf73587d6 100755
--- a/cmd/cgr-migrator/cgr-migrator.go
+++ b/cmd/cgr-migrator/cgr-migrator.go
@@ -227,8 +227,10 @@ func main() {
if mgrCfg.StorDBName != *outStorDBName || mgrCfg.StorDBType != *outStorDBName || mgrCfg.StorDBHost != *outStorDBHost {
sameStorDB = false
}
- m, err := migrator.NewMigrator(dmIN, dmOUT, mgrCfg.DataDbType, mgrCfg.DBDataEncoding, storDB, mgrCfg.StorDBType, outDataDB,
- *outDataDBType, mgrCfg.DBDataEncoding, instorDB, *outStorDBType, *dryRun, sameDataDB, sameStorDB, *datadb_versions, *stordb_versions)
+ m, err := migrator.NewMigrator(dmIN, dmOUT, mgrCfg.DataDbType, mgrCfg.DBDataEncoding,
+ storDBIn, storDBOut, mgrCfg.StorDBType, outDataDB,
+ *outDataDBType, mgrCfg.DBDataEncoding, outStorDB,
+ *outStorDBType, *dryRun, sameDataDB, sameStorDB, *datadb_versions, *stordb_versions)
if err != nil {
log.Fatal(err)
}
diff --git a/migrator/cdrs_it_test.go b/migrator/cdrs_it_test.go
index 9093243eb..e474e1dda 100755
--- a/migrator/cdrs_it_test.go
+++ b/migrator/cdrs_it_test.go
@@ -153,6 +153,8 @@ func testCdrITMigrateAndMove(t *testing.T) {
}
if rcvCDRs, _, err := cdrMigrator.storDBOut.GetCDRs(new(utils.CDRsFilter), false); err != utils.ErrNotFound {
t.Error(err)
+ } else if len(rcvCDRs) != 0 {
+ t.Errorf("Unexpected number of CDRs returned: %d", len(rcvCDRs))
}
err, _ = cdrMigrator.Migrate([]string{utils.MetaCDRs})
if err != nil {
diff --git a/migrator/tp_resources_it_test.go b/migrator/tp_resources_it_test.go
index e14a035a6..da4026802 100644
--- a/migrator/tp_resources_it_test.go
+++ b/migrator/tp_resources_it_test.go
@@ -18,144 +18,144 @@ You should have received a copy of the GNU General Public License
along with this program. If not, see
*/
-// package migrator
+package migrator
-// import (
-// "log"
-// "path"
-// "reflect"
-// "testing"
+import (
+ "log"
+ "path"
+ "reflect"
+ "testing"
-// "github.com/cgrates/cgrates/config"
-// "github.com/cgrates/cgrates/engine"
-// "github.com/cgrates/cgrates/utils"
-// )
+ "github.com/cgrates/cgrates/config"
+ "github.com/cgrates/cgrates/engine"
+ "github.com/cgrates/cgrates/utils"
+)
-// var (
-// tpResPathIn string
-// tpResPathOut string
-// tpResCfgIn *config.CGRConfig
-// tpResCfgOut *config.CGRConfig
-// tpResMigrator *Migrator
-// tpResources []*utils.TPResource
-// )
+var (
+ tpResPathIn string
+ tpResPathOut string
+ tpResCfgIn *config.CGRConfig
+ tpResCfgOut *config.CGRConfig
+ tpResMigrator *Migrator
+ tpResources []*utils.TPResource
+)
-// var sTestsTpResIT = []func(t *testing.T){
-// testTpResITConnect,
-// testTpResITFlush,
-// testTpResITPopulate,
-// testTpResITMove,
-// testTpResITCheckData,
-// }
+var sTestsTpResIT = []func(t *testing.T){
+ testTpResITConnect,
+ testTpResITFlush,
+ testTpResITPopulate,
+ testTpResITMove,
+ testTpResITCheckData,
+}
-// func TestTpResMove(t *testing.T) {
-// for _, stest := range sTestsTpResIT {
-// t.Run("TestTpResMove", stest)
-// }
-// }
+func TestTpResMove(t *testing.T) {
+ for _, stest := range sTestsTpResIT {
+ t.Run("TestTpResMove", stest)
+ }
+}
-// func testTpResITConnect(t *testing.T) {
-// var err error
-// tpResPathIn = path.Join(*dataDir, "conf", "samples", "tutmongo")
-// tpResCfgIn, err = config.NewCGRConfigFromFolder(tpResPathIn)
-// if err != nil {
-// t.Fatal(err)
-// }
-// tpResPathOut = path.Join(*dataDir, "conf", "samples", "tutmysql")
-// tpResCfgOut, err = config.NewCGRConfigFromFolder(tpResPathOut)
-// if err != nil {
-// t.Fatal(err)
-// }
-// storDBIn, err := engine.ConfigureStorDB(tpResCfgIn.StorDBType, tpResCfgIn.StorDBHost,
-// tpResCfgIn.StorDBPort, tpResCfgIn.StorDBName,
-// tpResCfgIn.StorDBUser, tpResCfgIn.StorDBPass,
-// config.CgrConfig().StorDBMaxOpenConns,
-// config.CgrConfig().StorDBMaxIdleConns,
-// config.CgrConfig().StorDBConnMaxLifetime,
-// config.CgrConfig().StorDBCDRSIndexes)
-// if err != nil {
-// log.Fatal(err)
-// }
-// storDBOut, err := engine.ConfigureStorDB(tpResCfgOut.StorDBType,
-// tpResCfgOut.StorDBHost, tpResCfgOut.StorDBPort, tpResCfgOut.StorDBName,
-// tpResCfgOut.StorDBUser, tpResCfgOut.StorDBPass,
-// config.CgrConfig().StorDBMaxOpenConns,
-// config.CgrConfig().StorDBMaxIdleConns,
-// config.CgrConfig().StorDBConnMaxLifetime,
-// config.CgrConfig().StorDBCDRSIndexes)
-// if err != nil {
-// log.Fatal(err)
-// }
-// tpResMigrator, err = NewMigrator(nil, nil, tpResCfgIn.DataDbType,
-// tpResCfgIn.DBDataEncoding, storDBIn, storDBOut, tpResCfgIn.StorDBType, nil,
-// tpResCfgIn.DataDbType, tpResCfgIn.DBDataEncoding, nil,
-// tpResCfgIn.StorDBType, false, false, false, false, false)
-// if err != nil {
-// log.Fatal(err)
-// }
-// }
+func testTpResITConnect(t *testing.T) {
+ var err error
+ tpResPathIn = path.Join(*dataDir, "conf", "samples", "tutmongo")
+ tpResCfgIn, err = config.NewCGRConfigFromFolder(tpResPathIn)
+ if err != nil {
+ t.Fatal(err)
+ }
+ tpResPathOut = path.Join(*dataDir, "conf", "samples", "tutmysql")
+ tpResCfgOut, err = config.NewCGRConfigFromFolder(tpResPathOut)
+ if err != nil {
+ t.Fatal(err)
+ }
+ storDBIn, err := engine.ConfigureStorDB(tpResCfgIn.StorDBType, tpResCfgIn.StorDBHost,
+ tpResCfgIn.StorDBPort, tpResCfgIn.StorDBName,
+ tpResCfgIn.StorDBUser, tpResCfgIn.StorDBPass,
+ config.CgrConfig().StorDBMaxOpenConns,
+ config.CgrConfig().StorDBMaxIdleConns,
+ config.CgrConfig().StorDBConnMaxLifetime,
+ config.CgrConfig().StorDBCDRSIndexes)
+ if err != nil {
+ log.Fatal(err)
+ }
+ storDBOut, err := engine.ConfigureStorDB(tpResCfgOut.StorDBType,
+ tpResCfgOut.StorDBHost, tpResCfgOut.StorDBPort, tpResCfgOut.StorDBName,
+ tpResCfgOut.StorDBUser, tpResCfgOut.StorDBPass,
+ config.CgrConfig().StorDBMaxOpenConns,
+ config.CgrConfig().StorDBMaxIdleConns,
+ config.CgrConfig().StorDBConnMaxLifetime,
+ config.CgrConfig().StorDBCDRSIndexes)
+ if err != nil {
+ log.Fatal(err)
+ }
+ tpResMigrator, err = NewMigrator(nil, nil, tpResCfgIn.DataDbType,
+ tpResCfgIn.DBDataEncoding, storDBIn, storDBOut, tpResCfgIn.StorDBType, nil,
+ tpResCfgIn.DataDbType, tpResCfgIn.DBDataEncoding, nil,
+ tpResCfgIn.StorDBType, false, false, false, false, false)
+ if err != nil {
+ log.Fatal(err)
+ }
+}
-// func testTpResITFlush(t *testing.T) {
-// if err := tpResMigrator.storDBIn.Flush(
-// path.Join(tpResCfgIn.DataFolderPath, "storage", tpResCfgIn.StorDBType)); err != nil {
-// t.Error(err)
-// }
+func testTpResITFlush(t *testing.T) {
+ if err := tpResMigrator.storDBIn.Flush(
+ path.Join(tpResCfgIn.DataFolderPath, "storage", tpResCfgIn.StorDBType)); err != nil {
+ t.Error(err)
+ }
-// if err := tpResMigrator.storDBOut.Flush(
-// path.Join(tpResCfgOut.DataFolderPath, "storage", tpResCfgOut.StorDBType)); err != nil {
-// t.Error(err)
-// }
-// }
+ if err := tpResMigrator.storDBOut.Flush(
+ path.Join(tpResCfgOut.DataFolderPath, "storage", tpResCfgOut.StorDBType)); err != nil {
+ t.Error(err)
+ }
+}
-// func testTpResITPopulate(t *testing.T) {
-// tpResources = []*utils.TPResource{
-// &utils.TPResource{
-// Tenant: "cgrates.org",
-// TPid: "TPR1",
-// ID: "ResGroup1",
-// FilterIDs: []string{"FLTR_1"},
-// ActivationInterval: &utils.TPActivationInterval{
-// ActivationTime: "2014-07-29T15:00:00Z",
-// ExpiryTime: "",
-// },
-// UsageTTL: "1s",
-// Limit: "7",
-// AllocationMessage: "",
-// Blocker: true,
-// Stored: true,
-// Weight: 20,
-// ThresholdIDs: []string{"ValOne", "ValTwo"},
-// },
-// }
-// if err := tpResMigrator.storDBIn.SetTPResources(tpResources); err != nil {
-// t.Error("Error when setting TpFilter ", err.Error())
-// }
-// currentVersion := engine.CurrentStorDBVersions()
-// err := tpResMigrator.storDBOut.SetVersions(currentVersion, false)
-// if err != nil {
-// t.Error("Error when setting version for TpFilter ", err.Error())
-// }
-// }
+func testTpResITPopulate(t *testing.T) {
+ tpResources = []*utils.TPResource{
+ &utils.TPResource{
+ Tenant: "cgrates.org",
+ TPid: "TPR1",
+ ID: "ResGroup1",
+ FilterIDs: []string{"FLTR_1"},
+ ActivationInterval: &utils.TPActivationInterval{
+ ActivationTime: "2014-07-29T15:00:00Z",
+ ExpiryTime: "",
+ },
+ UsageTTL: "1s",
+ Limit: "7",
+ AllocationMessage: "",
+ Blocker: true,
+ Stored: true,
+ Weight: 20,
+ ThresholdIDs: []string{"ValOne", "ValTwo"},
+ },
+ }
+ if err := tpResMigrator.storDBIn.SetTPResources(tpResources); err != nil {
+ t.Error("Error when setting TpFilter ", err.Error())
+ }
+ currentVersion := engine.CurrentStorDBVersions()
+ err := tpResMigrator.storDBOut.SetVersions(currentVersion, false)
+ if err != nil {
+ t.Error("Error when setting version for TpFilter ", err.Error())
+ }
+}
-// func testTpResITMove(t *testing.T) {
-// err, _ := tpResMigrator.Migrate([]string{utils.MetaTpResources})
-// if err != nil {
-// t.Error("Error when migrating TpFilter ", err.Error())
-// }
-// }
+func testTpResITMove(t *testing.T) {
+ err, _ := tpResMigrator.Migrate([]string{utils.MetaTpResources})
+ if err != nil {
+ t.Error("Error when migrating TpFilter ", err.Error())
+ }
+}
-// func testTpResITCheckData(t *testing.T) {
-// result, err := tpResMigrator.storDBOut.GetTPResources(
-// tpResources[0].TPid, tpResources[0].ID)
-// if err != nil {
-// t.Error("Error when getting TpFilter ", err.Error())
-// }
-// if !reflect.DeepEqual(tpResources[0], result[0]) {
-// t.Errorf("Expecting: %+v, received: %+v", tpResources[0], result[0])
-// }
-// result, err = tpResMigrator.storDBIn.GetTPResources(
-// tpResources[0].TPid, tpResources[0].ID)
-// if err != utils.ErrNotFound {
-// t.Error(err)
-// }
-// }
+func testTpResITCheckData(t *testing.T) {
+ result, err := tpResMigrator.storDBOut.GetTPResources(
+ tpResources[0].TPid, tpResources[0].ID)
+ if err != nil {
+ t.Error("Error when getting TpFilter ", err.Error())
+ }
+ if !reflect.DeepEqual(tpResources[0], result[0]) {
+ t.Errorf("Expecting: %+v, received: %+v", tpResources[0], result[0])
+ }
+ result, err = tpResMigrator.storDBIn.GetTPResources(
+ tpResources[0].TPid, tpResources[0].ID)
+ if err != utils.ErrNotFound {
+ t.Error(err)
+ }
+}
diff --git a/migrator/tp_stats_it_test.go b/migrator/tp_stats_it_test.go
index 64b2b1719..4b27d0e93 100644
--- a/migrator/tp_stats_it_test.go
+++ b/migrator/tp_stats_it_test.go
@@ -18,149 +18,149 @@ You should have received a copy of the GNU General Public License
along with this program. If not, see
*/
-// package migrator
+package migrator
-// import (
-// "log"
-// "path"
-// "reflect"
-// "testing"
+import (
+ "log"
+ "path"
+ "reflect"
+ "testing"
-// "github.com/cgrates/cgrates/config"
-// "github.com/cgrates/cgrates/engine"
-// "github.com/cgrates/cgrates/utils"
-// )
+ "github.com/cgrates/cgrates/config"
+ "github.com/cgrates/cgrates/engine"
+ "github.com/cgrates/cgrates/utils"
+)
-// var (
-// tpStatsPathIn string
-// tpStatsPathOut string
-// tpStatsCfgIn *config.CGRConfig
-// tpStatsCfgOut *config.CGRConfig
-// tpStatsMigrator *Migrator
-// tpStats []*utils.TPStats
-// )
+var (
+ tpStatsPathIn string
+ tpStatsPathOut string
+ tpStatsCfgIn *config.CGRConfig
+ tpStatsCfgOut *config.CGRConfig
+ tpStatsMigrator *Migrator
+ tpStats []*utils.TPStats
+)
-// var sTestsTpStatsIT = []func(t *testing.T){
-// testTpStatsITConnect,
-// testTpStatsITFlush,
-// testTpStatsITPopulate,
-// testTpStatsITMove,
-// testTpStatsITCheckData,
-// }
+var sTestsTpStatsIT = []func(t *testing.T){
+ testTpStatsITConnect,
+ testTpStatsITFlush,
+ testTpStatsITPopulate,
+ testTpStatsITMove,
+ testTpStatsITCheckData,
+}
-// func TestTpStatsMove(t *testing.T) {
-// for _, stest := range sTestsTpStatsIT {
-// t.Run("TestTpStatsMove", stest)
-// }
-// }
+func TestTpStatsMove(t *testing.T) {
+ for _, stest := range sTestsTpStatsIT {
+ t.Run("TestTpStatsMove", stest)
+ }
+}
-// func testTpStatsITConnect(t *testing.T) {
-// var err error
-// tpStatsPathIn = path.Join(*dataDir, "conf", "samples", "tutmongo")
-// tpStatsCfgIn, err = config.NewCGRConfigFromFolder(tpStatsPathIn)
-// if err != nil {
-// t.Fatal(err)
-// }
-// tpStatsPathOut = path.Join(*dataDir, "conf", "samples", "tutmysql")
-// tpStatsCfgOut, err = config.NewCGRConfigFromFolder(tpStatsPathOut)
-// if err != nil {
-// t.Fatal(err)
-// }
-// storDBIn, err := engine.ConfigureStorDB(tpStatsCfgIn.StorDBType, tpStatsCfgIn.StorDBHost,
-// tpStatsCfgIn.StorDBPort, tpStatsCfgIn.StorDBName,
-// tpStatsCfgIn.StorDBUser, tpStatsCfgIn.StorDBPass,
-// config.CgrConfig().StorDBMaxOpenConns,
-// config.CgrConfig().StorDBMaxIdleConns,
-// config.CgrConfig().StorDBConnMaxLifetime,
-// config.CgrConfig().StorDBCDRSIndexes)
-// if err != nil {
-// log.Fatal(err)
-// }
-// storDBOut, err := engine.ConfigureStorDB(tpStatsCfgOut.StorDBType,
-// tpStatsCfgOut.StorDBHost, tpStatsCfgOut.StorDBPort, tpStatsCfgOut.StorDBName,
-// tpStatsCfgOut.StorDBUser, tpStatsCfgOut.StorDBPass,
-// config.CgrConfig().StorDBMaxOpenConns,
-// config.CgrConfig().StorDBMaxIdleConns,
-// config.CgrConfig().StorDBConnMaxLifetime,
-// config.CgrConfig().StorDBCDRSIndexes)
-// if err != nil {
-// log.Fatal(err)
-// }
-// tpStatsMigrator, err = NewMigrator(nil, nil, tpStatsCfgIn.DataDbType,
-// tpStatsCfgIn.DBDataEncoding, storDBIn, storDBOut, tpStatsCfgIn.StorDBType, nil,
-// tpStatsCfgIn.DataDbType, tpStatsCfgIn.DBDataEncoding, nil,
-// tpStatsCfgIn.StorDBType, false, false, false, false, false)
-// if err != nil {
-// log.Fatal(err)
-// }
-// }
+func testTpStatsITConnect(t *testing.T) {
+ var err error
+ tpStatsPathIn = path.Join(*dataDir, "conf", "samples", "tutmongo")
+ tpStatsCfgIn, err = config.NewCGRConfigFromFolder(tpStatsPathIn)
+ if err != nil {
+ t.Fatal(err)
+ }
+ tpStatsPathOut = path.Join(*dataDir, "conf", "samples", "tutmysql")
+ tpStatsCfgOut, err = config.NewCGRConfigFromFolder(tpStatsPathOut)
+ if err != nil {
+ t.Fatal(err)
+ }
+ storDBIn, err := engine.ConfigureStorDB(tpStatsCfgIn.StorDBType, tpStatsCfgIn.StorDBHost,
+ tpStatsCfgIn.StorDBPort, tpStatsCfgIn.StorDBName,
+ tpStatsCfgIn.StorDBUser, tpStatsCfgIn.StorDBPass,
+ config.CgrConfig().StorDBMaxOpenConns,
+ config.CgrConfig().StorDBMaxIdleConns,
+ config.CgrConfig().StorDBConnMaxLifetime,
+ config.CgrConfig().StorDBCDRSIndexes)
+ if err != nil {
+ log.Fatal(err)
+ }
+ storDBOut, err := engine.ConfigureStorDB(tpStatsCfgOut.StorDBType,
+ tpStatsCfgOut.StorDBHost, tpStatsCfgOut.StorDBPort, tpStatsCfgOut.StorDBName,
+ tpStatsCfgOut.StorDBUser, tpStatsCfgOut.StorDBPass,
+ config.CgrConfig().StorDBMaxOpenConns,
+ config.CgrConfig().StorDBMaxIdleConns,
+ config.CgrConfig().StorDBConnMaxLifetime,
+ config.CgrConfig().StorDBCDRSIndexes)
+ if err != nil {
+ log.Fatal(err)
+ }
+ tpStatsMigrator, err = NewMigrator(nil, nil, tpStatsCfgIn.DataDbType,
+ tpStatsCfgIn.DBDataEncoding, storDBIn, storDBOut, tpStatsCfgIn.StorDBType, nil,
+ tpStatsCfgIn.DataDbType, tpStatsCfgIn.DBDataEncoding, nil,
+ tpStatsCfgIn.StorDBType, false, false, false, false, false)
+ if err != nil {
+ log.Fatal(err)
+ }
+}
-// func testTpStatsITFlush(t *testing.T) {
-// if err := tpStatsMigrator.storDBIn.Flush(
-// path.Join(tpStatsCfgIn.DataFolderPath, "storage", tpStatsCfgIn.StorDBType)); err != nil {
-// t.Error(err)
-// }
+func testTpStatsITFlush(t *testing.T) {
+ if err := tpStatsMigrator.storDBIn.Flush(
+ path.Join(tpStatsCfgIn.DataFolderPath, "storage", tpStatsCfgIn.StorDBType)); err != nil {
+ t.Error(err)
+ }
-// if err := tpStatsMigrator.storDBOut.Flush(
-// path.Join(tpStatsCfgOut.DataFolderPath, "storage", tpStatsCfgOut.StorDBType)); err != nil {
-// t.Error(err)
-// }
-// }
+ if err := tpStatsMigrator.storDBOut.Flush(
+ path.Join(tpStatsCfgOut.DataFolderPath, "storage", tpStatsCfgOut.StorDBType)); err != nil {
+ t.Error(err)
+ }
+}
-// func testTpStatsITPopulate(t *testing.T) {
-// tpStats = []*utils.TPStats{
-// &utils.TPStats{
-// Tenant: "cgrates.org",
-// TPid: "TPS1",
-// ID: "Stat1",
-// FilterIDs: []string{"FLTR_1"},
-// ActivationInterval: &utils.TPActivationInterval{
-// ActivationTime: "2014-07-29T15:00:00Z",
-// ExpiryTime: "",
-// },
-// TTL: "1",
-// Metrics: []*utils.MetricWithParams{
-// &utils.MetricWithParams{
-// MetricID: "*sum",
-// Parameters: "Param1",
-// },
-// },
-// Blocker: false,
-// Stored: false,
-// Weight: 20,
-// MinItems: 1,
-// ThresholdIDs: []string{"ThreshValue", "ThreshValueTwo"},
-// },
-// }
-// if err := tpStatsMigrator.storDBIn.SetTPResources(tpStats); err != nil {
-// t.Error("Error when setting TpFilter ", err.Error())
-// }
-// currentVersion := engine.CurrentStorDBVersions()
-// err := tpStatsMigrator.storDBOut.SetVersions(currentVersion, false)
-// if err != nil {
-// t.Error("Error when setting version for TpFilter ", err.Error())
-// }
-// }
+func testTpStatsITPopulate(t *testing.T) {
+ tpStats = []*utils.TPStats{
+ &utils.TPStats{
+ Tenant: "cgrates.org",
+ TPid: "TPS1",
+ ID: "Stat1",
+ FilterIDs: []string{"FLTR_1"},
+ ActivationInterval: &utils.TPActivationInterval{
+ ActivationTime: "2014-07-29T15:00:00Z",
+ ExpiryTime: "",
+ },
+ TTL: "1",
+ Metrics: []*utils.MetricWithParams{
+ &utils.MetricWithParams{
+ MetricID: "*sum",
+ Parameters: "Param1",
+ },
+ },
+ Blocker: false,
+ Stored: false,
+ Weight: 20,
+ MinItems: 1,
+ ThresholdIDs: []string{"ThreshValue", "ThreshValueTwo"},
+ },
+ }
+ if err := tpStatsMigrator.storDBIn.SetTPStats(tpStats); err != nil {
+ t.Error("Error when setting TpFilter ", err.Error())
+ }
+ currentVersion := engine.CurrentStorDBVersions()
+ err := tpStatsMigrator.storDBOut.SetVersions(currentVersion, false)
+ if err != nil {
+ t.Error("Error when setting version for TpFilter ", err.Error())
+ }
+}
-// func testTpStatsITMove(t *testing.T) {
-// err, _ := tpStatsMigrator.Migrate([]string{utils.MetaTpStats})
-// if err != nil {
-// t.Error("Error when migrating TpFilter ", err.Error())
-// }
-// }
+func testTpStatsITMove(t *testing.T) {
+ err, _ := tpStatsMigrator.Migrate([]string{utils.MetaTpStats})
+ if err != nil {
+ t.Error("Error when migrating TpFilter ", err.Error())
+ }
+}
-// func testTpStatsITCheckData(t *testing.T) {
-// result, err := tpStatsMigrator.storDBOut.GetTPStats(
-// tpStats[0].TPid, tpStats[0].ID)
-// if err != nil {
-// t.Error("Error when getting TpFilter ", err.Error())
-// }
-// if !reflect.DeepEqual(tpStats[0], result[0]) {
-// t.Errorf("Expecting: %+v, received: %+v", tpStats[0], result[0])
-// }
-// result, err = tpStatsMigrator.storDBIn.GetTPStats(
-// tpStats[0].TPid, tpStats[0].ID)
-// if err != utils.ErrNotFound {
-// t.Error(err)
-// }
-// }
+func testTpStatsITCheckData(t *testing.T) {
+ result, err := tpStatsMigrator.storDBOut.GetTPStats(
+ tpStats[0].TPid, tpStats[0].ID)
+ if err != nil {
+ t.Error("Error when getting TpFilter ", err.Error())
+ }
+ if !reflect.DeepEqual(tpStats[0], result[0]) {
+ t.Errorf("Expecting: %+v, received: %+v", tpStats[0], result[0])
+ }
+ result, err = tpStatsMigrator.storDBIn.GetTPStats(
+ tpStats[0].TPid, tpStats[0].ID)
+ if err != utils.ErrNotFound {
+ t.Error(err)
+ }
+}
diff --git a/migrator/tp_suppliers.go b/migrator/tp_suppliers.go
index 2fe5e6fe1..ef2616485 100644
--- a/migrator/tp_suppliers.go
+++ b/migrator/tp_suppliers.go
@@ -48,9 +48,9 @@ func (m *Migrator) migrateCurrentTPSuppliers() (err error) {
if err := m.storDBOut.SetTPSuppliers(suppliers); err != nil {
return err
}
- for _, suppliers := range suppliers {
- if err := m.storDBIn.RemTpData(utils.TBLTPSuppliers, attrs.TPid,
- map[string]string{"tenant": attrs.Tenant, "id": attrs.ID}); err != nil {
+ for _, supplier := range suppliers {
+ if err := m.storDBIn.RemTpData(utils.TBLTPSuppliers, supplier.TPid,
+ map[string]string{"tenant": supplier.Tenant, "id": supplier.ID}); err != nil {
return err
}
}
diff --git a/migrator/tp_suppliers_it_test.go b/migrator/tp_suppliers_it_test.go
index f0b3670bc..e8f0cff72 100644
--- a/migrator/tp_suppliers_it_test.go
+++ b/migrator/tp_suppliers_it_test.go
@@ -18,153 +18,153 @@ You should have received a copy of the GNU General Public License
along with this program. If not, see
*/
-// package migrator
+package migrator
-// import (
-// "log"
-// "path"
-// "reflect"
-// "testing"
+import (
+ "log"
+ "path"
+ "reflect"
+ "testing"
-// "github.com/cgrates/cgrates/config"
-// "github.com/cgrates/cgrates/engine"
-// "github.com/cgrates/cgrates/utils"
-// )
+ "github.com/cgrates/cgrates/config"
+ "github.com/cgrates/cgrates/engine"
+ "github.com/cgrates/cgrates/utils"
+)
-// var (
-// tpSplPathIn string
-// tpSplPathOut string
-// tpSplCfgIn *config.CGRConfig
-// tpSplCfgOut *config.CGRConfig
-// tpSplMigrator *Migrator
-// tpSuppliers []*utils.TPSupplierProfile
-// )
+var (
+ tpSplPathIn string
+ tpSplPathOut string
+ tpSplCfgIn *config.CGRConfig
+ tpSplCfgOut *config.CGRConfig
+ tpSplMigrator *Migrator
+ tpSuppliers []*utils.TPSupplierProfile
+)
-// var sTestsTpSplIT = []func(t *testing.T){
-// testTpSplITConnect,
-// testTpSplITFlush,
-// testTpSplITPopulate,
-// testTpSplITMove,
-// testTpSplITCheckData,
-// }
+var sTestsTpSplIT = []func(t *testing.T){
+ testTpSplITConnect,
+ testTpSplITFlush,
+ testTpSplITPopulate,
+ testTpSplITMove,
+ testTpSplITCheckData,
+}
-// func TestTpSplMove(t *testing.T) {
-// for _, stest := range sTestsTpSplIT {
-// t.Run("TestTpSplMove", stest)
-// }
-// }
+func TestTpSplMove(t *testing.T) {
+ for _, stest := range sTestsTpSplIT {
+ t.Run("TestTpSplMove", stest)
+ }
+}
-// func testTpSplITConnect(t *testing.T) {
-// var err error
-// tpSplPathIn = path.Join(*dataDir, "conf", "samples", "tutmongo")
-// tpSplCfgIn, err = config.NewCGRConfigFromFolder(tpSplPathIn)
-// if err != nil {
-// t.Fatal(err)
-// }
-// tpSplPathOut = path.Join(*dataDir, "conf", "samples", "tutmysql")
-// tpSplCfgOut, err = config.NewCGRConfigFromFolder(tpSplPathOut)
-// if err != nil {
-// t.Fatal(err)
-// }
-// storDBIn, err := engine.ConfigureStorDB(tpSplCfgIn.StorDBType, tpSplCfgIn.StorDBHost,
-// tpSplCfgIn.StorDBPort, tpSplCfgIn.StorDBName,
-// tpSplCfgIn.StorDBUser, tpSplCfgIn.StorDBPass,
-// config.CgrConfig().StorDBMaxOpenConns,
-// config.CgrConfig().StorDBMaxIdleConns,
-// config.CgrConfig().StorDBConnMaxLifetime,
-// config.CgrConfig().StorDBCDRSIndexes)
-// if err != nil {
-// log.Fatal(err)
-// }
-// storDBOut, err := engine.ConfigureStorDB(tpSplCfgOut.StorDBType,
-// tpSplCfgOut.StorDBHost, tpSplCfgOut.StorDBPort, tpSplCfgOut.StorDBName,
-// tpSplCfgOut.StorDBUser, tpSplCfgOut.StorDBPass,
-// config.CgrConfig().StorDBMaxOpenConns,
-// config.CgrConfig().StorDBMaxIdleConns,
-// config.CgrConfig().StorDBConnMaxLifetime,
-// config.CgrConfig().StorDBCDRSIndexes)
-// if err != nil {
-// log.Fatal(err)
-// }
-// tpSplMigrator, err = NewMigrator(nil, nil, tpSplCfgIn.DataDbType,
-// tpSplCfgIn.DBDataEncoding, storDBIn, storDBOut, tpSplCfgIn.StorDBType, nil,
-// tpSplCfgIn.DataDbType, tpSplCfgIn.DBDataEncoding, nil,
-// tpSplCfgIn.StorDBType, false, false, false, false, false)
-// if err != nil {
-// log.Fatal(err)
-// }
-// }
+func testTpSplITConnect(t *testing.T) {
+ var err error
+ tpSplPathIn = path.Join(*dataDir, "conf", "samples", "tutmongo")
+ tpSplCfgIn, err = config.NewCGRConfigFromFolder(tpSplPathIn)
+ if err != nil {
+ t.Fatal(err)
+ }
+ tpSplPathOut = path.Join(*dataDir, "conf", "samples", "tutmysql")
+ tpSplCfgOut, err = config.NewCGRConfigFromFolder(tpSplPathOut)
+ if err != nil {
+ t.Fatal(err)
+ }
+ storDBIn, err := engine.ConfigureStorDB(tpSplCfgIn.StorDBType, tpSplCfgIn.StorDBHost,
+ tpSplCfgIn.StorDBPort, tpSplCfgIn.StorDBName,
+ tpSplCfgIn.StorDBUser, tpSplCfgIn.StorDBPass,
+ config.CgrConfig().StorDBMaxOpenConns,
+ config.CgrConfig().StorDBMaxIdleConns,
+ config.CgrConfig().StorDBConnMaxLifetime,
+ config.CgrConfig().StorDBCDRSIndexes)
+ if err != nil {
+ log.Fatal(err)
+ }
+ storDBOut, err := engine.ConfigureStorDB(tpSplCfgOut.StorDBType,
+ tpSplCfgOut.StorDBHost, tpSplCfgOut.StorDBPort, tpSplCfgOut.StorDBName,
+ tpSplCfgOut.StorDBUser, tpSplCfgOut.StorDBPass,
+ config.CgrConfig().StorDBMaxOpenConns,
+ config.CgrConfig().StorDBMaxIdleConns,
+ config.CgrConfig().StorDBConnMaxLifetime,
+ config.CgrConfig().StorDBCDRSIndexes)
+ if err != nil {
+ log.Fatal(err)
+ }
+ tpSplMigrator, err = NewMigrator(nil, nil, tpSplCfgIn.DataDbType,
+ tpSplCfgIn.DBDataEncoding, storDBIn, storDBOut, tpSplCfgIn.StorDBType, nil,
+ tpSplCfgIn.DataDbType, tpSplCfgIn.DBDataEncoding, nil,
+ tpSplCfgIn.StorDBType, false, false, false, false, false)
+ if err != nil {
+ log.Fatal(err)
+ }
+}
-// func testTpSplITFlush(t *testing.T) {
-// if err := tpSplMigrator.storDBIn.Flush(
-// path.Join(tpSplCfgIn.DataFolderPath, "storage", tpSplCfgIn.StorDBType)); err != nil {
-// t.Error(err)
-// }
+func testTpSplITFlush(t *testing.T) {
+ if err := tpSplMigrator.storDBIn.Flush(
+ path.Join(tpSplCfgIn.DataFolderPath, "storage", tpSplCfgIn.StorDBType)); err != nil {
+ t.Error(err)
+ }
-// if err := tpSplMigrator.storDBOut.Flush(
-// path.Join(tpSplCfgOut.DataFolderPath, "storage", tpSplCfgOut.StorDBType)); err != nil {
-// t.Error(err)
-// }
-// }
+ if err := tpSplMigrator.storDBOut.Flush(
+ path.Join(tpSplCfgOut.DataFolderPath, "storage", tpSplCfgOut.StorDBType)); err != nil {
+ t.Error(err)
+ }
+}
-// func testTpSplITPopulate(t *testing.T) {
-// tpSuppliers = []*utils.TPSupplierProfile{
-// &utils.TPSupplierProfile{
-// TPid: "TP1",
-// Tenant: "cgrates.org",
-// ID: "SUPL_1",
-// FilterIDs: []string{"FLTR_ACNT_dan", "FLTR_DST_DE"},
-// ActivationInterval: &utils.TPActivationInterval{
-// ActivationTime: "2014-07-29T15:00:00Z",
-// ExpiryTime: "",
-// },
-// Sorting: "*lowest_cost",
-// SortingParameters: []string{},
-// Suppliers: []*utils.TPSupplier{
-// &utils.TPSupplier{
-// ID: "supplier1",
-// FilterIDs: []string{"FLTR_1"},
-// AccountIDs: []string{"Acc1", "Acc2"},
-// RatingPlanIDs: []string{"RPL_1"},
-// ResourceIDs: []string{"ResGroup1"},
-// StatIDs: []string{"Stat1"},
-// Weight: 10,
-// Blocker: false,
-// SupplierParameters: "SortingParam1",
-// },
-// },
-// Weight: 20,
-// },
-// }
-// if err := tpSplMigrator.storDBIn.SetTPSuppliers(tpSuppliers); err != nil {
-// t.Error("Error when setting TpFilter ", err.Error())
-// }
-// currentVersion := engine.CurrentStorDBVersions()
-// err := tpSplMigrator.storDBOut.SetVersions(currentVersion, false)
-// if err != nil {
-// t.Error("Error when setting version for TpFilter ", err.Error())
-// }
-// }
+func testTpSplITPopulate(t *testing.T) {
+ tpSuppliers = []*utils.TPSupplierProfile{
+ &utils.TPSupplierProfile{
+ TPid: "TP1",
+ Tenant: "cgrates.org",
+ ID: "SUPL_1",
+ FilterIDs: []string{"FLTR_ACNT_dan", "FLTR_DST_DE"},
+ ActivationInterval: &utils.TPActivationInterval{
+ ActivationTime: "2014-07-29T15:00:00Z",
+ ExpiryTime: "",
+ },
+ Sorting: "*lowest_cost",
+ SortingParameters: []string{},
+ Suppliers: []*utils.TPSupplier{
+ &utils.TPSupplier{
+ ID: "supplier1",
+ FilterIDs: []string{"FLTR_1"},
+ AccountIDs: []string{"Acc1", "Acc2"},
+ RatingPlanIDs: []string{"RPL_1"},
+ ResourceIDs: []string{"ResGroup1"},
+ StatIDs: []string{"Stat1"},
+ Weight: 10,
+ Blocker: false,
+ SupplierParameters: "SortingParam1",
+ },
+ },
+ Weight: 20,
+ },
+ }
+ if err := tpSplMigrator.storDBIn.SetTPSuppliers(tpSuppliers); err != nil {
+ t.Error("Error when setting TpFilter ", err.Error())
+ }
+ currentVersion := engine.CurrentStorDBVersions()
+ err := tpSplMigrator.storDBOut.SetVersions(currentVersion, false)
+ if err != nil {
+ t.Error("Error when setting version for TpFilter ", err.Error())
+ }
+}
-// func testTpSplITMove(t *testing.T) {
-// err, _ := tpSplMigrator.Migrate([]string{utils.MetaTpSuppliers})
-// if err != nil {
-// t.Error("Error when migrating TpFilter ", err.Error())
-// }
-// }
+func testTpSplITMove(t *testing.T) {
+ err, _ := tpSplMigrator.Migrate([]string{utils.MetaTpSuppliers})
+ if err != nil {
+ t.Error("Error when migrating TpFilter ", err.Error())
+ }
+}
-// func testTpSplITCheckData(t *testing.T) {
-// result, err := tpSplMigrator.storDBOut.GetTPSuppliers(
-// tpSuppliers[0].TPid, tpSuppliers[0].ID)
-// if err != nil {
-// t.Error("Error when getting TpFilter ", err.Error())
-// }
-// if !reflect.DeepEqual(tpSuppliers[0], result[0]) {
-// t.Errorf("Expecting: %+v, received: %+v", tpSuppliers[0], result[0])
-// }
-// result, err = tpSplMigrator.storDBIn.GetTPSuppliers(
-// tpSuppliers[0].TPid, tpSuppliers[0].ID)
-// if err != utils.ErrNotFound {
-// t.Error(err)
-// }
-// }
+func testTpSplITCheckData(t *testing.T) {
+ result, err := tpSplMigrator.storDBOut.GetTPSuppliers(
+ tpSuppliers[0].TPid, tpSuppliers[0].ID)
+ if err != nil {
+ t.Error("Error when getting TpFilter ", err.Error())
+ }
+ if !reflect.DeepEqual(tpSuppliers[0], result[0]) {
+ t.Errorf("Expecting: %+v, received: %+v", tpSuppliers[0], result[0])
+ }
+ result, err = tpSplMigrator.storDBIn.GetTPSuppliers(
+ tpSuppliers[0].TPid, tpSuppliers[0].ID)
+ if err != utils.ErrNotFound {
+ t.Error(err)
+ }
+}
diff --git a/migrator/tp_thresholds_it_test.go b/migrator/tp_thresholds_it_test.go
index 655bd9897..7e825aff2 100644
--- a/migrator/tp_thresholds_it_test.go
+++ b/migrator/tp_thresholds_it_test.go
@@ -18,143 +18,143 @@ You should have received a copy of the GNU General Public License
along with this program. If not, see
*/
-// package migrator
+package migrator
-// import (
-// "log"
-// "path"
-// "reflect"
-// "testing"
+import (
+ "log"
+ "path"
+ "reflect"
+ "testing"
-// "github.com/cgrates/cgrates/config"
-// "github.com/cgrates/cgrates/engine"
-// "github.com/cgrates/cgrates/utils"
-// )
+ "github.com/cgrates/cgrates/config"
+ "github.com/cgrates/cgrates/engine"
+ "github.com/cgrates/cgrates/utils"
+)
-// var (
-// tpTresPathIn string
-// tpTresPathOut string
-// tpTresCfgIn *config.CGRConfig
-// tpTresCfgOut *config.CGRConfig
-// tpTresMigrator *Migrator
-// tpThresholds []*utils.TPThreshold
-// )
+var (
+ tpTresPathIn string
+ tpTresPathOut string
+ tpTresCfgIn *config.CGRConfig
+ tpTresCfgOut *config.CGRConfig
+ tpTresMigrator *Migrator
+ tpThresholds []*utils.TPThreshold
+)
-// var sTestsTpTresIT = []func(t *testing.T){
-// testTpTresITConnect,
-// testTpTresITFlush,
-// testTpTresITPopulate,
-// testTpTresITMove,
-// testTpTresITCheckData,
-// }
+var sTestsTpTresIT = []func(t *testing.T){
+ testTpTresITConnect,
+ testTpTresITFlush,
+ testTpTresITPopulate,
+ testTpTresITMove,
+ testTpTresITCheckData,
+}
-// func TestTpTresMove(t *testing.T) {
-// for _, stest := range sTestsTpTresIT {
-// t.Run("TestTpTresMove", stest)
-// }
-// }
+func TestTpTresMove(t *testing.T) {
+ for _, stest := range sTestsTpTresIT {
+ t.Run("TestTpTresMove", stest)
+ }
+}
-// func testTpTresITConnect(t *testing.T) {
-// var err error
-// tpTresPathIn = path.Join(*dataDir, "conf", "samples", "tutmongo")
-// tpTresCfgIn, err = config.NewCGRConfigFromFolder(tpTresPathIn)
-// if err != nil {
-// t.Fatal(err)
-// }
-// tpTresPathOut = path.Join(*dataDir, "conf", "samples", "tutmysql")
-// tpTresCfgOut, err = config.NewCGRConfigFromFolder(tpTresPathOut)
-// if err != nil {
-// t.Fatal(err)
-// }
-// storDBIn, err := engine.ConfigureStorDB(tpTresCfgIn.StorDBType, tpTresCfgIn.StorDBHost,
-// tpTresCfgIn.StorDBPort, tpTresCfgIn.StorDBName,
-// tpTresCfgIn.StorDBUser, tpTresCfgIn.StorDBPass,
-// config.CgrConfig().StorDBMaxOpenConns,
-// config.CgrConfig().StorDBMaxIdleConns,
-// config.CgrConfig().StorDBConnMaxLifetime,
-// config.CgrConfig().StorDBCDRSIndexes)
-// if err != nil {
-// log.Fatal(err)
-// }
-// storDBOut, err := engine.ConfigureStorDB(tpTresCfgOut.StorDBType,
-// tpTresCfgOut.StorDBHost, tpTresCfgOut.StorDBPort, tpTresCfgOut.StorDBName,
-// tpTresCfgOut.StorDBUser, tpTresCfgOut.StorDBPass,
-// config.CgrConfig().StorDBMaxOpenConns,
-// config.CgrConfig().StorDBMaxIdleConns,
-// config.CgrConfig().StorDBConnMaxLifetime,
-// config.CgrConfig().StorDBCDRSIndexes)
-// if err != nil {
-// log.Fatal(err)
-// }
-// tpTresMigrator, err = NewMigrator(nil, nil, tpTresCfgIn.DataDbType,
-// tpTresCfgIn.DBDataEncoding, storDBIn, storDBOut, tpTresCfgIn.StorDBType, nil,
-// tpTresCfgIn.DataDbType, tpTresCfgIn.DBDataEncoding, nil,
-// tpTresCfgIn.StorDBType, false, false, false, false, false)
-// if err != nil {
-// log.Fatal(err)
-// }
-// }
+func testTpTresITConnect(t *testing.T) {
+ var err error
+ tpTresPathIn = path.Join(*dataDir, "conf", "samples", "tutmongo")
+ tpTresCfgIn, err = config.NewCGRConfigFromFolder(tpTresPathIn)
+ if err != nil {
+ t.Fatal(err)
+ }
+ tpTresPathOut = path.Join(*dataDir, "conf", "samples", "tutmysql")
+ tpTresCfgOut, err = config.NewCGRConfigFromFolder(tpTresPathOut)
+ if err != nil {
+ t.Fatal(err)
+ }
+ storDBIn, err := engine.ConfigureStorDB(tpTresCfgIn.StorDBType, tpTresCfgIn.StorDBHost,
+ tpTresCfgIn.StorDBPort, tpTresCfgIn.StorDBName,
+ tpTresCfgIn.StorDBUser, tpTresCfgIn.StorDBPass,
+ config.CgrConfig().StorDBMaxOpenConns,
+ config.CgrConfig().StorDBMaxIdleConns,
+ config.CgrConfig().StorDBConnMaxLifetime,
+ config.CgrConfig().StorDBCDRSIndexes)
+ if err != nil {
+ log.Fatal(err)
+ }
+ storDBOut, err := engine.ConfigureStorDB(tpTresCfgOut.StorDBType,
+ tpTresCfgOut.StorDBHost, tpTresCfgOut.StorDBPort, tpTresCfgOut.StorDBName,
+ tpTresCfgOut.StorDBUser, tpTresCfgOut.StorDBPass,
+ config.CgrConfig().StorDBMaxOpenConns,
+ config.CgrConfig().StorDBMaxIdleConns,
+ config.CgrConfig().StorDBConnMaxLifetime,
+ config.CgrConfig().StorDBCDRSIndexes)
+ if err != nil {
+ log.Fatal(err)
+ }
+ tpTresMigrator, err = NewMigrator(nil, nil, tpTresCfgIn.DataDbType,
+ tpTresCfgIn.DBDataEncoding, storDBIn, storDBOut, tpTresCfgIn.StorDBType, nil,
+ tpTresCfgIn.DataDbType, tpTresCfgIn.DBDataEncoding, nil,
+ tpTresCfgIn.StorDBType, false, false, false, false, false)
+ if err != nil {
+ log.Fatal(err)
+ }
+}
-// func testTpTresITFlush(t *testing.T) {
-// if err := tpTresMigrator.storDBIn.Flush(
-// path.Join(tpTresCfgIn.DataFolderPath, "storage", tpTresCfgIn.StorDBType)); err != nil {
-// t.Error(err)
-// }
+func testTpTresITFlush(t *testing.T) {
+ if err := tpTresMigrator.storDBIn.Flush(
+ path.Join(tpTresCfgIn.DataFolderPath, "storage", tpTresCfgIn.StorDBType)); err != nil {
+ t.Error(err)
+ }
-// if err := tpTresMigrator.storDBOut.Flush(
-// path.Join(tpTresCfgOut.DataFolderPath, "storage", tpTresCfgOut.StorDBType)); err != nil {
-// t.Error(err)
-// }
-// }
+ if err := tpTresMigrator.storDBOut.Flush(
+ path.Join(tpTresCfgOut.DataFolderPath, "storage", tpTresCfgOut.StorDBType)); err != nil {
+ t.Error(err)
+ }
+}
-// func testTpTresITPopulate(t *testing.T) {
-// tpThreshold = []*utils.TPThreshold{
-// &utils.TPThreshold{
-// TPid: "TH1",
-// Tenant: "cgrates.org",
-// ID: "Threhold",
-// FilterIDs: []string{"FLTR_1", "FLTR_2"},
-// ActivationInterval: &utils.TPActivationInterval{
-// ActivationTime: "2014-07-29T15:00:00Z",
-// ExpiryTime: "",
-// },
-// Recurrent: true,
-// MinSleep: "1s",
-// Blocker: true,
-// Weight: 10,
-// ActionIDs: []string{"Thresh1", "Thresh2"},
-// Async: true,
-// },
-// }
-// if err := tpTresMigrator.storDBIn.SetTPThresholds(tpThreshold); err != nil {
-// t.Error("Error when setting TpFilter ", err.Error())
-// }
-// currentVersion := engine.CurrentStorDBVersions()
-// err := tpTresMigrator.storDBOut.SetVersions(currentVersion, false)
-// if err != nil {
-// t.Error("Error when setting version for TpFilter ", err.Error())
-// }
-// }
+func testTpTresITPopulate(t *testing.T) {
+ tpThresholds = []*utils.TPThreshold{
+ &utils.TPThreshold{
+ TPid: "TH1",
+ Tenant: "cgrates.org",
+ ID: "Threhold",
+ FilterIDs: []string{"FLTR_1", "FLTR_2"},
+ ActivationInterval: &utils.TPActivationInterval{
+ ActivationTime: "2014-07-29T15:00:00Z",
+ ExpiryTime: "",
+ },
+ Recurrent: true,
+ MinSleep: "1s",
+ Blocker: true,
+ Weight: 10,
+ ActionIDs: []string{"Thresh1", "Thresh2"},
+ Async: true,
+ },
+ }
+ if err := tpTresMigrator.storDBIn.SetTPThresholds(tpThresholds); err != nil {
+ t.Error("Error when setting TpFilter ", err.Error())
+ }
+ currentVersion := engine.CurrentStorDBVersions()
+ err := tpTresMigrator.storDBOut.SetVersions(currentVersion, false)
+ if err != nil {
+ t.Error("Error when setting version for TpFilter ", err.Error())
+ }
+}
-// func testTpTresITMove(t *testing.T) {
-// err, _ := tpTresMigrator.Migrate([]string{utils.MetaTpThreshold})
-// if err != nil {
-// t.Error("Error when migrating TpFilter ", err.Error())
-// }
-// }
+func testTpTresITMove(t *testing.T) {
+ err, _ := tpTresMigrator.Migrate([]string{utils.MetaTpThresholds})
+ if err != nil {
+ t.Error("Error when migrating TpFilter ", err.Error())
+ }
+}
-// func testTpTresITCheckData(t *testing.T) {
-// result, err := tpTresMigrator.storDBOut.GetTPThresholds(
-// tpThreshold[0].TPid, tpThreshold[0].ID)
-// if err != nil {
-// t.Error("Error when getting TpFilter ", err.Error())
-// }
-// if !reflect.DeepEqual(tpThreshold[0], result[0]) {
-// t.Errorf("Expecting: %+v, received: %+v", tpThreshold[0], result[0])
-// }
-// result, err = tpTresMigrator.storDBIn.GetTPThresholds(
-// tpThreshold[0].TPid, tpThreshold[0].ID)
-// if err != utils.ErrNotFound {
-// t.Error(err)
-// }
-// }
+func testTpTresITCheckData(t *testing.T) {
+ result, err := tpTresMigrator.storDBOut.GetTPThresholds(
+ tpThresholds[0].TPid, tpThresholds[0].ID)
+ if err != nil {
+ t.Error("Error when getting TpFilter ", err.Error())
+ }
+ if !reflect.DeepEqual(tpThresholds[0], result[0]) {
+ t.Errorf("Expecting: %+v, received: %+v", tpThresholds[0], result[0])
+ }
+ result, err = tpTresMigrator.storDBIn.GetTPThresholds(
+ tpThresholds[0].TPid, tpThresholds[0].ID)
+ if err != utils.ErrNotFound {
+ t.Error(err)
+ }
+}
diff --git a/migrator/tp_timings_it_test.go b/migrator/tp_timings_it_test.go
index 50d4603d5..6084ff441 100644
--- a/migrator/tp_timings_it_test.go
+++ b/migrator/tp_timings_it_test.go
@@ -18,136 +18,136 @@ You should have received a copy of the GNU General Public License
along with this program. If not, see
*/
-// package migrator
+package migrator
-// import (
-// "log"
-// "path"
-// "reflect"
-// "testing"
+import (
+ "log"
+ "path"
+ "reflect"
+ "testing"
-// "github.com/cgrates/cgrates/config"
-// "github.com/cgrates/cgrates/engine"
-// "github.com/cgrates/cgrates/utils"
-// )
+ "github.com/cgrates/cgrates/config"
+ "github.com/cgrates/cgrates/engine"
+ "github.com/cgrates/cgrates/utils"
+)
-// var (
-// tpTimPathIn string
-// tpTimPathOut string
-// tpTimCfgIn *config.CGRConfig
-// tpTimCfgOut *config.CGRConfig
-// tpTimMigrator *Migrator
-// tpTimings []*utils.ApierTPTiming
-// )
+var (
+ tpTimPathIn string
+ tpTimPathOut string
+ tpTimCfgIn *config.CGRConfig
+ tpTimCfgOut *config.CGRConfig
+ tpTimMigrator *Migrator
+ tpTimings []*utils.ApierTPTiming
+)
-// var sTestsTpTimIT = []func(t *testing.T){
-// testTpTimITConnect,
-// testTpTimITFlush,
-// testTpTimITPopulate,
-// testTpTimITMove,
-// testTpTimITCheckData,
-// }
+var sTestsTpTimIT = []func(t *testing.T){
+ testTpTimITConnect,
+ testTpTimITFlush,
+ testTpTimITPopulate,
+ testTpTimITMove,
+ testTpTimITCheckData,
+}
-// func TestTpTimMove(t *testing.T) {
-// for _, stest := range sTestsTpTimIT {
-// t.Run("TestTpTimMove", stest)
-// }
-// }
+func TestTpTimMove(t *testing.T) {
+ for _, stest := range sTestsTpTimIT {
+ t.Run("TestTpTimMove", stest)
+ }
+}
-// func testTpTimITConnect(t *testing.T) {
-// var err error
-// tpTimPathIn = path.Join(*dataDir, "conf", "samples", "tutmongo")
-// tpTimCfgIn, err = config.NewCGRConfigFromFolder(tpTimPathIn)
-// if err != nil {
-// t.Fatal(err)
-// }
-// tpTimPathOut = path.Join(*dataDir, "conf", "samples", "tutmysql")
-// tpTimCfgOut, err = config.NewCGRConfigFromFolder(tpTimPathOut)
-// if err != nil {
-// t.Fatal(err)
-// }
-// storDBIn, err := engine.ConfigureStorDB(tpTimCfgIn.StorDBType, tpTimCfgIn.StorDBHost,
-// tpTimCfgIn.StorDBPort, tpTimCfgIn.StorDBName,
-// tpTimCfgIn.StorDBUser, tpTimCfgIn.StorDBPass,
-// config.CgrConfig().StorDBMaxOpenConns,
-// config.CgrConfig().StorDBMaxIdleConns,
-// config.CgrConfig().StorDBConnMaxLifetime,
-// config.CgrConfig().StorDBCDRSIndexes)
-// if err != nil {
-// log.Fatal(err)
-// }
-// storDBOut, err := engine.ConfigureStorDB(tpTimCfgOut.StorDBType,
-// tpTimCfgOut.StorDBHost, tpTimCfgOut.StorDBPort, tpTimCfgOut.StorDBName,
-// tpTimCfgOut.StorDBUser, tpTimCfgOut.StorDBPass,
-// config.CgrConfig().StorDBMaxOpenConns,
-// config.CgrConfig().StorDBMaxIdleConns,
-// config.CgrConfig().StorDBConnMaxLifetime,
-// config.CgrConfig().StorDBCDRSIndexes)
-// if err != nil {
-// log.Fatal(err)
-// }
-// tpTimMigrator, err = NewMigrator(nil, nil, tpTimCfgIn.DataDbType,
-// tpTimCfgIn.DBDataEncoding, storDBIn, storDBOut, tpTimCfgIn.StorDBType, nil,
-// tpTimCfgIn.DataDbType, tpTimCfgIn.DBDataEncoding, nil,
-// tpTimCfgIn.StorDBType, false, false, false, false, false)
-// if err != nil {
-// log.Fatal(err)
-// }
-// }
+func testTpTimITConnect(t *testing.T) {
+ var err error
+ tpTimPathIn = path.Join(*dataDir, "conf", "samples", "tutmongo")
+ tpTimCfgIn, err = config.NewCGRConfigFromFolder(tpTimPathIn)
+ if err != nil {
+ t.Fatal(err)
+ }
+ tpTimPathOut = path.Join(*dataDir, "conf", "samples", "tutmysql")
+ tpTimCfgOut, err = config.NewCGRConfigFromFolder(tpTimPathOut)
+ if err != nil {
+ t.Fatal(err)
+ }
+ storDBIn, err := engine.ConfigureStorDB(tpTimCfgIn.StorDBType, tpTimCfgIn.StorDBHost,
+ tpTimCfgIn.StorDBPort, tpTimCfgIn.StorDBName,
+ tpTimCfgIn.StorDBUser, tpTimCfgIn.StorDBPass,
+ config.CgrConfig().StorDBMaxOpenConns,
+ config.CgrConfig().StorDBMaxIdleConns,
+ config.CgrConfig().StorDBConnMaxLifetime,
+ config.CgrConfig().StorDBCDRSIndexes)
+ if err != nil {
+ log.Fatal(err)
+ }
+ storDBOut, err := engine.ConfigureStorDB(tpTimCfgOut.StorDBType,
+ tpTimCfgOut.StorDBHost, tpTimCfgOut.StorDBPort, tpTimCfgOut.StorDBName,
+ tpTimCfgOut.StorDBUser, tpTimCfgOut.StorDBPass,
+ config.CgrConfig().StorDBMaxOpenConns,
+ config.CgrConfig().StorDBMaxIdleConns,
+ config.CgrConfig().StorDBConnMaxLifetime,
+ config.CgrConfig().StorDBCDRSIndexes)
+ if err != nil {
+ log.Fatal(err)
+ }
+ tpTimMigrator, err = NewMigrator(nil, nil, tpTimCfgIn.DataDbType,
+ tpTimCfgIn.DBDataEncoding, storDBIn, storDBOut, tpTimCfgIn.StorDBType, nil,
+ tpTimCfgIn.DataDbType, tpTimCfgIn.DBDataEncoding, nil,
+ tpTimCfgIn.StorDBType, false, false, false, false, false)
+ if err != nil {
+ log.Fatal(err)
+ }
+}
-// func testTpTimITFlush(t *testing.T) {
-// if err := tpTimMigrator.storDBIn.Flush(
-// path.Join(tpTimCfgIn.DataFolderPath, "storage", tpTimCfgIn.StorDBType)); err != nil {
-// t.Error(err)
-// }
+func testTpTimITFlush(t *testing.T) {
+ if err := tpTimMigrator.storDBIn.Flush(
+ path.Join(tpTimCfgIn.DataFolderPath, "storage", tpTimCfgIn.StorDBType)); err != nil {
+ t.Error(err)
+ }
-// if err := tpTimMigrator.storDBOut.Flush(
-// path.Join(tpTimCfgOut.DataFolderPath, "storage", tpTimCfgOut.StorDBType)); err != nil {
-// t.Error(err)
-// }
-// }
+ if err := tpTimMigrator.storDBOut.Flush(
+ path.Join(tpTimCfgOut.DataFolderPath, "storage", tpTimCfgOut.StorDBType)); err != nil {
+ t.Error(err)
+ }
+}
-// func testTpTimITPopulate(t *testing.T) {
-// tpTimings = []*utils.ApierTPTiming{
-// &utils.ApierTPTiming{
-// TPid: "TPT1",
-// ID: "Timing",
-// Years: "2017",
-// Months: "05",
-// MonthDays: "01",
-// WeekDays: "1",
-// Time: "15:00:00Z",
-// },
-// }
-// if err := tpTimMigrator.storDBIn.SetTPTimings(tpTimings); err != nil {
-// t.Error("Error when setting TpFilter ", err.Error())
-// }
-// currentVersion := engine.CurrentStorDBVersions()
-// err := tpTimMigrator.storDBOut.SetVersions(currentVersion, false)
-// if err != nil {
-// t.Error("Error when setting version for TpTimings ", err.Error())
-// }
-// }
+func testTpTimITPopulate(t *testing.T) {
+ tpTimings = []*utils.ApierTPTiming{
+ &utils.ApierTPTiming{
+ TPid: "TPT1",
+ ID: "Timing",
+ Years: "2017",
+ Months: "05",
+ MonthDays: "01",
+ WeekDays: "1",
+ Time: "15:00:00Z",
+ },
+ }
+ if err := tpTimMigrator.storDBIn.SetTPTimings(tpTimings); err != nil {
+ t.Error("Error when setting TpFilter ", err.Error())
+ }
+ currentVersion := engine.CurrentStorDBVersions()
+ err := tpTimMigrator.storDBOut.SetVersions(currentVersion, false)
+ if err != nil {
+ t.Error("Error when setting version for TpTimings ", err.Error())
+ }
+}
-// func testTpTimITMove(t *testing.T) {
-// err, _ := tpTimMigrator.Migrate([]string{utils.MetaTpTiming})
-// if err != nil {
-// t.Error("Error when migrating TpTimings ", err.Error())
-// }
-// }
+func testTpTimITMove(t *testing.T) {
+ err, _ := tpTimMigrator.Migrate([]string{utils.MetaTpTiming})
+ if err != nil {
+ t.Error("Error when migrating TpTimings ", err.Error())
+ }
+}
-// func testTpTimITCheckData(t *testing.T) {
-// result, err := tpTimMigrator.storDBOut.GetTPTimings(
-// tpTimings[0].TPid, tpTimings[0].ID)
-// if err != nil {
-// t.Error("Error when getting TpTimings ", err.Error())
-// }
-// if !reflect.DeepEqual(tpTimings[0], result[0]) {
-// t.Errorf("Expecting: %+v, received: %+v", tpTimings[0], result[0])
-// }
-// result, err = tpTimMigrator.storDBIn.GetTPTimings(
-// tpTimings[0].TPid, tpTimings[0].ID)
-// if err != utils.ErrNotFound {
-// t.Error(err)
-// }
-// }
+func testTpTimITCheckData(t *testing.T) {
+ result, err := tpTimMigrator.storDBOut.GetTPTimings(
+ tpTimings[0].TPid, tpTimings[0].ID)
+ if err != nil {
+ t.Error("Error when getting TpTimings ", err.Error())
+ }
+ if !reflect.DeepEqual(tpTimings[0], result[0]) {
+ t.Errorf("Expecting: %+v, received: %+v", tpTimings[0], result[0])
+ }
+ result, err = tpTimMigrator.storDBIn.GetTPTimings(
+ tpTimings[0].TPid, tpTimings[0].ID)
+ if err != utils.ErrNotFound {
+ t.Error(err)
+ }
+}