Revise randomly failing tests

This commit is contained in:
ionutboangiu
2023-03-24 13:03:40 -04:00
committed by Dan Christian Bogos
parent 3fac828218
commit 15b404e8cf
8 changed files with 99 additions and 127 deletions

View File

@@ -960,6 +960,7 @@ func testInternalReplicateStats(t *testing.T) {
} else if reply != utils.OK {
t.Error("Unexpected reply returned", reply)
}
time.Sleep(50 * time.Millisecond) // wait for the replication
var rcv *engine.StatQueueProfile
if err := engineOneRPC.Call(utils.APIerSv1GetStatQueueProfile,
&utils.TenantID{Tenant: "cgrates.org", ID: "StatsToReplicate"}, &rcv); err != nil {

View File

@@ -1,73 +1,68 @@
{
// Real-time Online/Offline Charging System (OCS) for Telecom & ISP environments
// Copyright (C) ITsysCOM GmbH
"general": {
"log_level": 7,
"node_id":"MasterReplication",
"node_id":"MasterReplication"
},
"listen": {
"rpc_json": "127.0.0.1:2012",
"rpc_gob": "127.0.0.1:2013",
"http": "127.0.0.1:2080",
"http": "127.0.0.1:2080"
},
"rpc_conns": {
"rplConn": {
"strategy": "*broadcast_sync",
"conns": [{"address": "127.0.0.1:22012", "transport": "*json"}],
},
"conns": [{"address": "127.0.0.1:22012", "transport": "*json"}]
}
},
"data_db": {
"db_type": "mongo",
"db_name": "10",
"db_port": 27017,
"db_port": 27017
},
"stor_db": {
"db_type": "mongo",
"db_name": "cgrates",
"db_port": 27017,
"db_port": 27017
},
"rals": {
"enabled": true,
"enabled": true
},
"schedulers": {
"enabled": true,
"enabled": true
},
"cdrs": {
"enabled": true,
"enabled": true
},
"attributes": {
"enabled": true,
"enabled": true
},
"chargers": {
"enabled": true,
"attributes_conns": ["*internal"],
"attributes_conns": ["*internal"]
},
"sessions": {
"enabled": true,
"debit_interval": "5ms", // interval to perform debits on.
"debit_interval": "5ms",
"replication_conns": ["rplConn"],
"rals_conns": ["*internal"],
"cdrs_conns": ["*internal"],
"chargers_conns": ["*internal"],
"chargers_conns": ["*internal"]
},
"apiers": {
"enabled": true,
"scheduler_conns": ["*internal"],
},
"scheduler_conns": ["*internal"]
}
}

View File

@@ -1,64 +1,60 @@
{
// Real-time Online/Offline Charging System (OCS) for Telecom & ISP environments
// Copyright (C) ITsysCOM GmbH
"general": {
"log_level": 7,
"node_id":"MasterReplication",
"node_id":"MasterReplication"
},
"listen": {
"rpc_json": "127.0.0.1:2012",
"rpc_gob": "127.0.0.1:2013",
"http": "127.0.0.1:2080",
"http": "127.0.0.1:2080"
},
"rpc_conns": {
"rplConn": {
"strategy": "*broadcast_sync",
"conns": [{"address": "127.0.0.1:22012", "transport": "*json"}],
},
"conns": [{"address": "127.0.0.1:22012", "transport": "*json"}]
}
},
"stor_db": { // database used to store offline tariff plans and CDRs
"db_password": "CGRateS.org", // password to use when connecting to stordb
"stor_db": {
"db_password": "CGRateS.org"
},
"rals": {
"enabled": true,
"enabled": true
},
"schedulers": {
"enabled": true,
"enabled": true
},
"cdrs": {
"enabled": true,
"enabled": true
},
"attributes": {
"enabled": true,
"enabled": true
},
"chargers": {
"enabled": true,
"attributes_conns": ["*internal"],
"attributes_conns": ["*internal"]
},
"sessions": {
"enabled": true,
"debit_interval": "5ms", // interval to perform debits on.
"debit_interval": "5ms",
"replication_conns": ["rplConn"],
"rals_conns": ["*internal"],
"cdrs_conns": ["*internal"],
"chargers_conns": ["*internal"],
"chargers_conns": ["*internal"]
},
"apiers": {
"enabled": true,
"scheduler_conns": ["*internal"],
},
"scheduler_conns": ["*internal"]
}
}

View File

@@ -1,78 +1,68 @@
{
// Real-time Online/Offline Charging System (OCS) for Telecom & ISP environments
// Copyright (C) ITsysCOM GmbH
"general": {
"log_level": 7,
"node_id":"SlaveReplication",
"node_id":"SlaveReplication"
},
"listen": {
"rpc_json": "127.0.0.1:22012", // RPC JSON listening address
"rpc_gob": "127.0.0.1:22013", // RPC GOB listening address
"http": "127.0.0.1:22080", // HTTP listening address
"rpc_json": "127.0.0.1:22012",
"rpc_gob": "127.0.0.1:22013",
"http": "127.0.0.1:22080"
},
"rpc_conns": {
"conn1": {
"strategy": "*first",
"conns": [{"address": "127.0.0.1:22012", "transport":"*json"}],
},
"rplConn": {
"strategy": "*broadcast",
"conns": [{"address": "127.0.0.1:2012", "transport": "*json"}],
"conns": [{"address": "127.0.0.1:22012", "transport":"*json"}]
}
},
"data_db": {
"db_type": "mongo",
"db_name": "10",
"db_port": 27017,
"db_port": 27017
},
"stor_db": {
"db_type": "mongo",
"db_name": "cgrates",
"db_port": 27017,
"db_port": 27017
},
"rals": {
"enabled": true, // enable Rater service: <true|false>
"enabled": true
},
"cdrs": {
"enabled": true, // start the CDR Server service: <true|false>
"enabled": true
},
"schedulers": {
"enabled": true,
"enabled": true
},
"attributes": {
"enabled": true,
"enabled": true
},
"chargers": {
"enabled": true,
"attributes_conns": ["*internal"],
"attributes_conns": ["*internal"]
},
"sessions": {
"enabled": true, // starts SessionManager service: <true|false>
"debit_interval": "5ms", // interval to perform debits on.
"listen_bijson": "127.0.0.1:22014", // address where to listen for bidirectional JSON-RPC requests
"replication_conns": ["rplConn"],
"enabled": true,
"debit_interval": "5ms",
"listen_bijson": "127.0.0.1:22014",
"rals_conns": ["conn1"],
"cdrs_conns": ["*internal"],
"chargers_conns": ["*internal"],
"chargers_conns": ["*internal"]
},
"apiers": {
"enabled": true,
"scheduler_conns": ["*internal"],
},
"scheduler_conns": ["*internal"]
}
}

View File

@@ -1,69 +1,60 @@
{
// Real-time Online/Offline Charging System (OCS) for Telecom & ISP environments
// Copyright (C) ITsysCOM GmbH
"general": {
"log_level": 7,
"node_id":"SlaveReplication",
"node_id":"SlaveReplication"
},
"listen": {
"rpc_json": "127.0.0.1:22012", // RPC JSON listening address
"rpc_gob": "127.0.0.1:22013", // RPC GOB listening address
"http": "127.0.0.1:22080", // HTTP listening address
"rpc_json": "127.0.0.1:22012",
"rpc_gob": "127.0.0.1:22013",
"http": "127.0.0.1:22080"
},
"rpc_conns": {
"conn1": {
"strategy": "*first",
"conns": [{"address": "127.0.0.1:22012", "transport":"*json"}],
},
"rplConn": {
"strategy": "*broadcast",
"conns": [{"address": "127.0.0.1:2012", "transport": "*json"}],
"conns": [{"address": "127.0.0.1:22012", "transport":"*json"}]
}
},
"stor_db": { // database used to store offline tariff plans and CDRs
"db_password": "CGRateS.org", // password to use when connecting to stordb
"stor_db": {
"db_password": "CGRateS.org"
},
"rals": {
"enabled": true, // enable Rater service: <true|false>
"enabled": true
},
"cdrs": {
"enabled": true, // start the CDR Server service: <true|false>
"enabled": true
},
"schedulers": {
"enabled": true,
"enabled": true
},
"attributes": {
"enabled": true,
"enabled": true
},
"chargers": {
"enabled": true,
"attributes_conns": ["*internal"],
"attributes_conns": ["*internal"]
},
"sessions": {
"enabled": true, // starts SessionManager service: <true|false>
"debit_interval": "5ms", // interval to perform debits on.
"listen_bijson": "127.0.0.1:22014", // address where to listen for bidirectional JSON-RPC requests
"replication_conns": ["rplConn"],
"enabled": true,
"debit_interval": "5ms",
"listen_bijson": "127.0.0.1:22014",
"rals_conns": ["conn1"],
"cdrs_conns": ["*internal"],
"chargers_conns": ["*internal"],
"chargers_conns": ["*internal"]
},
"apiers": {
"enabled": true,
"scheduler_conns": ["*internal"],
},
"scheduler_conns": ["*internal"]
}
}

View File

@@ -52,7 +52,7 @@ var (
testSQLStop,
}
cdr = &engine.CDR{
CGRID: "CGRID",
CGRID: utils.UUIDSha1Prefix(),
RunID: "RunID",
}
db *gorm.DB
@@ -146,7 +146,6 @@ func testSQLInitDBs(t *testing.T) {
}
}
func testSQLInitDB(t *testing.T) {
cdr.CGRID = utils.UUIDSha1Prefix()
var err error
db, err = gorm.Open("mysql", fmt.Sprintf(dbConnString, "cgrates2"))
if err != nil {

View File

@@ -218,7 +218,7 @@ func testSessionSRplInitiate(t *testing.T) {
}, &aSessions); err != nil {
t.Error(err)
} else if len(aSessions) != 1 {
t.Errorf("Unexpected number of sessions received: %+v", utils.ToIJSON(aSessions))
t.Errorf("Unexpected number of sessions received: %+v", utils.ToJSON(aSessions))
// a tolerance of +/- 5ms is acceptable
} else if aSessions[0].Usage < 5*time.Millisecond || aSessions[0].Usage > 15*time.Millisecond {
t.Errorf("Expecting : ~%+v, received: %+v", 10*time.Millisecond, aSessions[0].Usage) //here
@@ -239,7 +239,7 @@ func testSessionSRplInitiate(t *testing.T) {
} else if pSessions[0].Usage < 5*time.Millisecond || pSessions[0].Usage > 15*time.Millisecond {
t.Errorf("Expecting : %+v, received: %+v", 10*time.Millisecond, pSessions[0].Usage)
} else if autoDebit1 = pSessions[0].NextAutoDebit; autoDebit1.IsZero() {
t.Errorf("unexpected NextAutoDebit: %s", utils.ToIJSON(aSessions[0]))
t.Errorf("unexpected NextAutoDebit: %s", utils.ToJSON(aSessions[0]))
}
//check active session (II)
@@ -252,7 +252,7 @@ func testSessionSRplInitiate(t *testing.T) {
}, &aSessions); err != nil {
t.Error(err)
} else if len(aSessions) != 1 {
t.Errorf("Unexpected number of sessions received: %+v", utils.ToIJSON(aSessions))
t.Errorf("Unexpected number of sessions received: %+v", utils.ToJSON(aSessions))
// a tolerance of +/- 5ms is acceptable
} else if aSessions[0].Usage < 15*time.Millisecond || aSessions[0].Usage > 25*time.Millisecond {
t.Errorf("Expecting : ~%+v, received: %+v", 20*time.Millisecond, aSessions[0].Usage) //here
@@ -271,7 +271,7 @@ func testSessionSRplInitiate(t *testing.T) {
} else if pSessions[0].Usage < 15*time.Millisecond || pSessions[0].Usage > 25*time.Millisecond {
t.Errorf("Expecting : %+v, received: %+v", 20*time.Millisecond, pSessions[0].Usage)
} else if autoDebit2 = pSessions[0].NextAutoDebit; autoDebit2.IsZero() {
t.Errorf("unexpected NextAutoDebit: %s", utils.ToIJSON(aSessions[0]))
t.Errorf("unexpected NextAutoDebit: %s", utils.ToJSON(aSessions[0]))
} else if autoDebit1 == autoDebit2 {
t.Error("Expecting NextAutoDebit to be different from the previous one")
}
@@ -301,7 +301,7 @@ func testSessionSRplStopMasterEngine(t *testing.T) {
if err := smgRplcSlvRPC.Call(utils.SessionSv1GetActiveSessions, nil, &aSessions); err != nil {
t.Error(err)
} else if len(aSessions) != 1 {
t.Errorf("Unexpected number of sessions received: %+v", utils.ToIJSON(aSessions))
t.Errorf("Unexpected number of sessions received: %+v", utils.ToJSON(aSessions))
// a tolerance of +/- 5ms is acceptable
} else if aSessions[0].Usage < 15*time.Millisecond || aSessions[0].Usage > 25*time.Millisecond {
t.Errorf("Expecting : ~%+v, received: %+v", 20*time.Millisecond, aSessions[0].Usage) //here
@@ -325,23 +325,23 @@ func testSessionSRplActivateSlave(t *testing.T) {
if err := smgRplcSlvRPC.Call(utils.SessionSv1GetActiveSessions, new(utils.SessionFilter), &aSessions); err != nil {
t.Error(err)
} else if len(aSessions) != 1 {
t.Errorf("Unexpected number of sessions received: %+v", utils.ToIJSON(aSessions))
t.Errorf("Unexpected number of sessions received: %+v", utils.ToJSON(aSessions))
// a tolerance of +/- 5ms is acceptable
} else if aSessions[0].Usage < 20*time.Millisecond || aSessions[0].Usage > 30*time.Millisecond {
t.Errorf("Expecting : ~%+v, received: %+v", 25*time.Millisecond, aSessions[0].Usage) //here
} else if autoDebit1 = aSessions[0].NextAutoDebit; autoDebit1.IsZero() {
t.Errorf("unexpected NextAutoDebit: %s", utils.ToIJSON(aSessions[0]))
t.Errorf("unexpected NextAutoDebit: %s", utils.ToJSON(aSessions[0]))
}
time.Sleep(10 * time.Millisecond)
if err := smgRplcSlvRPC.Call(utils.SessionSv1GetActiveSessions, new(utils.SessionFilter), &aSessions); err != nil {
t.Error(err)
} else if len(aSessions) != 1 {
t.Errorf("Unexpected number of sessions received: %+v", utils.ToIJSON(aSessions))
t.Errorf("Unexpected number of sessions received: %+v", utils.ToJSON(aSessions))
// a tolerance of +/- 5ms is acceptable
} else if aSessions[0].Usage < 30*time.Millisecond || aSessions[0].Usage > 45*time.Millisecond {
t.Errorf("Expecting : ~%+v, received: %+v", 40*time.Millisecond, aSessions[0].Usage) //here
} else if aSessions[0].Usage < 25*time.Millisecond || aSessions[0].Usage > 40*time.Millisecond {
t.Errorf("Expecting : ~%+v, received: %+v", 35*time.Millisecond, aSessions[0].Usage) //here
} else if autoDebit2 = aSessions[0].NextAutoDebit; autoDebit2.IsZero() {
t.Errorf("unexpected NextAutoDebit: %s", utils.ToIJSON(aSessions[0]))
t.Errorf("unexpected NextAutoDebit: %s", utils.ToJSON(aSessions[0]))
} else if autoDebit1 == autoDebit2 {
t.Error("Expecting NextAutoDebit to be different from the previous one")
}
@@ -358,8 +358,8 @@ func testSessionSRplCheckAccount(t *testing.T) {
if err := smgRplcSlvRPC.Call(utils.APIerSv2GetAccount, attrs, &acnt); err != nil {
t.Error(err)
// a tolerance of +/- 5ms is acceptable
} else if rply := acnt.BalanceMap[utils.VOICE].GetTotalValue(); rply < float64(5*time.Second-45*time.Millisecond) || rply > float64(5*time.Second-30*time.Millisecond) {
t.Errorf("Expecting: ~%v, received: %v", float64(5*time.Second-40*time.Millisecond), rply)
} else if rply := acnt.BalanceMap[utils.VOICE].GetTotalValue(); rply < float64(5*time.Second-40*time.Millisecond) || rply > float64(5*time.Second-25*time.Millisecond) {
t.Errorf("Expecting: ~%v, received: %v", float64(5*time.Second-35*time.Millisecond), rply)
}
}
@@ -395,13 +395,13 @@ func testSessionSRplTerminate(t *testing.T) {
//check if the session was terminated on slave
if err := smgRplcSlvRPC.Call(utils.SessionSv1GetActiveSessions,
new(utils.SessionFilter), &aSessions); err == nil || err.Error() != utils.ErrNotFound.Error() {
t.Errorf("Error: %v with len(aSessions)=%v , session : %+v", err, len(aSessions), utils.ToIJSON(aSessions))
t.Errorf("Error: %v with len(aSessions)=%v , session : %+v", err, len(aSessions), utils.ToJSON(aSessions))
}
// check to don't have passive session on slave
var pSessions []*sessions.ExternalSession
if err := smgRplcSlvRPC.Call(utils.SessionSv1GetPassiveSessions,
new(utils.SessionFilter), &pSessions); err == nil || err.Error() != utils.ErrNotFound.Error() {
t.Errorf("Error: %v with len(pSessions)=%v , session : %+v", err, len(pSessions), utils.ToIJSON(pSessions))
t.Errorf("Error: %v with len(pSessions)=%v , session : %+v", err, len(pSessions), utils.ToJSON(pSessions))
}
var acnt *engine.Account

View File

@@ -313,7 +313,7 @@ func testSessionsDataLastUsedMultipleUpdates(t *testing.T) {
utils.RequestType: utils.META_PREPAID,
utils.SetupTime: time.Date(2016, time.January, 5, 18, 30, 59, 0, time.UTC),
utils.AnswerTime: time.Date(2016, time.January, 5, 18, 31, 05, 0, time.UTC),
utils.Usage: "6144", // 5MB
utils.Usage: "6144", // 6MB
},
},
}
@@ -338,7 +338,7 @@ func testSessionsDataLastUsedMultipleUpdates(t *testing.T) {
t.Error(err)
} else if len(aSessions) != 1 ||
aSessions[0].Usage != time.Duration(6144) {
t.Errorf("wrong active sessions: %f", aSessions[0].Usage.Seconds())
t.Errorf("wrong active sessions: %d", aSessions[0].Usage)
}
usage = int64(8192)
@@ -360,7 +360,7 @@ func testSessionsDataLastUsedMultipleUpdates(t *testing.T) {
utils.SetupTime: time.Date(2016, time.January, 5, 18, 30, 59, 0, time.UTC),
utils.AnswerTime: time.Date(2016, time.January, 5, 18, 31, 05, 0, time.UTC),
utils.Usage: "8192", // 8 MB
utils.LastUsed: "7168",
utils.LastUsed: "7168", // 7 MB
"Extra1": "other",
},
},
@@ -407,7 +407,7 @@ func testSessionsDataLastUsedMultipleUpdates(t *testing.T) {
utils.RequestType: utils.META_PREPAID,
utils.SetupTime: time.Date(2016, time.January, 5, 18, 30, 59, 0, time.UTC),
utils.AnswerTime: time.Date(2016, time.January, 5, 18, 31, 05, 0, time.UTC),
utils.Usage: "1024", // 8 MB
utils.Usage: "1024", // 1 MB
utils.LastUsed: "5120", // 5 MB
"Extra1": "other2",
"Extra2": "other",
@@ -432,7 +432,7 @@ func testSessionsDataLastUsedMultipleUpdates(t *testing.T) {
t.Error(err)
} else if len(aSessions) != 1 ||
aSessions[0].Usage != time.Duration(13312) { // 14MB in used, 2MB extra reserved
t.Errorf("wrong active sessions: %+v", aSessions[0].Usage)
t.Errorf("wrong active sessions: %d", aSessions[0].Usage)
} else if aSessions[0].ExtraFields["Extra1"] != "other2" {
t.Errorf("Expected: \"other2\", received: %v", aSessions[0].ExtraFields["Extra1"])
} else if _, has := aSessions[0].ExtraFields["Extra"]; has {
@@ -457,7 +457,7 @@ func testSessionsDataLastUsedMultipleUpdates(t *testing.T) {
utils.RequestType: utils.META_PREPAID,
utils.SetupTime: time.Date(2016, time.January, 5, 18, 30, 59, 0, time.UTC),
utils.AnswerTime: time.Date(2016, time.January, 5, 18, 31, 05, 0, time.UTC),
utils.Usage: "1024", // 8 MB
utils.Usage: "1024", // 1 MB
},
},
}
@@ -479,7 +479,7 @@ func testSessionsDataLastUsedMultipleUpdates(t *testing.T) {
t.Error(err)
} else if len(aSessions) != 1 ||
aSessions[0].Usage != time.Duration(14336) { // 14MB in use
t.Errorf("wrong active sessions: %v", aSessions[0].Usage)
t.Errorf("wrong active sessions: %d", aSessions[0].Usage)
}
termArgs := &V1TerminateSessionArgs{
@@ -704,7 +704,7 @@ func testSessionsDataTTLExpMultiUpdates(t *testing.T) {
t.Error(err)
} else if len(aSessions) != 1 ||
int64(aSessions[0].Usage) != 4096 {
t.Errorf("wrong active sessions: %d", int64(aSessions[0].Usage))
t.Errorf("wrong active sessions: %d", aSessions[0].Usage)
}
usage = int64(4096)
@@ -842,7 +842,7 @@ func testSessionsDataMultipleDataNoUsage(t *testing.T) {
t.Error(err)
} else if len(aSessions) != 1 ||
int64(aSessions[0].Usage) != 2048 {
t.Errorf("wrong active sessions usage: %d", int64(aSessions[0].Usage))
t.Errorf("wrong active sessions usage: %d", aSessions[0].Usage)
}
usage = int64(1024)
@@ -889,7 +889,7 @@ func testSessionsDataMultipleDataNoUsage(t *testing.T) {
t.Error(err)
} else if len(aSessions) != 1 ||
int64(aSessions[0].Usage) != 2048 {
t.Errorf("wrong active sessions usage: %d", int64(aSessions[0].Usage))
t.Errorf("wrong active sessions usage: %d", aSessions[0].Usage)
}
usage = int64(0)
@@ -936,7 +936,7 @@ func testSessionsDataMultipleDataNoUsage(t *testing.T) {
t.Error(err)
} else if len(aSessions) != 1 ||
int64(aSessions[0].Usage) != 1024 {
t.Errorf("wrong active sessions usage: %d", int64(aSessions[0].Usage))
t.Errorf("wrong active sessions usage: %d", aSessions[0].Usage)
}
termArgs := &V1TerminateSessionArgs{
@@ -1050,7 +1050,7 @@ func testSessionsDataTTLUsageProtection(t *testing.T) {
t.Error(err)
} else if len(aSessions) != 1 ||
int64(aSessions[0].Usage) != 2048 {
t.Errorf("wrong active sessions usage: %d", int64(aSessions[0].Usage))
t.Errorf("wrong active sessions usage: %d", aSessions[0].Usage)
}
time.Sleep(60 * time.Millisecond)
if err := sDataRPC.Call(utils.SessionSv1GetActiveSessions,