mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-11 18:16:24 +05:00
Add test for Account with multiple destination ( DST_1002 RT_1CNT *any RT_10CNT)
This commit is contained in:
committed by
Dan Christian Bogos
parent
09caac4b10
commit
5507578e01
@@ -0,0 +1,2 @@
|
||||
#Tenant,Account,ActionPlanId,ActionTriggersId,AllowNegative,Disabled
|
||||
cgrates.org,1001,AP_PACKAGE_10,,,
|
||||
|
2
data/tariffplans/tp_destination_with_any/ActionPlans.csv
Normal file
2
data/tariffplans/tp_destination_with_any/ActionPlans.csv
Normal file
@@ -0,0 +1,2 @@
|
||||
#Id,ActionsId,TimingId,Weight
|
||||
AP_PACKAGE_10,ACT_TOPUP_RST_10,*asap,10
|
||||
|
3
data/tariffplans/tp_destination_with_any/Actions.csv
Normal file
3
data/tariffplans/tp_destination_with_any/Actions.csv
Normal file
@@ -0,0 +1,3 @@
|
||||
#ActionsId[0],Action[1],ExtraParameters[2],Filter[3],BalanceId[4],BalanceType[5],Categories[6],DestinationIds[7],RatingSubject[8],SharedGroup[9],ExpiryTime[10],TimingIds[11],Units[12],BalanceWeight[13],BalanceBlocker[14],BalanceDisabled[15],Weight[16]
|
||||
ACT_TOPUP_RST_10,*topup_reset,,,,*monetary,,*any,,,*unlimited,,10,10,false,false,10
|
||||
ACT_LOG_WARNING,*log,,,,,,,,,,,,,false,false,10
|
||||
|
2
data/tariffplans/tp_destination_with_any/Chargers.csv
Normal file
2
data/tariffplans/tp_destination_with_any/Chargers.csv
Normal file
@@ -0,0 +1,2 @@
|
||||
#Tenant,ID,FilterIDs,ActivationInterval,RunID,AttributeIDs,Weight
|
||||
cgrates.org,DEFAULT,,,*default,*none,0
|
||||
|
@@ -0,0 +1,3 @@
|
||||
#Id,DestinationId,RatesTag,RoundingMethod,RoundingDecimals,MaxCost,MaxCostStrategy
|
||||
DR_1002_1CNT,DST_1002,RT_1CNT,*up,4,0,
|
||||
DR_ANY,*any,RT_10CNT,*up,4,0,
|
||||
|
@@ -0,0 +1,2 @@
|
||||
#Id,Prefix
|
||||
DST_1002,1002
|
||||
|
4
data/tariffplans/tp_destination_with_any/Rates.csv
Normal file
4
data/tariffplans/tp_destination_with_any/Rates.csv
Normal file
@@ -0,0 +1,4 @@
|
||||
#Id,ConnectFee,Rate,RateUnit,RateIncrement,GroupIntervalStart
|
||||
RT_10CNT,0.2,0.1,60s,60s,0s
|
||||
RT_10CNT,0,0.05,60s,1s,60s
|
||||
RT_1CNT,0,0.01,60s,60s,0s
|
||||
|
3
data/tariffplans/tp_destination_with_any/RatingPlans.csv
Normal file
3
data/tariffplans/tp_destination_with_any/RatingPlans.csv
Normal file
@@ -0,0 +1,3 @@
|
||||
#Id,DestinationRatesId,TimingTag,Weight
|
||||
RP_1001,DR_1002_1CNT,*any,20
|
||||
RP_1001,DR_ANY,*any,10
|
||||
|
@@ -0,0 +1,2 @@
|
||||
#Tenant,Category,Subject,ActivationTime,RatingPlanId,RatesFallbackSubject
|
||||
cgrates.org,call,1001,2014-01-14T00:00:00Z,RP_1001,
|
||||
|
131
general_tests/destination_combined_it_test.go
Normal file
131
general_tests/destination_combined_it_test.go
Normal file
@@ -0,0 +1,131 @@
|
||||
// +build integration
|
||||
|
||||
/*
|
||||
Real-time Online/Offline Charging System (OCS) for Telecom & ISP environments
|
||||
Copyright (C) ITsysCOM GmbH
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
*/
|
||||
|
||||
package general_tests
|
||||
|
||||
import (
|
||||
"net/rpc/jsonrpc"
|
||||
"path"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
v1 "github.com/cgrates/cgrates/apier/v1"
|
||||
"github.com/cgrates/cgrates/config"
|
||||
"github.com/cgrates/cgrates/engine"
|
||||
"github.com/cgrates/cgrates/utils"
|
||||
)
|
||||
|
||||
// Start test wth combines rating plan
|
||||
// destination for 1002 cost 1CNT and *any cost 10CNT
|
||||
|
||||
var sTestsTutorials2 = []func(t *testing.T){
|
||||
testDestinationLoadConfig,
|
||||
testDestinationResetDB,
|
||||
testDestinationStartEngine,
|
||||
testDestinationRpcConn,
|
||||
testDestinationFromFolder,
|
||||
testDestinationGetCostFor1002,
|
||||
testDestinationGetCostFor1003,
|
||||
testTutorialStopEngine,
|
||||
}
|
||||
|
||||
func TestDestinationCombinesMySQL(t *testing.T) {
|
||||
tutorialConfDIR = "tutmysql"
|
||||
for _, stest := range sTestsTutorials2 {
|
||||
t.Run(tutorialConfDIR, stest)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func testDestinationLoadConfig(t *testing.T) {
|
||||
var err error
|
||||
tutorialCfgPath = path.Join(*dataDir, "conf", "samples", tutorialConfDIR)
|
||||
if tutorialCfg, err = config.NewCGRConfigFromPath(tutorialCfgPath); err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
tutorialDelay = 2000
|
||||
|
||||
}
|
||||
|
||||
func testDestinationResetDB(t *testing.T) {
|
||||
if err := engine.InitDataDb(tutorialCfg); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := engine.InitStorDb(tutorialCfg); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
func testDestinationStartEngine(t *testing.T) {
|
||||
if _, err := engine.StopStartEngine(tutorialCfgPath, tutorialDelay); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
func testDestinationRpcConn(t *testing.T) {
|
||||
var err error
|
||||
tutorialRpc, err = jsonrpc.Dial("tcp", tutorialCfg.ListenCfg().RPCJSONListen) // We connect over JSON so we can also troubleshoot if needed
|
||||
if err != nil {
|
||||
t.Fatal("Could not connect to rater: ", err.Error())
|
||||
}
|
||||
}
|
||||
|
||||
func testDestinationFromFolder(t *testing.T) {
|
||||
var reply string
|
||||
attrs := &utils.AttrLoadTpFromFolder{FolderPath: path.Join(*dataDir, "tariffplans", "tp_destination_with_any")}
|
||||
if err := tutorialRpc.Call("ApierV1.LoadTariffPlanFromFolder", attrs, &reply); err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
time.Sleep(500 * time.Millisecond)
|
||||
}
|
||||
|
||||
func testDestinationGetCostFor1002(t *testing.T) {
|
||||
attrs := v1.AttrGetCost{
|
||||
Tenant: "cgrates.org",
|
||||
Category: "call",
|
||||
Subject: "1001",
|
||||
Destination: "1002",
|
||||
AnswerTime: "*now",
|
||||
Usage: "1m",
|
||||
}
|
||||
var rply *engine.EventCost
|
||||
if err := tutorialRpc.Call("ApierV1.GetCost", attrs, &rply); err != nil {
|
||||
t.Error("Unexpected nil error received: ", err.Error())
|
||||
} else if *rply.Cost != 0.01 {
|
||||
t.Errorf("Unexpected cost received: %f", *rply.Cost)
|
||||
}
|
||||
}
|
||||
|
||||
func testDestinationGetCostFor1003(t *testing.T) {
|
||||
attrs := v1.AttrGetCost{
|
||||
Tenant: "cgrates.org",
|
||||
Category: "call",
|
||||
Subject: "1001",
|
||||
Destination: "1003",
|
||||
AnswerTime: "*now",
|
||||
Usage: "1m",
|
||||
}
|
||||
var rply *engine.EventCost
|
||||
if err := tutorialRpc.Call("ApierV1.GetCost", attrs, &rply); err != nil {
|
||||
t.Error("Unexpected nil error received: ", err.Error())
|
||||
} else if *rply.Cost != 0.3 {
|
||||
t.Errorf("Unexpected cost received: %f", *rply.Cost)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user