From d9d8df250f84ac43ea13d8c0fc2f0a0c43b302d2 Mon Sep 17 00:00:00 2001 From: porosnicuadrian Date: Tue, 14 Sep 2021 16:56:20 +0300 Subject: [PATCH] Fixed tests for the ComputeID case --- apier/v1/filter_indexes_it_test.go | 90 +++++++++++++++--------------- 1 file changed, 44 insertions(+), 46 deletions(-) diff --git a/apier/v1/filter_indexes_it_test.go b/apier/v1/filter_indexes_it_test.go index 944d60503..f7a0fd47b 100644 --- a/apier/v1/filter_indexes_it_test.go +++ b/apier/v1/filter_indexes_it_test.go @@ -92,7 +92,7 @@ var ( testV1FIdxComputeDispatcherProfileIndexes, testV1FIdxSetDispatcherProfile2, testV1FIdxComputeDispatcherProfileIndexes2, - + // special case for ComputeIndexesIDs multiple times testV1FIdxComputeIndexesMultipleProfilesAndFilters, testV1FIdxStopEngine, @@ -453,10 +453,10 @@ func testV1FIdxSetStatQueueProfileIndexes(t *testing.T) { QueueLength: 10, TTL: time.Duration(10) * time.Second, Metrics: []*engine.MetricWithFilters{ - &engine.MetricWithFilters{ + { MetricID: utils.MetaSum, }, - &engine.MetricWithFilters{ + { MetricID: utils.MetaACD, }, }, @@ -556,10 +556,10 @@ func testV1FIdxSetSecondStatQueueProfileIndexes(t *testing.T) { QueueLength: 10, TTL: time.Duration(10) * time.Second, Metrics: []*engine.MetricWithFilters{ - &engine.MetricWithFilters{ + { MetricID: "*sum", }, - &engine.MetricWithFilters{ + { MetricID: utils.MetaACD, }, }, @@ -2141,48 +2141,46 @@ func testV1FIdxComputeIndexesMultipleProfilesAndFilters(t *testing.T) { } } - /* - //now we will ComputeFilterIndexes of the remain profile - if err := tFIdxRpc.Call(utils.APIerSv1ComputeFilterIndexIDs, - &utils.ArgsComputeFilterIndexIDs{Tenant: "cgrates.org", - ThresholdIDs: []string{"THD_ACNT_1003"}}, - &reply); err != nil { - t.Error(err) - } else if reply != utils.OK { - t.Error("Unexpected reply returned") + //now we will ComputeFilterIndexes of the remain profile + if err := tFIdxRpc.Call(utils.APIerSv1ComputeFilterIndexIDs, + &utils.ArgsComputeFilterIndexIDs{Tenant: "cgrates.org", + ThresholdIDs: []string{"THD_ACNT_1003"}}, + &reply); err != nil { + t.Error(err) + } else if reply != utils.OK { + t.Error("Unexpected reply returned") + } + expectedIDx = []string{"*string:~*req.Account:1001:THD_ACNT_1002", + "*string:~*req.Account:1001:THD_ACNT_1003", + "*string:~*req.Account:1001:THD_ACNT_1001", + "*prefix:~*req.AnswerTime:12:THD_ACNT_1002", + "*prefix:~*req.AnswerTime:33:THD_ACNT_1002", + "*prefix:~*req.AnswerTime:12:THD_ACNT_1001", + "*prefix:~*req.AnswerTime:33:THD_ACNT_1001", + "*string:~*req.Usage:123s:THD_ACNT_1002", + "*string:~*req.Usage:123s:THD_ACNT_1001", + "*string:~*req.Subject:1004:THD_ACNT_1001", + "*string:~*req.Subject:6774:THD_ACNT_1001", + "*string:~*req.Subject:22312:THD_ACNT_1001", + "*string:~*opts.Subsystems:*attributes:THD_ACNT_1001", + "*prefix:~*req.Destinations:+0775:THD_ACNT_1001", + "*prefix:~*req.Destinations:+442:THD_ACNT_1001", + "*string:~*req.Subject:1004:THD_ACNT_1003", + "*string:~*req.Subject:6774:THD_ACNT_1003", + "*string:~*req.Subject:22312:THD_ACNT_1003", + "*string:~*opts.Subsystems:*attributes:THD_ACNT_1003", + "*prefix:~*req.Destinations:+0775:THD_ACNT_1003", + "*prefix:~*req.Destinations:+442:THD_ACNT_1003"} + if err := tFIdxRpc.Call(utils.APIerSv1GetFilterIndexes, + &AttrGetFilterIndexes{Tenant: "cgrates.org", ItemType: utils.MetaThresholds}, &replyIdx); err != nil { + t.Error(err) + } else { + sort.Strings(expectedIDx) + sort.Strings(replyIdx) + if !reflect.DeepEqual(expectedIDx, replyIdx) { + t.Errorf("Expected %+v \n, received %+v", utils.ToJSON(expectedIDx), utils.ToJSON(replyIdx)) } - expectedIDx = []string{"*string:~*req.Account:1001:THD_ACNT_1002", - "*string:~*req.Account:1001:THD_ACNT_1003", - "*string:~*req.Account:1001:THD_ACNT_1001", - "*prefix:~*req.AnswerTime:12:THD_ACNT_1002", - "*prefix:~*req.AnswerTime:33:THD_ACNT_1002", - "*prefix:~*req.AnswerTime:12:THD_ACNT_1001", - "*prefix:~*req.AnswerTime:33:THD_ACNT_1001", - "*string:~*req.Usage:123s:THD_ACNT_1002", - "*string:~*req.Usage:123s:THD_ACNT_1001", - "*string:~*req.Subject:1004:THD_ACNT_1001", - "*string:~*req.Subject:6774:THD_ACNT_1001", - "*string:~*req.Subject:22312:THD_ACNT_1001", - "*string:~*opts.Subsystems:*attributes:THD_ACNT_1001", - "*prefix:~*req.Destinations:+0775:THD_ACNT_1001", - "*prefix:~*req.Destinations:+442:THD_ACNT_1001", - "*string:~*req.Subject:1004:THD_ACNT_1003", - "*string:~*req.Subject:6774:THD_ACNT_1003", - "*string:~*req.Subject:22312:THD_ACNT_1003", - "*string:~*opts.Subsystems:*attributes:THD_ACNT_1003", - "*prefix:~*req.Destinations:+0775:THD_ACNT_1003", - "*prefix:~*req.Destinations:+442:THD_ACNT_1003"} - if err := tFIdxRpc.Call(utils.APIerSv1GetFilterIndexes, - &AttrGetFilterIndexes{Tenant: "cgrates.org", ItemType: utils.MetaThresholds}, &replyIdx); err != nil { - t.Error(err) - } else { - sort.Strings(expectedIDx) - sort.Strings(replyIdx) - if !reflect.DeepEqual(expectedIDx, replyIdx) { - t.Errorf("Expected %+v \n, received %+v", utils.ToJSON(expectedIDx), utils.ToJSON(replyIdx)) - } - } - */ + } } func testV1FIdxStopEngine(t *testing.T) {