mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-11 18:16:24 +05:00
Update tests
This commit is contained in:
committed by
Dan Christian Bogos
parent
468b335ba6
commit
cc467eb484
@@ -284,6 +284,11 @@ func testLoadItCheckAttributes(t *testing.T) {
|
||||
Value: config.NewRSRParsersMustCompile("CGRateS.org", utils.InfieldSep),
|
||||
},
|
||||
},
|
||||
Blockers: utils.DynamicBlockers{
|
||||
{
|
||||
Blocker: false,
|
||||
},
|
||||
},
|
||||
}
|
||||
eAttrPrf.Weights = make(utils.DynamicWeights, 1)
|
||||
eAttrPrf.Weights[0] = &utils.DynamicWeight{
|
||||
|
||||
@@ -407,6 +407,11 @@ func testCgrLdrGetAttributeProfileAfterLoad(t *testing.T) {
|
||||
Value: "Marketing",
|
||||
},
|
||||
},
|
||||
Blockers: utils.DynamicBlockers{
|
||||
{
|
||||
Blocker: false,
|
||||
},
|
||||
},
|
||||
}
|
||||
var replyAttr *engine.APIAttributeProfile
|
||||
if err := cgrLdrBIRPC.Call(context.Background(), utils.AdminSv1GetAttributeProfile,
|
||||
|
||||
@@ -369,14 +369,9 @@ func testDspSupGetSupplierForEvent(t *testing.T) {
|
||||
RouteParameters: "",
|
||||
},
|
||||
{
|
||||
ID: "route2",
|
||||
RateProfileIDs: []string{"RP_1002"},
|
||||
Weights: utils.DynamicWeights{{Weight: 20}},
|
||||
Blockers: utils.DynamicBlockers{
|
||||
{
|
||||
Blocker: false,
|
||||
},
|
||||
},
|
||||
ID: "route2",
|
||||
RateProfileIDs: []string{"RP_1002"},
|
||||
Weights: utils.DynamicWeights{{Weight: 20}},
|
||||
RouteParameters: "",
|
||||
},
|
||||
},
|
||||
@@ -394,6 +389,6 @@ func testDspSupGetSupplierForEvent(t *testing.T) {
|
||||
return supProf[0].Routes[i].Weights[0].Weight < supProf[0].Routes[j].Weights[0].Weight
|
||||
})
|
||||
if !reflect.DeepEqual(expected, *supProf[0]) {
|
||||
t.Errorf("Expected: %s ,received: %s", utils.ToJSON(expected), utils.ToJSON(supProf))
|
||||
t.Errorf("Expected: %s ,received: %s", utils.ToJSON(expected), utils.ToJSON(*supProf[0]))
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
241
general_tests/amqp_multipleconcurrentcalls_it_test.go
Normal file
241
general_tests/amqp_multipleconcurrentcalls_it_test.go
Normal file
@@ -0,0 +1,241 @@
|
||||
//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 (
|
||||
// "fmt"
|
||||
// "net/rpc"
|
||||
// "os"
|
||||
// "path"
|
||||
// "strconv"
|
||||
// "testing"
|
||||
// "time"
|
||||
|
||||
// "github.com/cgrates/cgrates/config"
|
||||
// "github.com/cgrates/cgrates/ees"
|
||||
// "github.com/cgrates/cgrates/engine"
|
||||
// "github.com/cgrates/cgrates/utils"
|
||||
// )
|
||||
|
||||
// var (
|
||||
// amqpMCCCfgPath string
|
||||
// amqpMCCCfg *config.CGRConfig
|
||||
// amqpMCCRPC *rpc.Client
|
||||
// amqpMCCConfDIR string //run tests for specific configuration
|
||||
// amqpMCCDelay int
|
||||
|
||||
// amqpMCCTests = []func(t *testing.T){
|
||||
// // testCreateDirectory,
|
||||
// testAMQPMCCLoadConfig,
|
||||
// testAMQPMCCInitDataDb,
|
||||
// testAMQPMCCResetStorDb,
|
||||
// // testAMQPMCCStartEngine,
|
||||
// testAMQPMCCRPCConn,
|
||||
// testAMQPMCCProcessEvent,
|
||||
// // testAMQPMCCStopEngine,
|
||||
// // testCleanDirectory,
|
||||
// }
|
||||
// )
|
||||
|
||||
// // Test start here
|
||||
// func TestAMQPMCC(t *testing.T) {
|
||||
// amqpMCCConfDIR = "amqp_multiplecalls_internal"
|
||||
// for _, stest := range amqpMCCTests {
|
||||
// t.Run(amqpMCCConfDIR, stest)
|
||||
// }
|
||||
// }
|
||||
|
||||
// var exportPath = []string{"/tmp/testCSV", "/tmp/testComposedCSV", "/tmp/testFWV", "/tmp/testCSVMasked",
|
||||
// "/tmp/testCSVfromVirt", "/tmp/testCSVExpTemp"}
|
||||
|
||||
// func testCreateDirectory(t *testing.T) {
|
||||
// for _, dir := range exportPath {
|
||||
// if err := os.RemoveAll(dir); err != nil {
|
||||
// t.Fatal("Error removing folder: ", dir, err)
|
||||
// }
|
||||
// if err := os.MkdirAll(dir, os.ModePerm); err != nil {
|
||||
// t.Fatal("Error creating folder: ", dir, err)
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
// func testCleanDirectory(t *testing.T) {
|
||||
// for _, dir := range exportPath {
|
||||
// if err := os.RemoveAll(dir); err != nil {
|
||||
// t.Fatal("Error removing folder: ", dir, err)
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
// func testAMQPMCCLoadConfig(t *testing.T) {
|
||||
// var err error
|
||||
// amqpMCCCfgPath = path.Join(*dataDir, "conf", "samples", amqpMCCConfDIR)
|
||||
// if amqpMCCCfg, err = config.NewCGRConfigFromPath(amqpMCCCfgPath); err != nil {
|
||||
// t.Error(err)
|
||||
// }
|
||||
// amqpMCCDelay = 1000
|
||||
// }
|
||||
|
||||
// func testAMQPMCCInitDataDb(t *testing.T) {
|
||||
// if err := engine.InitDataDb(amqpMCCCfg); err != nil {
|
||||
// t.Fatal(err)
|
||||
// }
|
||||
// }
|
||||
|
||||
// func testAMQPMCCResetStorDb(t *testing.T) {
|
||||
// if err := engine.InitStorDb(amqpMCCCfg); err != nil {
|
||||
// t.Fatal(err)
|
||||
// }
|
||||
// }
|
||||
|
||||
// func testAMQPMCCStartEngine(t *testing.T) {
|
||||
// if _, err := engine.StopStartEngine(amqpMCCCfgPath, amqpMCCDelay); err != nil {
|
||||
// t.Fatal(err)
|
||||
// }
|
||||
// }
|
||||
|
||||
// func testAMQPMCCRPCConn(t *testing.T) {
|
||||
// var err error
|
||||
// amqpMCCRPC, err = newRPCClient(amqpMCCCfg.ListenCfg()) // We connect over JSON so we can also troubleshoot if needed
|
||||
// if err != nil {
|
||||
// t.Fatal("Could not connect to rater: ", err.Error())
|
||||
// }
|
||||
// }
|
||||
|
||||
// func testAMQPMCCStopEngine(t *testing.T) {
|
||||
// if err := engine.KillEngine(amqpMCCDelay); err != nil {
|
||||
// t.Error(err)
|
||||
// }
|
||||
// }
|
||||
|
||||
// func exportCDR(idx string, client *rpc.Client, channel chan string, t *testing.T) {
|
||||
// var reply map[string]map[string]interface{}
|
||||
// if err := client.Call(utils.EeSv1ProcessEvent, &engine.CGREventWithEeIDs{
|
||||
// CGREvent: &utils.CGREvent{
|
||||
// Tenant: "cgrates.org",
|
||||
// ID: "event" + idx,
|
||||
// Event: map[string]interface{}{
|
||||
// utils.RunID: "run_" + idx,
|
||||
// utils.CGRID: "CGRID" + idx,
|
||||
// utils.Tenant: "cgrates.org",
|
||||
// utils.Category: "call",
|
||||
// utils.ToR: utils.MetaVoice,
|
||||
// utils.OriginID: "processCDR" + idx,
|
||||
// utils.OriginHost: "OriginHost" + idx,
|
||||
// utils.RequestType: utils.MetaPseudoPrepaid,
|
||||
// utils.AccountField: "1001",
|
||||
// utils.Destination: "1002",
|
||||
// utils.SetupTime: time.Date(2021, time.February, 2, 16, 14, 50, 0, time.UTC),
|
||||
// utils.AnswerTime: time.Date(2021, time.February, 2, 16, 15, 0, 0, time.UTC),
|
||||
// utils.Usage: 2 * time.Minute,
|
||||
// },
|
||||
// },
|
||||
// }, &reply); err != nil {
|
||||
// channel <- err.Error()
|
||||
// t.Error(err)
|
||||
// } else {
|
||||
// channel <- utils.ToJSON(reply)
|
||||
// }
|
||||
|
||||
// }
|
||||
|
||||
// func testAMQPMCCProcessEvent(t *testing.T) {
|
||||
// noOfExports := 2000
|
||||
// channel := make(chan string, noOfExports)
|
||||
// for i := 0; i < noOfExports; i++ {
|
||||
// idxStr := strconv.Itoa(i)
|
||||
// go func() {
|
||||
// var reply map[string]map[string]interface{}
|
||||
// if err := amqpMCCRPC.Call(utils.EeSv1ProcessEvent, &engine.CGREventWithEeIDs{
|
||||
// CGREvent: &utils.CGREvent{
|
||||
// Tenant: "cgrates.org",
|
||||
// ID: "event" + idxStr,
|
||||
// Event: map[string]interface{}{
|
||||
// utils.RunID: "run_" + idxStr,
|
||||
// utils.CGRID: "CGRID" + idxStr,
|
||||
// utils.Tenant: "cgrates.org",
|
||||
// utils.Category: "call",
|
||||
// utils.ToR: utils.MetaVoice,
|
||||
// utils.OriginID: "processCDR" + idxStr,
|
||||
// utils.OriginHost: "OriginHost" + idxStr,
|
||||
// utils.RequestType: utils.MetaPseudoPrepaid,
|
||||
// utils.AccountField: "1001",
|
||||
// utils.Destination: "1002",
|
||||
// utils.SetupTime: time.Date(2021, time.February, 2, 16, 14, 50, 0, time.UTC),
|
||||
// utils.AnswerTime: time.Date(2021, time.February, 2, 16, 15, 0, 0, time.UTC),
|
||||
// utils.Usage: 2 * time.Minute,
|
||||
// },
|
||||
// },
|
||||
// }, &reply); err != nil {
|
||||
// channel <- err.Error()
|
||||
// t.Error(err)
|
||||
// } else {
|
||||
// channel <- utils.ToJSON(reply)
|
||||
// }
|
||||
// }()
|
||||
// }
|
||||
// for i := 0; i < noOfExports; i++ {
|
||||
// chanStr := <-channel
|
||||
// fmt.Println(chanStr)
|
||||
// }
|
||||
// time.Sleep(10 * time.Second)
|
||||
|
||||
// }
|
||||
|
||||
// func TestAMQPMC1CExport(t *testing.T) {
|
||||
// var err error
|
||||
// amqpMCCCfgPath = path.Join(*dataDir, "conf", "samples", "amqp_multiplecalls_internal")
|
||||
// if amqpMCCCfg, err = config.NewCGRConfigFromPath(amqpMCCCfgPath); err != nil {
|
||||
// t.Error(err)
|
||||
// }
|
||||
// exporter, err := ees.NewEventExporter(amqpMCCCfg.EEsCfg().Exporters[0], amqpMCCCfg, nil, nil)
|
||||
// if err != nil {
|
||||
// t.Error(err)
|
||||
// }
|
||||
// for i := 1; i <= 10000; i++ {
|
||||
// idx := strconv.Itoa(i)
|
||||
// cgrEv := &utils.CGREvent{
|
||||
// Tenant: "cgrates.org",
|
||||
// ID: "event" + idx,
|
||||
// Event: map[string]interface{}{
|
||||
// utils.RunID: "run_" + idx,
|
||||
// utils.CGRID: "CGRID" + idx,
|
||||
// utils.Tenant: "cgrates.org",
|
||||
// utils.Category: "call",
|
||||
// utils.ToR: utils.MetaVoice,
|
||||
// utils.OriginID: "processCDR" + idx,
|
||||
// utils.OriginHost: "OriginHost" + idx,
|
||||
// utils.RequestType: utils.MetaPseudoPrepaid,
|
||||
// utils.AccountField: "1001",
|
||||
// utils.Destination: "1002",
|
||||
// utils.SetupTime: time.Date(2021, time.February, 2, 16, 14, 50, 0, time.UTC),
|
||||
// utils.AnswerTime: time.Date(2021, time.February, 2, 16, 15, 0, 0, time.UTC),
|
||||
// utils.Usage: 2 * time.Minute,
|
||||
// },
|
||||
// }
|
||||
// ev, err := exporter.PrepareMap(cgrEv)
|
||||
// if err != nil {
|
||||
// t.Error(err)
|
||||
// }
|
||||
// go ees.ExportWithAttempts(exporter, ev, "")
|
||||
// }
|
||||
// time.Sleep(time.Second)
|
||||
// }
|
||||
@@ -35,7 +35,7 @@ func TestIndexesRedis(t *testing.T) {
|
||||
cfg := config.NewDefaultCGRConfig()
|
||||
db, err := engine.NewRedisStorage(cfg.DataDbCfg().Host+":"+cfg.DataDbCfg().Port, 10, cfg.DataDbCfg().User,
|
||||
cfg.DataDbCfg().Password, cfg.GeneralCfg().DBDataEncoding, utils.RedisMaxConns, utils.RedisMaxAttempts,
|
||||
utils.EmptyString, false, 0, 0, false, utils.EmptyString, utils.EmptyString, utils.EmptyString)
|
||||
utils.EmptyString, false, 0, 0, 0, 0, false, utils.EmptyString, utils.EmptyString, utils.EmptyString)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
@@ -158,7 +158,7 @@ func testSessVolDiscAuthorizeEventSortRoutes1Min30Sec(t *testing.T) {
|
||||
{
|
||||
RouteID: "supplier2",
|
||||
SortingData: map[string]interface{}{
|
||||
"Cost": float64(1.200000000000001),
|
||||
"Cost": float64(1.2),
|
||||
utils.RateProfileID: "RP_SUPPLIER2",
|
||||
"Weight": float64(0),
|
||||
},
|
||||
@@ -174,7 +174,7 @@ func testSessVolDiscAuthorizeEventSortRoutes1Min30Sec(t *testing.T) {
|
||||
{
|
||||
RouteID: "supplier3",
|
||||
SortingData: map[string]interface{}{
|
||||
"Cost": float64(1.425000000000001),
|
||||
"Cost": float64(1.425),
|
||||
utils.RateProfileID: "RP_SUPPLIER3",
|
||||
"Weight": float64(0),
|
||||
},
|
||||
@@ -225,7 +225,7 @@ func testSessVolDiscAuthorizeEventSortRoutes11Min10Sec(t *testing.T) {
|
||||
{
|
||||
RouteID: "supplier2",
|
||||
SortingData: map[string]interface{}{
|
||||
"Cost": float64(8.933333333333337),
|
||||
"Cost": float64(8.933333333333332),
|
||||
utils.RateProfileID: "RP_SUPPLIER2",
|
||||
"Weight": float64(0),
|
||||
},
|
||||
@@ -241,7 +241,7 @@ func testSessVolDiscAuthorizeEventSortRoutes11Min10Sec(t *testing.T) {
|
||||
{
|
||||
RouteID: "supplier3",
|
||||
SortingData: map[string]interface{}{
|
||||
"Cost": float64(10.60833333333334),
|
||||
"Cost": float64(10.60833333333333),
|
||||
utils.RateProfileID: "RP_SUPPLIER3",
|
||||
"Weight": float64(0),
|
||||
},
|
||||
@@ -285,7 +285,7 @@ func testSessVolDiscAuthorizeEventSortRoutes20Min(t *testing.T) {
|
||||
RouteID: "supplier2",
|
||||
SortingData: map[string]interface{}{
|
||||
utils.RateProfileID: "RP_SUPPLIER2",
|
||||
"Cost": float64(16.00000000000001), // returns from accounts null concretes, so the cost will be null,
|
||||
"Cost": float64(16), // returns from accounts null concretes, so the cost will be null,
|
||||
"Weight": float64(0),
|
||||
},
|
||||
},
|
||||
@@ -308,7 +308,7 @@ func testSessVolDiscAuthorizeEventSortRoutes20Min(t *testing.T) {
|
||||
{
|
||||
RouteID: "supplier3",
|
||||
SortingData: map[string]interface{}{
|
||||
"Cost": float64(19.00000000000001),
|
||||
"Cost": float64(19),
|
||||
utils.RateProfileID: "RP_SUPPLIER3",
|
||||
"Weight": float64(0),
|
||||
},
|
||||
@@ -479,7 +479,7 @@ func testSessVolDiscAuthorizeEventSortRoutes1Min30SecAfterDebiting(t *testing.T)
|
||||
{
|
||||
RouteID: "supplier2",
|
||||
SortingData: map[string]interface{}{
|
||||
"Cost": float64(1.200000000000001),
|
||||
"Cost": float64(1.2),
|
||||
utils.RateProfileID: "RP_SUPPLIER2",
|
||||
"Weight": float64(0),
|
||||
},
|
||||
@@ -495,7 +495,7 @@ func testSessVolDiscAuthorizeEventSortRoutes1Min30SecAfterDebiting(t *testing.T)
|
||||
{
|
||||
RouteID: "supplier3",
|
||||
SortingData: map[string]interface{}{
|
||||
"Cost": float64(1.425000000000001),
|
||||
"Cost": float64(1.425),
|
||||
utils.RateProfileID: "RP_SUPPLIER3",
|
||||
"Weight": float64(0),
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user