mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-11 18:16:24 +05:00
Moving cache for Filter and update cgr-console
This commit is contained in:
committed by
Dan Christian Bogos
parent
3ac9852e2f
commit
ecdfda51ae
@@ -149,17 +149,19 @@ func testV1FIdxRpcConn(t *testing.T) {
|
||||
//ThresholdProfile
|
||||
func testV1FIdxSetThresholdProfile(t *testing.T) {
|
||||
var reply *engine.ThresholdProfile
|
||||
filter = &engine.Filter{
|
||||
Tenant: tenant,
|
||||
ID: "TestFilter",
|
||||
Rules: []*engine.FilterRule{{
|
||||
FieldName: "Account",
|
||||
Type: utils.MetaString,
|
||||
Values: []string{"1001"},
|
||||
}},
|
||||
ActivationInterval: &utils.ActivationInterval{
|
||||
ActivationTime: time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC),
|
||||
ExpiryTime: time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC),
|
||||
filter = &FilterWrapper{
|
||||
Filter: &engine.Filter{
|
||||
Tenant: tenant,
|
||||
ID: "TestFilter",
|
||||
Rules: []*engine.FilterRule{{
|
||||
FieldName: "Account",
|
||||
Type: utils.MetaString,
|
||||
Values: []string{"1001"},
|
||||
}},
|
||||
ActivationInterval: &utils.ActivationInterval{
|
||||
ActivationTime: time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC),
|
||||
ExpiryTime: time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC),
|
||||
},
|
||||
},
|
||||
}
|
||||
var result string
|
||||
@@ -247,17 +249,19 @@ func testV1FIdxComputeThresholdsIndexes(t *testing.T) {
|
||||
|
||||
func testV1FIdxSetSecondThresholdProfile(t *testing.T) {
|
||||
var reply *engine.ThresholdProfile
|
||||
filter = &engine.Filter{
|
||||
Tenant: tenant,
|
||||
ID: "TestFilter2",
|
||||
Rules: []*engine.FilterRule{{
|
||||
FieldName: "Account",
|
||||
Type: utils.MetaString,
|
||||
Values: []string{"1002"},
|
||||
}},
|
||||
ActivationInterval: &utils.ActivationInterval{
|
||||
ActivationTime: time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC),
|
||||
ExpiryTime: time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC),
|
||||
filter = &FilterWrapper{
|
||||
Filter: &engine.Filter{
|
||||
Tenant: tenant,
|
||||
ID: "TestFilter2",
|
||||
Rules: []*engine.FilterRule{{
|
||||
FieldName: "Account",
|
||||
Type: utils.MetaString,
|
||||
Values: []string{"1002"},
|
||||
}},
|
||||
ActivationInterval: &utils.ActivationInterval{
|
||||
ActivationTime: time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC),
|
||||
ExpiryTime: time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC),
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
@@ -428,17 +432,19 @@ func testV1FIdxRemoveThresholdProfile(t *testing.T) {
|
||||
//StatQueueProfile
|
||||
func testV1FIdxSetStatQueueProfileIndexes(t *testing.T) {
|
||||
var reply *engine.StatQueueProfile
|
||||
filter = &engine.Filter{
|
||||
Tenant: tenant,
|
||||
ID: "FLTR_1",
|
||||
Rules: []*engine.FilterRule{{
|
||||
FieldName: "Account",
|
||||
Type: utils.MetaString,
|
||||
Values: []string{"1001"},
|
||||
}},
|
||||
ActivationInterval: &utils.ActivationInterval{
|
||||
ActivationTime: time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC),
|
||||
ExpiryTime: time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC),
|
||||
filter = &FilterWrapper{
|
||||
Filter: &engine.Filter{
|
||||
Tenant: tenant,
|
||||
ID: "FLTR_1",
|
||||
Rules: []*engine.FilterRule{{
|
||||
FieldName: "Account",
|
||||
Type: utils.MetaString,
|
||||
Values: []string{"1001"},
|
||||
}},
|
||||
ActivationInterval: &utils.ActivationInterval{
|
||||
ActivationTime: time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC),
|
||||
ExpiryTime: time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC),
|
||||
},
|
||||
},
|
||||
}
|
||||
var result string
|
||||
@@ -535,17 +541,19 @@ func testV1FIdxComputeStatQueueProfileIndexes(t *testing.T) {
|
||||
|
||||
func testV1FIdxSetSecondStatQueueProfileIndexes(t *testing.T) {
|
||||
var reply *engine.StatQueueProfile
|
||||
filter = &engine.Filter{
|
||||
Tenant: tenant,
|
||||
ID: "FLTR_2",
|
||||
Rules: []*engine.FilterRule{{
|
||||
FieldName: "Account",
|
||||
Type: utils.MetaString,
|
||||
Values: []string{"1001"},
|
||||
}},
|
||||
ActivationInterval: &utils.ActivationInterval{
|
||||
ActivationTime: time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC),
|
||||
ExpiryTime: time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC),
|
||||
filter = &FilterWrapper{
|
||||
Filter: &engine.Filter{
|
||||
Tenant: tenant,
|
||||
ID: "FLTR_2",
|
||||
Rules: []*engine.FilterRule{{
|
||||
FieldName: "Account",
|
||||
Type: utils.MetaString,
|
||||
Values: []string{"1001"},
|
||||
}},
|
||||
ActivationInterval: &utils.ActivationInterval{
|
||||
ActivationTime: time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC),
|
||||
ExpiryTime: time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC),
|
||||
},
|
||||
},
|
||||
}
|
||||
var result string
|
||||
@@ -691,17 +699,19 @@ func testV1FIdxRemoveStatQueueProfile(t *testing.T) {
|
||||
//ResourceProfile
|
||||
func testV1FIdxSetResourceProfileIndexes(t *testing.T) {
|
||||
var reply *engine.ResourceProfile
|
||||
filter = &engine.Filter{
|
||||
Tenant: tenant,
|
||||
ID: "FLTR_RES_RCFG1",
|
||||
Rules: []*engine.FilterRule{{
|
||||
FieldName: "Account",
|
||||
Type: utils.MetaString,
|
||||
Values: []string{"1001"},
|
||||
}},
|
||||
ActivationInterval: &utils.ActivationInterval{
|
||||
ActivationTime: time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC),
|
||||
ExpiryTime: time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC),
|
||||
filter = &FilterWrapper{
|
||||
Filter: &engine.Filter{
|
||||
Tenant: tenant,
|
||||
ID: "FLTR_RES_RCFG1",
|
||||
Rules: []*engine.FilterRule{{
|
||||
FieldName: "Account",
|
||||
Type: utils.MetaString,
|
||||
Values: []string{"1001"},
|
||||
}},
|
||||
ActivationInterval: &utils.ActivationInterval{
|
||||
ActivationTime: time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC),
|
||||
ExpiryTime: time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC),
|
||||
},
|
||||
},
|
||||
}
|
||||
var result string
|
||||
@@ -788,17 +798,19 @@ func testV1FIdxComputeResourceProfileIndexes(t *testing.T) {
|
||||
|
||||
func testV1FIdxSetSecondResourceProfileIndexes(t *testing.T) {
|
||||
var reply *engine.StatQueueProfile
|
||||
filter = &engine.Filter{
|
||||
Tenant: tenant,
|
||||
ID: "FLTR_2",
|
||||
Rules: []*engine.FilterRule{{
|
||||
FieldName: "Account",
|
||||
Type: utils.MetaString,
|
||||
Values: []string{"1001"},
|
||||
}},
|
||||
ActivationInterval: &utils.ActivationInterval{
|
||||
ActivationTime: time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC),
|
||||
ExpiryTime: time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC),
|
||||
filter = &FilterWrapper{
|
||||
Filter: &engine.Filter{
|
||||
Tenant: tenant,
|
||||
ID: "FLTR_2",
|
||||
Rules: []*engine.FilterRule{{
|
||||
FieldName: "Account",
|
||||
Type: utils.MetaString,
|
||||
Values: []string{"1001"},
|
||||
}},
|
||||
ActivationInterval: &utils.ActivationInterval{
|
||||
ActivationTime: time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC),
|
||||
ExpiryTime: time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC),
|
||||
},
|
||||
},
|
||||
}
|
||||
var result string
|
||||
@@ -933,19 +945,21 @@ func testV1FIdxRemoveResourceProfile(t *testing.T) {
|
||||
//SupplierProfile
|
||||
func testV1FIdxSetSupplierProfileIndexes(t *testing.T) {
|
||||
var reply *engine.SupplierProfile
|
||||
filter = &engine.Filter{
|
||||
Tenant: tenant,
|
||||
ID: "FLTR_1",
|
||||
Rules: []*engine.FilterRule{
|
||||
{
|
||||
FieldName: "Account",
|
||||
Type: utils.MetaString,
|
||||
Values: []string{"1001"},
|
||||
filter = &FilterWrapper{
|
||||
Filter: &engine.Filter{
|
||||
Tenant: tenant,
|
||||
ID: "FLTR_1",
|
||||
Rules: []*engine.FilterRule{
|
||||
{
|
||||
FieldName: "Account",
|
||||
Type: utils.MetaString,
|
||||
Values: []string{"1001"},
|
||||
},
|
||||
},
|
||||
ActivationInterval: &utils.ActivationInterval{
|
||||
ActivationTime: time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC),
|
||||
ExpiryTime: time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC),
|
||||
},
|
||||
},
|
||||
ActivationInterval: &utils.ActivationInterval{
|
||||
ActivationTime: time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC),
|
||||
ExpiryTime: time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC),
|
||||
},
|
||||
}
|
||||
var result string
|
||||
@@ -1037,17 +1051,19 @@ func testV1FIdxComputeSupplierProfileIndexes(t *testing.T) {
|
||||
|
||||
func testV1FIdxSetSecondSupplierProfileIndexes(t *testing.T) {
|
||||
var reply *engine.SupplierProfile
|
||||
filter = &engine.Filter{
|
||||
Tenant: tenant,
|
||||
ID: "FLTR_2",
|
||||
Rules: []*engine.FilterRule{{
|
||||
FieldName: "Account",
|
||||
Type: utils.MetaString,
|
||||
Values: []string{"1001"},
|
||||
}},
|
||||
ActivationInterval: &utils.ActivationInterval{
|
||||
ActivationTime: time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC),
|
||||
ExpiryTime: time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC),
|
||||
filter = &FilterWrapper{
|
||||
Filter: &engine.Filter{
|
||||
Tenant: tenant,
|
||||
ID: "FLTR_2",
|
||||
Rules: []*engine.FilterRule{{
|
||||
FieldName: "Account",
|
||||
Type: utils.MetaString,
|
||||
Values: []string{"1001"},
|
||||
}},
|
||||
ActivationInterval: &utils.ActivationInterval{
|
||||
ActivationTime: time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC),
|
||||
ExpiryTime: time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC),
|
||||
},
|
||||
},
|
||||
}
|
||||
var result string
|
||||
@@ -1190,17 +1206,19 @@ func testV1FIdxRemoveSupplierProfile(t *testing.T) {
|
||||
//AttributeProfile
|
||||
func testV1FIdxSetAttributeProfileIndexes(t *testing.T) {
|
||||
var reply *engine.AttributeProfile
|
||||
filter = &engine.Filter{
|
||||
Tenant: tenant,
|
||||
ID: "FLTR_1",
|
||||
Rules: []*engine.FilterRule{{
|
||||
FieldName: "Account",
|
||||
Type: utils.MetaString,
|
||||
Values: []string{"1001"},
|
||||
}},
|
||||
ActivationInterval: &utils.ActivationInterval{
|
||||
ActivationTime: time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC),
|
||||
ExpiryTime: time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC),
|
||||
filter = &FilterWrapper{
|
||||
Filter: &engine.Filter{
|
||||
Tenant: tenant,
|
||||
ID: "FLTR_1",
|
||||
Rules: []*engine.FilterRule{{
|
||||
FieldName: "Account",
|
||||
Type: utils.MetaString,
|
||||
Values: []string{"1001"},
|
||||
}},
|
||||
ActivationInterval: &utils.ActivationInterval{
|
||||
ActivationTime: time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC),
|
||||
ExpiryTime: time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC),
|
||||
},
|
||||
},
|
||||
}
|
||||
var result string
|
||||
@@ -1302,17 +1320,19 @@ func testV1FIdxComputeAttributeProfileIndexes(t *testing.T) {
|
||||
|
||||
func testV1FIdxSetSecondAttributeProfileIndexes(t *testing.T) {
|
||||
var reply *engine.AttributeProfile
|
||||
filter = &engine.Filter{
|
||||
Tenant: tenant,
|
||||
ID: "FLTR_2",
|
||||
Rules: []*engine.FilterRule{{
|
||||
FieldName: "Account",
|
||||
Type: utils.MetaString,
|
||||
Values: []string{"1001"},
|
||||
}},
|
||||
ActivationInterval: &utils.ActivationInterval{
|
||||
ActivationTime: time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC),
|
||||
ExpiryTime: time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC),
|
||||
filter = &FilterWrapper{
|
||||
Filter: &engine.Filter{
|
||||
Tenant: tenant,
|
||||
ID: "FLTR_2",
|
||||
Rules: []*engine.FilterRule{{
|
||||
FieldName: "Account",
|
||||
Type: utils.MetaString,
|
||||
Values: []string{"1001"},
|
||||
}},
|
||||
ActivationInterval: &utils.ActivationInterval{
|
||||
ActivationTime: time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC),
|
||||
ExpiryTime: time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC),
|
||||
},
|
||||
},
|
||||
}
|
||||
var result string
|
||||
|
||||
@@ -153,24 +153,26 @@ func testV1FIdxCaProcessEventWithNotFound(t *testing.T) {
|
||||
}
|
||||
|
||||
func testV1FIdxCaSetThresholdProfile(t *testing.T) {
|
||||
filter = &engine.Filter{
|
||||
Tenant: "cgrates.org",
|
||||
ID: "TestFilter",
|
||||
Rules: []*engine.FilterRule{
|
||||
{
|
||||
FieldName: utils.DynamicDataPrefix + utils.Account,
|
||||
Type: "*string",
|
||||
Values: []string{"1001"},
|
||||
filter = &FilterWrapper{
|
||||
Filter: &engine.Filter{
|
||||
Tenant: "cgrates.org",
|
||||
ID: "TestFilter",
|
||||
Rules: []*engine.FilterRule{
|
||||
{
|
||||
FieldName: utils.DynamicDataPrefix + utils.Account,
|
||||
Type: "*string",
|
||||
Values: []string{"1001"},
|
||||
},
|
||||
{
|
||||
FieldName: utils.DynamicDataPrefix + utils.EventType,
|
||||
Type: "*string",
|
||||
Values: []string{utils.BalanceUpdate},
|
||||
},
|
||||
},
|
||||
{
|
||||
FieldName: utils.DynamicDataPrefix + utils.EventType,
|
||||
Type: "*string",
|
||||
Values: []string{utils.BalanceUpdate},
|
||||
ActivationInterval: &utils.ActivationInterval{
|
||||
ActivationTime: time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC),
|
||||
},
|
||||
},
|
||||
ActivationInterval: &utils.ActivationInterval{
|
||||
ActivationTime: time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC),
|
||||
},
|
||||
}
|
||||
var result string
|
||||
if err := tFIdxCaRpc.Call("ApierV1.SetFilter", filter, &result); err != nil {
|
||||
@@ -245,24 +247,26 @@ func testV1FIdxCaGetThresholdFromTP(t *testing.T) {
|
||||
|
||||
func testV1FIdxCaUpdateThresholdProfile(t *testing.T) {
|
||||
var result string
|
||||
filter = &engine.Filter{
|
||||
Tenant: "cgrates.org",
|
||||
ID: "TestFilter2",
|
||||
Rules: []*engine.FilterRule{
|
||||
{
|
||||
FieldName: utils.DynamicDataPrefix + utils.Account,
|
||||
Type: "*string",
|
||||
Values: []string{"1002"},
|
||||
filter = &FilterWrapper{
|
||||
Filter: &engine.Filter{
|
||||
Tenant: "cgrates.org",
|
||||
ID: "TestFilter2",
|
||||
Rules: []*engine.FilterRule{
|
||||
{
|
||||
FieldName: utils.DynamicDataPrefix + utils.Account,
|
||||
Type: "*string",
|
||||
Values: []string{"1002"},
|
||||
},
|
||||
{
|
||||
FieldName: utils.DynamicDataPrefix + utils.EventType,
|
||||
Type: "*string",
|
||||
Values: []string{utils.AccountUpdate},
|
||||
},
|
||||
},
|
||||
{
|
||||
FieldName: utils.DynamicDataPrefix + utils.EventType,
|
||||
Type: "*string",
|
||||
Values: []string{utils.AccountUpdate},
|
||||
ActivationInterval: &utils.ActivationInterval{
|
||||
ActivationTime: time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC),
|
||||
},
|
||||
},
|
||||
ActivationInterval: &utils.ActivationInterval{
|
||||
ActivationTime: time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC),
|
||||
},
|
||||
}
|
||||
if err := tFIdxCaRpc.Call("ApierV1.SetFilter", filter, &result); err != nil {
|
||||
t.Error(err)
|
||||
@@ -323,24 +327,26 @@ func testV1FIdxCaUpdateThresholdProfile(t *testing.T) {
|
||||
|
||||
func testV1FIdxCaUpdateThresholdProfileFromTP(t *testing.T) {
|
||||
var result string
|
||||
filter = &engine.Filter{
|
||||
Tenant: "cgrates.org",
|
||||
ID: "TestFilter3",
|
||||
Rules: []*engine.FilterRule{
|
||||
{
|
||||
FieldName: utils.DynamicDataPrefix + utils.Account,
|
||||
Type: "*string",
|
||||
Values: []string{"1003"},
|
||||
filter = &FilterWrapper{
|
||||
Filter: &engine.Filter{
|
||||
Tenant: "cgrates.org",
|
||||
ID: "TestFilter3",
|
||||
Rules: []*engine.FilterRule{
|
||||
{
|
||||
FieldName: utils.DynamicDataPrefix + utils.Account,
|
||||
Type: "*string",
|
||||
Values: []string{"1003"},
|
||||
},
|
||||
{
|
||||
FieldName: utils.DynamicDataPrefix + utils.EventType,
|
||||
Type: "*string",
|
||||
Values: []string{utils.BalanceUpdate},
|
||||
},
|
||||
},
|
||||
{
|
||||
FieldName: utils.DynamicDataPrefix + utils.EventType,
|
||||
Type: "*string",
|
||||
Values: []string{utils.BalanceUpdate},
|
||||
ActivationInterval: &utils.ActivationInterval{
|
||||
ActivationTime: time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC),
|
||||
},
|
||||
},
|
||||
ActivationInterval: &utils.ActivationInterval{
|
||||
ActivationTime: time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC),
|
||||
},
|
||||
}
|
||||
if err := tFIdxCaRpc.Call("ApierV1.SetFilter", filter, &result); err != nil {
|
||||
t.Error(err)
|
||||
@@ -482,24 +488,26 @@ func testV1FIdxCaGetStatQueuesWithNotFound(t *testing.T) {
|
||||
|
||||
func testV1FIdxCaSetStatQueueProfile(t *testing.T) {
|
||||
tenant := "cgrates.org"
|
||||
filter = &engine.Filter{
|
||||
Tenant: tenant,
|
||||
ID: "FLTR_1",
|
||||
Rules: []*engine.FilterRule{
|
||||
{
|
||||
FieldName: utils.DynamicDataPrefix + utils.Account,
|
||||
Type: "*string",
|
||||
Values: []string{"1001"},
|
||||
filter = &FilterWrapper{
|
||||
Filter: &engine.Filter{
|
||||
Tenant: tenant,
|
||||
ID: "FLTR_1",
|
||||
Rules: []*engine.FilterRule{
|
||||
{
|
||||
FieldName: utils.DynamicDataPrefix + utils.Account,
|
||||
Type: "*string",
|
||||
Values: []string{"1001"},
|
||||
},
|
||||
{
|
||||
FieldName: utils.DynamicDataPrefix + utils.EventType,
|
||||
Type: "*string",
|
||||
Values: []string{utils.AccountUpdate},
|
||||
},
|
||||
},
|
||||
{
|
||||
FieldName: utils.DynamicDataPrefix + utils.EventType,
|
||||
Type: "*string",
|
||||
Values: []string{utils.AccountUpdate},
|
||||
ActivationInterval: &utils.ActivationInterval{
|
||||
ActivationTime: time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC),
|
||||
},
|
||||
},
|
||||
ActivationInterval: &utils.ActivationInterval{
|
||||
ActivationTime: time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC),
|
||||
},
|
||||
}
|
||||
var result string
|
||||
|
||||
@@ -618,24 +626,26 @@ func testV1FIdxCaGetStatQueuesFromTP(t *testing.T) {
|
||||
}
|
||||
|
||||
func testV1FIdxCaUpdateStatQueueProfile(t *testing.T) {
|
||||
filter = &engine.Filter{
|
||||
Tenant: "cgrates.org",
|
||||
ID: "FLTR_2",
|
||||
Rules: []*engine.FilterRule{
|
||||
{
|
||||
FieldName: utils.DynamicDataPrefix + utils.Account,
|
||||
Type: "*string",
|
||||
Values: []string{"1003"},
|
||||
filter = &FilterWrapper{
|
||||
Filter: &engine.Filter{
|
||||
Tenant: "cgrates.org",
|
||||
ID: "FLTR_2",
|
||||
Rules: []*engine.FilterRule{
|
||||
{
|
||||
FieldName: utils.DynamicDataPrefix + utils.Account,
|
||||
Type: "*string",
|
||||
Values: []string{"1003"},
|
||||
},
|
||||
{
|
||||
FieldName: utils.DynamicDataPrefix + utils.EventType,
|
||||
Type: "*string",
|
||||
Values: []string{utils.BalanceUpdate},
|
||||
},
|
||||
},
|
||||
{
|
||||
FieldName: utils.DynamicDataPrefix + utils.EventType,
|
||||
Type: "*string",
|
||||
Values: []string{utils.BalanceUpdate},
|
||||
ActivationInterval: &utils.ActivationInterval{
|
||||
ActivationTime: time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC),
|
||||
},
|
||||
},
|
||||
ActivationInterval: &utils.ActivationInterval{
|
||||
ActivationTime: time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC),
|
||||
},
|
||||
}
|
||||
var result string
|
||||
if err := tFIdxCaRpc.Call("ApierV1.SetFilter", filter, &result); err != nil {
|
||||
@@ -688,24 +698,26 @@ func testV1FIdxCaUpdateStatQueueProfile(t *testing.T) {
|
||||
}
|
||||
|
||||
func testV1FIdxCaUpdateStatQueueProfileFromTP(t *testing.T) {
|
||||
filter = &engine.Filter{
|
||||
Tenant: "cgrates.org",
|
||||
ID: "FLTR_3",
|
||||
Rules: []*engine.FilterRule{
|
||||
{
|
||||
FieldName: utils.DynamicDataPrefix + utils.Account,
|
||||
Type: "*string",
|
||||
Values: []string{"1003"},
|
||||
filter = &FilterWrapper{
|
||||
Filter: &engine.Filter{
|
||||
Tenant: "cgrates.org",
|
||||
ID: "FLTR_3",
|
||||
Rules: []*engine.FilterRule{
|
||||
{
|
||||
FieldName: utils.DynamicDataPrefix + utils.Account,
|
||||
Type: "*string",
|
||||
Values: []string{"1003"},
|
||||
},
|
||||
{
|
||||
FieldName: utils.DynamicDataPrefix + utils.EventType,
|
||||
Type: "*string",
|
||||
Values: []string{utils.AccountUpdate},
|
||||
},
|
||||
},
|
||||
{
|
||||
FieldName: utils.DynamicDataPrefix + utils.EventType,
|
||||
Type: "*string",
|
||||
Values: []string{utils.AccountUpdate},
|
||||
ActivationInterval: &utils.ActivationInterval{
|
||||
ActivationTime: time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC),
|
||||
},
|
||||
},
|
||||
ActivationInterval: &utils.ActivationInterval{
|
||||
ActivationTime: time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC),
|
||||
},
|
||||
}
|
||||
var result string
|
||||
if err := tFIdxCaRpc.Call("ApierV1.SetFilter", filter, &result); err != nil {
|
||||
@@ -837,24 +849,26 @@ func testV1FIdxCaProcessAttributeProfileEventWithNotFound(t *testing.T) {
|
||||
}
|
||||
|
||||
func testV1FIdxCaSetAttributeProfile(t *testing.T) {
|
||||
filter = &engine.Filter{
|
||||
Tenant: "cgrates.org",
|
||||
ID: "TestFilter",
|
||||
Rules: []*engine.FilterRule{
|
||||
{
|
||||
FieldName: utils.DynamicDataPrefix + utils.Account,
|
||||
Type: "*string",
|
||||
Values: []string{"1009"},
|
||||
filter = &FilterWrapper{
|
||||
Filter: &engine.Filter{
|
||||
Tenant: "cgrates.org",
|
||||
ID: "TestFilter",
|
||||
Rules: []*engine.FilterRule{
|
||||
{
|
||||
FieldName: utils.DynamicDataPrefix + utils.Account,
|
||||
Type: "*string",
|
||||
Values: []string{"1009"},
|
||||
},
|
||||
{
|
||||
FieldName: utils.DynamicDataPrefix + utils.Destination,
|
||||
Type: "*string",
|
||||
Values: []string{"+491511231234"},
|
||||
},
|
||||
},
|
||||
{
|
||||
FieldName: utils.DynamicDataPrefix + utils.Destination,
|
||||
Type: "*string",
|
||||
Values: []string{"+491511231234"},
|
||||
ActivationInterval: &utils.ActivationInterval{
|
||||
ActivationTime: time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC),
|
||||
},
|
||||
},
|
||||
ActivationInterval: &utils.ActivationInterval{
|
||||
ActivationTime: time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC),
|
||||
},
|
||||
}
|
||||
var result string
|
||||
if err := tFIdxCaRpc.Call("ApierV1.SetFilter", filter, &result); err != nil {
|
||||
@@ -928,24 +942,26 @@ func testV1FIdxCaGetAttributeProfileFromTP(t *testing.T) {
|
||||
}
|
||||
|
||||
func testV1FIdxCaUpdateAttributeProfile(t *testing.T) {
|
||||
filter = &engine.Filter{
|
||||
Tenant: "cgrates.org",
|
||||
ID: "TestFilter2",
|
||||
Rules: []*engine.FilterRule{
|
||||
{
|
||||
FieldName: utils.DynamicDataPrefix + utils.Account,
|
||||
Type: "*string",
|
||||
Values: []string{"2009"},
|
||||
filter = &FilterWrapper{
|
||||
Filter: &engine.Filter{
|
||||
Tenant: "cgrates.org",
|
||||
ID: "TestFilter2",
|
||||
Rules: []*engine.FilterRule{
|
||||
{
|
||||
FieldName: utils.DynamicDataPrefix + utils.Account,
|
||||
Type: "*string",
|
||||
Values: []string{"2009"},
|
||||
},
|
||||
{
|
||||
FieldName: utils.DynamicDataPrefix + utils.Destination,
|
||||
Type: "*string",
|
||||
Values: []string{"+492511231234"},
|
||||
},
|
||||
},
|
||||
{
|
||||
FieldName: utils.DynamicDataPrefix + utils.Destination,
|
||||
Type: "*string",
|
||||
Values: []string{"+492511231234"},
|
||||
ActivationInterval: &utils.ActivationInterval{
|
||||
ActivationTime: time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC),
|
||||
},
|
||||
},
|
||||
ActivationInterval: &utils.ActivationInterval{
|
||||
ActivationTime: time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC),
|
||||
},
|
||||
}
|
||||
var result string
|
||||
if err := tFIdxCaRpc.Call("ApierV1.SetFilter", filter, &result); err != nil {
|
||||
@@ -999,24 +1015,26 @@ func testV1FIdxCaUpdateAttributeProfile(t *testing.T) {
|
||||
}
|
||||
|
||||
func testV1FIdxCaUpdateAttributeProfileFromTP(t *testing.T) {
|
||||
filter = &engine.Filter{
|
||||
Tenant: "cgrates.org",
|
||||
ID: "TestFilter3",
|
||||
Rules: []*engine.FilterRule{
|
||||
{
|
||||
FieldName: utils.DynamicDataPrefix + utils.Account,
|
||||
Type: "*string",
|
||||
Values: []string{"3009"},
|
||||
filter = &FilterWrapper{
|
||||
Filter: &engine.Filter{
|
||||
Tenant: "cgrates.org",
|
||||
ID: "TestFilter3",
|
||||
Rules: []*engine.FilterRule{
|
||||
{
|
||||
FieldName: utils.DynamicDataPrefix + utils.Account,
|
||||
Type: "*string",
|
||||
Values: []string{"3009"},
|
||||
},
|
||||
{
|
||||
FieldName: utils.DynamicDataPrefix + utils.Destination,
|
||||
Type: "*string",
|
||||
Values: []string{"+492511231234"},
|
||||
},
|
||||
},
|
||||
{
|
||||
FieldName: utils.DynamicDataPrefix + utils.Destination,
|
||||
Type: "*string",
|
||||
Values: []string{"+492511231234"},
|
||||
ActivationInterval: &utils.ActivationInterval{
|
||||
ActivationTime: time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC),
|
||||
},
|
||||
},
|
||||
ActivationInterval: &utils.ActivationInterval{
|
||||
ActivationTime: time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC),
|
||||
},
|
||||
}
|
||||
var result string
|
||||
if err := tFIdxCaRpc.Call("ApierV1.SetFilter", filter, &result); err != nil {
|
||||
@@ -1145,28 +1163,30 @@ func testV1FIdxCaGetResourceProfileWithNotFound(t *testing.T) {
|
||||
}
|
||||
}
|
||||
func testV1FIdxCaSetResourceProfile(t *testing.T) {
|
||||
filter = &engine.Filter{
|
||||
Tenant: "cgrates.org",
|
||||
ID: "FLTR_RES_RCFG1",
|
||||
Rules: []*engine.FilterRule{
|
||||
{
|
||||
FieldName: utils.DynamicDataPrefix + utils.Account,
|
||||
Type: "*string",
|
||||
Values: []string{"1001"},
|
||||
filter = &FilterWrapper{
|
||||
Filter: &engine.Filter{
|
||||
Tenant: "cgrates.org",
|
||||
ID: "FLTR_RES_RCFG1",
|
||||
Rules: []*engine.FilterRule{
|
||||
{
|
||||
FieldName: utils.DynamicDataPrefix + utils.Account,
|
||||
Type: "*string",
|
||||
Values: []string{"1001"},
|
||||
},
|
||||
{
|
||||
FieldName: utils.DynamicDataPrefix + utils.Subject,
|
||||
Type: "*string",
|
||||
Values: []string{"1002"},
|
||||
},
|
||||
{
|
||||
FieldName: utils.DynamicDataPrefix + utils.Destination,
|
||||
Type: "*string",
|
||||
Values: []string{"1001"},
|
||||
},
|
||||
},
|
||||
{
|
||||
FieldName: utils.DynamicDataPrefix + utils.Subject,
|
||||
Type: "*string",
|
||||
Values: []string{"1002"},
|
||||
ActivationInterval: &utils.ActivationInterval{
|
||||
ActivationTime: time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC),
|
||||
},
|
||||
{
|
||||
FieldName: utils.DynamicDataPrefix + utils.Destination,
|
||||
Type: "*string",
|
||||
Values: []string{"1001"},
|
||||
},
|
||||
},
|
||||
ActivationInterval: &utils.ActivationInterval{
|
||||
ActivationTime: time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC),
|
||||
},
|
||||
}
|
||||
var result string
|
||||
@@ -1269,28 +1289,30 @@ func testV1FIdxCaGetResourceProfileFromTP(t *testing.T) {
|
||||
}
|
||||
|
||||
func testV1FIdxCaUpdateResourceProfile(t *testing.T) {
|
||||
filter = &engine.Filter{
|
||||
Tenant: "cgrates.org",
|
||||
ID: "FLTR_RES_RCFG2",
|
||||
Rules: []*engine.FilterRule{
|
||||
{
|
||||
FieldName: utils.DynamicDataPrefix + utils.Account,
|
||||
Type: "*string",
|
||||
Values: []string{"2002"},
|
||||
filter = &FilterWrapper{
|
||||
Filter: &engine.Filter{
|
||||
Tenant: "cgrates.org",
|
||||
ID: "FLTR_RES_RCFG2",
|
||||
Rules: []*engine.FilterRule{
|
||||
{
|
||||
FieldName: utils.DynamicDataPrefix + utils.Account,
|
||||
Type: "*string",
|
||||
Values: []string{"2002"},
|
||||
},
|
||||
{
|
||||
FieldName: utils.DynamicDataPrefix + utils.Subject,
|
||||
Type: "*string",
|
||||
Values: []string{"2001"},
|
||||
},
|
||||
{
|
||||
FieldName: utils.DynamicDataPrefix + utils.Destination,
|
||||
Type: "*string",
|
||||
Values: []string{"2002"},
|
||||
},
|
||||
},
|
||||
{
|
||||
FieldName: utils.DynamicDataPrefix + utils.Subject,
|
||||
Type: "*string",
|
||||
Values: []string{"2001"},
|
||||
ActivationInterval: &utils.ActivationInterval{
|
||||
ActivationTime: time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC),
|
||||
},
|
||||
{
|
||||
FieldName: utils.DynamicDataPrefix + utils.Destination,
|
||||
Type: "*string",
|
||||
Values: []string{"2002"},
|
||||
},
|
||||
},
|
||||
ActivationInterval: &utils.ActivationInterval{
|
||||
ActivationTime: time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC),
|
||||
},
|
||||
}
|
||||
var result string
|
||||
@@ -1342,28 +1364,30 @@ func testV1FIdxCaUpdateResourceProfile(t *testing.T) {
|
||||
}
|
||||
|
||||
func testV1FIdxCaUpdateResourceProfileFromTP(t *testing.T) {
|
||||
filter = &engine.Filter{
|
||||
Tenant: "cgrates.org",
|
||||
ID: "FLTR_RES_RCFG3",
|
||||
Rules: []*engine.FilterRule{
|
||||
{
|
||||
FieldName: utils.DynamicDataPrefix + utils.Account,
|
||||
Type: "*string",
|
||||
Values: []string{"1002"},
|
||||
filter = &FilterWrapper{
|
||||
Filter: &engine.Filter{
|
||||
Tenant: "cgrates.org",
|
||||
ID: "FLTR_RES_RCFG3",
|
||||
Rules: []*engine.FilterRule{
|
||||
{
|
||||
FieldName: utils.DynamicDataPrefix + utils.Account,
|
||||
Type: "*string",
|
||||
Values: []string{"1002"},
|
||||
},
|
||||
{
|
||||
FieldName: utils.DynamicDataPrefix + utils.Subject,
|
||||
Type: "*string",
|
||||
Values: []string{"1001"},
|
||||
},
|
||||
{
|
||||
FieldName: utils.DynamicDataPrefix + utils.Destination,
|
||||
Type: "*string",
|
||||
Values: []string{"1002"},
|
||||
},
|
||||
},
|
||||
{
|
||||
FieldName: utils.DynamicDataPrefix + utils.Subject,
|
||||
Type: "*string",
|
||||
Values: []string{"1001"},
|
||||
ActivationInterval: &utils.ActivationInterval{
|
||||
ActivationTime: time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC),
|
||||
},
|
||||
{
|
||||
FieldName: utils.DynamicDataPrefix + utils.Destination,
|
||||
Type: "*string",
|
||||
Values: []string{"1002"},
|
||||
},
|
||||
},
|
||||
ActivationInterval: &utils.ActivationInterval{
|
||||
ActivationTime: time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC),
|
||||
},
|
||||
}
|
||||
var result string
|
||||
|
||||
@@ -23,12 +23,25 @@ import (
|
||||
"github.com/cgrates/cgrates/utils"
|
||||
)
|
||||
|
||||
type FilterWrapper struct {
|
||||
*engine.Filter
|
||||
Cache *string
|
||||
}
|
||||
|
||||
//SetFilter add a new Filter
|
||||
func (self *ApierV1) SetFilter(attrs *engine.Filter, reply *string) error {
|
||||
if missing := utils.MissingStructFields(attrs, []string{"Tenant", "ID"}); len(missing) != 0 {
|
||||
func (apierV1 *ApierV1) SetFilter(arg *FilterWrapper, reply *string) error {
|
||||
if missing := utils.MissingStructFields(arg.Filter, []string{"Tenant", "ID"}); len(missing) != 0 {
|
||||
return utils.NewErrMandatoryIeMissing(missing...)
|
||||
}
|
||||
if err := self.DataManager.SetFilter(attrs); err != nil {
|
||||
if err := apierV1.DataManager.SetFilter(arg.Filter); err != nil {
|
||||
return utils.APIErrorHandler(err)
|
||||
}
|
||||
//handle caching for Filter
|
||||
argCache := engine.ArgsGetCacheItem{
|
||||
CacheID: utils.CacheFilters,
|
||||
ItemID: arg.TenantID(),
|
||||
}
|
||||
if err := apierV1.CallCache(GetCacheOpt(arg.Cache), argCache); err != nil {
|
||||
return utils.APIErrorHandler(err)
|
||||
}
|
||||
*reply = utils.OK
|
||||
@@ -36,11 +49,11 @@ func (self *ApierV1) SetFilter(attrs *engine.Filter, reply *string) error {
|
||||
}
|
||||
|
||||
//GetFilter returns a Filter
|
||||
func (self *ApierV1) GetFilter(arg utils.TenantID, reply *engine.Filter) error {
|
||||
func (apierV1 *ApierV1) GetFilter(arg utils.TenantID, reply *engine.Filter) error {
|
||||
if missing := utils.MissingStructFields(&arg, []string{"Tenant", "ID"}); len(missing) != 0 { //Params missing
|
||||
return utils.NewErrMandatoryIeMissing(missing...)
|
||||
}
|
||||
if fltr, err := self.DataManager.GetFilter(arg.Tenant, arg.ID, true, true, utils.NonTransactional); err != nil {
|
||||
if fltr, err := apierV1.DataManager.GetFilter(arg.Tenant, arg.ID, true, true, utils.NonTransactional); err != nil {
|
||||
if err.Error() != utils.ErrNotFound.Error() {
|
||||
err = utils.NewErrServerError(err)
|
||||
}
|
||||
@@ -70,16 +83,24 @@ func (apierV1 *ApierV1) GetFilterIDs(tenant string, fltrIDs *[]string) error {
|
||||
}
|
||||
|
||||
//RemoveFilter remove a specific filter
|
||||
func (self *ApierV1) RemoveFilter(arg utils.TenantID, reply *string) error {
|
||||
func (apierV1 *ApierV1) RemoveFilter(arg utils.TenantIDWrapper, reply *string) error {
|
||||
if missing := utils.MissingStructFields(&arg, []string{"Tenant", "ID"}); len(missing) != 0 { //Params missing
|
||||
return utils.NewErrMandatoryIeMissing(missing...)
|
||||
}
|
||||
if err := self.DataManager.RemoveFilter(arg.Tenant, arg.ID, utils.NonTransactional); err != nil {
|
||||
if err := apierV1.DataManager.RemoveFilter(arg.Tenant, arg.ID, utils.NonTransactional); err != nil {
|
||||
if err.Error() != utils.ErrNotFound.Error() {
|
||||
err = utils.NewErrServerError(err)
|
||||
}
|
||||
return err
|
||||
}
|
||||
//handle caching for Filter
|
||||
argCache := engine.ArgsGetCacheItem{
|
||||
CacheID: utils.CacheFilters,
|
||||
ItemID: arg.TenantID(),
|
||||
}
|
||||
if err := apierV1.CallCache(GetCacheOpt(arg.Cache), argCache); err != nil {
|
||||
return utils.APIErrorHandler(err)
|
||||
}
|
||||
*reply = utils.OK
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -38,7 +38,7 @@ var (
|
||||
filterCfg *config.CGRConfig
|
||||
filterRPC *rpc.Client
|
||||
filterDataDir = "/usr/share/cgrates"
|
||||
filter *engine.Filter
|
||||
filter *FilterWrapper
|
||||
filterConfigDIR string //run tests for specific configuration
|
||||
)
|
||||
|
||||
@@ -115,19 +115,21 @@ func testFilterGetFilterBeforeSet(t *testing.T) {
|
||||
}
|
||||
|
||||
func testFilterSetFilter(t *testing.T) {
|
||||
filter = &engine.Filter{
|
||||
Tenant: "cgrates.org",
|
||||
ID: "Filter1",
|
||||
Rules: []*engine.FilterRule{
|
||||
{
|
||||
FieldName: "*string",
|
||||
Type: "Account",
|
||||
Values: []string{"1001", "1002"},
|
||||
filter = &FilterWrapper{
|
||||
Filter: &engine.Filter{
|
||||
Tenant: "cgrates.org",
|
||||
ID: "Filter1",
|
||||
Rules: []*engine.FilterRule{
|
||||
{
|
||||
FieldName: "*string",
|
||||
Type: "Account",
|
||||
Values: []string{"1001", "1002"},
|
||||
},
|
||||
},
|
||||
ActivationInterval: &utils.ActivationInterval{
|
||||
ActivationTime: time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC),
|
||||
ExpiryTime: time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC),
|
||||
},
|
||||
},
|
||||
ActivationInterval: &utils.ActivationInterval{
|
||||
ActivationTime: time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC),
|
||||
ExpiryTime: time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC),
|
||||
},
|
||||
}
|
||||
|
||||
@@ -153,8 +155,8 @@ func testFilterGetFilterAfterSet(t *testing.T) {
|
||||
var reply *engine.Filter
|
||||
if err := filterRPC.Call("ApierV1.GetFilter", &utils.TenantID{Tenant: "cgrates.org", ID: "Filter1"}, &reply); err != nil {
|
||||
t.Error(err)
|
||||
} else if !reflect.DeepEqual(filter, reply) {
|
||||
t.Errorf("Expecting : %+v, received: %+v", filter, reply)
|
||||
} else if !reflect.DeepEqual(filter.Filter, reply) {
|
||||
t.Errorf("Expecting : %+v, received: %+v", filter.Filter, reply)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -181,16 +183,18 @@ func testFilterUpdateFilter(t *testing.T) {
|
||||
|
||||
func testFilterGetFilterAfterUpdate(t *testing.T) {
|
||||
var reply *engine.Filter
|
||||
if err := filterRPC.Call("ApierV1.GetFilter", &utils.TenantID{Tenant: "cgrates.org", ID: "Filter1"}, &reply); err != nil {
|
||||
if err := filterRPC.Call("ApierV1.GetFilter",
|
||||
&utils.TenantID{Tenant: "cgrates.org", ID: "Filter1"}, &reply); err != nil {
|
||||
t.Error(err)
|
||||
} else if !reflect.DeepEqual(filter, reply) {
|
||||
t.Errorf("Expecting : %+v, received: %+v", filter, reply)
|
||||
} else if !reflect.DeepEqual(filter.Filter, reply) {
|
||||
t.Errorf("Expecting : %+v, received: %+v", filter.Filter, reply)
|
||||
}
|
||||
}
|
||||
|
||||
func testFilterRemoveFilter(t *testing.T) {
|
||||
var resp string
|
||||
if err := filterRPC.Call("ApierV1.RemoveFilter", &utils.TenantID{Tenant: "cgrates.org", ID: "Filter1"}, &resp); err != nil {
|
||||
if err := filterRPC.Call("ApierV1.RemoveFilter",
|
||||
&utils.TenantIDWrapper{Tenant: "cgrates.org", ID: "Filter1"}, &resp); err != nil {
|
||||
t.Error(err)
|
||||
} else if resp != utils.OK {
|
||||
t.Error("Unexpected reply returned", resp)
|
||||
@@ -199,7 +203,8 @@ func testFilterRemoveFilter(t *testing.T) {
|
||||
|
||||
func testFilterGetFilterAfterRemove(t *testing.T) {
|
||||
var reply *engine.Filter
|
||||
if err := filterRPC.Call("ApierV1.GetFilter", &utils.TenantID{Tenant: "cgrates.org", ID: "Filter1"}, &reply); err == nil || err.Error() != utils.ErrNotFound.Error() {
|
||||
if err := filterRPC.Call("ApierV1.GetFilter",
|
||||
&utils.TenantID{Tenant: "cgrates.org", ID: "Filter1"}, &reply); err == nil || err.Error() != utils.ErrNotFound.Error() {
|
||||
t.Error(err)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -283,19 +283,21 @@ func testV1STSGetStatsAfterRestart(t *testing.T) {
|
||||
|
||||
func testV1STSSetStatQueueProfile(t *testing.T) {
|
||||
var reply *engine.StatQueueProfile
|
||||
filter = &engine.Filter{
|
||||
Tenant: "cgrates.org",
|
||||
ID: "FLTR_1",
|
||||
Rules: []*engine.FilterRule{
|
||||
{
|
||||
FieldName: "Account",
|
||||
Type: "*string",
|
||||
Values: []string{"1001"},
|
||||
filter = &FilterWrapper{
|
||||
Filter: &engine.Filter{
|
||||
Tenant: "cgrates.org",
|
||||
ID: "FLTR_1",
|
||||
Rules: []*engine.FilterRule{
|
||||
{
|
||||
FieldName: "Account",
|
||||
Type: "*string",
|
||||
Values: []string{"1001"},
|
||||
},
|
||||
},
|
||||
ActivationInterval: &utils.ActivationInterval{
|
||||
ActivationTime: time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC),
|
||||
ExpiryTime: time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC),
|
||||
},
|
||||
},
|
||||
ActivationInterval: &utils.ActivationInterval{
|
||||
ActivationTime: time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC),
|
||||
ExpiryTime: time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC),
|
||||
},
|
||||
}
|
||||
var result string
|
||||
@@ -361,19 +363,21 @@ func testV1STSGetStatQueueProfileIDs(t *testing.T) {
|
||||
|
||||
func testV1STSUpdateStatQueueProfile(t *testing.T) {
|
||||
var result string
|
||||
filter = &engine.Filter{
|
||||
Tenant: "cgrates.org",
|
||||
ID: "FLTR_2",
|
||||
Rules: []*engine.FilterRule{
|
||||
{
|
||||
FieldName: "Account",
|
||||
Type: "*string",
|
||||
Values: []string{"1001"},
|
||||
filter = &FilterWrapper{
|
||||
Filter: &engine.Filter{
|
||||
Tenant: "cgrates.org",
|
||||
ID: "FLTR_2",
|
||||
Rules: []*engine.FilterRule{
|
||||
{
|
||||
FieldName: "Account",
|
||||
Type: "*string",
|
||||
Values: []string{"1001"},
|
||||
},
|
||||
},
|
||||
ActivationInterval: &utils.ActivationInterval{
|
||||
ActivationTime: time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC),
|
||||
ExpiryTime: time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC),
|
||||
},
|
||||
},
|
||||
ActivationInterval: &utils.ActivationInterval{
|
||||
ActivationTime: time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC),
|
||||
ExpiryTime: time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC),
|
||||
},
|
||||
}
|
||||
if err := stsV1Rpc.Call("ApierV1.SetFilter", filter, &result); err != nil {
|
||||
|
||||
@@ -24,7 +24,7 @@ func init() {
|
||||
c := &CmdRemoveFilter{
|
||||
name: "filter_remove",
|
||||
rpcMethod: "ApierV1.RemoveFilter",
|
||||
rpcParams: &utils.TenantID{},
|
||||
rpcParams: &utils.TenantIDWrapper{},
|
||||
}
|
||||
commands[c.Name()] = c
|
||||
c.CommandExecuter = &CommandExecuter{c}
|
||||
@@ -34,7 +34,7 @@ func init() {
|
||||
type CmdRemoveFilter struct {
|
||||
name string
|
||||
rpcMethod string
|
||||
rpcParams *utils.TenantID
|
||||
rpcParams *utils.TenantIDWrapper
|
||||
*CommandExecuter
|
||||
}
|
||||
|
||||
@@ -48,7 +48,7 @@ func (self *CmdRemoveFilter) RpcMethod() string {
|
||||
|
||||
func (self *CmdRemoveFilter) RpcParams(reset bool) interface{} {
|
||||
if reset || self.rpcParams == nil {
|
||||
self.rpcParams = &utils.TenantID{}
|
||||
self.rpcParams = &utils.TenantIDWrapper{}
|
||||
}
|
||||
return self.rpcParams
|
||||
}
|
||||
|
||||
@@ -18,13 +18,13 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
|
||||
package console
|
||||
|
||||
import "github.com/cgrates/cgrates/engine"
|
||||
import "github.com/cgrates/cgrates/apier/v1"
|
||||
|
||||
func init() {
|
||||
c := &CmdSetFilter{
|
||||
name: "filter_set",
|
||||
rpcMethod: "ApierV1.SetFilter",
|
||||
rpcParams: &engine.Filter{},
|
||||
rpcParams: &v1.FilterWrapper{},
|
||||
}
|
||||
commands[c.Name()] = c
|
||||
c.CommandExecuter = &CommandExecuter{c}
|
||||
@@ -34,7 +34,7 @@ func init() {
|
||||
type CmdSetFilter struct {
|
||||
name string
|
||||
rpcMethod string
|
||||
rpcParams *engine.Filter
|
||||
rpcParams *v1.FilterWrapper
|
||||
*CommandExecuter
|
||||
}
|
||||
|
||||
@@ -48,7 +48,7 @@ func (self *CmdSetFilter) RpcMethod() string {
|
||||
|
||||
func (self *CmdSetFilter) RpcParams(reset bool) interface{} {
|
||||
if reset || self.rpcParams == nil {
|
||||
self.rpcParams = &engine.Filter{}
|
||||
self.rpcParams = &v1.FilterWrapper{}
|
||||
}
|
||||
return self.rpcParams
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ func init() {
|
||||
c := &CmdRemoveResource{
|
||||
name: "resource_remove",
|
||||
rpcMethod: "ApierV1.RemoveResourceProfile",
|
||||
rpcParams: &utils.TenantID{},
|
||||
rpcParams: &utils.TenantIDWrapper{},
|
||||
}
|
||||
commands[c.Name()] = c
|
||||
c.CommandExecuter = &CommandExecuter{c}
|
||||
@@ -34,7 +34,7 @@ func init() {
|
||||
type CmdRemoveResource struct {
|
||||
name string
|
||||
rpcMethod string
|
||||
rpcParams *utils.TenantID
|
||||
rpcParams *utils.TenantIDWrapper
|
||||
*CommandExecuter
|
||||
}
|
||||
|
||||
@@ -48,7 +48,7 @@ func (self *CmdRemoveResource) RpcMethod() string {
|
||||
|
||||
func (self *CmdRemoveResource) RpcParams(reset bool) interface{} {
|
||||
if reset || self.rpcParams == nil {
|
||||
self.rpcParams = &utils.TenantID{}
|
||||
self.rpcParams = &utils.TenantIDWrapper{}
|
||||
}
|
||||
return self.rpcParams
|
||||
}
|
||||
|
||||
@@ -18,13 +18,13 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
|
||||
package console
|
||||
|
||||
import "github.com/cgrates/cgrates/engine"
|
||||
import "github.com/cgrates/cgrates/apier/v1"
|
||||
|
||||
func init() {
|
||||
c := &CmdSetResource{
|
||||
name: "resource_set",
|
||||
rpcMethod: "ApierV1.SetResourceProfile",
|
||||
rpcParams: &engine.ResourceProfile{},
|
||||
rpcParams: &v1.ResourceWrapper{},
|
||||
}
|
||||
commands[c.Name()] = c
|
||||
c.CommandExecuter = &CommandExecuter{c}
|
||||
@@ -34,7 +34,7 @@ func init() {
|
||||
type CmdSetResource struct {
|
||||
name string
|
||||
rpcMethod string
|
||||
rpcParams *engine.ResourceProfile
|
||||
rpcParams *v1.ResourceWrapper
|
||||
*CommandExecuter
|
||||
}
|
||||
|
||||
@@ -48,7 +48,7 @@ func (self *CmdSetResource) RpcMethod() string {
|
||||
|
||||
func (self *CmdSetResource) RpcParams(reset bool) interface{} {
|
||||
if reset || self.rpcParams == nil {
|
||||
self.rpcParams = &engine.ResourceProfile{}
|
||||
self.rpcParams = &v1.ResourceWrapper{}
|
||||
}
|
||||
return self.rpcParams
|
||||
}
|
||||
|
||||
@@ -381,19 +381,12 @@ func (dm *DataManager) GetFilter(tenant, id string, cacheRead, cacheWrite bool,
|
||||
}
|
||||
|
||||
func (dm *DataManager) SetFilter(fltr *Filter) (err error) {
|
||||
if err = dm.DataDB().SetFilterDrv(fltr); err != nil {
|
||||
return
|
||||
}
|
||||
return dm.CacheDataFromDB(utils.FilterPrefix, []string{fltr.TenantID()}, true)
|
||||
return dm.DataDB().SetFilterDrv(fltr)
|
||||
|
||||
}
|
||||
|
||||
func (dm *DataManager) RemoveFilter(tenant, id, transactionID string) (err error) {
|
||||
if err = dm.DataDB().RemoveFilterDrv(tenant, id); err != nil {
|
||||
return
|
||||
}
|
||||
Cache.Remove(utils.CacheFilters, utils.ConcatenatedKey(tenant, id),
|
||||
cacheCommit(transactionID), transactionID)
|
||||
return
|
||||
return dm.DataDB().RemoveFilterDrv(tenant, id)
|
||||
}
|
||||
|
||||
func (dm *DataManager) GetThreshold(tenant, id string,
|
||||
|
||||
@@ -1157,7 +1157,6 @@ func testOnStorITResourceProfile(t *testing.T) {
|
||||
t.Error(err)
|
||||
} else if !reflect.DeepEqual(rL, rcv) {
|
||||
t.Errorf("Expecting: %v, received: %v", utils.ToJSON(rL), utils.ToJSON(rcv))
|
||||
|
||||
}
|
||||
expectedR := []string{"rsp_cgrates.org:RL_TEST2"}
|
||||
if itm, err := onStor.DataDB().GetKeysForPrefix(utils.ResourceProfilesPrefix); err != nil {
|
||||
|
||||
Reference in New Issue
Block a user