diff --git a/.github/workflows/integration_tests.yaml b/.github/workflows/integration_tests.yaml index e8fff10af..8dee0e01c 100644 --- a/.github/workflows/integration_tests.yaml +++ b/.github/workflows/integration_tests.yaml @@ -48,11 +48,12 @@ jobs: run: | ansible-playbook data/ansible/integration_tests/main.yaml -i localhost, -c local -e "ansible_user=$(whoami) cgrates_dir=$GITHUB_WORKSPACE clone_repository=false install_go=false" - - name: Run integration tests - run: | - sudo env "PATH=$PATH" ./integration_test.sh - - name: Run flaky tests continue-on-error: true run: | sudo env "PATH=$PATH" ./flaky_test.sh + + - name: Run integration tests + run: | + sudo env "PATH=$PATH" ./integration_test.sh + diff --git a/agents/diam_it_test.go b/agents/diam_it_test.go index cbfbd2f6a..864f23702 100644 --- a/agents/diam_it_test.go +++ b/agents/diam_it_test.go @@ -22,6 +22,7 @@ along with this program. If not, see package agents import ( + "errors" "flag" "fmt" "os" @@ -34,6 +35,7 @@ import ( "github.com/cgrates/birpc" "github.com/cgrates/birpc/context" + "github.com/cgrates/birpc/jsonrpc" "github.com/cgrates/cgrates/config" "github.com/cgrates/cgrates/engine" "github.com/cgrates/cgrates/utils" @@ -1606,3 +1608,14 @@ cgrates.com,Default,,,*default,*none,20`), t.Errorf("Expected: %f, received: %f", float64(time.Hour), acnt.BalanceMap[utils.MetaVoice].GetTotalValue()) } } + +func newRPCClient(cfg *config.ListenCfg) (c *birpc.Client, err error) { + switch *utils.Encoding { + case utils.MetaJSON: + return jsonrpc.Dial(utils.TCP, cfg.RPCJSONListen) + case utils.MetaGOB: + return birpc.Dial(utils.TCP, cfg.RPCGOBListen) + default: + return nil, errors.New("UNSUPPORTED_RPC") + } +} diff --git a/agents/lib_test.go b/agents/lib_test.go deleted file mode 100644 index 77fe79c43..000000000 --- a/agents/lib_test.go +++ /dev/null @@ -1,39 +0,0 @@ -/* -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 agents - -import ( - "errors" - - "github.com/cgrates/birpc" - "github.com/cgrates/birpc/jsonrpc" - "github.com/cgrates/cgrates/config" - "github.com/cgrates/cgrates/utils" -) - -func newRPCClient(cfg *config.ListenCfg) (c *birpc.Client, err error) { - switch *utils.Encoding { - case utils.MetaJSON: - return jsonrpc.Dial(utils.TCP, cfg.RPCJSONListen) - case utils.MetaGOB: - return birpc.Dial(utils.TCP, cfg.RPCGOBListen) - default: - return nil, errors.New("UNSUPPORTED_RPC") - } -} diff --git a/apier/v1/accounts_it_test.go b/apier/v1/accounts_it_test.go index b16f5cb89..90ec122a3 100644 --- a/apier/v1/accounts_it_test.go +++ b/apier/v1/accounts_it_test.go @@ -21,6 +21,7 @@ along with this program. If not, see package v1 import ( + "errors" "path" "reflect" "testing" @@ -28,6 +29,7 @@ import ( "github.com/cgrates/birpc" "github.com/cgrates/birpc/context" + "github.com/cgrates/birpc/jsonrpc" "github.com/cgrates/cgrates/config" "github.com/cgrates/cgrates/engine" "github.com/cgrates/cgrates/utils" @@ -1459,3 +1461,14 @@ func testAccITSetBalanceWithTimeSuffix(t *testing.T) { } } } + +func newRPCClient(cfg *config.ListenCfg) (c *birpc.Client, err error) { + switch *utils.Encoding { + case utils.MetaJSON: + return jsonrpc.Dial(utils.TCP, cfg.RPCJSONListen) + case utils.MetaGOB: + return birpc.Dial(utils.TCP, cfg.RPCGOBListen) + default: + return nil, errors.New("UNSUPPORTED_RPC") + } +} diff --git a/apier/v1/lib_test.go b/apier/v1/lib_test.go deleted file mode 100644 index 140c7248b..000000000 --- a/apier/v1/lib_test.go +++ /dev/null @@ -1,39 +0,0 @@ -/* -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 v1 - -import ( - "errors" - - "github.com/cgrates/birpc" - "github.com/cgrates/birpc/jsonrpc" - "github.com/cgrates/cgrates/config" - "github.com/cgrates/cgrates/utils" -) - -func newRPCClient(cfg *config.ListenCfg) (c *birpc.Client, err error) { - switch *utils.Encoding { - case utils.MetaJSON: - return jsonrpc.Dial(utils.TCP, cfg.RPCJSONListen) - case utils.MetaGOB: - return birpc.Dial(utils.TCP, cfg.RPCGOBListen) - default: - return nil, errors.New("UNSUPPORTED_RPC") - } -} diff --git a/apier/v2/accounts_it_test.go b/apier/v2/accounts_it_test.go index 9e96290d8..474c43296 100644 --- a/apier/v2/accounts_it_test.go +++ b/apier/v2/accounts_it_test.go @@ -22,13 +22,14 @@ along with this program. If not, see package v2 import ( + "errors" "path" "reflect" "testing" - "github.com/cgrates/birpc/context" - "github.com/cgrates/birpc" + "github.com/cgrates/birpc/context" + "github.com/cgrates/birpc/jsonrpc" v1 "github.com/cgrates/cgrates/apier/v1" "github.com/cgrates/cgrates/config" "github.com/cgrates/cgrates/engine" @@ -276,3 +277,14 @@ func testAccountsKillEngine(t *testing.T) { t.Error(err) } } + +func newRPCClient(cfg *config.ListenCfg) (c *birpc.Client, err error) { + switch *utils.Encoding { + case utils.MetaJSON: + return jsonrpc.Dial(utils.TCP, cfg.RPCJSONListen) + case utils.MetaGOB: + return birpc.Dial(utils.TCP, cfg.RPCGOBListen) + default: + return nil, errors.New("UNSUPPORTED_RPC") + } +} diff --git a/apier/v2/lib_test.go b/apier/v2/lib_test.go deleted file mode 100644 index 0b53dfccc..000000000 --- a/apier/v2/lib_test.go +++ /dev/null @@ -1,39 +0,0 @@ -/* -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 v2 - -import ( - "errors" - - "github.com/cgrates/birpc" - "github.com/cgrates/birpc/jsonrpc" - "github.com/cgrates/cgrates/config" - "github.com/cgrates/cgrates/utils" -) - -func newRPCClient(cfg *config.ListenCfg) (c *birpc.Client, err error) { - switch *utils.Encoding { - case utils.MetaJSON: - return jsonrpc.Dial(utils.TCP, cfg.RPCJSONListen) - case utils.MetaGOB: - return birpc.Dial(utils.TCP, cfg.RPCGOBListen) - default: - return nil, errors.New("UNSUPPORTED_RPC") - } -} diff --git a/cmd/cgr-tester/cdr_repl/process_cdr.go b/cmd/cgr-tester/cdr_repl/process_cdr.go index 6c192bdbc..740a9bc3a 100644 --- a/cmd/cgr-tester/cdr_repl/process_cdr.go +++ b/cmd/cgr-tester/cdr_repl/process_cdr.go @@ -32,13 +32,15 @@ import ( "github.com/cgrates/rpcclient" ) +var dataDir = flag.String("data_dir", "/usr/share/cgrates", "CGR data dir path here") + func main() { flag.Parse() var err error var cdrsMasterRpc *rpcclient.RPCClient var cdrsMasterCfgPath string var cdrsMasterCfg *config.CGRConfig - cdrsMasterCfgPath = path.Join(*utils.DataDir, "conf", "samples", "cdrsreplicationmaster") + cdrsMasterCfgPath = path.Join(*dataDir, "conf", "samples", "cdrsreplicationmaster") if cdrsMasterCfg, err = config.NewCGRConfigFromPath(cdrsMasterCfgPath); err != nil { log.Fatal("Got config error: ", err.Error()) } diff --git a/dispatchers/lib_test.go b/dispatchers/lib_test.go index ea0166f2b..385e0417a 100644 --- a/dispatchers/lib_test.go +++ b/dispatchers/lib_test.go @@ -1,3 +1,5 @@ +//go:build integration || flaky + /* Real-time Online/Offline Charging System (OCS) for Telecom & ISP environments Copyright (C) ITsysCOM GmbH diff --git a/ees/amqp_it_test.go b/ees/amqp_it_test.go index 070367cc9..8976588cd 100644 --- a/ees/amqp_it_test.go +++ b/ees/amqp_it_test.go @@ -22,13 +22,14 @@ along with this program. If not, see package ees import ( + "errors" "path" "testing" "time" - "github.com/cgrates/birpc/context" - "github.com/cgrates/birpc" + "github.com/cgrates/birpc/context" + "github.com/cgrates/birpc/jsonrpc" "github.com/cgrates/cgrates/config" "github.com/cgrates/cgrates/engine" "github.com/cgrates/cgrates/utils" @@ -175,3 +176,14 @@ func testAMQPVerifyExport(t *testing.T) { t.Error(err) } } + +func newRPCClient(cfg *config.ListenCfg) (c *birpc.Client, err error) { + switch *utils.Encoding { + case utils.MetaJSON: + return jsonrpc.Dial(utils.TCP, cfg.RPCJSONListen) + case utils.MetaGOB: + return birpc.Dial(utils.TCP, cfg.RPCGOBListen) + default: + return nil, errors.New("UNSUPPORTED_RPC") + } +} diff --git a/ees/lib_test.go b/ees/lib_test.go index 8be365b50..11fc2f9ea 100644 --- a/ees/lib_test.go +++ b/ees/lib_test.go @@ -19,29 +19,12 @@ along with this program. If not, see package ees import ( - "errors" "os" "testing" - "github.com/cgrates/birpc" - "github.com/cgrates/birpc/jsonrpc" "github.com/cgrates/cgrates/engine" - - "github.com/cgrates/cgrates/config" - "github.com/cgrates/cgrates/utils" ) -func newRPCClient(cfg *config.ListenCfg) (c *birpc.Client, err error) { - switch *utils.Encoding { - case utils.MetaJSON: - return jsonrpc.Dial(utils.TCP, cfg.RPCJSONListen) - case utils.MetaGOB: - return birpc.Dial(utils.TCP, cfg.RPCGOBListen) - default: - return nil, errors.New("UNSUPPORTED_RPC") - } -} - var exportPath = []string{"/tmp/testCSV", "/tmp/testComposedCSV", "/tmp/testFWV", "/tmp/testCSVMasked", "/tmp/testCSVfromVirt", "/tmp/testCSVExpTemp"} diff --git a/engine/lib_test.go b/engine/lib_test.go deleted file mode 100644 index 76a8b31e4..000000000 --- a/engine/lib_test.go +++ /dev/null @@ -1,39 +0,0 @@ -/* -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 engine - -import ( - "errors" - - "github.com/cgrates/birpc" - "github.com/cgrates/birpc/jsonrpc" - "github.com/cgrates/cgrates/config" - "github.com/cgrates/cgrates/utils" -) - -func newRPCClient(cfg *config.ListenCfg) (c *birpc.Client, err error) { - switch *utils.Encoding { - case utils.MetaJSON: - return jsonrpc.Dial(utils.TCP, cfg.RPCJSONListen) - case utils.MetaGOB: - return birpc.Dial(utils.TCP, cfg.RPCGOBListen) - default: - return nil, errors.New("UNSUPPORTED_RPC") - } -} diff --git a/engine/z_actions_it_test.go b/engine/z_actions_it_test.go index b37f13654..24dfd4d30 100644 --- a/engine/z_actions_it_test.go +++ b/engine/z_actions_it_test.go @@ -21,6 +21,7 @@ along with this program. If not, see package engine import ( + "errors" "io" "net/http" "net/http/httptest" @@ -33,6 +34,7 @@ import ( "github.com/cgrates/birpc" "github.com/cgrates/birpc/context" + "github.com/cgrates/birpc/jsonrpc" "github.com/cgrates/cgrates/config" "github.com/cgrates/cgrates/utils" ) @@ -978,3 +980,14 @@ func testActionsitremoteSetAccount(t *testing.T) { t.Errorf("Expected: %s,received: %s", utils.ToJSON(exp), utils.ToJSON(acc2)) } } + +func newRPCClient(cfg *config.ListenCfg) (c *birpc.Client, err error) { + switch *utils.Encoding { + case utils.MetaJSON: + return jsonrpc.Dial(utils.TCP, cfg.RPCJSONListen) + case utils.MetaGOB: + return birpc.Dial(utils.TCP, cfg.RPCGOBListen) + default: + return nil, errors.New("UNSUPPORTED_RPC") + } +} diff --git a/ers/ers_reload_it_test.go b/ers/ers_reload_it_test.go index a1294e949..20bc7fdac 100644 --- a/ers/ers_reload_it_test.go +++ b/ers/ers_reload_it_test.go @@ -21,13 +21,14 @@ along with this program. If not, see package ers import ( + "errors" "os" "path" "testing" - "github.com/cgrates/birpc/context" - "github.com/cgrates/birpc" + "github.com/cgrates/birpc/context" + "github.com/cgrates/birpc/jsonrpc" "github.com/cgrates/cgrates/config" "github.com/cgrates/cgrates/engine" "github.com/cgrates/cgrates/utils" @@ -167,3 +168,14 @@ func testReloadITKillEngine(t *testing.T) { t.Error(err) } } + +func newRPCClient(cfg *config.ListenCfg) (c *birpc.Client, err error) { + switch *utils.Encoding { + case utils.MetaJSON: + return jsonrpc.Dial(utils.TCP, cfg.RPCJSONListen) + case utils.MetaGOB: + return birpc.Dial(utils.TCP, cfg.RPCGOBListen) + default: + return nil, errors.New("UNSUPPORTED_RPC") + } +} diff --git a/ers/lib_test.go b/ers/lib_test.go index 385150d07..0fd1af1f8 100644 --- a/ers/lib_test.go +++ b/ers/lib_test.go @@ -19,27 +19,10 @@ along with this program. If not, see package ers import ( - "errors" "os" "testing" - - "github.com/cgrates/birpc" - "github.com/cgrates/birpc/jsonrpc" - "github.com/cgrates/cgrates/config" - "github.com/cgrates/cgrates/utils" ) -func newRPCClient(cfg *config.ListenCfg) (c *birpc.Client, err error) { - switch *utils.Encoding { - case utils.MetaJSON: - return jsonrpc.Dial(utils.TCP, cfg.RPCJSONListen) - case utils.MetaGOB: - return birpc.Dial(utils.TCP, cfg.RPCGOBListen) - default: - return nil, errors.New("UNSUPPORTED_RPC") - } -} - func testCreateDirs(t *testing.T) { for _, dir := range []string{"/tmp/ers/in", "/tmp/ers/out", "/tmp/ers2/in", "/tmp/ers2/out", diff --git a/general_tests/lib_test.go b/general_tests/lib_test.go index f6e8669f9..1342c1c99 100644 --- a/general_tests/lib_test.go +++ b/general_tests/lib_test.go @@ -1,3 +1,5 @@ +//go:build integration || flaky + /* Real-time Online/Offline Charging System (OCS) for Telecom & ISP environments Copyright (C) ITsysCOM GmbH diff --git a/loaders/lib_test.go b/loaders/lib_test.go index 66ebed93b..1c0a78bfe 100644 --- a/loaders/lib_test.go +++ b/loaders/lib_test.go @@ -20,14 +20,12 @@ package loaders import ( "encoding/csv" - "errors" "io" "strings" "testing" "github.com/cgrates/birpc" "github.com/cgrates/birpc/context" - "github.com/cgrates/birpc/jsonrpc" "github.com/cgrates/rpcclient" "github.com/cgrates/cgrates/config" @@ -39,17 +37,6 @@ var loaderPaths = []string{"/tmp/In", "/tmp/Out", "/tmp/LoaderIn", "/tmp/Subpath "/tmp/SubpathLoaderWithMove", "/tmp/SubpathOut", "/tmp/templateLoaderIn", "/tmp/templateLoaderOut", "/tmp/customSepLoaderIn", "/tmp/customSepLoaderOut"} -func newRPCClient(cfg *config.ListenCfg) (c *birpc.Client, err error) { - switch *utils.Encoding { - case utils.MetaJSON: - return jsonrpc.Dial(utils.TCP, cfg.RPCJSONListen) - case utils.MetaGOB: - return birpc.Dial(utils.TCP, cfg.RPCGOBListen) - default: - return nil, errors.New("UNSUPPORTED_RPC") - } -} - type testMockCacheConn struct { calls map[string]func(arg any, rply any) error } diff --git a/loaders/loader_it_test.go b/loaders/loader_it_test.go index 93a574e85..dfaaeefac 100644 --- a/loaders/loader_it_test.go +++ b/loaders/loader_it_test.go @@ -22,6 +22,7 @@ package loaders import ( "encoding/csv" + "errors" "io" "os" "path" @@ -33,6 +34,7 @@ import ( "github.com/cgrates/birpc" "github.com/cgrates/birpc/context" + "github.com/cgrates/birpc/jsonrpc" "github.com/cgrates/cgrates/config" "github.com/cgrates/cgrates/engine" "github.com/cgrates/cgrates/utils" @@ -151,7 +153,14 @@ func testLoaderStartEngine(t *testing.T) { // Connect rpc client to rater func testLoaderRPCConn(t *testing.T) { var err error - loaderRPC, err = newRPCClient(loaderCfg.ListenCfg()) // We connect over JSON so we can also troubleshoot if needed + switch *utils.Encoding { + case utils.MetaJSON: + loaderRPC, err = jsonrpc.Dial(utils.TCP, loaderCfg.ListenCfg().RPCJSONListen) + case utils.MetaGOB: + loaderRPC, err = birpc.Dial(utils.TCP, loaderCfg.ListenCfg().RPCGOBListen) + default: + loaderRPC, err = nil, errors.New("UNSUPPORTED_RPC") + } if err != nil { t.Fatal(err) } diff --git a/registrarc/lib_test.go b/registrarc/lib_test.go deleted file mode 100644 index 335cc8f85..000000000 --- a/registrarc/lib_test.go +++ /dev/null @@ -1,38 +0,0 @@ -/* -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 registrarc - -import ( - "errors" - - "github.com/cgrates/birpc" - "github.com/cgrates/birpc/jsonrpc" - "github.com/cgrates/cgrates/config" - "github.com/cgrates/cgrates/utils" -) - -func newRPCClient(cfg *config.ListenCfg) (c *birpc.Client, err error) { - switch *utils.Encoding { - case utils.MetaJSON: - return jsonrpc.Dial(utils.TCP, cfg.RPCJSONListen) - case utils.MetaGOB: - return birpc.Dial(utils.TCP, cfg.RPCGOBListen) - default: - return nil, errors.New("UNSUPPORTED_RPC") - } -} diff --git a/registrarc/registarc_defaultid_it_test.go b/registrarc/registarc_defaultid_it_test.go index 5c735a8a5..2c549c8a9 100644 --- a/registrarc/registarc_defaultid_it_test.go +++ b/registrarc/registarc_defaultid_it_test.go @@ -1,15 +1,36 @@ +//go: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 registrarc import ( "bytes" + "errors" "os/exec" "path" "testing" "time" - "github.com/cgrates/birpc/context" - "github.com/cgrates/birpc" + "github.com/cgrates/birpc/context" + "github.com/cgrates/birpc/jsonrpc" "github.com/cgrates/cgrates/config" "github.com/cgrates/cgrates/engine" "github.com/cgrates/cgrates/utils" @@ -141,3 +162,14 @@ func testDsphNodeStopDispatcher(t *testing.T) { t.Error(err) } } + +func newRPCClient(cfg *config.ListenCfg) (c *birpc.Client, err error) { + switch *utils.Encoding { + case utils.MetaJSON: + return jsonrpc.Dial(utils.TCP, cfg.RPCJSONListen) + case utils.MetaGOB: + return birpc.Dial(utils.TCP, cfg.RPCGOBListen) + default: + return nil, errors.New("UNSUPPORTED_RPC") + } +} diff --git a/sessions/lib_test.go b/sessions/lib_test.go deleted file mode 100644 index 6964e8848..000000000 --- a/sessions/lib_test.go +++ /dev/null @@ -1,39 +0,0 @@ -/* -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 sessions - -import ( - "errors" - - "github.com/cgrates/birpc" - "github.com/cgrates/birpc/jsonrpc" - "github.com/cgrates/cgrates/config" - "github.com/cgrates/cgrates/utils" -) - -func newRPCClient(cfg *config.ListenCfg) (c *birpc.Client, err error) { - switch *utils.Encoding { - case utils.MetaJSON: - return jsonrpc.Dial(utils.TCP, cfg.RPCJSONListen) - case utils.MetaGOB: - return birpc.Dial(utils.TCP, cfg.RPCGOBListen) - default: - return nil, errors.New("UNSUPPORTED_RPC") - } -} diff --git a/sessions/sessions_birpc_it_test.go b/sessions/sessions_birpc_it_test.go index 150e3fe84..6915bce47 100644 --- a/sessions/sessions_birpc_it_test.go +++ b/sessions/sessions_birpc_it_test.go @@ -22,12 +22,14 @@ along with this program. If not, see package sessions import ( + "errors" "path" "testing" "time" "github.com/cgrates/birpc" "github.com/cgrates/birpc/context" + "github.com/cgrates/birpc/jsonrpc" "github.com/cgrates/cgrates/config" "github.com/cgrates/cgrates/engine" "github.com/cgrates/cgrates/utils" @@ -394,3 +396,14 @@ func testSessionsBiRPCStopCgrEngine(t *testing.T) { t.Error(err) } } + +func newRPCClient(cfg *config.ListenCfg) (c *birpc.Client, err error) { + switch *utils.Encoding { + case utils.MetaJSON: + return jsonrpc.Dial(utils.TCP, cfg.RPCJSONListen) + case utils.MetaGOB: + return birpc.Dial(utils.TCP, cfg.RPCGOBListen) + default: + return nil, errors.New("UNSUPPORTED_RPC") + } +}