mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-11 18:16:24 +05:00
Add in tutorial folder all strategy for suppliers
This commit is contained in:
committed by
Dan Christian Bogos
parent
9687eaff46
commit
88d7f95759
@@ -1,3 +1,4 @@
|
||||
#Tenant,Account,ActionPlanId,ActionTriggersId,AllowNegative,Disabled
|
||||
cgrates.org,1001,AP_PACKAGE_10,,,
|
||||
cgrates.org,1002,AP_PACKAGE_10,,,
|
||||
cgrates.org,1003,AP_PACKAGE_10,,,
|
||||
|
||||
|
@@ -11,5 +11,9 @@ cgrates.org,ATTR_1002_SESSIONAUTH,,,,RequestType,*any,*postpaid,true,,
|
||||
cgrates.org,ATTR_1002_SESSIONAUTH,,,,PaypalAccount,*any,cgrates@paypal.com,true,,
|
||||
cgrates.org,ATTR_1002_SESSIONAUTH,,,,LCRProfile,*any,premium_cli,true,,
|
||||
cgrates.org,ATTR_1002_SESSIONAUTH,,,,ResourceAllocation,*any,"ResGroup1",true,,
|
||||
cgrates.org,ATTR_1003_SESSIONAUTH,*sessions,*string:Account:1003,,Password,*any,CGRateS.org,true,false,10
|
||||
cgrates.org,ATTR_1003_SESSIONAUTH,,,,RequestType,*any,*prepaid,true,,
|
||||
cgrates.org,ATTR_1003_SESSIONAUTH,,,,PaypalAccount,*any,cgrates@paypal.com,true,,
|
||||
cgrates.org,ATTR_1003_SESSIONAUTH,,,,LCRProfile,*any,premium_cli,true,,
|
||||
|
||||
|
||||
|
||||
|
@@ -1,9 +1,13 @@
|
||||
#Tenant[0],ID[1],FilterType[2],FilterFieldName[3],FilterFieldValues[4],ActivationInterval[5]
|
||||
cgrates.org,FLTR_1,*string,Account,1001;1002,2014-07-29T15:00:00Z
|
||||
cgrates.org,FLTR_DST_FS,string,Account,1001,2014-07-29T15:00:00Z
|
||||
cgrates.org,FLTR_RES,*string,Account,1001;1002;1003,2014-07-29T15:00:00Z
|
||||
cgrates.org,FLTR_DST_FS,*string,Account,1001,2014-07-29T15:00:00Z
|
||||
cgrates.org,FLTR_DST_FS,*destinations,Destination,DST_FS,
|
||||
cgrates.org,FLTR_RES_GR3,*string,Account,1003,2014-07-29T15:00:00Z
|
||||
cgrates.org,FLTR_ACNT_1001_1002,*string,Account,1001;1002,2014-07-29T15:00:00Z
|
||||
cgrates.org,FLTR_ACNT_1001_1002,*string,RunID,*default,
|
||||
cgrates.org,FLTR_ACNT_1001_1003,*string,Destination,1001;1002,
|
||||
cgrates.org,FLTR_ACNT_1001,*string,Account,1001,2014-07-29T15:00:00Z
|
||||
cgrates.org,FLTR_ACNT_1002,*string,Account,1002,2014-07-29T15:00:00Z
|
||||
cgrates.org,FLTR_ACNT_1003,*string,Account,1003,2014-07-29T15:00:00Z
|
||||
cgrates.org,FLTR_ACNT_1003_1001,*string,Account,1003,2014-07-29T15:00:00Z
|
||||
cgrates.org,FLTR_ACNT_1003_1001,*string,RunID,*default,
|
||||
cgrates.org,FLTR_ACNT_1003_1001,*string,Destination,1001,
|
||||
|
||||
|
@@ -17,7 +17,7 @@ Scenario:
|
||||
|
||||
- Create 3 accounts (equivalent of FreeSWITCH default test users - 1001, 1002, 1003).
|
||||
|
||||
- 1001, 1002 will receive 10units of *monetary balance.
|
||||
- 1001, 1002,1003 will receive 10units of *monetary balance.
|
||||
|
||||
|
||||
- Add 1 StatQueueProfile with 2 metrics :
|
||||
|
||||
@@ -2,4 +2,5 @@
|
||||
RP_1001,DR_1002_20CNT,*any,10
|
||||
RP_1001,DR_1003_MAXCOST_DISC,*any,10
|
||||
RP_1002,DR_1001_20CNT,*any,10
|
||||
RP_1002_LOW,DR_1001_10CNT,*any,10
|
||||
RP_1002_LOW,DR_1001_10CNT,*any,10
|
||||
RP_1003,DR_1001_10CNT,*any,10
|
||||
|
@@ -1,3 +1,4 @@
|
||||
#Direction,Tenant,Category,Subject,ActivationTime,RatingPlanId,RatesFallbackSubject,CdrStatQueueIds
|
||||
*out,cgrates.org,call,1001,2014-01-14T00:00:00Z,RP_1001,,
|
||||
*out,cgrates.org,call,1002,2014-01-14T00:00:00Z,RP_1002,,
|
||||
*out,cgrates.org,call,1003,2014-01-14T00:00:00Z,RP_1003,,
|
||||
|
||||
|
@@ -1,2 +1,2 @@
|
||||
#Tenant[0],Id[1],FilterIDs[2],ActivationInterval[3],TTL[4],Limit[5],AllocationMessage[6],Blocker[7],Stored[8],Weight[9],ThresholdIDs[10]
|
||||
cgrates.org,ResGroup1,FLTR_1,2014-07-29T15:00:00Z,3600s,7,,false,true,10,
|
||||
cgrates.org,ResGroup1,FLTR_RES,2014-07-29T15:00:00Z,3600s,7,,false,true,10,
|
||||
|
@@ -1,2 +1,3 @@
|
||||
#Tenant[0],Id[1],FilterIDs[2],ActivationInterval[3],QueueLength[4],TTL[5],Metrics[6],MetricParams[7],Blocker[8],Stored[9],Weight[10],MinItems[11],ThresholdIDs[12]
|
||||
cgrates.org,Stats2,FLTR_ACNT_1001_1002,2014-07-29T15:00:00Z,100,1s,*tcc;*tcd,,false,true,30,0,
|
||||
cgrates.org,Stats2_1,FLTR_ACNT_1003_1001,2014-07-29T15:00:00Z,100,1s,*tcc;*tcd,,false,true,30,0,
|
||||
|
||||
|
@@ -1,5 +1,8 @@
|
||||
#Tenant,ID,FilterIDs,ActivationInterval,Sorting,SortingParamameters,SupplierID,SupplierFilterIDs,SupplierAccountIDs,SupplierRatingPlanIDs,SupplierResourceIDs,SupplierStatIDs,SupplierWeight,SupplierBlocker,SupplierParameters,Weight
|
||||
cgrates.org,SPL_WEIGHT,FLTR_ACNT_1001,2017-11-27T00:00:00Z,*weight,,supplier1,,,RP_1002,,,10,,,10
|
||||
cgrates.org,SPL_WEIGHT,,,,,supplier2,,,RP_1001,,,20,,,10
|
||||
cgrates.org,SPL_LEASTCOST_1,FLTR_ACNT_1002,2017-11-27T00:00:00Z,*least_cost,,supplier1,,,RP_1002,,,10,false,,10
|
||||
cgrates.org,SPL_LEASTCOST_1,,,,,supplier2,,,RP_1002_LOW,,,10,,,
|
||||
cgrates.org,SPL_ACNT_1001,FLTR_ACNT_1001,2017-11-27T00:00:00Z,*weight,,supplier1,,,,,,10,,,10
|
||||
cgrates.org,SPL_ACNT_1001,,,,,supplier2,,,,,,20,,,20
|
||||
cgrates.org,SPL_ACNT_1002,FLTR_ACNT_1002,2017-11-27T00:00:00Z,*least_cost,,supplier1,,,RP_1002_LOW,,,10,false,,10
|
||||
cgrates.org,SPL_ACNT_1002,,,,,supplier2,,,RP_1002,,,20,,,
|
||||
cgrates.org,SPL_ACNT_1003,FLTR_ACNT_1003,2017-11-27T00:00:00Z,*qos,*tcc;*tcd,supplier1,,,,,Stats2,10,false,,10
|
||||
cgrates.org,SPL_ACNT_1003,,,,,supplier2,,,,,Stats2_1,20,,,
|
||||
|
||||
|
||||
|
@@ -113,7 +113,6 @@
|
||||
{"address": "*internal"}
|
||||
],
|
||||
"string_indexed_fields": ["Account"],
|
||||
"prefix_indexed_fields": ["Destination"],
|
||||
},
|
||||
|
||||
|
||||
@@ -122,7 +121,7 @@
|
||||
"thresholds_conns": [
|
||||
{"address": "*internal"}
|
||||
],
|
||||
"string_indexed_fields": ["Account"],
|
||||
"string_indexed_fields": ["Account","RunID","Destination"],
|
||||
},
|
||||
|
||||
|
||||
@@ -144,7 +143,6 @@
|
||||
{"address": "*internal"}
|
||||
],
|
||||
"string_indexed_fields": ["Account"],
|
||||
"prefix_indexed_fields": ["Destination"],
|
||||
},
|
||||
|
||||
|
||||
|
||||
@@ -245,7 +245,7 @@ func testDspSupAddAttributesWithPermision2(t *testing.T) {
|
||||
func testDspSupTestAuthKey2(t *testing.T) {
|
||||
var rpl *engine.SortedSuppliers
|
||||
eRpl := &engine.SortedSuppliers{
|
||||
ProfileID: "SPL_LEASTCOST_1",
|
||||
ProfileID: "SPL_ACNT_1002",
|
||||
Sorting: utils.MetaLeastCost,
|
||||
SortedSuppliers: []*engine.SortedSupplier{
|
||||
&engine.SortedSupplier{
|
||||
|
||||
@@ -66,6 +66,8 @@ var sTestsCalls = []func(t *testing.T){
|
||||
testCallGetActiveSessions,
|
||||
testCallCall1002To1001,
|
||||
testCallCall1001To1003,
|
||||
testCallCall1003To1001,
|
||||
testCallCall1003To1001SecondTime,
|
||||
testCallCheckResourceAllocation,
|
||||
testCallAccount1001,
|
||||
testCall1001Cdrs,
|
||||
@@ -274,6 +276,13 @@ func testCallAccountsBefore(t *testing.T) {
|
||||
} else if reply2.BalanceMap[utils.MONETARY].GetTotalValue() != 10.0 {
|
||||
t.Errorf("Calling ApierV1.GetBalance received: %f", reply2.BalanceMap[utils.MONETARY].GetTotalValue())
|
||||
}
|
||||
var reply3 *engine.Account
|
||||
attrs3 := &utils.AttrGetAccount{Tenant: "cgrates.org", Account: "1003"}
|
||||
if err := tutorialCallsRpc.Call("ApierV2.GetAccount", attrs3, &reply3); err != nil {
|
||||
t.Error("Got error on ApierV2.GetAccount: ", err.Error())
|
||||
} else if reply3.BalanceMap[utils.MONETARY].GetTotalValue() != 10.0 {
|
||||
t.Errorf("Calling ApierV1.GetBalance received: %f", reply3.BalanceMap[utils.MONETARY].GetTotalValue())
|
||||
}
|
||||
}
|
||||
|
||||
func testCallStatMetricsBefore(t *testing.T) {
|
||||
@@ -288,6 +297,12 @@ func testCallStatMetricsBefore(t *testing.T) {
|
||||
} else if !reflect.DeepEqual(expectedMetrics, metrics) {
|
||||
t.Errorf("expecting: %+v, received reply: %s", expectedMetrics, metrics)
|
||||
}
|
||||
if err := tutorialCallsRpc.Call(utils.StatSv1GetQueueStringMetrics,
|
||||
&utils.TenantID{Tenant: "cgrates.org", ID: "Stats2_1"}, &metrics); err != nil {
|
||||
t.Error(err)
|
||||
} else if !reflect.DeepEqual(expectedMetrics, metrics) {
|
||||
t.Errorf("expecting: %+v, received reply: %s", expectedMetrics, metrics)
|
||||
}
|
||||
}
|
||||
|
||||
func testCallCheckResourceBeforeAllocation(t *testing.T) {
|
||||
@@ -409,6 +424,25 @@ func testCallCall1001To1003(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
// Call from 1003 (prepaid) to 1001 for 20 seconds
|
||||
func testCallCall1003To1001(t *testing.T) {
|
||||
if err := engine.PjsuaCallUri(
|
||||
&engine.PjsuaAccount{Id: "sip:1003@127.0.0.1", Username: "1003", Password: "CGRateS.org", Realm: "*"},
|
||||
"sip:1001@127.0.0.1", "sip:127.0.0.1:5080", time.Duration(20)*time.Second, 5074); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
time.Sleep(22 * time.Second)
|
||||
}
|
||||
|
||||
// Call from 1003 (prepaid) to 1001 for 15 seconds
|
||||
func testCallCall1003To1001SecondTime(t *testing.T) {
|
||||
if err := engine.PjsuaCallUri(
|
||||
&engine.PjsuaAccount{Id: "sip:1003@127.0.0.1", Username: "1003", Password: "CGRateS.org", Realm: "*"},
|
||||
"sip:1001@127.0.0.1", "sip:127.0.0.1:5080", time.Duration(15)*time.Second, 5075); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
// Check if the resource was Allocated
|
||||
func testCallCheckResourceAllocation(t *testing.T) {
|
||||
var rs *engine.Resources
|
||||
@@ -427,7 +461,7 @@ func testCallCheckResourceAllocation(t *testing.T) {
|
||||
t.Errorf("Resources: %+v", utils.ToJSON(rs))
|
||||
}
|
||||
for _, r := range *rs {
|
||||
if r.ID == "ResGroup1" && (len(r.Usages) != 1 || len(r.TTLIdx) != 1) {
|
||||
if r.ID == "ResGroup1" && (len(r.Usages) != 2 || len(r.TTLIdx) != 2) {
|
||||
t.Errorf("Unexpected resource: %+v", utils.ToJSON(r))
|
||||
}
|
||||
}
|
||||
@@ -435,7 +469,7 @@ func testCallCheckResourceAllocation(t *testing.T) {
|
||||
|
||||
// Make sure account was debited properly
|
||||
func testCallAccount1001(t *testing.T) {
|
||||
time.Sleep(time.Duration(80) * time.Second) // Allow calls to finish before start querying the results
|
||||
time.Sleep(time.Duration(60) * time.Second) // Allow calls to finish before start querying the results
|
||||
var reply *engine.Account
|
||||
attrs := &utils.AttrGetAccount{Tenant: "cgrates.org", Account: "1001"}
|
||||
if err := tutorialCallsRpc.Call("ApierV2.GetAccount", attrs, &reply); err != nil {
|
||||
@@ -502,20 +536,31 @@ func testCall1002Cdrs(t *testing.T) {
|
||||
|
||||
func testCallStatMetrics(t *testing.T) {
|
||||
var metrics map[string]string
|
||||
expectedMetrics1 := map[string]string{
|
||||
firstStatMetrics1 := map[string]string{
|
||||
utils.MetaTCC: "1.35009",
|
||||
utils.MetaTCD: "2m25s",
|
||||
}
|
||||
expectedMetrics2 := map[string]string{
|
||||
firstStatMetrics2 := map[string]string{
|
||||
utils.MetaTCC: "1.34009",
|
||||
utils.MetaTCD: "2m24s",
|
||||
}
|
||||
secondStatMetrics := map[string]string{
|
||||
utils.MetaTCC: "0.6",
|
||||
utils.MetaTCD: "35s",
|
||||
}
|
||||
|
||||
if err := tutorialCallsRpc.Call(utils.StatSv1GetQueueStringMetrics,
|
||||
&utils.TenantID{Tenant: "cgrates.org", ID: "Stats2"}, &metrics); err != nil {
|
||||
t.Error(err)
|
||||
} else if !reflect.DeepEqual(expectedMetrics1, metrics) &&
|
||||
!reflect.DeepEqual(expectedMetrics2, metrics) {
|
||||
t.Errorf("expecting: %+v, received reply: %s", expectedMetrics1, metrics)
|
||||
} else if !reflect.DeepEqual(firstStatMetrics1, metrics) &&
|
||||
!reflect.DeepEqual(firstStatMetrics2, metrics) {
|
||||
t.Errorf("expecting: %+v, received reply: %s", firstStatMetrics1, metrics)
|
||||
}
|
||||
if err := tutorialCallsRpc.Call(utils.StatSv1GetQueueStringMetrics,
|
||||
&utils.TenantID{Tenant: "cgrates.org", ID: "Stats2_1"}, &metrics); err != nil {
|
||||
t.Error(err)
|
||||
} else if !reflect.DeepEqual(secondStatMetrics, metrics) {
|
||||
t.Errorf("expecting: %+v, received reply: %s", secondStatMetrics, metrics)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user