From 7fe6723dedd2760b99f8d719aece3a2634782df7 Mon Sep 17 00:00:00 2001 From: ionutboangiu Date: Mon, 17 May 2021 11:16:25 +0300 Subject: [PATCH] Fix failing tests after removal of ActivationInterval from Thresholds --- engine/loader_csv_test.go | 2 +- engine/model_helpers_test.go | 31 +++++++++++++++++++++++++------ engine/thresholds_test.go | 6 +++--- loaders/loader_test.go | 2 +- 4 files changed, 30 insertions(+), 11 deletions(-) diff --git a/engine/loader_csv_test.go b/engine/loader_csv_test.go index 9048605af..3f4718ee7 100644 --- a/engine/loader_csv_test.go +++ b/engine/loader_csv_test.go @@ -271,7 +271,7 @@ func TestLoadThresholdProfiles(t *testing.T) { TPid: testTPID, Tenant: "cgrates.org", ID: "Threshold1", - FilterIDs: []string{"*string:~*req.Account:1001", "*string:~*req.RunID:*default", "*ai:~*req.AnswerTime:2014-07-29T15:00:00Z"}, + FilterIDs: []string{"*string:~*req.Account:1001", "*string:~*req.RunID:*default"}, MaxHits: 12, MinHits: 10, MinSleep: "1s", diff --git a/engine/model_helpers_test.go b/engine/model_helpers_test.go index c14ad3656..2416b309b 100644 --- a/engine/model_helpers_test.go +++ b/engine/model_helpers_test.go @@ -587,7 +587,7 @@ func TestTPThresholdsAsTPThreshold(t *testing.T) { { TPid: tps[0].Tpid, ID: tps[0].ID, - FilterIDs: []string{"FilterID1", "FilterID2", "*ai:~*req.AnswerTime:2014-07-29T15:00:00Z"}, + FilterIDs: []string{"*ai:~*req.AnswerTime:2014-07-29T15:00:00Z", "FilterID1", "FilterID2"}, MinSleep: tps[0].MinSleep, MaxHits: tps[0].MaxHits, MinHits: tps[0].MinHits, @@ -598,7 +598,7 @@ func TestTPThresholdsAsTPThreshold(t *testing.T) { { TPid: tps[0].Tpid, ID: tps[0].ID, - FilterIDs: []string{"FilterID2", "FilterID1", "*ai:~*req.AnswerTime:2014-07-29T15:00:00Z"}, + FilterIDs: []string{"*ai:~*req.AnswerTime:2014-07-29T15:00:00Z", "FilterID2", "FilterID1"}, MinSleep: tps[0].MinSleep, MaxHits: tps[0].MaxHits, MinHits: tps[0].MinHits, @@ -642,7 +642,7 @@ func TestAPItoModelTPThreshold(t *testing.T) { Tpid: "TP1", Tenant: "cgrates.org", ID: "TH_1", - FilterIDs: "FilterID1;*ai:~*req.AnswerTime:2014-07-14T14:35:00Z", + FilterIDs: "FilterID1", MaxHits: 12, MinHits: 10, MinSleep: "1s", @@ -650,6 +650,12 @@ func TestAPItoModelTPThreshold(t *testing.T) { Weight: 20.0, ActionIDs: "WARN3", }, + { + Tpid: "TP1", + ID: "TH_1", + Tenant: "cgrates.org", + FilterIDs: "*ai:~*req.AnswerTime:2014-07-14T14:35:00Z", + }, } rcv := APItoModelTPThreshold(th) if !reflect.DeepEqual(models, rcv) { @@ -675,7 +681,7 @@ func TestAPItoModelTPThreshold2(t *testing.T) { Tpid: "TP1", Tenant: "cgrates.org", ID: "TH_1", - FilterIDs: "FLTR_1;*ai:~*req.AnswerTime:2014-07-14T14:35:00Z", + FilterIDs: "FLTR_1", MaxHits: 12, MinHits: 10, MinSleep: "1s", @@ -689,6 +695,12 @@ func TestAPItoModelTPThreshold2(t *testing.T) { ID: "TH_1", FilterIDs: "FLTR_2", }, + { + Tpid: "TP1", + Tenant: "cgrates.org", + ID: "TH_1", + FilterIDs: "*ai:~*req.AnswerTime:2014-07-14T14:35:00Z", + }, } rcv := APItoModelTPThreshold(th) if !reflect.DeepEqual(models, rcv) { @@ -714,7 +726,7 @@ func TestAPItoModelTPThreshold3(t *testing.T) { Tpid: "TP1", Tenant: "cgrates.org", ID: "TH_1", - FilterIDs: "FLTR_1;*ai:~*req.AnswerTime:2014-07-14T14:35:00Z", + FilterIDs: "FLTR_1", MaxHits: 12, MinHits: 10, MinSleep: "1s", @@ -727,6 +739,7 @@ func TestAPItoModelTPThreshold3(t *testing.T) { Tenant: "cgrates.org", ID: "TH_1", ActionIDs: "LOG", + FilterIDs: "*ai:~*req.AnswerTime:2014-07-14T14:35:00Z", }, } rcv := APItoModelTPThreshold(th) @@ -4276,7 +4289,7 @@ func TestModelHelpersAPItoModelTPThresholdExpTime2(t *testing.T) { Tpid: "TP1", Tenant: "cgrates.org", ID: "TH_1", - FilterIDs: "FilterID1;*ai:~*req.AnswerTime:2014-07-14T14:35:00Z|2014-07-15T14:35:00Z", + FilterIDs: "FilterID1", MaxHits: 12, MinHits: 10, MinSleep: "1s", @@ -4284,6 +4297,12 @@ func TestModelHelpersAPItoModelTPThresholdExpTime2(t *testing.T) { Weight: 20.0, ActionIDs: "WARN3", }, + { + Tpid: "TP1", + Tenant: "cgrates.org", + ID: "TH_1", + FilterIDs: "*ai:~*req.AnswerTime:2014-07-14T14:35:00Z|2014-07-15T14:35:00Z", + }, } result := APItoModelTPThreshold(testStruct) diff --git a/engine/thresholds_test.go b/engine/thresholds_test.go index 8a7118f87..289f32cd9 100644 --- a/engine/thresholds_test.go +++ b/engine/thresholds_test.go @@ -191,7 +191,7 @@ func TestThresholdsmatchingThresholdsForEvent(t *testing.T) { { Tenant: "cgrates.org", ID: "TH_1", - FilterIDs: []string{"FLTR_TH_1", "*ai:~*req.AnswerTime:2014-07-14T14:35:00Z"}, + FilterIDs: []string{"FLTR_TH_1", "*ai:*now:2014-07-14T14:35:00Z"}, MaxHits: 12, Blocker: false, Weight: 20.0, @@ -201,7 +201,7 @@ func TestThresholdsmatchingThresholdsForEvent(t *testing.T) { { Tenant: "cgrates.org", ID: "TH_2", - FilterIDs: []string{"FLTR_TH_2", "*ai:~*req.AnswerTime:2014-07-14T14:35:00Z"}, + FilterIDs: []string{"FLTR_TH_2", "*ai:*now:2014-07-14T14:35:00Z"}, MaxHits: 12, MinSleep: 5 * time.Minute, Blocker: false, @@ -212,7 +212,7 @@ func TestThresholdsmatchingThresholdsForEvent(t *testing.T) { { Tenant: "cgrates.org", ID: "TH_3", - FilterIDs: []string{"FLTR_TH_3", "*ai:~*req.AnswerTime:2014-07-14T14:35:00Z"}, + FilterIDs: []string{"FLTR_TH_3", "*ai:*now:2014-07-14T14:35:00Z"}, MaxHits: 12, MinSleep: 5 * time.Minute, Blocker: false, diff --git a/loaders/loader_test.go b/loaders/loader_test.go index 8e93b1a91..350ce6907 100644 --- a/loaders/loader_test.go +++ b/loaders/loader_test.go @@ -571,7 +571,7 @@ func TestLoaderProcessThresholds(t *testing.T) { eTh1 := &engine.ThresholdProfile{ Tenant: "cgrates.org", ID: "Threshold1", - FilterIDs: []string{"*string:~*req.Account:1001", "*string:~*req.RunID:*default", "*ai:~*req.AnswerTime:2014-07-29T15:00:00Z"}, + FilterIDs: []string{"*string:~*req.Account:1001", "*string:~*req.RunID:*default"}, MaxHits: 12, MinHits: 10, MinSleep: time.Second,