revise integration tests

This commit is contained in:
gezimbll
2024-05-22 03:14:48 -04:00
committed by Dan Christian Bogos
parent 07ea67e638
commit 18fa884ea1
6 changed files with 20 additions and 17 deletions

View File

@@ -44,13 +44,13 @@
"stats": {
"enabled": true,
"store_interval": "1s",
"store_interval": "-1",
"thresholds_conns": ["*internal"]
},
"thresholds": {
"enabled": true,
"store_interval": "1s"
"store_interval": "-1"
},
"chargers": {

View File

@@ -148,8 +148,8 @@ func testReloadVerifyFirstReload(t *testing.T) {
} else if len(readers) != 3 { // 2 active readers and 1 default
t.Errorf("Expecting: <2>, received: <%+v>", len(readers))
}
} else if len(readers) != 3 { // 2 active readers and 1 default
t.Errorf("Expecting: <2>, received: <%+v>", len(readers))
} else if len(readers) != 1 { // 2 active readers and 1 default
t.Errorf("Expecting: <1>, received: <%+v>", len(readers))
}
}

View File

@@ -199,7 +199,7 @@ func testConfigSReload(t *testing.T) {
t.Errorf("\nExpected %+v ,\n received: %+v", utils.ToIJSON(cfgStr), utils.ToIJSON(rpl8))
}
cfgStr = "{\"cdrs\":{\"accounts_conns\":[],\"actions_conns\":[],\"attributes_conns\":[],\"chargers_conns\":[\"*internal\"],\"ees_conns\":[],\"enabled\":true,\"extra_fields\":[],\"online_cdr_exports\":null,\"opts\":{\"*accounts\":[],\"*attributes\":[],\"*chargers\":[],\"*ees\":[],\"*rates\":[],\"*stats\":[],\"*thresholds\":[]},\"rates_conns\":[],\"session_cost_retries\":5,\"stats_conns\":[],\"store_cdrs\":true,\"thresholds_conns\":[]}}"
cfgStr = "{\"cdrs\":{\"accounts_conns\":[],\"actions_conns\":[],\"attributes_conns\":[],\"chargers_conns\":[\"*internal\"],\"ees_conns\":[],\"enabled\":true,\"extra_fields\":[],\"online_cdr_exports\":null,\"opts\":{\"*accounts\":[],\"*attributes\":[],\"*chargers\":[],\"*ees\":[],\"*rates\":[],\"*refund\":[],\"*rerate\":[],\"*stats\":[],\"*store\":[],\"*thresholds\":[]},\"rates_conns\":[],\"session_cost_retries\":5,\"stats_conns\":[],\"thresholds_conns\":[]}}"
var rpl10 string
if err := testRPC.Call(context.Background(), utils.ConfigSv1GetConfigAsJSON, &config.SectionWithAPIOpts{
Tenant: "cgrates.org",

View File

@@ -142,7 +142,7 @@ func testSectConfigSReloadGeneral(t *testing.T) {
} else if reply != utils.OK {
t.Errorf("Expected OK received: %+v", reply)
}
cfgStr := "{\"general\":{\"connect_attempts\":5,\"connect_timeout\":\"1s\",\"dbdata_encoding\":\"*msgpack\",\"decimal_max_scale\":0,\"decimal_min_scale\":0,\"decimal_precision\":0,\"decimal_rounding_mode\":\"*toNearestEven\",\"default_caching\":\"*reload\",\"default_category\":\"call\",\"default_request_type\":\"*rated\",\"default_tenant\":\"cgrates.org\",\"default_timezone\":\"Local\",\"digest_equal\":\":\",\"digest_separator\":\",\",\"locking_timeout\":\"0\",\"max_parallel_conns\":100,\"max_reconnect_interval\":\"0\",\"node_id\":\"98ead14\",\"opts\":{\"*exporterIDs\":[]},\"reconnects\":-1,\"reply_timeout\":\"50s\",\"rounding_decimals\":5,\"rsr_separator\":\";\",\"tpexport_dir\":\"/var/spool/cgrates/tpe\"}}"
cfgStr := "{\"general\":{\"caching_delay\":\"0\",\"connect_attempts\":5,\"connect_timeout\":\"1s\",\"dbdata_encoding\":\"*msgpack\",\"decimal_max_scale\":0,\"decimal_min_scale\":0,\"decimal_precision\":0,\"decimal_rounding_mode\":\"*toNearestEven\",\"default_caching\":\"*reload\",\"default_category\":\"call\",\"default_request_type\":\"*rated\",\"default_tenant\":\"cgrates.org\",\"default_timezone\":\"Local\",\"digest_equal\":\":\",\"digest_separator\":\",\",\"locking_timeout\":\"0\",\"max_parallel_conns\":100,\"max_reconnect_interval\":\"0\",\"node_id\":\"98ead14\",\"opts\":{\"*exporterIDs\":[]},\"reconnects\":-1,\"reply_timeout\":\"50s\",\"rounding_decimals\":5,\"rsr_separator\":\";\",\"tpexport_dir\":\"/var/spool/cgrates/tpe\"}}"
var rpl string
if err := testSectRPC.Call(context.Background(), utils.ConfigSv1GetConfigAsJSON, &config.SectionWithAPIOpts{
Tenant: "cgrates.org",
@@ -374,7 +374,7 @@ func testSectConfigSReloadCDRS(t *testing.T) {
} else if reply != utils.OK {
t.Errorf("Expected OK received: %+v", reply)
}
cfgStr := "{\"cdrs\":{\"accounts_conns\":[],\"actions_conns\":[],\"attributes_conns\":[],\"chargers_conns\":[\"*internal\"],\"ees_conns\":[],\"enabled\":true,\"extra_fields\":[],\"online_cdr_exports\":null,\"opts\":{\"*accounts\":[],\"*attributes\":[],\"*chargers\":[],\"*ees\":[],\"*rates\":[],\"*stats\":[],\"*thresholds\":[]},\"rates_conns\":[],\"session_cost_retries\":5,\"stats_conns\":[],\"store_cdrs\":true,\"thresholds_conns\":[]}}"
cfgStr := "{\"cdrs\":{\"accounts_conns\":[],\"actions_conns\":[],\"attributes_conns\":[],\"chargers_conns\":[\"*internal\"],\"ees_conns\":[],\"enabled\":true,\"extra_fields\":[],\"online_cdr_exports\":null,\"opts\":{\"*accounts\":[],\"*attributes\":[],\"*chargers\":[],\"*ees\":[],\"*rates\":[],\"*refund\":[],\"*rerate\":[],\"*stats\":[],\"*store\":[],\"*thresholds\":[]},\"rates_conns\":[],\"session_cost_retries\":5,\"stats_conns\":[],\"thresholds_conns\":[]}}"
var rpl string
if err := testSectRPC.Call(context.Background(), utils.ConfigSv1GetConfigAsJSON, &config.SectionWithAPIOpts{
Tenant: "cgrates.org",

View File

@@ -24,6 +24,7 @@ package general_tests
import (
"path"
"reflect"
"sort"
"testing"
"time"
@@ -1064,13 +1065,16 @@ func testV1FltrChargerSuffix(t *testing.T) {
utils.Destination: "999",
},
}
var result2 []*engine.ChrgSProcessEventReply
if err := fltrRpc.Call(context.Background(), utils.ChargerSv1ProcessEvent, cgrEv, &result2); err != nil {
t.Error(err)
} else {
processedEv[0].CGREvent.APIOpts[utils.MetaChargeID] = result2[0].CGREvent.APIOpts[utils.MetaChargeID]
if utils.ToJSON(result2) != utils.ToJSON(processedEv) {
t.Errorf("Expecting : %s, \n received: %s", utils.ToJSON(processedEv), utils.ToJSON(result2))
sort.Slice(result2, func(i, j int) bool {
return result2[i].ChargerSProfile < result2[j].ChargerSProfile
})
if processedEv[0].ChargerSProfile != result2[1].ChargerSProfile {
t.Errorf("Expecting : %s, \n received: %s", utils.ToJSON(processedEv[0]), utils.ToJSON(result2[1]))
}
}
@@ -1116,9 +1120,11 @@ func testV1FltrChargerSuffix(t *testing.T) {
if err := fltrRpc.Call(context.Background(), utils.ChargerSv1ProcessEvent, cgrEv, &result2); err != nil {
t.Error(err)
} else {
processedEv[0].CGREvent.APIOpts[utils.MetaChargeID] = result2[0].CGREvent.APIOpts[utils.MetaChargeID]
if utils.ToJSON(result2) != utils.ToJSON(processedEv) {
t.Errorf("Expecting : %s, \n received: %s", utils.ToJSON(processedEv), utils.ToJSON(result2))
sort.Slice(result2, func(i, j int) bool {
return result2[i].ChargerSProfile < result2[j].ChargerSProfile
})
if processedEv[0].ChargerSProfile != result2[1].ChargerSProfile {
t.Errorf("Expecting : %s, \n received: %s", utils.ToJSON(processedEv[0]), utils.ToJSON(result2[1]))
}
}
}

View File

@@ -21,7 +21,6 @@ package services
import (
"fmt"
"runtime"
"strings"
"sync"
"github.com/cgrates/birpc"
@@ -101,9 +100,7 @@ func (cdrSrv *CDRService) Start(ctx *context.Context, _ context.CancelFunc) (err
go cdrSrv.cdrS.ListenAndServe(cdrSrv.stopChan)
runtime.Gosched()
utils.Logger.Info("Registering CDRS RPC service.")
srv, err := birpc.NewServiceWithMethodsRename(cdrSrv.cdrS, utils.CDRsV1, true, func(oldFn string) (newFn string) {
return strings.TrimPrefix(oldFn, utils.V1Prfx)
})
srv, err := engine.NewService2(cdrSrv.cdrS, utils.CDRsV1, utils.V1Prfx)
if err != nil {
return err
}