mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-11 18:16:24 +05:00
Added migrator tests
This commit is contained in:
committed by
Dan Christian Bogos
parent
28e1d22de1
commit
9ec3517ee5
161
migrator/tp_resources_it_test.go
Normal file
161
migrator/tp_resources_it_test.go
Normal file
@@ -0,0 +1,161 @@
|
||||
// +build integration
|
||||
|
||||
/*
|
||||
Real-time Online/Offline Charging System (OCS) for Telecom & ISP environments
|
||||
Copyright (C) ITsysCOM GmbH
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
*/
|
||||
|
||||
// package migrator
|
||||
|
||||
// import (
|
||||
// "log"
|
||||
// "path"
|
||||
// "reflect"
|
||||
// "testing"
|
||||
|
||||
// "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 sTestsTpResIT = []func(t *testing.T){
|
||||
// testTpResITConnect,
|
||||
// testTpResITFlush,
|
||||
// testTpResITPopulate,
|
||||
// testTpResITMove,
|
||||
// testTpResITCheckData,
|
||||
// }
|
||||
|
||||
// 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 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)
|
||||
// }
|
||||
// }
|
||||
|
||||
// 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 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)
|
||||
// }
|
||||
// }
|
||||
166
migrator/tp_stats_it_test.go
Normal file
166
migrator/tp_stats_it_test.go
Normal file
@@ -0,0 +1,166 @@
|
||||
// +build integration
|
||||
|
||||
/*
|
||||
Real-time Online/Offline Charging System (OCS) for Telecom & ISP environments
|
||||
Copyright (C) ITsysCOM GmbH
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
*/
|
||||
|
||||
// package migrator
|
||||
|
||||
// import (
|
||||
// "log"
|
||||
// "path"
|
||||
// "reflect"
|
||||
// "testing"
|
||||
|
||||
// "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 sTestsTpStatsIT = []func(t *testing.T){
|
||||
// testTpStatsITConnect,
|
||||
// testTpStatsITFlush,
|
||||
// testTpStatsITPopulate,
|
||||
// testTpStatsITMove,
|
||||
// testTpStatsITCheckData,
|
||||
// }
|
||||
|
||||
// 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 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)
|
||||
// }
|
||||
// }
|
||||
|
||||
// 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 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)
|
||||
// }
|
||||
// }
|
||||
170
migrator/tp_suppliers_it_test.go
Normal file
170
migrator/tp_suppliers_it_test.go
Normal file
@@ -0,0 +1,170 @@
|
||||
// +build integration
|
||||
|
||||
/*
|
||||
Real-time Online/Offline Charging System (OCS) for Telecom & ISP environments
|
||||
Copyright (C) ITsysCOM GmbH
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
*/
|
||||
|
||||
// package migrator
|
||||
|
||||
// import (
|
||||
// "log"
|
||||
// "path"
|
||||
// "reflect"
|
||||
// "testing"
|
||||
|
||||
// "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 sTestsTpSplIT = []func(t *testing.T){
|
||||
// testTpSplITConnect,
|
||||
// testTpSplITFlush,
|
||||
// testTpSplITPopulate,
|
||||
// testTpSplITMove,
|
||||
// testTpSplITCheckData,
|
||||
// }
|
||||
|
||||
// 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 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)
|
||||
// }
|
||||
// }
|
||||
|
||||
// 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 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)
|
||||
// }
|
||||
// }
|
||||
160
migrator/tp_thresholds_it_test.go
Normal file
160
migrator/tp_thresholds_it_test.go
Normal file
@@ -0,0 +1,160 @@
|
||||
// +build integration
|
||||
|
||||
/*
|
||||
Real-time Online/Offline Charging System (OCS) for Telecom & ISP environments
|
||||
Copyright (C) ITsysCOM GmbH
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
*/
|
||||
|
||||
// package migrator
|
||||
|
||||
// import (
|
||||
// "log"
|
||||
// "path"
|
||||
// "reflect"
|
||||
// "testing"
|
||||
|
||||
// "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 sTestsTpTresIT = []func(t *testing.T){
|
||||
// testTpTresITConnect,
|
||||
// testTpTresITFlush,
|
||||
// testTpTresITPopulate,
|
||||
// testTpTresITMove,
|
||||
// testTpTresITCheckData,
|
||||
// }
|
||||
|
||||
// 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 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)
|
||||
// }
|
||||
// }
|
||||
|
||||
// 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 testTpTresITMove(t *testing.T) {
|
||||
// err, _ := tpTresMigrator.Migrate([]string{utils.MetaTpThreshold})
|
||||
// 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)
|
||||
// }
|
||||
// }
|
||||
153
migrator/tp_timings_it_test.go
Normal file
153
migrator/tp_timings_it_test.go
Normal file
@@ -0,0 +1,153 @@
|
||||
// +build integration
|
||||
|
||||
/*
|
||||
Real-time Online/Offline Charging System (OCS) for Telecom & ISP environments
|
||||
Copyright (C) ITsysCOM GmbH
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
*/
|
||||
|
||||
// package migrator
|
||||
|
||||
// import (
|
||||
// "log"
|
||||
// "path"
|
||||
// "reflect"
|
||||
// "testing"
|
||||
|
||||
// "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 sTestsTpTimIT = []func(t *testing.T){
|
||||
// testTpTimITConnect,
|
||||
// testTpTimITFlush,
|
||||
// testTpTimITPopulate,
|
||||
// testTpTimITMove,
|
||||
// testTpTimITCheckData,
|
||||
// }
|
||||
|
||||
// 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 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)
|
||||
// }
|
||||
// }
|
||||
|
||||
// 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 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)
|
||||
// }
|
||||
// }
|
||||
Reference in New Issue
Block a user