mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-12 02:26:26 +05:00
Integration tests for stats and thresholds
This commit is contained in:
committed by
Dan Christian Bogos
parent
78c9641a8a
commit
83c71bb956
@@ -53,10 +53,13 @@ var (
|
||||
testStatsStartEngine,
|
||||
testStatsRPCConn,
|
||||
testStatsGetStatQueueBeforeSet,
|
||||
testStatsGetStatQueueProfilesBeforeSet,
|
||||
testStatsSetStatQueueProfiles,
|
||||
testStatsGetStatQueueAfterSet,
|
||||
testStatsGetStatQueueIDs,
|
||||
testStatsGetStatQueueProfileIDs,
|
||||
testStatsGetStatQueueProfiles1,
|
||||
testStatsGetStatQueueProfilesWithPrefix,
|
||||
testStatsGetStatQueueProfileCount,
|
||||
testStatsRemoveStatQueueProfiles,
|
||||
testStatsGetStatQueuesAfterRemove,
|
||||
@@ -164,6 +167,15 @@ func testStatsGetStatQueueBeforeSet(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func testStatsGetStatQueueProfilesBeforeSet(t *testing.T) {
|
||||
var reply []*engine.StatQueueProfile
|
||||
var args *utils.ArgsItemIDs
|
||||
if err := sqRPC.Call(context.Background(), utils.AdminSv1GetStatQueueProfiles,
|
||||
args, &reply); err == nil || err.Error() != utils.ErrNotFound.Error() {
|
||||
t.Errorf("expected: <%+v>, \nreceived: <%+v>", utils.ErrNotFound, err)
|
||||
}
|
||||
}
|
||||
|
||||
func testStatsSetStatQueueProfiles(t *testing.T) {
|
||||
sqPrf1 := &engine.StatQueueProfileWithAPIOpts{
|
||||
StatQueueProfile: &engine.StatQueueProfile{
|
||||
@@ -426,6 +438,110 @@ func testStatsGetStatQueueProfileIDs(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func testStatsGetStatQueueProfiles1(t *testing.T) {
|
||||
var reply []*engine.StatQueueProfile
|
||||
var args *utils.ArgsItemIDs
|
||||
exp := []*engine.StatQueueProfile{
|
||||
{
|
||||
Tenant: "cgrates.org",
|
||||
ID: "SQ_1",
|
||||
Weight: 10,
|
||||
QueueLength: 100,
|
||||
TTL: time.Duration(1 * time.Minute),
|
||||
MinItems: 5,
|
||||
Metrics: []*engine.MetricWithFilters{
|
||||
{
|
||||
MetricID: utils.MetaACC,
|
||||
},
|
||||
{
|
||||
MetricID: utils.MetaACD,
|
||||
},
|
||||
{
|
||||
MetricID: utils.MetaASR,
|
||||
},
|
||||
{
|
||||
MetricID: utils.MetaDDC,
|
||||
},
|
||||
{
|
||||
MetricID: utils.MetaTCD,
|
||||
},
|
||||
},
|
||||
ThresholdIDs: []string{utils.MetaNone},
|
||||
},
|
||||
{
|
||||
Tenant: "cgrates.org",
|
||||
ID: "SQ_2",
|
||||
Weight: 20,
|
||||
Metrics: []*engine.MetricWithFilters{
|
||||
{
|
||||
MetricID: utils.MetaASR,
|
||||
},
|
||||
{
|
||||
MetricID: utils.MetaTCD,
|
||||
},
|
||||
{
|
||||
MetricID: utils.MetaPDD,
|
||||
},
|
||||
{
|
||||
MetricID: utils.MetaTCC,
|
||||
},
|
||||
{
|
||||
MetricID: utils.MetaTCD,
|
||||
},
|
||||
},
|
||||
ThresholdIDs: []string{utils.MetaNone},
|
||||
},
|
||||
}
|
||||
if err := sqRPC.Call(context.Background(), utils.AdminSv1GetStatQueueProfiles,
|
||||
args, &reply); err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
sort.Slice(reply, func(i int, j int) bool {
|
||||
return (reply)[i].ID < (reply)[j].ID
|
||||
})
|
||||
if !reflect.DeepEqual(reply, exp) {
|
||||
t.Errorf("expected: <%+v>, \nreceived: <%+v>", exp, reply)
|
||||
}
|
||||
}
|
||||
|
||||
func testStatsGetStatQueueProfilesWithPrefix(t *testing.T) {
|
||||
var reply []*engine.StatQueueProfile
|
||||
args := &utils.ArgsItemIDs{
|
||||
ItemsPrefix: "SQ_2",
|
||||
}
|
||||
exp := []*engine.StatQueueProfile{
|
||||
{
|
||||
Tenant: "cgrates.org",
|
||||
ID: "SQ_2",
|
||||
Weight: 20,
|
||||
Metrics: []*engine.MetricWithFilters{
|
||||
{
|
||||
MetricID: utils.MetaASR,
|
||||
},
|
||||
{
|
||||
MetricID: utils.MetaTCD,
|
||||
},
|
||||
{
|
||||
MetricID: utils.MetaPDD,
|
||||
},
|
||||
{
|
||||
MetricID: utils.MetaTCC,
|
||||
},
|
||||
{
|
||||
MetricID: utils.MetaTCD,
|
||||
},
|
||||
},
|
||||
ThresholdIDs: []string{utils.MetaNone},
|
||||
},
|
||||
}
|
||||
if err := sqRPC.Call(context.Background(), utils.AdminSv1GetStatQueueProfiles,
|
||||
args, &reply); err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
if !reflect.DeepEqual(reply, exp) {
|
||||
t.Errorf("expected: <%+v>, \nreceived: <%+v>", exp, reply)
|
||||
}
|
||||
}
|
||||
func testStatsGetStatQueueProfileCount(t *testing.T) {
|
||||
var reply int
|
||||
if err := sqRPC.Call(context.Background(), utils.AdminSv1GetStatQueueProfileCount,
|
||||
|
||||
@@ -53,6 +53,8 @@ var (
|
||||
testThresholdsGetThresholdAfterSet,
|
||||
testThresholdsGetThresholdIDs,
|
||||
testThresholdsGetThresholdProfileIDs,
|
||||
testThresholdsGetThresholdProfiles,
|
||||
testThresholdsGetThresholdProfilesWithPrefix,
|
||||
testThresholdsGetThresholdProfileCount,
|
||||
testThresholdsGetThresholdsForEvent,
|
||||
testThresholdsRemoveThresholdProfiles,
|
||||
@@ -324,6 +326,72 @@ func testThresholdsGetThresholdProfileIDs(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func testThresholdsGetThresholdProfiles(t *testing.T) {
|
||||
exp := []*engine.ThresholdProfile{
|
||||
{
|
||||
Tenant: "cgrates.org",
|
||||
ID: "THD_1",
|
||||
FilterIDs: []string{"*string:~*req.Account:1001"},
|
||||
ActionProfileIDs: []string{"actPrfID"},
|
||||
MaxHits: 5,
|
||||
MinHits: 1,
|
||||
Weight: 10,
|
||||
},
|
||||
{
|
||||
Tenant: "cgrates.org",
|
||||
ID: "THD_2",
|
||||
FilterIDs: []string{"*string:~*req.Account:1001"},
|
||||
ActionProfileIDs: []string{"actPrfID"},
|
||||
MaxHits: 7,
|
||||
MinHits: 0,
|
||||
Weight: 20,
|
||||
},
|
||||
}
|
||||
var ths []*engine.ThresholdProfile
|
||||
if err := thRPC.Call(context.Background(), utils.AdminSv1GetThresholdProfiles,
|
||||
&utils.ArgsItemIDs{
|
||||
Tenant: "cgrates.org",
|
||||
}, &ths); err != nil {
|
||||
t.Error(err)
|
||||
} else {
|
||||
sort.Slice(ths, func(i int, j int) bool {
|
||||
return (ths)[i].ID < (ths)[j].ID
|
||||
})
|
||||
if !reflect.DeepEqual(ths, exp) {
|
||||
t.Errorf("expected: <%+v>, \nreceived: <%+v>", exp, ths)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func testThresholdsGetThresholdProfilesWithPrefix(t *testing.T) {
|
||||
exp := []*engine.ThresholdProfile{
|
||||
{
|
||||
Tenant: "cgrates.org",
|
||||
ID: "THD_2",
|
||||
FilterIDs: []string{"*string:~*req.Account:1001"},
|
||||
ActionProfileIDs: []string{"actPrfID"},
|
||||
MaxHits: 7,
|
||||
MinHits: 0,
|
||||
Weight: 20,
|
||||
},
|
||||
}
|
||||
var ths []*engine.ThresholdProfile
|
||||
if err := thRPC.Call(context.Background(), utils.AdminSv1GetThresholdProfiles,
|
||||
&utils.ArgsItemIDs{
|
||||
Tenant: "cgrates.org",
|
||||
ItemsPrefix: "THD_2",
|
||||
}, &ths); err != nil {
|
||||
t.Error(err)
|
||||
} else {
|
||||
sort.Slice(ths, func(i int, j int) bool {
|
||||
return (ths)[i].ID < (ths)[j].ID
|
||||
})
|
||||
if !reflect.DeepEqual(ths, exp) {
|
||||
t.Errorf("expected: <%+v>, \nreceived: <%+v>", exp, ths)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func testThresholdsGetThresholdProfileCount(t *testing.T) {
|
||||
var reply int
|
||||
if err := thRPC.Call(context.Background(), utils.AdminSv1GetThresholdProfileCount,
|
||||
|
||||
@@ -1372,6 +1372,7 @@ const (
|
||||
AdminSv1GetThresholdProfileIDs = "AdminSv1.GetThresholdProfileIDs"
|
||||
AdminSv1GetThresholdProfileCount = "AdminSv1.GetThresholdProfileCount"
|
||||
AdminSv1GetThresholdProfile = "AdminSv1.GetThresholdProfile"
|
||||
AdminSv1GetThresholdProfiles = "AdminSv1.GetThresholdProfiles"
|
||||
AdminSv1RemoveThresholdProfile = "AdminSv1.RemoveThresholdProfile"
|
||||
AdminSv1SetThresholdProfile = "AdminSv1.SetThresholdProfile"
|
||||
)
|
||||
@@ -1390,6 +1391,7 @@ const (
|
||||
AdminSv1GetStatQueueProfile = "AdminSv1.GetStatQueueProfile"
|
||||
AdminSv1RemoveStatQueueProfile = "AdminSv1.RemoveStatQueueProfile"
|
||||
AdminSv1SetStatQueueProfile = "AdminSv1.SetStatQueueProfile"
|
||||
AdminSv1GetStatQueueProfiles = "AdminSv1.GetStatQueueProfiles"
|
||||
AdminSv1GetStatQueueProfileIDs = "AdminSv1.GetStatQueueProfileIDs"
|
||||
AdminSv1GetStatQueueProfileCount = "AdminSv1.GetStatQueueProfileCount"
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user