mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-21 23:28:44 +05:00
Remove MinItems from ThresholdProfiles and add/remote time.Sleep from resourcesv1_it_test.go and tp_it_test.go
This commit is contained in:
@@ -122,7 +122,6 @@ func testV1RsRpcConn(t *testing.T) {
|
||||
|
||||
func testV1RsFromFolder(t *testing.T) {
|
||||
var reply string
|
||||
time.Sleep(time.Duration(2000) * time.Millisecond)
|
||||
attrs := &utils.AttrLoadTpFromFolder{FolderPath: path.Join(*dataDir, "tariffplans", "tutorial")}
|
||||
if err := rlsV1Rpc.Call("ApierV1.LoadTariffPlanFromFolder", attrs, &reply); err != nil {
|
||||
t.Error(err)
|
||||
@@ -132,6 +131,7 @@ func testV1RsFromFolder(t *testing.T) {
|
||||
}
|
||||
|
||||
func testV1RsGetResourcesForEvent(t *testing.T) {
|
||||
time.Sleep(time.Duration(1000) * time.Millisecond)
|
||||
var reply *[]*engine.ResourceProfile
|
||||
args := &utils.ArgRSv1ResourceUsage{
|
||||
Tenant: "cgrates.org",
|
||||
|
||||
@@ -84,7 +84,7 @@ func testTPInitCfg(t *testing.T) {
|
||||
config.SetCgrConfig(tpCfg)
|
||||
switch tpConfigDIR {
|
||||
case "tutmongo": // Mongo needs more time to reset db, need to investigate
|
||||
tpDelay = 2000
|
||||
tpDelay = 4000
|
||||
default:
|
||||
tpDelay = 2000
|
||||
}
|
||||
@@ -114,6 +114,7 @@ func testTPRpcConn(t *testing.T) {
|
||||
}
|
||||
|
||||
func testTPImportTPFromFolderPath(t *testing.T) {
|
||||
time.Sleep(time.Duration(1 * time.Second))
|
||||
var reply string
|
||||
if err := tpRPC.Call("ApierV1.ImportTariffPlanFromFolder", utils.AttrImportTPFromFolder{TPid: "TEST_TPID2", FolderPath: path.Join(tpDataDir, "tariffplans", "tutorial")}, &reply); err != nil {
|
||||
t.Error("Got error on ApierV1.ImportTarrifPlanFromFolder: ", err.Error())
|
||||
|
||||
@@ -453,18 +453,15 @@ DROP TABLE IF EXISTS tp_thresholds;
|
||||
CREATE TABLE tp_thresholds (
|
||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`tpid` varchar(64) NOT NULL,
|
||||
`tenant` varchar(64) NOT NULL,
|
||||
`tag` varchar(64) NOT NULL,
|
||||
`filter_type` varchar(16) NOT NULL,
|
||||
`filter_field_name` varchar(64) NOT NULL,
|
||||
`filter_field_values` varchar(256) NOT NULL,
|
||||
`activation_interval` varchar(64) NOT NULL,
|
||||
`threshold_type` char(64) NOT NULL,
|
||||
`threshold_value` DECIMAL(20,4) NOT NULL,
|
||||
`min_items` int(11) NOT NULL,
|
||||
`recurrent` BOOLEAN NOT NULL,
|
||||
`min_sleep` varchar(16) NOT NULL,
|
||||
`blocker` BOOLEAN NOT NULL,
|
||||
`stored` BOOLEAN NOT NULL,
|
||||
`weight` decimal(8,2) NOT NULL,
|
||||
`action_ids` varchar(64) NOT NULL,
|
||||
`created_at` TIMESTAMP,
|
||||
|
||||
@@ -448,18 +448,15 @@ DROP TABLE IF EXISTS tp_thresholds;
|
||||
CREATE TABLE tp_thresholds (
|
||||
"id" SERIAL PRIMARY KEY,
|
||||
"tpid" varchar(64) NOT NULL,
|
||||
"tenant"varchar(64) NOT NULL,
|
||||
"tag" varchar(64) NOT NULL,
|
||||
"filter_type" varchar(16) NOT NULL,
|
||||
"filter_field_name" varchar(64) NOT NULL,
|
||||
"filter_field_values" varchar(256) NOT NULL,
|
||||
"activation_interval" varchar(64) NOT NULL,
|
||||
"threshold_type" VARCHAR(64) NOT NULL,
|
||||
"threshold_value" NUMERIC(20,4) NOT NULL,
|
||||
"min_items" INTEGER NOT NULL,
|
||||
"recurrent" BOOLEAN NOT NULL,
|
||||
"min_sleep" varchar(16) NOT NULL,
|
||||
"blocker" BOOLEAN NOT NULL,
|
||||
"stored" BOOLEAN NOT NULL,
|
||||
"weight" decimal(8,2) NOT NULL,
|
||||
"action_ids" varchar(64) NOT NULL,
|
||||
"created_at" TIMESTAMP WITH TIME ZONE
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
#Tenant[0],Id[1],FilterType[2],FilterFieldName[3],FilterFieldValues[4],ActivationInterval[5],MinItems[6],Recurrent[7],MinSleep[8],Blocker[9],Weight[10],ActionIDs[11]
|
||||
cgrates.org,Threshold1,*string,Account,1001;1002,2014-07-29T15:00:00Z,10,true,1s,true,10,THRESH1;THRESH2
|
||||
#Tenant[0],Id[1],FilterType[2],FilterFieldName[3],FilterFieldValues[4],ActivationInterval[5],Recurrent[6],MinSleep[7],Blocker[8],Weight[9],ActionIDs[10]
|
||||
cgrates.org,Threshold1,*string,Account,1001;1002,2014-07-29T15:00:00Z,true,1s,true,10,THRESH1;THRESH2
|
||||
|
||||
|
@@ -1,2 +1,2 @@
|
||||
#Tenant[0],Id[1],FilterType[2],FilterFieldName[3],FilterFieldValues[4],ActivationInterval[5],MinItems[6],Recurrent[7],MinSleep[8],Blocker[9],Weight[10],MinItems[11],ActionIDs[12]
|
||||
cgrates.org,Threshold1,*string,Account,1001;1002,2014-07-29T15:00:00Z,10,true,1s,true,10,THRESH1;THRESH2
|
||||
#Tenant[0],Id[1],FilterType[2],FilterFieldName[3],FilterFieldValues[4],ActivationInterval[5],Recurrent[6],MinSleep[7],Blocker[8],Weight[9],ActionIDs[10]
|
||||
cgrates.org,Threshold1,*string,Account,1001;1002,2014-07-29T15:00:00Z,true,1s,true,10,THRESH1;THRESH2
|
||||
|
||||
|
@@ -278,8 +278,8 @@ cgrates.org,Stats1,*string,Account,1001;1002,2014-07-29T15:00:00Z,100,1s,*asr;*a
|
||||
`
|
||||
|
||||
thresholds = `
|
||||
#Tenant[0],Id[1],FilterType[2],FilterFieldName[3],FilterFieldValues[4],ActivationInterval[5],MinItems[6],Recurrent[7],MinSleep[8],Blocker[9],Weight[10],ActionIDs[11]
|
||||
cgrates.org,Threshold1,*string,Account,1001;1002,2014-07-29T15:00:00Z,10,true,1s,true,10,THRESH1;THRESH2
|
||||
#Tenant[0],Id[1],FilterType[2],FilterFieldName[3],FilterFieldValues[4],ActivationInterval[5],Recurrent[6],MinSleep[7],Blocker[8],Weight[9],ActionIDs[10]
|
||||
cgrates.org,Threshold1,*string,Account,1001;1002,2014-07-29T15:00:00Z,true,1s,true,10,THRESH1;THRESH2
|
||||
`
|
||||
)
|
||||
|
||||
@@ -1482,7 +1482,6 @@ func TestLoadThresholds(t *testing.T) {
|
||||
ActivationInterval: &utils.TPActivationInterval{
|
||||
ActivationTime: "2014-07-29T15:00:00Z",
|
||||
},
|
||||
MinItems: 10,
|
||||
Recurrent: true,
|
||||
MinSleep: "1s",
|
||||
Blocker: true,
|
||||
|
||||
@@ -2137,9 +2137,6 @@ func (tps TpThresholdS) AsTPThreshold() (result []*utils.TPThreshold) {
|
||||
if tp.ActionIDs != "" {
|
||||
th.ActionIDs = append(th.ActionIDs, strings.Split(tp.ActionIDs, utils.INFIELD_SEP)...)
|
||||
}
|
||||
if tp.MinItems != 0 {
|
||||
th.MinItems = tp.MinItems
|
||||
}
|
||||
if tp.Weight != 0 {
|
||||
th.Weight = tp.Weight
|
||||
}
|
||||
@@ -2182,7 +2179,6 @@ func APItoModelTPThreshold(th *utils.TPThreshold) (mdls TpThresholdS) {
|
||||
if i == 0 {
|
||||
mdl.Blocker = th.Blocker
|
||||
mdl.Weight = th.Weight
|
||||
mdl.MinItems = th.MinItems
|
||||
mdl.Recurrent = th.Recurrent
|
||||
mdl.MinSleep = th.MinSleep
|
||||
if th.ActivationInterval != nil {
|
||||
@@ -2220,7 +2216,6 @@ func APItoThresholdProfile(tpTH *utils.TPThreshold, timezone string) (th *Thresh
|
||||
th = &ThresholdProfile{
|
||||
Tenant: tpTH.Tenant,
|
||||
ID: tpTH.ID,
|
||||
MinItems: tpTH.MinItems,
|
||||
Recurrent: tpTH.Recurrent,
|
||||
Weight: tpTH.Weight,
|
||||
Blocker: tpTH.Blocker,
|
||||
|
||||
@@ -940,7 +940,6 @@ func TestAsTPThresholdAsAsTPThreshold(t *testing.T) {
|
||||
FilterFieldName: "Account",
|
||||
FilterFieldValues: "1001;1002",
|
||||
ActivationInterval: "2014-07-29T15:00:00Z",
|
||||
MinItems: 100,
|
||||
Recurrent: false,
|
||||
MinSleep: "1s",
|
||||
Blocker: false,
|
||||
@@ -962,7 +961,6 @@ func TestAsTPThresholdAsAsTPThreshold(t *testing.T) {
|
||||
ActivationInterval: &utils.TPActivationInterval{
|
||||
ActivationTime: tps[0].ActivationInterval,
|
||||
},
|
||||
MinItems: tps[0].MinItems,
|
||||
MinSleep: tps[0].MinSleep,
|
||||
Recurrent: tps[0].Recurrent,
|
||||
Blocker: tps[0].Blocker,
|
||||
@@ -984,7 +982,6 @@ func TestAPItoTPThreshold(t *testing.T) {
|
||||
&utils.TPRequestFilter{Type: MetaString, FieldName: "Account", Values: []string{"1001", "1002"}},
|
||||
},
|
||||
ActivationInterval: &utils.TPActivationInterval{ActivationTime: "2014-07-29T15:00:00Z"},
|
||||
MinItems: 100,
|
||||
Recurrent: false,
|
||||
MinSleep: "1s",
|
||||
Blocker: false,
|
||||
@@ -995,7 +992,6 @@ func TestAPItoTPThreshold(t *testing.T) {
|
||||
eTPs := &ThresholdProfile{
|
||||
ID: tps.ID,
|
||||
Filters: make([]*RequestFilter, len(tps.Filters)),
|
||||
MinItems: tps.MinItems,
|
||||
Recurrent: tps.Recurrent,
|
||||
Blocker: tps.Blocker,
|
||||
Weight: tps.Weight,
|
||||
|
||||
@@ -508,11 +508,10 @@ type TpThreshold struct {
|
||||
FilterFieldName string `index:"3" re:""`
|
||||
FilterFieldValues string `index:"4" re:""`
|
||||
ActivationInterval string `index:"5" re:""`
|
||||
MinItems int `index:"6" re:""`
|
||||
Recurrent bool `index:"7" re:""`
|
||||
MinSleep string `index:"8" re:""`
|
||||
Blocker bool `index:"9" re:""`
|
||||
Weight float64 `index:"10" re:"\d+\.?\d*"`
|
||||
ActionIDs string `index:"11" re:""`
|
||||
Recurrent bool `index:"6" re:""`
|
||||
MinSleep string `index:"7" re:""`
|
||||
Blocker bool `index:"8" re:""`
|
||||
Weight float64 `index:"9" re:"\d+\.?\d*"`
|
||||
ActionIDs string `index:"10" re:""`
|
||||
CreatedAt time.Time
|
||||
}
|
||||
|
||||
@@ -2055,7 +2055,6 @@ func testOnStorITCRUDThresholdProfile(t *testing.T) {
|
||||
ID: "test",
|
||||
ActivationInterval: &utils.ActivationInterval{},
|
||||
Filters: []*RequestFilter{},
|
||||
MinItems: 10,
|
||||
Recurrent: true,
|
||||
MinSleep: timeMinSleep,
|
||||
Blocker: true,
|
||||
|
||||
@@ -718,7 +718,7 @@ func (ms *MongoStorage) HasData(category, subject string) (has bool, err error)
|
||||
case utils.StatQueuePrefix:
|
||||
count, err = db.C(colRes).Find(bson.M{"id": subject}).Count()
|
||||
has = count > 0
|
||||
case utils.ThresholdsPrefix:
|
||||
case utils.ThresholdProfilePrefix:
|
||||
count, err = db.C(colThs).Find(bson.M{"id": subject}).Count()
|
||||
has = count > 0
|
||||
default:
|
||||
|
||||
@@ -37,7 +37,6 @@ type ThresholdProfile struct {
|
||||
ID string
|
||||
Filters []*RequestFilter // Filters for the request
|
||||
ActivationInterval *utils.ActivationInterval // Time when this limit becomes active and expires
|
||||
MinItems int // number of items agregated for the threshold to match
|
||||
Recurrent bool
|
||||
MinSleep time.Duration
|
||||
Blocker bool // blocker flag to stop processing on filters matched
|
||||
|
||||
@@ -1360,7 +1360,6 @@ type TPThreshold struct {
|
||||
ID string
|
||||
Filters []*TPRequestFilter // Filters for the request
|
||||
ActivationInterval *TPActivationInterval // Time when this limit becomes active and expires
|
||||
MinItems int // number of items agregated for the threshold to match
|
||||
Recurrent bool
|
||||
MinSleep string
|
||||
Blocker bool // blocker flag to stop processing on filters matched
|
||||
|
||||
Reference in New Issue
Block a user