mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-14 20:59:53 +05:00
Add integration test for loading ActionProfile from file
This commit is contained in:
committed by
Dan Christian Bogos
parent
43b5e1f97e
commit
f8e636074b
@@ -121,21 +121,61 @@ func testActionSLoadFromFolder(t *testing.T) {
|
||||
|
||||
func testActionSGetActionProfile(t *testing.T) {
|
||||
expected := &engine.ActionProfile{
|
||||
Tenant: "",
|
||||
ID: "",
|
||||
FilterIDs: nil,
|
||||
ActivationInterval: nil,
|
||||
Weight: 0,
|
||||
Schedule: "",
|
||||
AccountIDs: nil,
|
||||
Actions: nil,
|
||||
Tenant: "cgrates.org",
|
||||
ID: "ONE_TIME_ACT",
|
||||
FilterIDs: []string{},
|
||||
Weight: 10,
|
||||
Schedule: utils.ASAP,
|
||||
AccountIDs: map[string]struct{}{"1001": struct{}{}, "1002": struct{}{}},
|
||||
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",
|
||||
Path: "~*balance.TestVoiceBalance.Value",
|
||||
Value: config.NewRSRParsersMustCompile("15m15s", actPrfCfg.GeneralCfg().RSRSep),
|
||||
},
|
||||
},
|
||||
}
|
||||
var reply *engine.ActionProfile
|
||||
if err := actSRPC.Call(utils.APIerSv1GetActionProfile,
|
||||
utils.TenantIDWithOpts{TenantID: &utils.TenantID{Tenant: "cgrates.org", ID: "ATTR_3"}}, &reply); err != nil {
|
||||
utils.TenantIDWithOpts{TenantID: &utils.TenantID{Tenant: "cgrates.org", ID: "ONE_TIME_ACT"}}, &reply); err != nil {
|
||||
t.Fatal(err)
|
||||
} else if !reflect.DeepEqual(expected, reply) {
|
||||
t.Errorf("Expecting : %+v, received: %+v", utils.ToJSON(expected), utils.ToJSON(reply))
|
||||
} else {
|
||||
for _, act := range reply.Actions { // the path variable from RSRParsers is with lower letter and need to be compiled manually in tests to pass reflect.DeepEqual
|
||||
act.Value.Compile()
|
||||
}
|
||||
if !reflect.DeepEqual(expected, reply) {
|
||||
t.Errorf("Expecting : %+v \n received: %+v", utils.ToJSON(expected), utils.ToJSON(reply))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#Tenant,ID,FilterIDs,ActivationInterval,Weight,Schedule,AccountIDs,ActionID,ActionFilterIDs,ActionBlocker,ActionTTL,ActionType,ActionOpts,ActionPath,ActionValue
|
||||
cgrates.org,ONE_TIME_ACT,,,10,"*asap","1001;1002",TOPUP,,false,0s,*topup,,~*balance.TestBalance.Value,10
|
||||
cgrates.org,ONE_TIME_ACT,,,,,,SET_BALACE_TEST_DATA,,false,0s,*set_balance,,~*balance.TestDataBalance.Type,*data
|
||||
cgrates.org,ONE_TIME_ACT,,,,,,SET_BALANCE_TEST_DATA,,false,0s,*set_balance,,~*balance.TestDataBalance.Type,*data
|
||||
cgrates.org,ONE_TIME_ACT,,,,,,TOPUP_TEST_DATA,,false,0s,*topup,,~*balance.TestDataBalance.Value,1024
|
||||
cgrates.org,ONE_TIME_ACT,,,,,,SET_BALACE_TEST_VOICE,,false,0s,*set_balance,,~*balance.TestVoiceBalance.Type,*voice
|
||||
cgrates.org,ONE_TIME_ACT,,,,,,SET_BALANCE_TEST_VOICE,,false,0s,*set_balance,,~*balance.TestVoiceBalance.Type,*voice
|
||||
cgrates.org,ONE_TIME_ACT,,,,,,TOPUP_TEST_VOICE,,false,0s,*topup,,~*balance.TestVoiceBalance.Value,15m15s
|
||||
|
||||
|
@@ -28,53 +28,56 @@ import (
|
||||
|
||||
var (
|
||||
filterIndexesPrefixMap = utils.StringSet{
|
||||
utils.AttributeFilterIndexes: {},
|
||||
utils.ResourceFilterIndexes: {},
|
||||
utils.StatFilterIndexes: {},
|
||||
utils.ThresholdFilterIndexes: {},
|
||||
utils.RouteFilterIndexes: {},
|
||||
utils.ChargerFilterIndexes: {},
|
||||
utils.DispatcherFilterIndexes: {},
|
||||
utils.RateProfilesFilterIndexPrfx: {},
|
||||
utils.RateFilterIndexPrfx: {},
|
||||
utils.ActionPlanIndexes: {},
|
||||
utils.FilterIndexPrfx: {},
|
||||
utils.AttributeFilterIndexes: {},
|
||||
utils.ResourceFilterIndexes: {},
|
||||
utils.StatFilterIndexes: {},
|
||||
utils.ThresholdFilterIndexes: {},
|
||||
utils.RouteFilterIndexes: {},
|
||||
utils.ChargerFilterIndexes: {},
|
||||
utils.DispatcherFilterIndexes: {},
|
||||
utils.RateProfilesFilterIndexPrfx: {},
|
||||
utils.ActionProfilesFilterIndexPrfx: {},
|
||||
utils.RateFilterIndexPrfx: {},
|
||||
utils.ActionPlanIndexes: {},
|
||||
utils.FilterIndexPrfx: {},
|
||||
}
|
||||
cachePrefixMap = utils.StringSet{
|
||||
utils.DESTINATION_PREFIX: {},
|
||||
utils.REVERSE_DESTINATION_PREFIX: {},
|
||||
utils.RATING_PLAN_PREFIX: {},
|
||||
utils.RATING_PROFILE_PREFIX: {},
|
||||
utils.ACTION_PREFIX: {},
|
||||
utils.ACTION_PLAN_PREFIX: {},
|
||||
utils.AccountActionPlansPrefix: {},
|
||||
utils.ACTION_TRIGGER_PREFIX: {},
|
||||
utils.SHARED_GROUP_PREFIX: {},
|
||||
utils.ResourceProfilesPrefix: {},
|
||||
utils.TimingsPrefix: {},
|
||||
utils.ResourcesPrefix: {},
|
||||
utils.StatQueuePrefix: {},
|
||||
utils.StatQueueProfilePrefix: {},
|
||||
utils.ThresholdPrefix: {},
|
||||
utils.ThresholdProfilePrefix: {},
|
||||
utils.FilterPrefix: {},
|
||||
utils.RouteProfilePrefix: {},
|
||||
utils.AttributeProfilePrefix: {},
|
||||
utils.ChargerProfilePrefix: {},
|
||||
utils.DispatcherProfilePrefix: {},
|
||||
utils.DispatcherHostPrefix: {},
|
||||
utils.RateProfilePrefix: {},
|
||||
utils.AttributeFilterIndexes: {},
|
||||
utils.ResourceFilterIndexes: {},
|
||||
utils.StatFilterIndexes: {},
|
||||
utils.ThresholdFilterIndexes: {},
|
||||
utils.RouteFilterIndexes: {},
|
||||
utils.ChargerFilterIndexes: {},
|
||||
utils.DispatcherFilterIndexes: {},
|
||||
utils.RateProfilesFilterIndexPrfx: {},
|
||||
utils.RateFilterIndexPrfx: {},
|
||||
utils.FilterIndexPrfx: {},
|
||||
utils.MetaAPIBan: {}, // not realy a prefix as this is not stored in DB
|
||||
utils.DESTINATION_PREFIX: {},
|
||||
utils.REVERSE_DESTINATION_PREFIX: {},
|
||||
utils.RATING_PLAN_PREFIX: {},
|
||||
utils.RATING_PROFILE_PREFIX: {},
|
||||
utils.ACTION_PREFIX: {},
|
||||
utils.ACTION_PLAN_PREFIX: {},
|
||||
utils.AccountActionPlansPrefix: {},
|
||||
utils.ACTION_TRIGGER_PREFIX: {},
|
||||
utils.SHARED_GROUP_PREFIX: {},
|
||||
utils.ResourceProfilesPrefix: {},
|
||||
utils.TimingsPrefix: {},
|
||||
utils.ResourcesPrefix: {},
|
||||
utils.StatQueuePrefix: {},
|
||||
utils.StatQueueProfilePrefix: {},
|
||||
utils.ThresholdPrefix: {},
|
||||
utils.ThresholdProfilePrefix: {},
|
||||
utils.FilterPrefix: {},
|
||||
utils.RouteProfilePrefix: {},
|
||||
utils.AttributeProfilePrefix: {},
|
||||
utils.ChargerProfilePrefix: {},
|
||||
utils.DispatcherProfilePrefix: {},
|
||||
utils.DispatcherHostPrefix: {},
|
||||
utils.RateProfilePrefix: {},
|
||||
utils.ActionProfilePrefix: {},
|
||||
utils.AttributeFilterIndexes: {},
|
||||
utils.ResourceFilterIndexes: {},
|
||||
utils.StatFilterIndexes: {},
|
||||
utils.ThresholdFilterIndexes: {},
|
||||
utils.RouteFilterIndexes: {},
|
||||
utils.ChargerFilterIndexes: {},
|
||||
utils.DispatcherFilterIndexes: {},
|
||||
utils.RateProfilesFilterIndexPrfx: {},
|
||||
utils.ActionProfilesFilterIndexPrfx: {},
|
||||
utils.RateFilterIndexPrfx: {},
|
||||
utils.FilterIndexPrfx: {},
|
||||
utils.MetaAPIBan: {}, // not realy a prefix as this is not stored in DB
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
@@ -229,18 +229,20 @@ var (
|
||||
DispatcherProfileIDs: CacheDispatcherProfiles,
|
||||
DispatcherHostIDs: CacheDispatcherHosts,
|
||||
RateProfileIDs: CacheRateProfiles,
|
||||
ActionProfileIDs: CacheActionProfiles,
|
||||
|
||||
TimingIDs: CacheTimings,
|
||||
AttributeFilterIndexIDs: CacheAttributeFilterIndexes,
|
||||
ResourceFilterIndexIDs: CacheResourceFilterIndexes,
|
||||
StatFilterIndexIDs: CacheStatFilterIndexes,
|
||||
ThresholdFilterIndexIDs: CacheThresholdFilterIndexes,
|
||||
RouteFilterIndexIDs: CacheRouteFilterIndexes,
|
||||
ChargerFilterIndexIDs: CacheChargerFilterIndexes,
|
||||
DispatcherFilterIndexIDs: CacheDispatcherFilterIndexes,
|
||||
RateProfilesFilterIndexIDs: CacheRateProfilesFilterIndexes,
|
||||
RateFilterIndexIDs: CacheRateFilterIndexes,
|
||||
FilterIndexIDs: CacheReverseFilterIndexes,
|
||||
TimingIDs: CacheTimings,
|
||||
AttributeFilterIndexIDs: CacheAttributeFilterIndexes,
|
||||
ResourceFilterIndexIDs: CacheResourceFilterIndexes,
|
||||
StatFilterIndexIDs: CacheStatFilterIndexes,
|
||||
ThresholdFilterIndexIDs: CacheThresholdFilterIndexes,
|
||||
RouteFilterIndexIDs: CacheRouteFilterIndexes,
|
||||
ChargerFilterIndexIDs: CacheChargerFilterIndexes,
|
||||
DispatcherFilterIndexIDs: CacheDispatcherFilterIndexes,
|
||||
RateProfilesFilterIndexIDs: CacheRateProfilesFilterIndexes,
|
||||
RateFilterIndexIDs: CacheRateFilterIndexes,
|
||||
FilterIndexIDs: CacheReverseFilterIndexes,
|
||||
ActionProfilesFilterIndexIDs: CacheActionProfilesFilterIndexes,
|
||||
}
|
||||
ConcurrentReqsLimit int
|
||||
ConcurrentReqsStrategy string
|
||||
|
||||
Reference in New Issue
Block a user