mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-11 18:16:24 +05:00
Updated IT tests
This commit is contained in:
@@ -77,7 +77,7 @@ func TestSchedWithFiltersSingleAccount(t *testing.T) {
|
||||
case utils.MetaInternal:
|
||||
schedConfDIR = "filtered_scheduler_internal"
|
||||
case utils.MetaSQL:
|
||||
schedConfDIR = "filtered_scheduler"
|
||||
schedConfDIR = "filtered_scheduler_mysql"
|
||||
case utils.MetaMongo:
|
||||
schedConfDIR = "filtered_scheduler_mongo"
|
||||
case utils.MetaPostgres:
|
||||
@@ -96,7 +96,7 @@ func TestSchedWithFilters2(t *testing.T) {
|
||||
case utils.MetaInternal:
|
||||
schedConfDIR = "filtered_scheduler2_internal"
|
||||
case utils.MetaSQL:
|
||||
schedConfDIR = "filtered_scheduler2"
|
||||
schedConfDIR = "filtered_scheduler2_mysql"
|
||||
case utils.MetaMongo:
|
||||
schedConfDIR = "filtered_scheduler2_mongo"
|
||||
case utils.MetaPostgres:
|
||||
@@ -153,7 +153,7 @@ func testSchedFromFolder(t *testing.T) {
|
||||
}
|
||||
|
||||
func testSchedVeifyAllAccounts(t *testing.T) {
|
||||
if schedConfDIR == "filtered_scheduler" || schedConfDIR == "filtered_scheduler2" {
|
||||
if !(schedConfDIR == "tutinternal" || schedConfDIR == "tutmysql" || schedConfDIR == "tutmongo") {
|
||||
t.SkipNow()
|
||||
}
|
||||
|
||||
@@ -191,7 +191,7 @@ func testSchedVeifyAllAccounts(t *testing.T) {
|
||||
}
|
||||
|
||||
func testSchedVeifyAccount1001(t *testing.T) {
|
||||
if schedConfDIR == "tutmysql" || schedConfDIR == "filtered_scheduler2" {
|
||||
if !(schedConfDIR == "filtered_scheduler_internal" || schedConfDIR == "filtered_scheduler_mysql" || schedConfDIR == "filtered_scheduler_mongo") {
|
||||
t.SkipNow()
|
||||
}
|
||||
var acnt *engine.Account
|
||||
@@ -232,7 +232,7 @@ func testSchedVeifyAccount1001(t *testing.T) {
|
||||
}
|
||||
|
||||
func testSchedVeifyAccount1002and1003(t *testing.T) {
|
||||
if schedConfDIR == "tutmysql" || schedConfDIR == "filtered_scheduler" {
|
||||
if !(schedConfDIR == "filtered_scheduler2_internal" || schedConfDIR == "filtered_scheduler2_mysql" || schedConfDIR == "filtered_scheduler2_mongo") {
|
||||
t.SkipNow()
|
||||
}
|
||||
var acnt *engine.Account
|
||||
|
||||
@@ -38,74 +38,72 @@ var (
|
||||
stsV1Rpc *rpc.Client
|
||||
statConfig *StatQueueWithCache
|
||||
stsV1ConfDIR string //run tests for specific configuration
|
||||
)
|
||||
|
||||
var evs = []*utils.CGREvent{
|
||||
{
|
||||
Tenant: "cgrates.org",
|
||||
ID: "event1",
|
||||
Event: map[string]interface{}{
|
||||
utils.Account: "1001",
|
||||
utils.AnswerTime: time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC),
|
||||
utils.Usage: time.Duration(135 * time.Second),
|
||||
utils.COST: 123.0}},
|
||||
{
|
||||
Tenant: "cgrates.org",
|
||||
ID: "event2",
|
||||
Event: map[string]interface{}{
|
||||
utils.Account: "1002",
|
||||
utils.AnswerTime: time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC),
|
||||
utils.Usage: time.Duration(45 * time.Second)}},
|
||||
{
|
||||
Tenant: "cgrates.org",
|
||||
ID: "event3",
|
||||
Event: map[string]interface{}{
|
||||
utils.Account: "1002",
|
||||
utils.SetupTime: time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC),
|
||||
utils.Usage: 0}},
|
||||
}
|
||||
evs = []*utils.CGREvent{
|
||||
{
|
||||
Tenant: "cgrates.org",
|
||||
ID: "event1",
|
||||
Event: map[string]interface{}{
|
||||
utils.Account: "1001",
|
||||
utils.AnswerTime: time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC),
|
||||
utils.Usage: time.Duration(135 * time.Second),
|
||||
utils.COST: 123.0}},
|
||||
{
|
||||
Tenant: "cgrates.org",
|
||||
ID: "event2",
|
||||
Event: map[string]interface{}{
|
||||
utils.Account: "1002",
|
||||
utils.AnswerTime: time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC),
|
||||
utils.Usage: time.Duration(45 * time.Second)}},
|
||||
{
|
||||
Tenant: "cgrates.org",
|
||||
ID: "event3",
|
||||
Event: map[string]interface{}{
|
||||
utils.Account: "1002",
|
||||
utils.SetupTime: time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC),
|
||||
utils.Usage: 0}},
|
||||
}
|
||||
|
||||
sTestsStatSV1 = []func(t *testing.T){
|
||||
testV1STSLoadConfig,
|
||||
testV1STSInitDataDb,
|
||||
testV1STSStartEngine,
|
||||
testV1STSRpcConn,
|
||||
testV1STSFromFolder,
|
||||
testV1STSGetStats,
|
||||
testV1STSProcessEvent,
|
||||
testV1STSGetStatsAfterRestart,
|
||||
testV1STSSetStatQueueProfile,
|
||||
testV1STSGetStatQueueProfileIDs,
|
||||
testV1STSUpdateStatQueueProfile,
|
||||
testV1STSRemoveStatQueueProfile,
|
||||
testV1STSStatsPing,
|
||||
testV1STSProcessMetricsWithFilter,
|
||||
testV1STSProcessStaticMetrics,
|
||||
testV1STSProcessStatWithThreshold,
|
||||
testV1STSStopEngine,
|
||||
}
|
||||
)
|
||||
|
||||
func init() {
|
||||
rand.Seed(time.Now().UnixNano()) // used in benchmarks
|
||||
}
|
||||
|
||||
var sTestsStatSV1 = []func(t *testing.T){
|
||||
testV1STSLoadConfig,
|
||||
testV1STSInitDataDb,
|
||||
testV1STSStartEngine,
|
||||
testV1STSRpcConn,
|
||||
testV1STSFromFolder,
|
||||
testV1STSGetStats,
|
||||
testV1STSProcessEvent,
|
||||
testV1STSGetStatsAfterRestart,
|
||||
testV1STSSetStatQueueProfile,
|
||||
testV1STSGetStatQueueProfileIDs,
|
||||
testV1STSUpdateStatQueueProfile,
|
||||
testV1STSRemoveStatQueueProfile,
|
||||
testV1STSStatsPing,
|
||||
testV1STSProcessMetricsWithFilter,
|
||||
testV1STSProcessStaticMetrics,
|
||||
testV1STSProcessStatWithThreshold,
|
||||
testV1STSStopEngine,
|
||||
}
|
||||
|
||||
//Test start here
|
||||
func TestSTSV1ITMySQL(t *testing.T) {
|
||||
stsV1ConfDIR = "tutmysql"
|
||||
for _, stest := range sTestsStatSV1 {
|
||||
t.Run(stsV1ConfDIR, stest)
|
||||
func TestSTSV1IT(t *testing.T) {
|
||||
switch *dbType {
|
||||
case utils.MetaInternal:
|
||||
stsV1ConfDIR = "tutinternal"
|
||||
case utils.MetaSQL:
|
||||
stsV1ConfDIR = "tutmysql"
|
||||
case utils.MetaMongo:
|
||||
stsV1ConfDIR = "tutmongo"
|
||||
case utils.MetaPostgres:
|
||||
t.SkipNow()
|
||||
default:
|
||||
t.Fatal("Unknown Database type")
|
||||
}
|
||||
}
|
||||
|
||||
func TestSTSV1ITMongo(t *testing.T) {
|
||||
stsV1ConfDIR = "tutmongo"
|
||||
for _, stest := range sTestsStatSV1 {
|
||||
t.Run(stsV1ConfDIR, stest)
|
||||
}
|
||||
}
|
||||
|
||||
func TestSTSV1ITInternal(t *testing.T) {
|
||||
stsV1ConfDIR = "tutinternal"
|
||||
for _, stest := range sTestsStatSV1 {
|
||||
t.Run(stsV1ConfDIR, stest)
|
||||
}
|
||||
|
||||
@@ -38,53 +38,57 @@ var (
|
||||
splSv1Rpc *rpc.Client
|
||||
splPrf *SupplierWithCache
|
||||
splSv1ConfDIR string //run tests for specific configuration
|
||||
|
||||
sTestsSupplierSV1 = []func(t *testing.T){
|
||||
testV1SplSLoadConfig,
|
||||
testV1SplSInitDataDb,
|
||||
testV1SplSResetStorDb,
|
||||
testV1SplSStartEngine,
|
||||
testV1SplSRpcConn,
|
||||
testV1SplSFromFolder,
|
||||
testV1SplSGetWeightSuppliers,
|
||||
testV1SplSGetLeastCostSuppliers,
|
||||
testV1SplSGetLeastCostSuppliersWithMaxCost,
|
||||
testV1SplSGetLeastCostSuppliersWithMaxCost2,
|
||||
testV1SplSGetLeastCostSuppliersWithMaxCostNotFound,
|
||||
testV1SplSGetHighestCostSuppliers,
|
||||
testV1SplSGetLeastCostSuppliersErr,
|
||||
testV1SplSPolulateStatsForQOS,
|
||||
testV1SplSGetQOSSuppliers,
|
||||
testV1SplSGetQOSSuppliers2,
|
||||
testV1SplSGetQOSSuppliers3,
|
||||
testV1SplSGetQOSSuppliersFiltred,
|
||||
testV1SplSGetQOSSuppliersFiltred2,
|
||||
testV1SplSGetSupplierWithoutFilter,
|
||||
testV1SplSSetSupplierProfiles,
|
||||
testV1SplSGetSupplierProfileIDs,
|
||||
testV1SplSUpdateSupplierProfiles,
|
||||
testV1SplSRemSupplierProfiles,
|
||||
testV1SplSGetSupplierForEvent,
|
||||
// reset the database and load the TP again
|
||||
// testV1SplSInitDataDb,
|
||||
// testV1SplSFromFolder,
|
||||
// for the moment we decide to comment the tests
|
||||
// testV1SplsOneSupplierWithoutDestination,
|
||||
testV1SplSupplierPing,
|
||||
testV1SplSStopEngine,
|
||||
}
|
||||
)
|
||||
|
||||
var sTestsSupplierSV1 = []func(t *testing.T){
|
||||
testV1SplSLoadConfig,
|
||||
testV1SplSInitDataDb,
|
||||
testV1SplSResetStorDb,
|
||||
testV1SplSStartEngine,
|
||||
testV1SplSRpcConn,
|
||||
testV1SplSFromFolder,
|
||||
testV1SplSGetWeightSuppliers,
|
||||
testV1SplSGetLeastCostSuppliers,
|
||||
testV1SplSGetLeastCostSuppliersWithMaxCost,
|
||||
testV1SplSGetLeastCostSuppliersWithMaxCost2,
|
||||
testV1SplSGetLeastCostSuppliersWithMaxCostNotFound,
|
||||
testV1SplSGetHighestCostSuppliers,
|
||||
testV1SplSGetLeastCostSuppliersErr,
|
||||
testV1SplSPolulateStatsForQOS,
|
||||
testV1SplSGetQOSSuppliers,
|
||||
testV1SplSGetQOSSuppliers2,
|
||||
testV1SplSGetQOSSuppliers3,
|
||||
testV1SplSGetQOSSuppliersFiltred,
|
||||
testV1SplSGetQOSSuppliersFiltred2,
|
||||
testV1SplSGetSupplierWithoutFilter,
|
||||
testV1SplSSetSupplierProfiles,
|
||||
testV1SplSGetSupplierProfileIDs,
|
||||
testV1SplSUpdateSupplierProfiles,
|
||||
testV1SplSRemSupplierProfiles,
|
||||
testV1SplSGetSupplierForEvent,
|
||||
// reset the database and load the TP again
|
||||
// testV1SplSInitDataDb,
|
||||
// testV1SplSFromFolder,
|
||||
// for the moment we decide to comment the tests
|
||||
// testV1SplsOneSupplierWithoutDestination,
|
||||
testV1SplSupplierPing,
|
||||
testV1SplSStopEngine,
|
||||
}
|
||||
|
||||
// Test start here
|
||||
func TestSuplSV1ITMySQL(t *testing.T) {
|
||||
splSv1ConfDIR = "tutmysql"
|
||||
for _, stest := range sTestsSupplierSV1 {
|
||||
t.Run(splSv1ConfDIR, stest)
|
||||
func TestSuplSV1IT(t *testing.T) {
|
||||
switch *dbType {
|
||||
case utils.MetaInternal:
|
||||
splSv1ConfDIR = "tutinternal"
|
||||
case utils.MetaSQL:
|
||||
splSv1ConfDIR = "tutmysql"
|
||||
case utils.MetaMongo:
|
||||
splSv1ConfDIR = "tutmongo"
|
||||
case utils.MetaPostgres:
|
||||
t.SkipNow()
|
||||
default:
|
||||
t.Fatal("Unknown Database type")
|
||||
}
|
||||
}
|
||||
|
||||
func TestSuplSV1ITMongo(t *testing.T) {
|
||||
splSv1ConfDIR = "tutmongo"
|
||||
for _, stest := range sTestsSupplierSV1 {
|
||||
t.Run(splSv1ConfDIR, stest)
|
||||
}
|
||||
|
||||
@@ -38,183 +38,181 @@ var (
|
||||
tSv1Rpc *rpc.Client
|
||||
tPrfl *engine.ThresholdWithCache
|
||||
tSv1ConfDIR string //run tests for specific configuration
|
||||
|
||||
tEvs = []*engine.ArgsProcessEvent{
|
||||
{
|
||||
CGREvent: &utils.CGREvent{ // hitting THD_ACNT_BALANCE_1
|
||||
Tenant: "cgrates.org",
|
||||
ID: "event1",
|
||||
Event: map[string]interface{}{
|
||||
utils.EventType: utils.AccountUpdate,
|
||||
utils.Account: "1002",
|
||||
utils.AllowNegative: true,
|
||||
utils.Disabled: false,
|
||||
utils.Units: 12.3},
|
||||
},
|
||||
},
|
||||
{
|
||||
CGREvent: &utils.CGREvent{ // hitting THD_ACNT_BALANCE_1
|
||||
Tenant: "cgrates.org",
|
||||
ID: "event2",
|
||||
Event: map[string]interface{}{
|
||||
utils.EventType: utils.BalanceUpdate,
|
||||
utils.Account: "1002",
|
||||
utils.BalanceID: utils.MetaDefault,
|
||||
utils.Units: 12.3,
|
||||
utils.ExpiryTime: time.Date(2009, 11, 10, 23, 00, 0, 0, time.UTC),
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
CGREvent: &utils.CGREvent{ // hitting THD_STATS_1
|
||||
Tenant: "cgrates.org",
|
||||
ID: "event3",
|
||||
Event: map[string]interface{}{
|
||||
utils.EventType: utils.StatUpdate,
|
||||
utils.StatID: "Stats1",
|
||||
utils.Account: "1002",
|
||||
"ASR": 35.0,
|
||||
"ACD": "2m45s",
|
||||
"TCC": 12.7,
|
||||
"TCD": "12m15s",
|
||||
"ACC": 0.75,
|
||||
"PDD": "2s",
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
CGREvent: &utils.CGREvent{ // hitting THD_STATS_1 and THD_STATS_2
|
||||
Tenant: "cgrates.org",
|
||||
ID: "event4",
|
||||
Event: map[string]interface{}{
|
||||
utils.EventType: utils.StatUpdate,
|
||||
utils.StatID: "STATS_HOURLY_DE",
|
||||
utils.Account: "1002",
|
||||
"ASR": 35.0,
|
||||
"ACD": "2m45s",
|
||||
"TCD": "1h",
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
CGREvent: &utils.CGREvent{ // hitting THD_STATS_3
|
||||
Tenant: "cgrates.org",
|
||||
ID: "event5",
|
||||
Event: map[string]interface{}{
|
||||
utils.EventType: utils.StatUpdate,
|
||||
utils.StatID: "STATS_DAILY_DE",
|
||||
utils.Account: "1002",
|
||||
"ACD": "2m45s",
|
||||
"TCD": "3h1s",
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
CGREvent: &utils.CGREvent{ // hitting THD_RES_1
|
||||
Tenant: "cgrates.org",
|
||||
ID: "event6",
|
||||
Event: map[string]interface{}{
|
||||
utils.EventType: utils.ResourceUpdate,
|
||||
utils.Account: "1002",
|
||||
utils.ResourceID: "RES_GRP_1",
|
||||
utils.Usage: 10.0,
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
CGREvent: &utils.CGREvent{ // hitting THD_RES_1
|
||||
Tenant: "cgrates.org",
|
||||
ID: "event6",
|
||||
Event: map[string]interface{}{
|
||||
utils.EventType: utils.ResourceUpdate,
|
||||
utils.Account: "1002",
|
||||
utils.ResourceID: "RES_GRP_1",
|
||||
utils.Usage: 10.0,
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
CGREvent: &utils.CGREvent{ // hitting THD_RES_1
|
||||
Tenant: "cgrates.org",
|
||||
ID: "event6",
|
||||
Event: map[string]interface{}{
|
||||
utils.EventType: utils.ResourceUpdate,
|
||||
utils.Account: "1002",
|
||||
utils.ResourceID: "RES_GRP_1",
|
||||
utils.Usage: 10.0,
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
CGREvent: &utils.CGREvent{ // hitting THD_CDRS_1
|
||||
Tenant: "cgrates.org",
|
||||
ID: "cdrev1",
|
||||
Event: map[string]interface{}{
|
||||
utils.EventType: utils.CDR,
|
||||
"field_extr1": "val_extr1",
|
||||
"fieldextr2": "valextr2",
|
||||
utils.CGRID: utils.Sha1("dsafdsaf", time.Date(2013, 11, 7, 8, 42, 26, 0, time.UTC).String()),
|
||||
utils.RunID: utils.MetaRaw,
|
||||
utils.OrderID: 123,
|
||||
utils.OriginHost: "192.168.1.1",
|
||||
utils.Source: utils.UNIT_TEST,
|
||||
utils.OriginID: "dsafdsaf",
|
||||
utils.ToR: utils.VOICE,
|
||||
utils.RequestType: utils.META_RATED,
|
||||
utils.Direction: "*out",
|
||||
utils.Tenant: "cgrates.org",
|
||||
utils.Category: "call",
|
||||
utils.Account: "1007",
|
||||
utils.Subject: "1007",
|
||||
utils.Destination: "+4986517174963",
|
||||
utils.SetupTime: time.Date(2013, 11, 7, 8, 42, 20, 0, time.UTC),
|
||||
utils.PDD: time.Duration(0) * time.Second,
|
||||
utils.AnswerTime: time.Date(2013, 11, 7, 8, 42, 26, 0, time.UTC),
|
||||
utils.Usage: time.Duration(10) * time.Second,
|
||||
utils.SUPPLIER: "SUPPL1",
|
||||
utils.COST: -1.0,
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
sTestsThresholdSV1 = []func(t *testing.T){
|
||||
testV1TSLoadConfig,
|
||||
testV1TSInitDataDb,
|
||||
testV1TSResetStorDb,
|
||||
testV1TSStartEngine,
|
||||
testV1TSRpcConn,
|
||||
testV1TSFromFolder,
|
||||
testV1TSGetThresholds,
|
||||
testV1TSProcessEvent,
|
||||
testV1TSGetThresholdsAfterProcess,
|
||||
testV1TSGetThresholdsAfterRestart,
|
||||
testv1TSGetThresholdProfileIDs,
|
||||
testV1TSSetThresholdProfile,
|
||||
testV1TSUpdateThresholdProfile,
|
||||
testV1TSRemoveThresholdProfile,
|
||||
testV1TSMaxHits,
|
||||
testV1TSStopEngine,
|
||||
}
|
||||
)
|
||||
|
||||
var tEvs = []*engine.ArgsProcessEvent{
|
||||
{
|
||||
CGREvent: &utils.CGREvent{ // hitting THD_ACNT_BALANCE_1
|
||||
Tenant: "cgrates.org",
|
||||
ID: "event1",
|
||||
Event: map[string]interface{}{
|
||||
utils.EventType: utils.AccountUpdate,
|
||||
utils.Account: "1002",
|
||||
utils.AllowNegative: true,
|
||||
utils.Disabled: false,
|
||||
utils.Units: 12.3},
|
||||
},
|
||||
},
|
||||
{
|
||||
CGREvent: &utils.CGREvent{ // hitting THD_ACNT_BALANCE_1
|
||||
Tenant: "cgrates.org",
|
||||
ID: "event2",
|
||||
Event: map[string]interface{}{
|
||||
utils.EventType: utils.BalanceUpdate,
|
||||
utils.Account: "1002",
|
||||
utils.BalanceID: utils.MetaDefault,
|
||||
utils.Units: 12.3,
|
||||
utils.ExpiryTime: time.Date(2009, 11, 10, 23, 00, 0, 0, time.UTC),
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
CGREvent: &utils.CGREvent{ // hitting THD_STATS_1
|
||||
Tenant: "cgrates.org",
|
||||
ID: "event3",
|
||||
Event: map[string]interface{}{
|
||||
utils.EventType: utils.StatUpdate,
|
||||
utils.StatID: "Stats1",
|
||||
utils.Account: "1002",
|
||||
"ASR": 35.0,
|
||||
"ACD": "2m45s",
|
||||
"TCC": 12.7,
|
||||
"TCD": "12m15s",
|
||||
"ACC": 0.75,
|
||||
"PDD": "2s",
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
CGREvent: &utils.CGREvent{ // hitting THD_STATS_1 and THD_STATS_2
|
||||
Tenant: "cgrates.org",
|
||||
ID: "event4",
|
||||
Event: map[string]interface{}{
|
||||
utils.EventType: utils.StatUpdate,
|
||||
utils.StatID: "STATS_HOURLY_DE",
|
||||
utils.Account: "1002",
|
||||
"ASR": 35.0,
|
||||
"ACD": "2m45s",
|
||||
"TCD": "1h",
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
CGREvent: &utils.CGREvent{ // hitting THD_STATS_3
|
||||
Tenant: "cgrates.org",
|
||||
ID: "event5",
|
||||
Event: map[string]interface{}{
|
||||
utils.EventType: utils.StatUpdate,
|
||||
utils.StatID: "STATS_DAILY_DE",
|
||||
utils.Account: "1002",
|
||||
"ACD": "2m45s",
|
||||
"TCD": "3h1s",
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
CGREvent: &utils.CGREvent{ // hitting THD_RES_1
|
||||
Tenant: "cgrates.org",
|
||||
ID: "event6",
|
||||
Event: map[string]interface{}{
|
||||
utils.EventType: utils.ResourceUpdate,
|
||||
utils.Account: "1002",
|
||||
utils.ResourceID: "RES_GRP_1",
|
||||
utils.Usage: 10.0,
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
CGREvent: &utils.CGREvent{ // hitting THD_RES_1
|
||||
Tenant: "cgrates.org",
|
||||
ID: "event6",
|
||||
Event: map[string]interface{}{
|
||||
utils.EventType: utils.ResourceUpdate,
|
||||
utils.Account: "1002",
|
||||
utils.ResourceID: "RES_GRP_1",
|
||||
utils.Usage: 10.0,
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
CGREvent: &utils.CGREvent{ // hitting THD_RES_1
|
||||
Tenant: "cgrates.org",
|
||||
ID: "event6",
|
||||
Event: map[string]interface{}{
|
||||
utils.EventType: utils.ResourceUpdate,
|
||||
utils.Account: "1002",
|
||||
utils.ResourceID: "RES_GRP_1",
|
||||
utils.Usage: 10.0,
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
CGREvent: &utils.CGREvent{ // hitting THD_CDRS_1
|
||||
Tenant: "cgrates.org",
|
||||
ID: "cdrev1",
|
||||
Event: map[string]interface{}{
|
||||
utils.EventType: utils.CDR,
|
||||
"field_extr1": "val_extr1",
|
||||
"fieldextr2": "valextr2",
|
||||
utils.CGRID: utils.Sha1("dsafdsaf", time.Date(2013, 11, 7, 8, 42, 26, 0, time.UTC).String()),
|
||||
utils.RunID: utils.MetaRaw,
|
||||
utils.OrderID: 123,
|
||||
utils.OriginHost: "192.168.1.1",
|
||||
utils.Source: utils.UNIT_TEST,
|
||||
utils.OriginID: "dsafdsaf",
|
||||
utils.ToR: utils.VOICE,
|
||||
utils.RequestType: utils.META_RATED,
|
||||
utils.Direction: "*out",
|
||||
utils.Tenant: "cgrates.org",
|
||||
utils.Category: "call",
|
||||
utils.Account: "1007",
|
||||
utils.Subject: "1007",
|
||||
utils.Destination: "+4986517174963",
|
||||
utils.SetupTime: time.Date(2013, 11, 7, 8, 42, 20, 0, time.UTC),
|
||||
utils.PDD: time.Duration(0) * time.Second,
|
||||
utils.AnswerTime: time.Date(2013, 11, 7, 8, 42, 26, 0, time.UTC),
|
||||
utils.Usage: time.Duration(10) * time.Second,
|
||||
utils.SUPPLIER: "SUPPL1",
|
||||
utils.COST: -1.0,
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
var sTestsThresholdSV1 = []func(t *testing.T){
|
||||
testV1TSLoadConfig,
|
||||
testV1TSInitDataDb,
|
||||
testV1TSResetStorDb,
|
||||
testV1TSStartEngine,
|
||||
testV1TSRpcConn,
|
||||
testV1TSFromFolder,
|
||||
testV1TSGetThresholds,
|
||||
testV1TSProcessEvent,
|
||||
testV1TSGetThresholdsAfterProcess,
|
||||
testV1TSGetThresholdsAfterRestart,
|
||||
testv1TSGetThresholdProfileIDs,
|
||||
testV1TSSetThresholdProfile,
|
||||
testV1TSUpdateThresholdProfile,
|
||||
testV1TSRemoveThresholdProfile,
|
||||
testV1TSMaxHits,
|
||||
testV1TSStopEngine,
|
||||
}
|
||||
|
||||
// Test start here
|
||||
func TestTSV1ITMySQL(t *testing.T) {
|
||||
tSv1ConfDIR = "tutmysql"
|
||||
for _, stest := range sTestsThresholdSV1 {
|
||||
t.Run(tSv1ConfDIR, stest)
|
||||
func TestTSV1IT(t *testing.T) {
|
||||
switch *dbType {
|
||||
case utils.MetaInternal:
|
||||
tSv1ConfDIR = "tutinternal"
|
||||
case utils.MetaSQL:
|
||||
tSv1ConfDIR = "tutmysql"
|
||||
case utils.MetaMongo:
|
||||
tSv1ConfDIR = "tutmongo"
|
||||
case utils.MetaPostgres:
|
||||
t.SkipNow()
|
||||
default:
|
||||
t.Fatal("Unknown Database type")
|
||||
}
|
||||
}
|
||||
|
||||
func TestTSV1ITMongo(t *testing.T) {
|
||||
tSv1ConfDIR = "tutmongo"
|
||||
for _, stest := range sTestsThresholdSV1 {
|
||||
t.Run(tSv1ConfDIR, stest)
|
||||
}
|
||||
}
|
||||
|
||||
func TestTSV1ITInternal(t *testing.T) {
|
||||
tSv1ConfDIR = "tutinternal"
|
||||
for _, stest := range sTestsThresholdSV1 {
|
||||
t.Run(tSv1ConfDIR, stest)
|
||||
}
|
||||
|
||||
@@ -39,40 +39,38 @@ var (
|
||||
tpRPC *rpc.Client
|
||||
tpDataDir = "/usr/share/cgrates"
|
||||
tpConfigDIR string //run tests for specific configuration
|
||||
|
||||
sTestsTP = []func(t *testing.T){
|
||||
testTPInitCfg,
|
||||
testTPResetStorDb,
|
||||
testTPStartEngine,
|
||||
testTPRpcConn,
|
||||
testTPImportTPFromFolderPath,
|
||||
testTPExportTPToFolder,
|
||||
testTPKillEngine,
|
||||
}
|
||||
)
|
||||
|
||||
var sTestsTP = []func(t *testing.T){
|
||||
testTPInitCfg,
|
||||
testTPResetStorDb,
|
||||
testTPStartEngine,
|
||||
testTPRpcConn,
|
||||
testTPImportTPFromFolderPath,
|
||||
testTPExportTPToFolder,
|
||||
testTPKillEngine,
|
||||
}
|
||||
|
||||
//Test start here
|
||||
func TestTPITMySql(t *testing.T) {
|
||||
func TestTPIT(t *testing.T) {
|
||||
switch *dbType {
|
||||
case utils.MetaInternal:
|
||||
tpConfigDIR = "tutinternal"
|
||||
case utils.MetaSQL:
|
||||
tpConfigDIR = "tutmysql"
|
||||
case utils.MetaMongo:
|
||||
tpConfigDIR = "tutmongo"
|
||||
case utils.MetaPostgres:
|
||||
tpConfigDIR = "tutpostgres"
|
||||
default:
|
||||
t.Fatal("Unknown Database type")
|
||||
}
|
||||
tpConfigDIR = "tutmysql"
|
||||
for _, stest := range sTestsTP {
|
||||
t.Run(tpConfigDIR, stest)
|
||||
}
|
||||
}
|
||||
|
||||
func TestTPITMongo(t *testing.T) {
|
||||
tpConfigDIR = "tutmongo"
|
||||
for _, stest := range sTestsTP {
|
||||
t.Run(tpConfigDIR, stest)
|
||||
}
|
||||
}
|
||||
|
||||
func TestTPITPG(t *testing.T) {
|
||||
tpConfigDIR = "tutpostgres"
|
||||
for _, stest := range sTestsTP {
|
||||
t.Run(tpConfigDIR, stest)
|
||||
}
|
||||
}
|
||||
|
||||
func testTPInitCfg(t *testing.T) {
|
||||
var err error
|
||||
tpCfgPath = path.Join(tpDataDir, "conf", "samples", tpConfigDIR)
|
||||
|
||||
@@ -38,32 +38,39 @@ var (
|
||||
vrsDelay int
|
||||
vrsConfigDIR string //run tests for specific configuration
|
||||
vrsStorageType string
|
||||
|
||||
sTestsVrs = []func(t *testing.T){
|
||||
testVrsInitCfg,
|
||||
testVrsResetStorDb,
|
||||
testVrsStartEngine,
|
||||
testVrsRpcConn,
|
||||
testVrsDataDB,
|
||||
testVrsStorDB,
|
||||
testVrsSetDataDBVrs,
|
||||
testVrsSetStorDBVrs,
|
||||
testVrsKillEngine,
|
||||
}
|
||||
)
|
||||
|
||||
var sTestsVrs = []func(t *testing.T){
|
||||
testVrsInitCfg,
|
||||
testVrsResetStorDb,
|
||||
testVrsStartEngine,
|
||||
testVrsRpcConn,
|
||||
testVrsDataDB,
|
||||
testVrsStorDB,
|
||||
testVrsSetDataDBVrs,
|
||||
testVrsSetStorDBVrs,
|
||||
testVrsKillEngine,
|
||||
}
|
||||
|
||||
//Test start here
|
||||
func TestVrsITMySql(t *testing.T) {
|
||||
vrsConfigDIR = "tutmysql"
|
||||
vrsStorageType = utils.REDIS
|
||||
for _, stest := range sTestsVrs {
|
||||
t.Run(vrsConfigDIR, stest)
|
||||
func TestVrsIT(t *testing.T) {
|
||||
switch *dbType {
|
||||
case utils.MetaInternal:
|
||||
// vrsConfigDIR = "tutinternal"
|
||||
// vrsStorageType = utils.INTERNAL
|
||||
t.SkipNow() // as is commented below
|
||||
case utils.MetaSQL:
|
||||
vrsConfigDIR = "tutmysql"
|
||||
vrsStorageType = utils.REDIS
|
||||
case utils.MetaMongo:
|
||||
vrsConfigDIR = "tutmongo"
|
||||
vrsStorageType = utils.MONGO
|
||||
case utils.MetaPostgres:
|
||||
t.SkipNow()
|
||||
default:
|
||||
t.Fatal("Unknown Database type")
|
||||
}
|
||||
}
|
||||
|
||||
func TestVrsITMongo(t *testing.T) {
|
||||
vrsConfigDIR = "tutmongo"
|
||||
vrsStorageType = utils.MONGO
|
||||
for _, stest := range sTestsVrs {
|
||||
t.Run(vrsConfigDIR, stest)
|
||||
}
|
||||
|
||||
@@ -16,15 +16,13 @@
|
||||
},
|
||||
|
||||
|
||||
"data_db": { // database used to store runtime data (eg: accounts, cdr stats)
|
||||
"db_type": "redis", // data_db type: <redis|mongo>
|
||||
"db_port": 6379, // data_db port to reach the database
|
||||
"db_name": "10", // data_db database name to connect to
|
||||
"data_db": {
|
||||
"db_type": "*internal",
|
||||
},
|
||||
|
||||
|
||||
"stor_db": {
|
||||
"db_password": "CGRateS.org",
|
||||
"db_type": "*internal",
|
||||
},
|
||||
|
||||
|
||||
|
||||
@@ -16,15 +16,17 @@
|
||||
},
|
||||
|
||||
|
||||
"data_db": { // database used to store runtime data (eg: accounts, cdr stats)
|
||||
"db_type": "redis", // data_db type: <redis|mongo>
|
||||
"db_port": 6379, // data_db port to reach the database
|
||||
"db_name": "10", // data_db database name to connect to
|
||||
"data_db": {
|
||||
"db_type": "mongo",
|
||||
"db_name": "10",
|
||||
"db_port": 27017,
|
||||
},
|
||||
|
||||
|
||||
"stor_db": {
|
||||
"db_password": "CGRateS.org",
|
||||
"db_type": "mongo",
|
||||
"db_name": "cgrates",
|
||||
"db_port": 27017,
|
||||
},
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user