mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-19 22:28:45 +05:00
Updated integration tests
This commit is contained in:
committed by
Dan Christian Bogos
parent
b49f895cc2
commit
f63dc62519
@@ -127,37 +127,37 @@ func testActionSGetActionProfile(t *testing.T) {
|
||||
FilterIDs: []string{},
|
||||
Weight: 10,
|
||||
Schedule: utils.ASAP,
|
||||
AccountIDs: map[string]struct{}{"1001": struct{}{}, "1002": struct{}{}},
|
||||
AccountIDs: utils.StringSet{"1001": {}, "1002": {}},
|
||||
Actions: []*engine.APAction{
|
||||
&engine.APAction{
|
||||
{
|
||||
ID: "TOPUP",
|
||||
FilterIDs: []string{},
|
||||
Type: "*topup",
|
||||
Path: "~*balance.TestBalance.Value",
|
||||
Value: config.NewRSRParsersMustCompile("10", actPrfCfg.GeneralCfg().RSRSep),
|
||||
},
|
||||
&engine.APAction{
|
||||
{
|
||||
ID: "SET_BALANCE_TEST_DATA",
|
||||
FilterIDs: []string{},
|
||||
Type: "*set_balance",
|
||||
Path: "~*balance.TestDataBalance.Type",
|
||||
Value: config.NewRSRParsersMustCompile("*data", actPrfCfg.GeneralCfg().RSRSep),
|
||||
},
|
||||
&engine.APAction{
|
||||
{
|
||||
ID: "TOPUP_TEST_DATA",
|
||||
FilterIDs: []string{},
|
||||
Type: "*topup",
|
||||
Path: "~*balance.TestDataBalance.Value",
|
||||
Value: config.NewRSRParsersMustCompile("1024", actPrfCfg.GeneralCfg().RSRSep),
|
||||
},
|
||||
&engine.APAction{
|
||||
{
|
||||
ID: "SET_BALANCE_TEST_VOICE",
|
||||
FilterIDs: []string{},
|
||||
Type: "*set_balance",
|
||||
Path: "~*balance.TestVoiceBalance.Type",
|
||||
Value: config.NewRSRParsersMustCompile("*voice", actPrfCfg.GeneralCfg().RSRSep),
|
||||
},
|
||||
&engine.APAction{
|
||||
{
|
||||
ID: "TOPUP_TEST_VOICE",
|
||||
FilterIDs: []string{},
|
||||
Type: "*topup",
|
||||
@@ -166,6 +166,12 @@ func testActionSGetActionProfile(t *testing.T) {
|
||||
},
|
||||
},
|
||||
}
|
||||
if *encoding == utils.MetaGOB {
|
||||
expected.FilterIDs = nil
|
||||
for i := range expected.Actions {
|
||||
expected.Actions[i].FilterIDs = nil
|
||||
}
|
||||
}
|
||||
var reply *engine.ActionProfile
|
||||
if err := actSRPC.Call(utils.APIerSv1GetActionProfile,
|
||||
utils.TenantIDWithOpts{TenantID: &utils.TenantID{Tenant: "cgrates.org", ID: "ONE_TIME_ACT"}}, &reply); err != nil {
|
||||
|
||||
@@ -677,7 +677,7 @@ func testInternalRemoteITGetDispatcherHost(t *testing.T) {
|
||||
func testInternalRemoteITGetRouteProfile(t *testing.T) {
|
||||
var rcv *engine.RateProfile
|
||||
if err := internalRPC.Call(utils.APIerSv1GetRateProfile,
|
||||
&utils.TenantID{Tenant: "cgrates.org", ID: "RP1"},
|
||||
&utils.TenantIDWithOpts{TenantID: &utils.TenantID{Tenant: "cgrates.org", ID: "RP1"}},
|
||||
&rcv); err == nil || err.Error() != utils.ErrNotFound.Error() {
|
||||
t.Error(err)
|
||||
}
|
||||
@@ -754,7 +754,7 @@ func testInternalRemoteITGetRouteProfile(t *testing.T) {
|
||||
|
||||
var rPfrg *engine.RateProfile
|
||||
if err := internalRPC.Call(utils.APIerSv1GetRateProfile,
|
||||
&utils.TenantID{Tenant: "cgrates.org", ID: "RP1"},
|
||||
&utils.TenantIDWithOpts{TenantID: &utils.TenantID{Tenant: "cgrates.org", ID: "RP1"}},
|
||||
&rPfrg); err != nil {
|
||||
t.Error(err)
|
||||
} else if !reflect.DeepEqual(rPrf.RateProfileWithOpts.RateProfile, rPfrg) {
|
||||
|
||||
@@ -558,11 +558,7 @@ func testV1RsReleaseResource(t *testing.T) {
|
||||
t.Errorf("Resources: %+v", rs)
|
||||
}
|
||||
if rs == nil {
|
||||
t.Errorf("Expecting rs to not be nil")
|
||||
// rs shoud not be nil so exit function
|
||||
// to avoid nil segmentation fault;
|
||||
// if this happens try to run this test manualy
|
||||
return
|
||||
t.Fatal("Expecting rs to not be nil")
|
||||
}
|
||||
// make sure Resource1 have no more active resources
|
||||
for _, r := range *rs {
|
||||
@@ -636,11 +632,7 @@ func testV1RsDBStore(t *testing.T) {
|
||||
t.Errorf("Resources: %+v", rs)
|
||||
}
|
||||
if rs == nil {
|
||||
t.Errorf("Expecting rs to not be nil")
|
||||
// rs shoud not be nil so exit function
|
||||
// to avoid nil segmentation fault;
|
||||
// if this happens try to run this test manualy
|
||||
return
|
||||
t.Fatal("Expecting rs to not be nil")
|
||||
}
|
||||
// count resources before restart
|
||||
for _, r := range *rs {
|
||||
@@ -690,7 +682,7 @@ func testV1RsDBStore(t *testing.T) {
|
||||
t.Errorf("Unexpected resource: %+v", r)
|
||||
}
|
||||
case "ResGroup2":
|
||||
if len(r.Usages) != 3 || len(r.TTLIdx) != 3 {
|
||||
if len(r.Usages) != 4 || len(r.TTLIdx) != 4 {
|
||||
t.Errorf("Unexpected resource: %s", utils.ToJSON(r))
|
||||
}
|
||||
}
|
||||
@@ -914,7 +906,7 @@ func testV1RsAllocateUnlimited(t *testing.T) {
|
||||
Tenant: "cgrates.org",
|
||||
ID: "RES_ULTIMITED",
|
||||
Usages: map[string]*engine.ResourceUsage{
|
||||
"651a8db2-4f67-4cf8-b622-169e8a482e51": &engine.ResourceUsage{
|
||||
"651a8db2-4f67-4cf8-b622-169e8a482e51": {
|
||||
Tenant: "cgrates.org",
|
||||
ID: "651a8db2-4f67-4cf8-b622-169e8a482e51",
|
||||
Units: 1,
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
"node_id": "TestFailCDRS",
|
||||
"poster_attempts": 1, // number of attempts before considering post request failed (eg: *http_post, CDR exports)
|
||||
"failed_posts_ttl": "1s", // time to wait before writing the failed posts in a single file
|
||||
"failed_posts_dir": "/tmp/failed_posts" // directory path where we store failed requests
|
||||
},
|
||||
|
||||
"stor_db": {
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
"log_level": 7,
|
||||
"poster_attempts": 1, // number of attempts before considering post request failed (eg: *http_post, CDR exports)
|
||||
"failed_posts_ttl": "1s", // time to wait before writing the failed posts in a single file
|
||||
"failed_posts_dir": "/tmp/failed_posts" // directory path where we store failed requests
|
||||
},
|
||||
|
||||
"data_db": {
|
||||
|
||||
@@ -7,7 +7,8 @@
|
||||
"general": {
|
||||
"log_level": 7,
|
||||
"poster_attempts": 1, // number of attempts before considering post request failed (eg: *http_post, CDR exports)
|
||||
"failed_posts_ttl": "1s" // time to wait before writing the failed posts in a single file
|
||||
"failed_posts_ttl": "1s", // time to wait before writing the failed posts in a single file
|
||||
"failed_posts_dir": "/tmp/failed_posts" // directory path where we store failed requests
|
||||
},
|
||||
|
||||
|
||||
|
||||
@@ -383,7 +383,7 @@ func (rS *ResourceService) storeResources() {
|
||||
break // no more keys, backup completed
|
||||
}
|
||||
if rIf, ok := Cache.Get(utils.CacheResources, rID); !ok || rIf == nil {
|
||||
utils.Logger.Warning(fmt.Sprintf("<ResourceS> failed retrieving from cache resource with ID: %s", rID))
|
||||
utils.Logger.Warning(fmt.Sprintf("<%s> failed retrieving from cache resource with ID: %s", utils.ResourceS, rID))
|
||||
} else if err := rS.StoreResource(rIf.(*Resource)); err != nil {
|
||||
failedRIDs = append(failedRIDs, rID) // record failure so we can schedule it for next backup
|
||||
}
|
||||
|
||||
@@ -23,6 +23,7 @@ package general_tests
|
||||
import (
|
||||
"io/ioutil"
|
||||
"net/rpc"
|
||||
"os"
|
||||
"path"
|
||||
"testing"
|
||||
"time"
|
||||
@@ -78,6 +79,12 @@ func testCDRsPostFailoverInitConfig(t *testing.T) {
|
||||
if cdrsPostFailCfg, err = config.NewCGRConfigFromPath(cdrsPostFailCfgPath); err != nil {
|
||||
t.Fatal("Got config error: ", err.Error())
|
||||
}
|
||||
if err = os.RemoveAll(cdrsPostFailCfg.GeneralCfg().FailedPostsDir); err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
if err = os.MkdirAll(cdrsPostFailCfg.GeneralCfg().FailedPostsDir, 0755); err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
}
|
||||
|
||||
func testCDRsPostFailoverInitDataDb(t *testing.T) {
|
||||
@@ -206,6 +213,9 @@ func testCDRsPostFailoverToFile(t *testing.T) {
|
||||
}
|
||||
|
||||
func testCDRsPostFailoverKillEngine(t *testing.T) {
|
||||
if err = os.RemoveAll(cdrsPostFailCfg.GeneralCfg().FailedPostsDir); err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
if err := engine.KillEngine(*waitRater); err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
|
||||
@@ -200,7 +200,7 @@ func testPosterITAMQPv1(t *testing.T) {
|
||||
t.Errorf("Calling APIerSv1.ExecuteAction received: %s", reply)
|
||||
}
|
||||
// verify if acction was executed
|
||||
time.Sleep(100 * time.Millisecond)
|
||||
time.Sleep(150 * time.Millisecond)
|
||||
ev, err := testPosterReadFolder(utils.MetaAMQPV1jsonMap)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
|
||||
@@ -94,7 +94,7 @@ func (v1ms *mongoStorDBMigrator) createV1SMCosts() (err error) {
|
||||
v1ms.mgoDB.DB().Collection(utils.OldSMCosts).Drop(v1ms.mgoDB.GetContext())
|
||||
v1ms.mgoDB.DB().Collection(utils.SessionCostsTBL).Drop(v1ms.mgoDB.GetContext())
|
||||
return v1ms.mgoDB.DB().RunCommand(v1ms.mgoDB.GetContext(),
|
||||
bson.D{{Key: "create", Value: utils.OldSMCosts}, {Key: "size", Value: 1024}}).Err()
|
||||
bson.D{{Key: "create", Value: utils.OldSMCosts}, {Key: "size", Value: 1024}, {Key: "capped", Value: true}}).Err()
|
||||
}
|
||||
|
||||
//get
|
||||
|
||||
@@ -72,7 +72,7 @@ func (reS *ResourceService) Start() (err error) {
|
||||
if reS.IsRunning() {
|
||||
return utils.ErrServiceAlreadyRunning
|
||||
}
|
||||
|
||||
reS.srvDep[utils.DataDB].Add(1)
|
||||
<-reS.cacheS.GetPrecacheChannel(utils.CacheResourceProfiles)
|
||||
<-reS.cacheS.GetPrecacheChannel(utils.CacheResources)
|
||||
<-reS.cacheS.GetPrecacheChannel(utils.CacheResourceFilterIndexes)
|
||||
@@ -110,6 +110,7 @@ func (reS *ResourceService) Reload() (err error) {
|
||||
|
||||
// Shutdown stops the service
|
||||
func (reS *ResourceService) Shutdown() (err error) {
|
||||
defer reS.srvDep[utils.DataDB].Done()
|
||||
reS.Lock()
|
||||
defer reS.Unlock()
|
||||
if err = reS.reS.Shutdown(); err != nil {
|
||||
|
||||
Reference in New Issue
Block a user