mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-11 18:16:24 +05:00
Updated apier/tests for stats.go/thresholds/go by adding tenant default value
This commit is contained in:
committed by
Dan Christian Bogos
parent
79c5c99fcb
commit
79469d9987
@@ -81,6 +81,7 @@ var (
|
||||
testV1STSProcessMetricsWithFilter,
|
||||
testV1STSProcessStaticMetrics,
|
||||
testV1STSProcessStatWithThreshold,
|
||||
testV1STSV1GetQueueIDs,
|
||||
testV1STSGetStatQueueProfileWithoutTenant,
|
||||
testV1STSRemStatQueueProfileWithoutTenant,
|
||||
//testV1STSProcessCDRStat,
|
||||
@@ -1244,3 +1245,22 @@ func testV1STSRemStatQueueProfileWithoutTenant(t *testing.T) {
|
||||
t.Error(err)
|
||||
}
|
||||
}
|
||||
|
||||
func testV1STSV1GetQueueIDs(t *testing.T) {
|
||||
expected := []string{"StatWithThreshold", "Stats1", "StaticStatQueue", "CustomStatProfile"}
|
||||
var qIDs []string
|
||||
if err := stsV1Rpc.Call(utils.StatSv1GetQueueIDs,
|
||||
&utils.TenantWithOpts{},
|
||||
&qIDs); err != nil {
|
||||
t.Error(err)
|
||||
} else if !reflect.DeepEqual(qIDs, expected) {
|
||||
t.Errorf("Expected %+v \n ,received %+v", expected, qIDs)
|
||||
}
|
||||
if err := stsV1Rpc.Call(utils.StatSv1GetQueueIDs,
|
||||
&utils.TenantWithOpts{Tenant: "cgrates.org"},
|
||||
&qIDs); err != nil {
|
||||
t.Error(err)
|
||||
} else if !reflect.DeepEqual(qIDs, expected) {
|
||||
t.Errorf("Expected %+v \n ,received %+v", expected, qIDs)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -243,6 +243,7 @@ var (
|
||||
testV1TSGetThresholdProfileWithoutTenant,
|
||||
testV1TSRemThresholdProfileWithoutTenant,
|
||||
testV1TSProcessEventWithoutTenant,
|
||||
testV1TSGetThresholdsWithoutTenant,
|
||||
testV1TSStopEngine,
|
||||
}
|
||||
)
|
||||
@@ -314,6 +315,12 @@ func testV1TSFromFolder(t *testing.T) {
|
||||
func testV1TSGetThresholds(t *testing.T) {
|
||||
var tIDs []string
|
||||
expectedIDs := []string{"THD_RES_1", "THD_STATS_2", "THD_STATS_1", "THD_ACNT_BALANCE_1", "THD_ACNT_EXPIRED", "THD_STATS_3", "THD_CDRS_1"}
|
||||
if err := tSv1Rpc.Call(utils.ThresholdSv1GetThresholdIDs,
|
||||
&utils.TenantWithOpts{}, &tIDs); err != nil {
|
||||
t.Error(err)
|
||||
} else if len(expectedIDs) != len(tIDs) {
|
||||
t.Errorf("expecting: %+v, received reply: %s", expectedIDs, tIDs)
|
||||
}
|
||||
if err := tSv1Rpc.Call(utils.ThresholdSv1GetThresholdIDs,
|
||||
&utils.TenantWithOpts{Tenant: "cgrates.org"}, &tIDs); err != nil {
|
||||
t.Error(err)
|
||||
@@ -838,3 +845,23 @@ func testV1TSProcessEventWithoutTenant(t *testing.T) {
|
||||
t.Errorf("Expecting ids: %s, received: %s", eIDs, ids)
|
||||
}
|
||||
}
|
||||
|
||||
func testV1TSGetThresholdsWithoutTenant(t *testing.T) {
|
||||
expectedThreshold := &engine.Threshold{
|
||||
Tenant: "cgrates.org",
|
||||
ID: "THD_ACNT_BALANCE_1",
|
||||
Hits: 1,
|
||||
}
|
||||
var reply *engine.Threshold
|
||||
if err := tSv1Rpc.Call(utils.ThresholdSv1GetThreshold,
|
||||
&utils.TenantIDWithOpts{TenantID: &utils.TenantID{ID: "THD_ACNT_BALANCE_1"}},
|
||||
&reply); err != nil {
|
||||
t.Error(err)
|
||||
} else if !reflect.DeepEqual(expectedThreshold.ID, reply.ID) {
|
||||
t.Errorf("Expected %+v \n, received %+v", utils.ToJSON(expectedThreshold.ID), utils.ToJSON(reply.ID))
|
||||
} else if !reflect.DeepEqual(expectedThreshold.Tenant, reply.Tenant) {
|
||||
t.Errorf("Expected %+v \n, received %+v", utils.ToJSON(expectedThreshold.Tenant), utils.ToJSON(reply.Tenant))
|
||||
} else if !reflect.DeepEqual(expectedThreshold.ID, reply.ID) {
|
||||
t.Errorf("Expected %+v \n, received %+v", utils.ToJSON(expectedThreshold.Tenant), utils.ToJSON(reply.Tenant))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -463,6 +463,9 @@ func (sS *StatService) V1GetQueueFloatMetrics(args *utils.TenantID, reply *map[s
|
||||
|
||||
// V1GetQueueIDs returns list of queueIDs registered for a tenant
|
||||
func (sS *StatService) V1GetQueueIDs(tenant string, qIDs *[]string) (err error) {
|
||||
if tenant == utils.EmptyString {
|
||||
tenant = sS.cgrcfg.GeneralCfg().DefaultTenant
|
||||
}
|
||||
prfx := utils.StatQueuePrefix + tenant + ":"
|
||||
keys, err := sS.dm.DataDB().GetKeysForPrefix(prfx)
|
||||
if err != nil {
|
||||
|
||||
@@ -430,6 +430,9 @@ func (tS *ThresholdService) V1GetThresholdsForEvent(args *ThresholdsArgsProcessE
|
||||
|
||||
// V1GetThresholdIDs returns list of thresholdIDs configured for a tenant
|
||||
func (tS *ThresholdService) V1GetThresholdIDs(tenant string, tIDs *[]string) (err error) {
|
||||
if tenant == utils.EmptyString {
|
||||
tenant = tS.cgrcfg.GeneralCfg().DefaultTenant
|
||||
}
|
||||
prfx := utils.ThresholdPrefix + tenant + ":"
|
||||
keys, err := tS.dm.DataDB().GetKeysForPrefix(prfx)
|
||||
if err != nil {
|
||||
@@ -446,7 +449,11 @@ func (tS *ThresholdService) V1GetThresholdIDs(tenant string, tIDs *[]string) (er
|
||||
// V1GetThreshold retrieves a Threshold
|
||||
func (tS *ThresholdService) V1GetThreshold(tntID *utils.TenantID, t *Threshold) (err error) {
|
||||
var thd *Threshold
|
||||
if thd, err = tS.dm.GetThreshold(tntID.Tenant, tntID.ID, true, true, ""); err != nil {
|
||||
tnt := tntID.Tenant
|
||||
if tnt == utils.EmptyString {
|
||||
tnt = tS.cgrcfg.GeneralCfg().DefaultTenant
|
||||
}
|
||||
if thd, err = tS.dm.GetThreshold(tnt, tntID.ID, true, true, ""); err != nil {
|
||||
return
|
||||
}
|
||||
*t = *thd
|
||||
|
||||
@@ -1499,6 +1499,7 @@ const (
|
||||
StatSv1Ping = "StatSv1.Ping"
|
||||
StatSv1GetStatQueuesForEvent = "StatSv1.GetStatQueuesForEvent"
|
||||
StatSv1GetStatQueue = "StatSv1.GetStatQueue"
|
||||
StatSv1V1GetQueueIDs = "StatSv1.GetQueueIDs"
|
||||
APIerSv1GetStatQueueProfile = "APIerSv1.GetStatQueueProfile"
|
||||
APIerSv1RemoveStatQueueProfile = "APIerSv1.RemoveStatQueueProfile"
|
||||
APIerSv1SetStatQueueProfile = "APIerSv1.SetStatQueueProfile"
|
||||
|
||||
Reference in New Issue
Block a user