diff --git a/data/conf/samples/ld_process_match_rt_internal/cgrates.json b/data/conf/samples/ld_process_match_rt_internal/cgrates.json
index c8704753b..3df0a4eb2 100644
--- a/data/conf/samples/ld_process_match_rt_internal/cgrates.json
+++ b/data/conf/samples/ld_process_match_rt_internal/cgrates.json
@@ -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"}],
+ },
+ },
}
\ No newline at end of file
diff --git a/data/conf/samples/ld_process_match_rt_mongo/cgrates.json b/data/conf/samples/ld_process_match_rt_mongo/cgrates.json
index 166497893..e78fe8990 100644
--- a/data/conf/samples/ld_process_match_rt_mongo/cgrates.json
+++ b/data/conf/samples/ld_process_match_rt_mongo/cgrates.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"}],
+ },
+ },
}
\ No newline at end of file
diff --git a/data/conf/samples/ld_process_match_rt_mysql/cgrates.json b/data/conf/samples/ld_process_match_rt_mysql/cgrates.json
index e7323bdd3..60707fcc1 100644
--- a/data/conf/samples/ld_process_match_rt_mysql/cgrates.json
+++ b/data/conf/samples/ld_process_match_rt_mysql/cgrates.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"]
},
diff --git a/data/tariffplans/loadRateTest/Accounts.csv b/data/tariffplans/loadRateTest/Accounts.csv
index ae971aa61..67882eafa 100644
--- a/data/tariffplans/loadRateTest/Accounts.csv
+++ b/data/tariffplans/loadRateTest/Accounts.csv
@@ -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,,,,,,
\ No newline at end of file
diff --git a/general_tests/ld_process_match_ac_it_test.go b/general_tests/ld_process_match_ac_it_test.go
new file mode 100644
index 000000000..654f6250c
--- /dev/null
+++ b/general_tests/ld_process_match_ac_it_test.go
@@ -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
+*/
+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)
+ }
+}
diff --git a/general_tests/ld_process_match_rt_it_test.go b/general_tests/ld_process_match_rt_it_test.go
index b353c099d..e6a37c80c 100644
--- a/general_tests/ld_process_match_rt_it_test.go
+++ b/general_tests/ld_process_match_rt_it_test.go
@@ -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
*/
-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))
// }
}