mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-17 06:09:53 +05:00
Added test for account panic
This commit is contained in:
committed by
Dan Christian Bogos
parent
7749fcd15b
commit
3915bdc06f
@@ -25,5 +25,49 @@
|
||||
"db_type": "*internal"
|
||||
},
|
||||
|
||||
"loaders": [
|
||||
{
|
||||
"id": "*default",
|
||||
"enabled": true,
|
||||
"tenant": "cgrates.org",
|
||||
"tp_in_dir": "/usr/share/cgrates/tariffplans/loadRateTest",
|
||||
"tp_out_dir": "",
|
||||
},
|
||||
],
|
||||
|
||||
"rates": {
|
||||
"enabled": true
|
||||
},
|
||||
|
||||
"cdrs": {
|
||||
"enabled": true,
|
||||
"chargers_conns":["*internal"],
|
||||
"accounts_conns": ["*localhost"],
|
||||
"rates_conns": ["*localhost"],
|
||||
"ees_conns": ["conn1"]
|
||||
},
|
||||
|
||||
"chargers": {
|
||||
"enabled": true,
|
||||
"attributes_conns": ["*internal"],
|
||||
},
|
||||
|
||||
"attributes": {
|
||||
"enabled": true,
|
||||
"stats_conns": ["*localhost"],
|
||||
"resources_conns": ["*localhost"],
|
||||
"accounts_conns": ["*localhost"]
|
||||
},
|
||||
|
||||
"accounts": {
|
||||
"enabled": true,
|
||||
},
|
||||
|
||||
"rpc_conns": {
|
||||
"conn1": {
|
||||
"strategy": "*first",
|
||||
"conns": [{"address": "127.0.0.1:22012", "transport":"*json"}],
|
||||
},
|
||||
},
|
||||
|
||||
}
|
||||
@@ -27,6 +27,50 @@
|
||||
"db_name": "cgrates",
|
||||
"db_port": 27017,
|
||||
},
|
||||
"loaders": [
|
||||
{
|
||||
"id": "*default",
|
||||
"enabled": true,
|
||||
"tenant": "cgrates.org",
|
||||
"tp_in_dir": "/usr/share/cgrates/tariffplans/loadRateTest",
|
||||
"tp_out_dir": "",
|
||||
},
|
||||
],
|
||||
|
||||
"rates": {
|
||||
"enabled": true
|
||||
},
|
||||
|
||||
"cdrs": {
|
||||
"enabled": true,
|
||||
"chargers_conns":["*internal"],
|
||||
"accounts_conns": ["*localhost"],
|
||||
"rates_conns": ["*localhost"],
|
||||
"ees_conns": ["conn1"]
|
||||
},
|
||||
|
||||
"chargers": {
|
||||
"enabled": true,
|
||||
"attributes_conns": ["*internal"],
|
||||
},
|
||||
|
||||
"attributes": {
|
||||
"enabled": true,
|
||||
"stats_conns": ["*localhost"],
|
||||
"resources_conns": ["*localhost"],
|
||||
"accounts_conns": ["*localhost"]
|
||||
},
|
||||
|
||||
"accounts": {
|
||||
"enabled": true,
|
||||
},
|
||||
|
||||
"rpc_conns": {
|
||||
"conn1": {
|
||||
"strategy": "*first",
|
||||
"conns": [{"address": "127.0.0.1:22012", "transport":"*json"}],
|
||||
},
|
||||
},
|
||||
|
||||
|
||||
}
|
||||
@@ -39,11 +39,10 @@
|
||||
"enabled": true
|
||||
},
|
||||
|
||||
|
||||
"cdrs": {
|
||||
"enabled": true,
|
||||
"chargers_conns":["*internal"],
|
||||
//"accounts_conns": ["*localhost"]
|
||||
"accounts_conns": ["*localhost"],
|
||||
"rates_conns": ["*localhost"],
|
||||
"ees_conns": ["conn1"]
|
||||
},
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
#Tenant,ID,FilterIDs,Weights,Opts,BalanceID,BalanceFilterIDs,BalanceWeights,BalanceType,BalanceUnits,BalanceUnitFactors,BalanceOpts,BalanceCostIncrements,BalanceAttributeIDs,BalanceRateProfileIDs,ThresholdIDs
|
||||
cgrates.org,ACC_PRF_1,,;20,,MonetaryBalance,,;10,*monetary,14,fltr1&fltr2;100;fltr3;200,,fltr1&fltr2;1.3;2.3;3.3,attr1;attr2,,*none
|
||||
cgrates.org,ACC_PRF_1,,;20,,MonetaryBalance,,;10,*concrete,14,fltr1&fltr2;100;fltr3;200,,fltr1&fltr2;1.3;2.3;3.3,attr1;attr2,,*none
|
||||
cgrates.org,1001,,,,VoiceBalance,,;10,*voice,3600000000000,,,,,,
|
||||
|
153
general_tests/ld_process_match_ac_it_test.go
Normal file
153
general_tests/ld_process_match_ac_it_test.go
Normal file
@@ -0,0 +1,153 @@
|
||||
//go:build integration
|
||||
// +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 (
|
||||
"path"
|
||||
"reflect"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/cgrates/birpc"
|
||||
"github.com/cgrates/birpc/context"
|
||||
"github.com/cgrates/cgrates/config"
|
||||
"github.com/cgrates/cgrates/engine"
|
||||
"github.com/cgrates/cgrates/loaders"
|
||||
"github.com/cgrates/cgrates/utils"
|
||||
)
|
||||
|
||||
var (
|
||||
testLdPrMatchAcCfgDir string
|
||||
testLdPrMatchAcCfgPath string
|
||||
testLdPrMatchAcCfg *config.CGRConfig
|
||||
testLdPrMatchAcRPC *birpc.Client
|
||||
|
||||
testLdPrMatchAcTests = []func(t *testing.T){
|
||||
testLdPrMatchAcLoadConfig,
|
||||
testLdPrMatchAcResetDataDB,
|
||||
testLdPrMatchAcResetStorDb,
|
||||
testLdPrMatchAcStartEngine,
|
||||
testLdPrMatchAcRPCConn,
|
||||
testLdPrMatchAcLoadTP,
|
||||
testLdPrMatchAcCDRSProcessEvent,
|
||||
testLdPrMatchAcStopCgrEngine,
|
||||
}
|
||||
)
|
||||
|
||||
func TestLdPrMatchAcChange(t *testing.T) {
|
||||
switch *dbType {
|
||||
case utils.MetaInternal:
|
||||
testLdPrMatchAcCfgDir = "ld_process_match_rt_internal"
|
||||
case utils.MetaMySQL:
|
||||
testLdPrMatchAcCfgDir = "ld_process_match_rt_mysql"
|
||||
case utils.MetaMongo:
|
||||
testLdPrMatchAcCfgDir = "ld_process_match_rt_mongo"
|
||||
case utils.MetaPostgres:
|
||||
t.SkipNow()
|
||||
default:
|
||||
t.Fatal("Unknown Database type")
|
||||
}
|
||||
for _, testLdPrMatchAcTest := range testLdPrMatchAcTests {
|
||||
t.Run(testLdPrMatchAcCfgDir, testLdPrMatchAcTest)
|
||||
}
|
||||
}
|
||||
|
||||
func testLdPrMatchAcLoadConfig(t *testing.T) {
|
||||
var err error
|
||||
testLdPrMatchAcCfgPath = path.Join(*dataDir, "conf", "samples", testLdPrMatchAcCfgDir)
|
||||
if testLdPrMatchAcCfg, err = config.NewCGRConfigFromPath(context.Background(), testLdPrMatchAcCfgPath); err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
}
|
||||
|
||||
func testLdPrMatchAcResetDataDB(t *testing.T) {
|
||||
if err := engine.InitDataDB(testLdPrMatchAcCfg); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
func testLdPrMatchAcResetStorDb(t *testing.T) {
|
||||
if err := engine.InitStorDB(testLdPrMatchAcCfg); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
func testLdPrMatchAcStartEngine(t *testing.T) {
|
||||
if _, err := engine.StopStartEngine(testLdPrMatchAcCfgPath, *waitRater); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
func testLdPrMatchAcRPCConn(t *testing.T) {
|
||||
var err error
|
||||
testLdPrMatchAcRPC, err = newRPCClient(testLdPrMatchAcCfg.ListenCfg())
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
func testLdPrMatchAcLoadTP(t *testing.T) {
|
||||
var reply string
|
||||
if err := testLdPrMatchAcRPC.Call(context.Background(), utils.LoaderSv1Load,
|
||||
&loaders.ArgsProcessFolder{
|
||||
StopOnError: true,
|
||||
Caching: utils.StringPointer(utils.MetaReload),
|
||||
}, &reply); err != nil {
|
||||
t.Error(err)
|
||||
} else if reply != utils.OK {
|
||||
t.Error("Unexpected reply returned:", reply)
|
||||
}
|
||||
}
|
||||
|
||||
func testLdPrMatchAcCDRSProcessEvent(t *testing.T) {
|
||||
ev := &engine.ArgV1ProcessEvent{
|
||||
CGREvent: utils.CGREvent{
|
||||
Tenant: "cgrates.org",
|
||||
ID: "TestEv1",
|
||||
Event: map[string]interface{}{
|
||||
utils.ToR: utils.MetaVoice,
|
||||
utils.OriginID: "TestEv1",
|
||||
utils.RequestType: utils.MetaPrepaid,
|
||||
utils.AccountField: "1001",
|
||||
utils.Subject: "1001",
|
||||
utils.Destination: "1002",
|
||||
utils.Usage: time.Minute,
|
||||
},
|
||||
APIOpts: map[string]interface{}{
|
||||
utils.OptsRateS: false,
|
||||
utils.OptsCDRsExport: false,
|
||||
utils.OptsAccountS: true,
|
||||
},
|
||||
},
|
||||
}
|
||||
var rply string
|
||||
if err := testLdPrMatchAcRPC.Call(context.Background(), utils.CDRsV1ProcessEvent, ev, &rply); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
expected := "OK"
|
||||
if !reflect.DeepEqual(utils.ToJSON(&expected), utils.ToJSON(&rply)) {
|
||||
t.Errorf("Expecting : %+v, received: %+v", utils.ToJSON(&expected), utils.ToJSON(&rply))
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func testLdPrMatchAcStopCgrEngine(t *testing.T) {
|
||||
if err := engine.KillEngine(100); err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
}
|
||||
@@ -15,7 +15,7 @@ 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 apis
|
||||
package general_tests
|
||||
|
||||
import (
|
||||
"net"
|
||||
@@ -43,12 +43,11 @@ var (
|
||||
testLdPrMatchRtLoadConfig,
|
||||
testLdPrMatchRtResetDataDB,
|
||||
testLdPrMatchRtResetStorDb,
|
||||
testLdPrMatchRtStartEngine,
|
||||
// testLdPrMatchRtStartEngine,
|
||||
testLdPrMatchRtRPCConn,
|
||||
testLdPrMatchRtLoadTP,
|
||||
testLdPrMatchRtCDRSProcessEvent,
|
||||
|
||||
testLdPrMatchRtStopCgrEngine,
|
||||
// testLdPrMatchRtStopCgrEngine,
|
||||
}
|
||||
)
|
||||
|
||||
@@ -160,6 +159,7 @@ func testLdPrMatchRtCDRSProcessEvent(t *testing.T) {
|
||||
APIOpts: map[string]interface{}{
|
||||
utils.OptsRateS: true,
|
||||
utils.OptsCDRsExport: true,
|
||||
utils.OptsAccountS: false,
|
||||
},
|
||||
}
|
||||
var rply string
|
||||
@@ -170,22 +170,24 @@ func testLdPrMatchRtCDRSProcessEvent(t *testing.T) {
|
||||
if !reflect.DeepEqual(utils.ToJSON(&expected), utils.ToJSON(&rply)) {
|
||||
t.Errorf("Expecting : %+v, received: %+v", utils.ToJSON(&expected), utils.ToJSON(&rply))
|
||||
}
|
||||
// costInterval := testRPC1.Event.Event["*rateSCost"].(map[string]interface{})["CostIntervals"]
|
||||
// ratesField := testRPC1.Event.Event["*rateSCost"].(map[string]interface{})["Rates"]
|
||||
// expected2 := utils.CGREvent{
|
||||
// Tenant: "cgrates.org",
|
||||
// ID: "TestEv1",
|
||||
// Event: map[string]interface{}{
|
||||
// "Altered": nil,
|
||||
// utils.Cost: 0.4,
|
||||
// "CostIntervals": []map[string]interface{}{},
|
||||
// "CostIntervals": costInterval,
|
||||
// "ID": "RT_RETAIL1",
|
||||
// "MaxCost": 0,
|
||||
// "MaxCostStrategy": "",
|
||||
// "MinCost": 0,
|
||||
// "Rates": map[string]interface{}{},
|
||||
// "Rates": ratesField,
|
||||
// },
|
||||
// }
|
||||
// if !reflect.DeepEqual(utils.ToJSON(expected2.Event), utils.ToJSON(testRPC1.Event.Event["*rateSCost"])) {
|
||||
// t.Errorf("\nExpecting : %+v \n,received: %+v", utils.ToJSON(expected2.Event), utils.ToJSON(testRPC1.Event.Event["*rateSCost"]))
|
||||
// if !reflect.DeepEqual(utils.ToJSON(expected2), utils.ToJSON(testRPC1.Event)) {
|
||||
// t.Errorf("\nExpecting : %+v \n,received: %+v", utils.ToJSON(expected2), utils.ToJSON(testRPC1.Event))
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user