mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-20 06:38:45 +05:00
Update integration test for resources
This commit is contained in:
committed by
Dan Christian Bogos
parent
28c228d421
commit
63c60e013a
@@ -1146,6 +1146,7 @@ func testV1FIdxCaGetResourceProfileWithNotFound(t *testing.T) {
|
||||
UsageID: "651a8db2-4f67-4cf8-b622-169e8a482e61",
|
||||
CGREvent: utils.CGREvent{
|
||||
Tenant: "cgrates.org",
|
||||
ID: utils.UUIDSha1Prefix(),
|
||||
Event: map[string]interface{}{
|
||||
utils.Account: "1002",
|
||||
utils.Subject: "1001",
|
||||
@@ -1221,6 +1222,7 @@ func testV1FIdxCaSetResourceProfile(t *testing.T) {
|
||||
UsageID: "651a8db2-4f67-4cf8-b622-169e8a482e61",
|
||||
CGREvent: utils.CGREvent{
|
||||
Tenant: "cgrates.org",
|
||||
ID: utils.UUIDSha1Prefix(),
|
||||
Event: map[string]interface{}{
|
||||
utils.Account: "1001",
|
||||
utils.Subject: "1002",
|
||||
@@ -1249,6 +1251,7 @@ func testV1FIdxCaGetResourceProfileFromTP(t *testing.T) {
|
||||
UsageID: "651a8db2-4f67-4cf8-b622-169e8a482e63",
|
||||
CGREvent: utils.CGREvent{
|
||||
Tenant: "cgrates.org",
|
||||
ID: utils.UUIDSha1Prefix(),
|
||||
Event: map[string]interface{}{
|
||||
utils.Account: "1001",
|
||||
utils.Subject: "1002",
|
||||
@@ -1273,6 +1276,7 @@ func testV1FIdxCaGetResourceProfileFromTP(t *testing.T) {
|
||||
UsageID: "651a8db2-4f67-4cf8-b622-169e8a482e61",
|
||||
CGREvent: utils.CGREvent{
|
||||
Tenant: "cgrates.org",
|
||||
ID: utils.UUIDSha1Prefix(),
|
||||
Event: map[string]interface{}{
|
||||
utils.Account: "1002",
|
||||
utils.Subject: "1001",
|
||||
@@ -1348,6 +1352,7 @@ func testV1FIdxCaUpdateResourceProfile(t *testing.T) {
|
||||
UsageID: "651a8db2-4f67-4cf8-b622-169e8a482e61",
|
||||
CGREvent: utils.CGREvent{
|
||||
Tenant: "cgrates.org",
|
||||
ID: utils.UUIDSha1Prefix(),
|
||||
Event: map[string]interface{}{
|
||||
utils.Account: "2002",
|
||||
utils.Subject: "2001",
|
||||
@@ -1413,6 +1418,7 @@ func testV1FIdxCaUpdateResourceProfileFromTP(t *testing.T) {
|
||||
UsageID: "651a8db2-4f67-4cf8-b622-169e8a482e65",
|
||||
CGREvent: utils.CGREvent{
|
||||
Tenant: "cgrates.org",
|
||||
ID: utils.UUIDSha1Prefix(),
|
||||
Event: map[string]interface{}{
|
||||
utils.Account: "1002",
|
||||
utils.Subject: "1001",
|
||||
@@ -1433,6 +1439,7 @@ func testV1FIdxCaRemoveResourceProfile(t *testing.T) {
|
||||
UsageID: "653a8db2-4f67-4cf8-b622-169e8a482e61",
|
||||
CGREvent: utils.CGREvent{
|
||||
Tenant: "cgrates.org",
|
||||
ID: utils.UUIDSha1Prefix(),
|
||||
Event: map[string]interface{}{
|
||||
utils.Account: "2002",
|
||||
utils.Subject: "2001",
|
||||
@@ -1454,6 +1461,7 @@ func testV1FIdxCaRemoveResourceProfile(t *testing.T) {
|
||||
UsageID: "654a8db2-4f67-4cf8-b622-169e8a482e61",
|
||||
CGREvent: utils.CGREvent{
|
||||
Tenant: "cgrates.org",
|
||||
ID: utils.UUIDSha1Prefix(),
|
||||
Event: map[string]interface{}{
|
||||
utils.Account: "1002",
|
||||
utils.Subject: "1001",
|
||||
|
||||
@@ -133,11 +133,14 @@ func testV1RsGetResourcesForEvent(t *testing.T) {
|
||||
ID: "Event1",
|
||||
Event: map[string]interface{}{"Unknown": "unknown"},
|
||||
},
|
||||
UsageID: "RandomUsageID",
|
||||
}
|
||||
if err := rlsV1Rpc.Call(utils.ResourceSv1GetResourcesForEvent, args, &reply); err == nil || err.Error() != utils.ErrNotFound.Error() {
|
||||
t.Error(err)
|
||||
}
|
||||
args.CGREvent.Event = map[string]interface{}{"Destination": "10", "Account": "1001"}
|
||||
args.CGREvent.ID = utils.UUIDSha1Prefix()
|
||||
args.UsageID = "RandomUsageID2"
|
||||
if err := rlsV1Rpc.Call(utils.ResourceSv1GetResourcesForEvent, args, &reply); err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
@@ -156,11 +159,15 @@ func testV1RsGetResourcesForEvent(t *testing.T) {
|
||||
}
|
||||
|
||||
args.CGREvent.Event = map[string]interface{}{"Destination": "20"}
|
||||
args.CGREvent.ID = utils.UUIDSha1Prefix()
|
||||
args.UsageID = "RandomUsageID3"
|
||||
if err := rlsV1Rpc.Call(utils.ResourceSv1GetResourcesForEvent, args, &reply); err == nil || err.Error() != utils.ErrNotFound.Error() {
|
||||
t.Error(err)
|
||||
}
|
||||
|
||||
args.CGREvent.Event = map[string]interface{}{"Account": "1002", "Subject": "test", "Destination": "1002"}
|
||||
args.CGREvent.ID = utils.UUIDSha1Prefix()
|
||||
args.UsageID = "RandomUsageID5"
|
||||
if err := rlsV1Rpc.Call(utils.ResourceSv1GetResourcesForEvent, args, &reply); err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
@@ -169,6 +176,8 @@ func testV1RsGetResourcesForEvent(t *testing.T) {
|
||||
}
|
||||
|
||||
args.CGREvent.Event = map[string]interface{}{"Account": "1002", "Subject": "test", "Destination": "1001"}
|
||||
args.CGREvent.ID = utils.UUIDSha1Prefix()
|
||||
args.UsageID = "RandomUsageID5"
|
||||
if err := rlsV1Rpc.Call(utils.ResourceSv1GetResourcesForEvent, args, &reply); err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
@@ -185,6 +194,7 @@ func testV1RsTTL0(t *testing.T) {
|
||||
argsRU := utils.ArgRSv1ResourceUsage{
|
||||
CGREvent: utils.CGREvent{
|
||||
Tenant: "cgrates.org",
|
||||
ID: utils.UUIDSha1Prefix(),
|
||||
Event: map[string]interface{}{
|
||||
"Account": "3001",
|
||||
"Destination": "3002"},
|
||||
@@ -201,6 +211,7 @@ func testV1RsTTL0(t *testing.T) {
|
||||
argsRU = utils.ArgRSv1ResourceUsage{
|
||||
CGREvent: utils.CGREvent{
|
||||
Tenant: "cgrates.org",
|
||||
ID: utils.UUIDSha1Prefix(),
|
||||
Event: map[string]interface{}{
|
||||
"Account": "3001",
|
||||
"Destination": "3002"},
|
||||
@@ -215,6 +226,7 @@ func testV1RsTTL0(t *testing.T) {
|
||||
argsRU = utils.ArgRSv1ResourceUsage{
|
||||
CGREvent: utils.CGREvent{
|
||||
Tenant: "cgrates.org",
|
||||
ID: utils.UUIDSha1Prefix(),
|
||||
Event: map[string]interface{}{
|
||||
"Account": "3001",
|
||||
"Destination": "3002"},
|
||||
@@ -231,11 +243,12 @@ func testV1RsTTL0(t *testing.T) {
|
||||
args := &utils.ArgRSv1ResourceUsage{
|
||||
CGREvent: utils.CGREvent{
|
||||
Tenant: "cgrates.org",
|
||||
ID: "Event2",
|
||||
ID: utils.UUIDSha1Prefix(),
|
||||
Event: map[string]interface{}{
|
||||
"Account": "3001",
|
||||
"Destination": "3002"},
|
||||
},
|
||||
UsageID: "651a8db2-4f67-4cf8-b622-169e8a482e21",
|
||||
}
|
||||
expiryTime, err := utils.ParseTimeDetectLayout("0001-01-01T00:00:00Z", "")
|
||||
if err != nil {
|
||||
@@ -274,6 +287,7 @@ func testV1RsTTL0(t *testing.T) {
|
||||
UsageID: "651a8db2-4f67-4cf8-b622-169e8a482e25", // same ID should be accepted by first group since the previous resource should be expired
|
||||
CGREvent: utils.CGREvent{
|
||||
Tenant: "cgrates.org",
|
||||
ID: utils.UUIDSha1Prefix(),
|
||||
Event: map[string]interface{}{
|
||||
"Account": "3001",
|
||||
"Destination": "3002"},
|
||||
@@ -292,6 +306,7 @@ func testV1RsAllocateResource(t *testing.T) {
|
||||
UsageID: "651a8db2-4f67-4cf8-b622-169e8a482e51",
|
||||
CGREvent: utils.CGREvent{
|
||||
Tenant: "cgrates.org",
|
||||
ID: utils.UUIDSha1Prefix(),
|
||||
Event: map[string]interface{}{
|
||||
"Account": "1002",
|
||||
"Subject": "1001",
|
||||
@@ -312,6 +327,7 @@ func testV1RsAllocateResource(t *testing.T) {
|
||||
UsageID: "651a8db2-4f67-4cf8-b622-169e8a482e52",
|
||||
CGREvent: utils.CGREvent{
|
||||
Tenant: "cgrates.org",
|
||||
ID: utils.UUIDSha1Prefix(),
|
||||
Event: map[string]interface{}{
|
||||
"Account": "1002",
|
||||
"Subject": "1001",
|
||||
@@ -332,6 +348,7 @@ func testV1RsAllocateResource(t *testing.T) {
|
||||
UsageID: "651a8db2-4f67-4cf8-b622-169e8a482e53",
|
||||
CGREvent: utils.CGREvent{
|
||||
Tenant: "cgrates.org",
|
||||
ID: utils.UUIDSha1Prefix(),
|
||||
Event: map[string]interface{}{
|
||||
"Account": "dan",
|
||||
"Subject": "dan",
|
||||
@@ -352,6 +369,7 @@ func testV1RsAllocateResource(t *testing.T) {
|
||||
UsageID: "651a8db2-4f67-4cf8-b622-169e8a482e54", // same ID should be accepted by first group since the previous resource should be expired
|
||||
CGREvent: utils.CGREvent{
|
||||
Tenant: "cgrates.org",
|
||||
ID: utils.UUIDSha1Prefix(),
|
||||
Event: map[string]interface{}{
|
||||
"Account": "1002",
|
||||
"Subject": "1001",
|
||||
@@ -369,6 +387,7 @@ func testV1RsAllocateResource(t *testing.T) {
|
||||
UsageID: "651a8db2-4f67-4cf8-b622-169e8a482e55", // same ID should be accepted by first group since the previous resource should be expired
|
||||
CGREvent: utils.CGREvent{
|
||||
Tenant: "cgrates.org",
|
||||
ID: utils.UUIDSha1Prefix(),
|
||||
Event: map[string]interface{}{
|
||||
"Account": "1002",
|
||||
"Subject": "1001",
|
||||
@@ -392,6 +411,7 @@ func testV1RsAuthorizeResources(t *testing.T) {
|
||||
UsageID: "651a8db2-4f67-4cf8-b622-169e8a482e61",
|
||||
CGREvent: utils.CGREvent{
|
||||
Tenant: "cgrates.org",
|
||||
ID: utils.UUIDSha1Prefix(),
|
||||
Event: map[string]interface{}{
|
||||
"Account": "1002",
|
||||
"Subject": "1001",
|
||||
@@ -408,6 +428,7 @@ func testV1RsAuthorizeResources(t *testing.T) {
|
||||
UsageID: "651a8db2-4f67-4cf8-b622-169e8a482e61",
|
||||
CGREvent: utils.CGREvent{
|
||||
Tenant: "cgrates.org",
|
||||
ID: utils.UUIDSha1Prefix(),
|
||||
Event: map[string]interface{}{
|
||||
"Account": "1002",
|
||||
"Subject": "1001",
|
||||
@@ -428,6 +449,7 @@ func testV1RsReleaseResource(t *testing.T) {
|
||||
UsageID: "651a8db2-4f67-4cf8-b622-169e8a482e55", // same ID should be accepted by first group since the previous resource should be expired
|
||||
CGREvent: utils.CGREvent{
|
||||
Tenant: "cgrates.org",
|
||||
ID: utils.UUIDSha1Prefix(),
|
||||
Event: map[string]interface{}{
|
||||
"Account": "1002",
|
||||
"Subject": "1001",
|
||||
@@ -444,6 +466,7 @@ func testV1RsReleaseResource(t *testing.T) {
|
||||
UsageID: "651a8db2-4f67-4cf8-b622-169e8a482e61",
|
||||
CGREvent: utils.CGREvent{
|
||||
Tenant: "cgrates.org",
|
||||
ID: utils.UUIDSha1Prefix(),
|
||||
Event: map[string]interface{}{
|
||||
"Account": "1002",
|
||||
"Subject": "1001",
|
||||
@@ -465,7 +488,9 @@ func testV1RsReleaseResource(t *testing.T) {
|
||||
"Account": "1002",
|
||||
"Subject": "1001",
|
||||
"Destination": "1002"},
|
||||
}}
|
||||
},
|
||||
UsageID: utils.UUIDSha1Prefix(),
|
||||
}
|
||||
if err := rlsV1Rpc.Call(utils.ResourceSv1GetResourcesForEvent, args, &rs); err != nil {
|
||||
t.Error(err)
|
||||
} else if len(*rs) != 2 {
|
||||
@@ -492,6 +517,7 @@ func testV1RsDBStore(t *testing.T) {
|
||||
UsageID: "651a8db2-4f67-4cf8-b622-169e8a482e71",
|
||||
CGREvent: utils.CGREvent{
|
||||
Tenant: "cgrates.org",
|
||||
ID: utils.UUIDSha1Prefix(),
|
||||
Event: map[string]interface{}{
|
||||
"Account": "1002",
|
||||
"Subject": "1001",
|
||||
@@ -515,7 +541,9 @@ func testV1RsDBStore(t *testing.T) {
|
||||
"Account": "1002",
|
||||
"Subject": "1001",
|
||||
"Destination": "1002"},
|
||||
}}
|
||||
},
|
||||
UsageID: "651a8db2-4f67-4cf8-b622-169e8a482e71",
|
||||
}
|
||||
if err := rlsV1Rpc.Call(utils.ResourceSv1GetResourcesForEvent, args, &rs); err != nil {
|
||||
t.Error(err)
|
||||
} else if len(*rs) != 2 {
|
||||
@@ -558,7 +586,9 @@ func testV1RsDBStore(t *testing.T) {
|
||||
"Account": "1002",
|
||||
"Subject": "1001",
|
||||
"Destination": "1002"},
|
||||
}}
|
||||
},
|
||||
UsageID: "651a8db2-4f67-4cf8-b622-169e8a482e71",
|
||||
}
|
||||
if err := rlsV1Rpc.Call(utils.ResourceSv1GetResourcesForEvent, args, &rs); err != nil {
|
||||
t.Error(err)
|
||||
} else if len(*rs) != 2 {
|
||||
|
||||
@@ -38,11 +38,11 @@ var sTestsDspRes = []func(t *testing.T){
|
||||
}
|
||||
|
||||
//Test start here
|
||||
func TestDspResourceSTMySQL(t *testing.T) {
|
||||
func TestDspResourceSITMySQL(t *testing.T) {
|
||||
testDsp(t, sTestsDspRes, "TestDspResourceS", "all", "all2", "dispatchers", "tutorial", "oldtutorial", "dispatchers")
|
||||
}
|
||||
|
||||
func TestDspResourceSMongo(t *testing.T) {
|
||||
func TestDspResourceSITMongo(t *testing.T) {
|
||||
testDsp(t, sTestsDspRes, "TestDspResourceS", "all", "all2", "dispatchers_mongo", "tutorial", "oldtutorial", "dispatchers")
|
||||
}
|
||||
|
||||
@@ -112,6 +112,7 @@ func testDspResTestAuthKey(t *testing.T) {
|
||||
utils.Destination: "1002",
|
||||
},
|
||||
},
|
||||
UsageID: utils.UUIDSha1Prefix(),
|
||||
ArgDispatcher: &utils.ArgDispatcher{
|
||||
APIKey: utils.StringPointer("12345"),
|
||||
},
|
||||
@@ -134,6 +135,7 @@ func testDspResTestAuthKey2(t *testing.T) {
|
||||
utils.Destination: "1002",
|
||||
},
|
||||
},
|
||||
UsageID: utils.UUIDSha1Prefix(),
|
||||
ArgDispatcher: &utils.ArgDispatcher{
|
||||
APIKey: utils.StringPointer("res12345"),
|
||||
},
|
||||
@@ -161,6 +163,7 @@ func testDspResTestAuthKey3(t *testing.T) {
|
||||
UsageID: "651a8db2-4f67-4cf8-b622-169e8a482e51",
|
||||
CGREvent: utils.CGREvent{
|
||||
Tenant: "cgrates.org",
|
||||
ID: utils.UUIDSha1Prefix(),
|
||||
Event: map[string]interface{}{
|
||||
"Account": "1002",
|
||||
"Subject": "1001",
|
||||
@@ -189,6 +192,7 @@ func testDspResTestAuthKey3(t *testing.T) {
|
||||
UsageID: "651a8db2-4f67-4cf8-b622-169e8a482e61",
|
||||
CGREvent: utils.CGREvent{
|
||||
Tenant: "cgrates.org",
|
||||
ID: utils.UUIDSha1Prefix(),
|
||||
Event: map[string]interface{}{
|
||||
"Account": "1002",
|
||||
"Subject": "1001",
|
||||
@@ -209,6 +213,7 @@ func testDspResTestAuthKey3(t *testing.T) {
|
||||
UsageID: "651a8db2-4f67-4cf8-b622-169e8a482e55",
|
||||
CGREvent: utils.CGREvent{
|
||||
Tenant: "cgrates.org",
|
||||
ID: utils.UUIDSha1Prefix(),
|
||||
Event: map[string]interface{}{
|
||||
"Account": "1002",
|
||||
"Subject": "1001",
|
||||
@@ -228,12 +233,13 @@ func testDspResTestAuthKey3(t *testing.T) {
|
||||
UsageID: "651a8db2-4f67-4cf8-b622-169e8a482e61",
|
||||
CGREvent: utils.CGREvent{
|
||||
Tenant: "cgrates.org",
|
||||
ID: utils.UUIDSha1Prefix(),
|
||||
Event: map[string]interface{}{
|
||||
"Account": "1002",
|
||||
"Subject": "1001",
|
||||
"Destination": "1002"},
|
||||
},
|
||||
Units: 7,
|
||||
Units: 6,
|
||||
ArgDispatcher: &utils.ArgDispatcher{
|
||||
APIKey: utils.StringPointer("res12345"),
|
||||
},
|
||||
@@ -253,6 +259,7 @@ func testDspResTestAuthKey3(t *testing.T) {
|
||||
"Subject": "1001",
|
||||
"Destination": "1002"},
|
||||
},
|
||||
UsageID: "651a8db2-4f67-4cf8-b622-169e8a482e61",
|
||||
ArgDispatcher: &utils.ArgDispatcher{
|
||||
APIKey: utils.StringPointer("res12345"),
|
||||
},
|
||||
@@ -272,8 +279,8 @@ func testDspResTestAuthKey3(t *testing.T) {
|
||||
// make sure Resource1 have no more active resources
|
||||
for _, r := range *rs {
|
||||
if r.ID == "ResGroup1" &&
|
||||
(len(r.Usages) != 0 || len(r.TTLIdx) != 0) {
|
||||
t.Errorf("Unexpected resource: %+v", r)
|
||||
(len(r.Usages) != 1 || len(r.TTLIdx) != 0) {
|
||||
t.Errorf("Unexpected resource: %+v", utils.ToJSON(r))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -447,7 +447,7 @@ func (rS *ResourceService) matchingResourcesForEvent(ev *utils.CGREvent,
|
||||
if x, ok := Cache.Get(utils.CacheEventResources, evUUID); ok { // The ResourceIDs were cached as utils.StringMap{"resID":bool}
|
||||
isCached = true
|
||||
if x == nil {
|
||||
err = utils.ErrNotFound
|
||||
return nil, utils.ErrNotFound
|
||||
}
|
||||
rIDs = x.(utils.StringMap)
|
||||
} else { // select the resourceIDs out of dataDB
|
||||
|
||||
@@ -402,6 +402,7 @@ func testV1FltrPopulateResources(t *testing.T) {
|
||||
argsRU := utils.ArgRSv1ResourceUsage{
|
||||
CGREvent: utils.CGREvent{
|
||||
Tenant: "cgrates.org",
|
||||
ID: utils.UUIDSha1Prefix(),
|
||||
Event: map[string]interface{}{
|
||||
"Account": "3001",
|
||||
"Destination": "3002"},
|
||||
|
||||
Reference in New Issue
Block a user