mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-11 18:16:24 +05:00
updated it tests in apier and general_tests
This commit is contained in:
committed by
Dan Christian Bogos
parent
c53a3903de
commit
f21ed245ca
@@ -579,6 +579,14 @@ func (apiv1 *APIerSv1) SetActions(attrs V1AttrSetActions, reply *string) (err er
|
||||
if err := apiv1.DataManager.SetActions(attrs.ActionsId, storeActions, utils.NonTransactional); err != nil {
|
||||
return utils.NewErrServerError(err)
|
||||
}
|
||||
if err := apiv1.ConnMgr.Call(apiv1.Config.ApierCfg().CachesConns, nil,
|
||||
utils.CacheSv1ReloadCache, utils.AttrReloadCacheWithArgDispatcher{
|
||||
AttrReloadCache: utils.AttrReloadCache{
|
||||
ArgsCache: utils.ArgsCache{ActionIDs: &[]string{attrs.ActionsId}},
|
||||
},
|
||||
}, reply); err != nil {
|
||||
return err
|
||||
}
|
||||
//generate a loadID for CacheActions and store it in database
|
||||
if err := apiv1.DataManager.SetLoadIDs(map[string]int64{utils.CacheActions: time.Now().UnixNano()}); err != nil {
|
||||
return utils.APIErrorHandler(err)
|
||||
@@ -668,6 +676,7 @@ func (apiv1 *APIerSv1) SetActionPlan(attrs AttrSetActionPlan, reply *string) (er
|
||||
if exists, err := apiv1.DataManager.HasData(utils.ACTION_PREFIX, apiAtm.ActionsId, ""); err != nil {
|
||||
return 0, utils.NewErrServerError(err)
|
||||
} else if !exists {
|
||||
utils.Logger.Debug("TEST IF EXIT HERE ??? ")
|
||||
return 0, fmt.Errorf("%s:%s", utils.ErrBrokenReference.Error(), apiAtm.ActionsId)
|
||||
}
|
||||
timing := new(engine.RITiming)
|
||||
|
||||
@@ -20,6 +20,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
package v1
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"path"
|
||||
"reflect"
|
||||
"testing"
|
||||
@@ -37,19 +38,20 @@ var (
|
||||
testInternalReplicateITStartEngine,
|
||||
testInternalReplicateITRPCConn,
|
||||
|
||||
// testInternalReplicateITDestination,
|
||||
testInternalReplicateITAttributeProfile,
|
||||
// testInternalReplicateITRatingProfile,
|
||||
testInternalReplicateITSupplierProfile,
|
||||
testInternalReplicateITStatQueueProfile,
|
||||
testInternalReplicateITDispatcherProfile,
|
||||
testInternalReplicateITChargerProfile,
|
||||
testInternalReplicateITDispatcherHost,
|
||||
testInternalReplicateITFilter,
|
||||
testInternalReplicateITResourceProfile,
|
||||
// testInternalReplicateITActions,
|
||||
// // testInternalReplicateITDestination,was commetner
|
||||
// testInternalReplicateITAttributeProfile,
|
||||
// // testInternalReplicateITRatingProfile, was commetner
|
||||
// testInternalReplicateITSupplierProfile,
|
||||
// testInternalReplicateITStatQueueProfile,
|
||||
// testInternalReplicateITDispatcherProfile,
|
||||
// testInternalReplicateITChargerProfile,
|
||||
// testInternalReplicateITDispatcherHost,
|
||||
// testInternalReplicateITFilter,
|
||||
// testInternalReplicateITResourceProfile,
|
||||
testInternalReplicateITActions, //-> was commetner
|
||||
testInternalReplicateITActionPlan,
|
||||
testInternalReplicateITThresholdProfile,
|
||||
// testInternalReplicateITThresholdProfile,
|
||||
// testInternalReplicateITSetAccount,
|
||||
|
||||
testInternalReplicateITKillEngine,
|
||||
}
|
||||
@@ -836,10 +838,15 @@ func testInternalReplicateITActions(t *testing.T) {
|
||||
} else if reply != utils.OK {
|
||||
t.Errorf("Unexpected reply returned: %s", reply)
|
||||
}
|
||||
if err := internalRPC.Call(utils.APIerSv1SetActions, attrs1, &reply); err == nil || err.Error() != "EXISTS" {
|
||||
t.Error("Unexpected result on duplication: ", err.Error())
|
||||
}
|
||||
// if err := internalRPC.Call(utils.APIerSv1SetActions, attrs1, &reply); err == nil || err.Error() != "EXISTS" {
|
||||
// t.Error("Unexpected result on duplication: ", err.Error())
|
||||
// }
|
||||
//check
|
||||
if err := internalRPC.Call(utils.APIerSv1GetActions, "ACTS_1", &reply1); err != nil {
|
||||
t.Error("Got error on APIerSv1.GetActions: ", err.Error())
|
||||
} else if !reflect.DeepEqual(attrs1.Actions, reply1) {
|
||||
t.Errorf("Expected: %v, received: %v", utils.ToJSON(attrs1.Actions), utils.ToJSON(reply1))
|
||||
}
|
||||
if err := engineOneRPC.Call(utils.APIerSv1GetActions, "ACTS_1", &reply1); err != nil {
|
||||
t.Error("Got error on APIerSv1.GetActions: ", err.Error())
|
||||
} else if !reflect.DeepEqual(attrs1.Actions, reply1) {
|
||||
@@ -853,33 +860,32 @@ func testInternalReplicateITActions(t *testing.T) {
|
||||
}
|
||||
|
||||
func testInternalReplicateITActionPlan(t *testing.T) {
|
||||
var reply string
|
||||
if err := internalRPC.Call(utils.APIerSv2SetActions, &utils.AttrSetActions{
|
||||
ActionsId: "ACTS_1",
|
||||
Actions: []*utils.TPAction{{Identifier: utils.LOG}},
|
||||
}, &reply); err != nil && err.Error() != utils.ErrExists.Error() {
|
||||
t.Error(err)
|
||||
} else if reply != utils.OK {
|
||||
t.Errorf("Calling APIerSv2.SetActions received: %s", reply)
|
||||
}
|
||||
//var reply string
|
||||
// if err := internalRPC.Call(utils.APIerSv2SetActions, &utils.AttrSetActions{
|
||||
// ActionsId: "ACTS_1",
|
||||
// Actions: []*utils.TPAction{{Identifier: utils.LOG}},
|
||||
// }, &reply); err != nil && err.Error() != utils.ErrExists.Error() {
|
||||
// t.Error(err)
|
||||
// } else if reply != utils.OK {
|
||||
// t.Errorf("Calling APIerSv2.SetActions received: %s", reply)
|
||||
// }
|
||||
// check
|
||||
var aps []*engine.ActionPlan
|
||||
if err := engineOneRPC.Call(utils.APIerSv1GetActionPlan,
|
||||
AttrGetActionPlan{ID: utils.EmptyString}, &aps); err == nil || err.Error() != utils.ErrNotFound.Error() {
|
||||
t.Errorf("Error: %+v, rcv: %+v", err, utils.ToJSON(aps))
|
||||
}
|
||||
if err := engineTwoRPC.Call(utils.APIerSv1GetActionPlan,
|
||||
AttrGetActionPlan{ID: utils.EmptyString}, &aps); err == nil || err.Error() != utils.ErrNotFound.Error() {
|
||||
t.Errorf("Error: %+v, rcv: %+v", err, utils.ToJSON(aps))
|
||||
}
|
||||
// if err := engineOneRPC.Call(utils.APIerSv1GetActionPlan,
|
||||
// AttrGetActionPlan{ID: utils.EmptyString}, &aps); err == nil || err.Error() != utils.ErrNotFound.Error() {
|
||||
// t.Errorf("Error: %+v, rcv: %+v", err, utils.ToJSON(aps))
|
||||
// }
|
||||
// if err := engineTwoRPC.Call(utils.APIerSv1GetActionPlan,
|
||||
// AttrGetActionPlan{ID: utils.EmptyString}, &aps); err == nil || err.Error() != utils.ErrNotFound.Error() {
|
||||
// t.Errorf("Error: %+v, rcv: %+v", err, utils.ToJSON(aps))
|
||||
// }
|
||||
// set
|
||||
atms1 := &AttrSetActionPlan{
|
||||
Id: "ATMS_1",
|
||||
ActionPlan: []*AttrActionPlan{
|
||||
&AttrActionPlan{
|
||||
ActionsId: "ACTS_1",
|
||||
MonthDays: "1",
|
||||
Time: "00:00:00",
|
||||
Time: utils.ASAP,
|
||||
Weight: 20.0},
|
||||
},
|
||||
}
|
||||
@@ -890,6 +896,19 @@ func testInternalReplicateITActionPlan(t *testing.T) {
|
||||
t.Errorf("Unexpected reply returned: %s", reply1)
|
||||
}
|
||||
// check
|
||||
if err := internalRPC.Call(utils.APIerSv1GetActionPlan,
|
||||
AttrGetActionPlan{ID: utils.EmptyString}, &aps); err != nil {
|
||||
t.Error(err)
|
||||
} else if len(aps) != 1 {
|
||||
t.Errorf("Expected: %v,\n received: %v", 1, len(aps))
|
||||
} else if aps[0].Id != "ATMS_1" {
|
||||
t.Errorf("Expected: ATMS_1,\n received: %v", aps[0].Id)
|
||||
} else if aps[0].ActionTimings[0].ActionsID != "ACTS_1" {
|
||||
t.Errorf("Expected: ACTS_1,\n received: %v", aps[0].ActionTimings[0].ActionsID)
|
||||
} else if aps[0].ActionTimings[0].Weight != 20.0 {
|
||||
t.Errorf("Expected: 20.0,\n received: %v", aps[0].ActionTimings[0].Weight)
|
||||
}
|
||||
// check
|
||||
if err := engineOneRPC.Call(utils.APIerSv1GetActionPlan,
|
||||
AttrGetActionPlan{ID: utils.EmptyString}, &aps); err != nil {
|
||||
t.Error(err)
|
||||
@@ -902,22 +921,35 @@ func testInternalReplicateITActionPlan(t *testing.T) {
|
||||
} else if aps[0].ActionTimings[0].Weight != 20.0 {
|
||||
t.Errorf("Expected: 20.0,\n received: %v", aps[0].ActionTimings[0].Weight)
|
||||
}
|
||||
// remove
|
||||
if err := internalRPC.Call(utils.APIerSv1RemoveActionPlan, &AttrGetActionPlan{
|
||||
ID: "ATMS_1"}, &reply); err != nil {
|
||||
t.Error(err)
|
||||
} else if reply != utils.OK {
|
||||
t.Error("Unexpected reply returned", reply)
|
||||
}
|
||||
//check again
|
||||
if err := engineOneRPC.Call(utils.APIerSv1GetActionPlan,
|
||||
AttrGetActionPlan{ID: utils.EmptyString}, &aps); err == nil || err.Error() != utils.ErrNotFound.Error() {
|
||||
t.Errorf("Error: %+v, rcv: %+v", err, utils.ToJSON(aps))
|
||||
}
|
||||
// check
|
||||
if err := engineTwoRPC.Call(utils.APIerSv1GetActionPlan,
|
||||
AttrGetActionPlan{ID: utils.EmptyString}, &aps); err == nil || err.Error() != utils.ErrNotFound.Error() {
|
||||
t.Errorf("Error: %+v, rcv: %+v", err, utils.ToJSON(aps))
|
||||
AttrGetActionPlan{ID: utils.EmptyString}, &aps); err != nil {
|
||||
t.Error(err)
|
||||
} else if len(aps) != 1 {
|
||||
t.Errorf("Expected: %v,\n received: %v", 1, len(aps))
|
||||
} else if aps[0].Id != "ATMS_1" {
|
||||
t.Errorf("Expected: ATMS_1,\n received: %v", aps[0].Id)
|
||||
} else if aps[0].ActionTimings[0].ActionsID != "ACTS_1" {
|
||||
t.Errorf("Expected: ACTS_1,\n received: %v", aps[0].ActionTimings[0].ActionsID)
|
||||
} else if aps[0].ActionTimings[0].Weight != 20.0 {
|
||||
t.Errorf("Expected: 20.0,\n received: %v", aps[0].ActionTimings[0].Weight)
|
||||
}
|
||||
// // remove
|
||||
// if err := internalRPC.Call(utils.APIerSv1RemoveActionPlan, &AttrGetActionPlan{
|
||||
// ID: "ATMS_1"}, &reply); err != nil {
|
||||
// t.Error(err)
|
||||
// } else if reply != utils.OK {
|
||||
// t.Error("Unexpected reply returned", reply)
|
||||
// }
|
||||
// //check again
|
||||
// if err := engineOneRPC.Call(utils.APIerSv1GetActionPlan,
|
||||
// AttrGetActionPlan{ID: utils.EmptyString}, &aps); err == nil || err.Error() != utils.ErrNotFound.Error() {
|
||||
// t.Errorf("Error: %+v, rcv: %+v", err, utils.ToJSON(aps))
|
||||
// }
|
||||
// if err := engineTwoRPC.Call(utils.APIerSv1GetActionPlan,
|
||||
// AttrGetActionPlan{ID: utils.EmptyString}, &aps); err == nil || err.Error() != utils.ErrNotFound.Error() {
|
||||
// t.Errorf("Error: %+v, rcv: %+v", err, utils.ToJSON(aps))
|
||||
// }
|
||||
}
|
||||
|
||||
func testInternalReplicateITThresholdProfile(t *testing.T) {
|
||||
@@ -1008,6 +1040,62 @@ func testInternalReplicateITThresholdProfile(t *testing.T) {
|
||||
err.Error() != utils.ErrNotFound.Error() {
|
||||
t.Error(err)
|
||||
}
|
||||
//chec kalso the treshold
|
||||
// with GetThreshold
|
||||
}
|
||||
|
||||
func testInternalReplicateITSetAccount(t *testing.T) {
|
||||
//check
|
||||
var reply string
|
||||
if err := engineOneRPC.Call(utils.APIerSv1GetAccount,
|
||||
&utils.AttrGetAccount{Account: "AccountTest", Tenant: tenant}, &reply); err == nil ||
|
||||
err.Error() != utils.ErrNotFound.Error() {
|
||||
t.Error(err)
|
||||
}
|
||||
if err := engineTwoRPC.Call(utils.APIerSv1GetAccount,
|
||||
&utils.AttrGetAccount{Account: "AccountTest", Tenant: tenant}, &reply); err == nil ||
|
||||
err.Error() != utils.ErrNotFound.Error() {
|
||||
t.Error(err)
|
||||
}
|
||||
//set
|
||||
attrSetAccount := &utils.AttrSetAccount{
|
||||
Account: "AccountTest",
|
||||
Tenant: tenant}
|
||||
if err := internalRPC.Call(utils.APIerSv1SetAccount, attrSetAccount, &reply); err != nil {
|
||||
t.Error(err)
|
||||
} else if reply != utils.OK {
|
||||
t.Error("Unexpected reply returned", reply)
|
||||
}
|
||||
//check
|
||||
tmp := engine.Account{}
|
||||
rcvAccount := tmp.AsOldStructure()
|
||||
if err := engineOneRPC.Call(utils.APIerSv1GetAccount,
|
||||
&utils.AttrGetAccount{Account: "AccountTest", Tenant: tenant}, &rcvAccount); err != nil {
|
||||
t.Errorf("Unexpected error : %+v\nRCV: %+v", err, rcvAccount)
|
||||
}
|
||||
if err := engineTwoRPC.Call(utils.APIerSv1GetAccount,
|
||||
&utils.AttrGetAccount{Account: "AccountTest", Tenant: tenant}, &rcvAccount); err != nil {
|
||||
t.Errorf("Unexpected error : %+v", err)
|
||||
}
|
||||
//remove
|
||||
if err := internalRPC.Call(utils.APIerSv1RemoveAccount,
|
||||
&utils.AttrRemoveAccount{
|
||||
Account: "AccountTest",
|
||||
Tenant: tenant}, &reply); err != nil {
|
||||
t.Errorf("Unexpected error : %+v", err)
|
||||
}
|
||||
//check
|
||||
if err := engineOneRPC.Call(utils.APIerSv1GetAccount,
|
||||
&utils.AttrGetAccount{Account: "AccountTest", Tenant: tenant}, &reply); err == nil ||
|
||||
err.Error() != utils.ErrNotFound.Error() {
|
||||
t.Error(err)
|
||||
}
|
||||
if err := engineTwoRPC.Call(utils.APIerSv1GetAccount,
|
||||
&utils.AttrGetAccount{Account: "AccountTest", Tenant: tenant}, &reply); err == nil ||
|
||||
err.Error() != utils.ErrNotFound.Error() {
|
||||
t.Error(err)
|
||||
}
|
||||
fmt.Println("PASSED")
|
||||
}
|
||||
|
||||
func testInternalReplicateITKillEngine(t *testing.T) {
|
||||
|
||||
@@ -27,7 +27,6 @@
|
||||
"connCache": {
|
||||
"strategy": "*broadcast",
|
||||
"conns": [
|
||||
{"address": "*internal"},
|
||||
{"address": "127.0.0.1:2022", "transport":"*json"},
|
||||
{"address": "127.0.0.1:2032", "transport":"*json"}
|
||||
],
|
||||
@@ -46,7 +45,7 @@
|
||||
"*destinations": {"remote":true,"replicate":true},
|
||||
"*rating_plans": {"remote":true,"replicate":true},
|
||||
"*rating_profiles":{"remote":true,"replicate":true},
|
||||
"*actions":{"remote":true,"replicate":true},
|
||||
"*actions":{"remote":false,"replicate":true},
|
||||
"*action_plans": {"remote":true,"replicate":true},
|
||||
"*account_action_plans":{"remote":true,"replicate":true},
|
||||
"*action_triggers":{"remote":true,"replicate":true},
|
||||
|
||||
@@ -728,6 +728,11 @@ func testOnStorITActions(t *testing.T) {
|
||||
acts, utils.NonTransactional); err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
if rcv, err := onStor.HasData(utils.ACTION_PREFIX, acts[0].Id, ""); err != nil {
|
||||
t.Error(err)
|
||||
} else if rcv != true {
|
||||
t.Errorf("Expecting: true, received: %v", rcv)
|
||||
}
|
||||
//get from cache
|
||||
if rcv, err := onStor.GetActions(acts[0].Id,
|
||||
false, utils.NonTransactional); err != nil {
|
||||
|
||||
@@ -738,8 +738,15 @@ func (iDB *InternalDB) GetActionsDrv(id string) (acts Actions, err error) {
|
||||
}
|
||||
|
||||
func (iDB *InternalDB) SetActionsDrv(id string, acts Actions) (err error) {
|
||||
utils.Logger.Debug("ENTER IN SET ACTIONS DRV ??? ")
|
||||
iDB.db.Set(utils.CacheActions, id, acts, nil,
|
||||
cacheCommit(utils.NonTransactional), utils.NonTransactional)
|
||||
utils.Logger.Debug("Set With Success ")
|
||||
x, ok := iDB.db.Get(utils.CacheActions, id)
|
||||
if !ok || x == nil {
|
||||
utils.Logger.Debug("NOT FOUND ")
|
||||
}
|
||||
utils.Logger.Debug(fmt.Sprintf("ACTIONS : %+v", utils.ToJSON(x.(Actions))))
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@@ -44,8 +44,11 @@ var (
|
||||
testdoubleRemoveInitDataDb,
|
||||
testdoubleRemoveStartEngine,
|
||||
testdoubleRemoveRpcConn,
|
||||
testdoubleRemoveFromFolder,
|
||||
|
||||
testdoubleRemoveStatQueueProfile,
|
||||
testdoubleRemoveActions,
|
||||
testdoubleRemoveActionPlan,
|
||||
|
||||
testdoubleRemoveKillEngine,
|
||||
}
|
||||
)
|
||||
@@ -98,15 +101,6 @@ func testdoubleRemoveRpcConn(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func testdoubleRemoveFromFolder(t *testing.T) {
|
||||
var reply string
|
||||
attrs := &utils.AttrLoadTpFromFolder{FolderPath: path.Join(*dataDir, "tariffplans", "oldtutorial")}
|
||||
if err := sesRPC.Call(utils.APIerSv1LoadTariffPlanFromFolder, attrs, &reply); err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
time.Sleep(500 * time.Millisecond)
|
||||
}
|
||||
|
||||
func testdoubleRemoveStatQueueProfile(t *testing.T) {
|
||||
// check
|
||||
var reply *engine.StatQueueProfile
|
||||
@@ -182,6 +176,133 @@ func testdoubleRemoveStatQueueProfile(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func testdoubleRemoveActions(t *testing.T) {
|
||||
// check
|
||||
var reply1 []*utils.TPAction
|
||||
if err := sesRPC.Call(utils.APIerSv1GetActions, "ACTS_1", &reply1); err == nil || err.Error() != "SERVER_ERROR: NOT_FOUND" {
|
||||
t.Error(err)
|
||||
}
|
||||
// set
|
||||
attrs1 := &v1.V1AttrSetActions{
|
||||
ActionsId: "ACTS_1",
|
||||
Actions: []*v1.V1TPAction{
|
||||
&v1.V1TPAction{
|
||||
Identifier: utils.TOPUP_RESET,
|
||||
BalanceType: utils.MONETARY,
|
||||
Units: 75.0,
|
||||
ExpiryTime: utils.UNLIMITED,
|
||||
Weight: 20.0}}}
|
||||
var reply string
|
||||
if err := sesRPC.Call(utils.APIerSv1SetActions, attrs1, &reply); err != nil {
|
||||
t.Error(err)
|
||||
} else if reply != utils.OK {
|
||||
t.Errorf("Unexpected reply returned: %s", reply)
|
||||
}
|
||||
// set it again (expect EXISTS)
|
||||
if err := sesRPC.Call(utils.APIerSv1SetActions, attrs1, &reply); err == nil || err.Error() != "EXISTS" {
|
||||
t.Error(err)
|
||||
}
|
||||
// check
|
||||
if err := sesRPC.Call(utils.APIerSv1GetActions, "ACTS_1", &reply1); err != nil {
|
||||
t.Error("Got error on APIerSv1.GetActions: ", err.Error())
|
||||
} else if !reflect.DeepEqual(attrs1.Actions, reply1) {
|
||||
t.Errorf("Expected: %v, received: %v", utils.ToJSON(attrs1.Actions), utils.ToJSON(reply1))
|
||||
}
|
||||
// remove
|
||||
if err := sesRPC.Call(utils.APIerSv1RemoveActions, &v1.AttrRemoveActions{
|
||||
ActionIDs: []string{"ACTS_1"}}, &reply); err != nil {
|
||||
t.Error(err)
|
||||
} else if reply != utils.OK {
|
||||
t.Error("Unexpected reply returned", reply)
|
||||
}
|
||||
// remove it again (expect ErrNotFound)
|
||||
// if err := sesRPC.Call(utils.APIerSv1RemoveActions, &v1.AttrRemoveActions{
|
||||
// ActionIDs: []string{"ACTS_1"}}, &reply); err == nil ||
|
||||
// err.Error() != utils.ErrNotFound.Error() {
|
||||
// t.Error(err)
|
||||
// }
|
||||
// check again
|
||||
if err := sesRPC.Call(utils.APIerSv1GetActions, "ACTS_1", &reply1); err == nil || err.Error() != "SERVER_ERROR: NOT_FOUND" {
|
||||
t.Error(err)
|
||||
}
|
||||
}
|
||||
|
||||
func testdoubleRemoveActionPlan(t *testing.T) {
|
||||
//set action
|
||||
var reply string
|
||||
|
||||
if err := sesRPC.Call(utils.APIerSv2SetActions, &utils.AttrSetActions{
|
||||
ActionsId: "ACTS_1",
|
||||
Actions: []*utils.TPAction{{Identifier: utils.LOG}},
|
||||
}, &reply); err != nil && err.Error() != utils.ErrExists.Error() {
|
||||
t.Error(err)
|
||||
} else if reply != utils.OK {
|
||||
t.Errorf("Calling APIerSv2.SetActions received: %s", reply)
|
||||
}
|
||||
// check action
|
||||
attrs1 := &utils.AttrSetActions{
|
||||
ActionsId: "ACTS_1",
|
||||
Actions: []*utils.TPAction{{Identifier: utils.LOG}}}
|
||||
var reply1 []*utils.TPAction
|
||||
if err := sesRPC.Call(utils.APIerSv1GetActions, "ACTS_1", &reply1); err != nil {
|
||||
t.Error("Got error on APIerSv1.GetActions: ", err.Error())
|
||||
} else if !reflect.DeepEqual(attrs1.Actions, reply) {
|
||||
t.Errorf("Expected: %v, received: %v", utils.ToJSON(attrs1.Actions), utils.ToJSON(reply1))
|
||||
}
|
||||
// check
|
||||
var aps []*engine.ActionPlan
|
||||
if err := sesRPC.Call(utils.APIerSv1GetActionPlan,
|
||||
v1.AttrGetActionPlan{ID: utils.EmptyString}, &aps); err == nil || err.Error() != utils.ErrNotFound.Error() {
|
||||
t.Errorf("Error: %+v, rcv: %+v", err, utils.ToJSON(aps))
|
||||
}
|
||||
// set
|
||||
atms1 := &v1.AttrSetActionPlan{
|
||||
Id: "ATMS_1",
|
||||
ActionPlan: []*v1.AttrActionPlan{
|
||||
&v1.AttrActionPlan{
|
||||
ActionsId: "ACTS_1",
|
||||
Time: utils.ASAP,
|
||||
Weight: 20.0},
|
||||
},
|
||||
}
|
||||
if err := sesRPC.Call(utils.APIerSv1SetActionPlan, atms1, &reply); err != nil {
|
||||
t.Error("Got error on APIerSv1.SetActionPlan: ", err.Error())
|
||||
} else if reply != utils.OK {
|
||||
t.Errorf("Unexpected reply returned: %s", reply)
|
||||
}
|
||||
// // set it again (expect EXISTS)
|
||||
// if err := sesRPC.Call(utils.APIerSv1SetActionPlan, atms1, &reply); err == nil || err.Error() != "EXISTS" {
|
||||
// t.Error(err)
|
||||
// }
|
||||
// check
|
||||
if err := sesRPC.Call(utils.APIerSv1GetActionPlan,
|
||||
v1.AttrGetActionPlan{ID: "ATMS_1"}, &aps); err != nil {
|
||||
t.Error(err)
|
||||
} else if len(aps) != 1 {
|
||||
t.Errorf("Expected: %v,\n received: %v", 1, len(aps))
|
||||
} else if aps[0].Id != "ATMS_1" {
|
||||
t.Errorf("Expected: ATMS_1,\n received: %v", aps[0].Id)
|
||||
} else if aps[0].ActionTimings[0].ActionsID != "ACTS_1" {
|
||||
t.Errorf("Expected: ACTS_1,\n received: %v", aps[0].ActionTimings[0].ActionsID)
|
||||
} else if aps[0].ActionTimings[0].Weight != 20.0 {
|
||||
t.Errorf("Expected: 20.0,\n received: %v", aps[0].ActionTimings[0].Weight)
|
||||
}
|
||||
|
||||
// // // remove
|
||||
// if err := sesRPC.Call(utils.APIerSv1RemoveActionPlan, &v1.AttrGetActionPlan{
|
||||
// ID: "ATMS_1"}, &reply); err != nil {
|
||||
// t.Error(err)
|
||||
// } else if reply != utils.OK {
|
||||
// t.Error("Unexpected reply returned", reply)
|
||||
// }
|
||||
// //check again
|
||||
// if err := sesRPC.Call(utils.APIerSv1GetActionPlan,
|
||||
// v1.AttrGetActionPlan{ID: utils.EmptyString}, &aps); err == nil || err.Error() != utils.ErrNotFound.Error() {
|
||||
// t.Errorf("Error: %+v, rcv: %+v", err, utils.ToJSON(aps))
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
func testdoubleRemoveKillEngine(t *testing.T) {
|
||||
if err := engine.KillEngine(100); err != nil {
|
||||
t.Error(err)
|
||||
|
||||
Reference in New Issue
Block a user