diff --git a/ees/filecsv_it_test.go b/ees/filecsv_it_test.go index 9185ccfb0..9c5169a66 100644 --- a/ees/filecsv_it_test.go +++ b/ees/filecsv_it_test.go @@ -54,7 +54,7 @@ var ( testCsvVerifyExports, testCsvExportComposedEvent, testCsvVerifyComposedExports, - testCsvStopCgrEngine, + testStopCgrEngine, testCleanDirectory, } ) @@ -326,9 +326,3 @@ func testCsvVerifyComposedExports(t *testing.T) { t.Errorf("Expecting: \n<%q>, \nreceived: \n<%q>", eCnt, string(outContent1)) } } - -func testCsvStopCgrEngine(t *testing.T) { - if err := engine.KillEngine(100); err != nil { - t.Error(err) - } -} diff --git a/ees/filefwv_it_test.go b/ees/filefwv_it_test.go index c99c6ab0f..d1c27d9af 100644 --- a/ees/filefwv_it_test.go +++ b/ees/filefwv_it_test.go @@ -50,7 +50,7 @@ var ( testFwvRPCConn, testFwvExportEvent, testFwvVerifyExports, - testFwvStopCgrEngine, + testStopCgrEngine, testCleanDirectory, } ) @@ -156,9 +156,3 @@ func testFwvVerifyExports(t *testing.T) { t.Errorf("Expecting: <%+v>, received: <%+v>", len(eHdr+eTrl+eCnt), len(outContent1)) } } - -func testFwvStopCgrEngine(t *testing.T) { - if err := engine.KillEngine(100); err != nil { - t.Error(err) - } -} diff --git a/ees/httpjsonmap_it_test.go b/ees/httpjsonmap_it_test.go new file mode 100644 index 000000000..93599d776 --- /dev/null +++ b/ees/httpjsonmap_it_test.go @@ -0,0 +1,88 @@ +// +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 ees + +import ( + "net/rpc" + "path" + "testing" + + "github.com/cgrates/cgrates/config" + "github.com/cgrates/cgrates/engine" +) + +var ( + httpJSONMapConfigDir string + httpJSONMapCfgPath string + httpJSONMapCfg *config.CGRConfig + httpJSONMapRpc *rpc.Client + + sTestsHTTPJsonMap = []func(t *testing.T){ + testHTTPJsonMapLoadConfig, + testHTTPJsonMapResetDataDB, + testHTTPJsonMapResetStorDb, + testHTTPJsonMapStartEngine, + testHTTPJsonMapRPCConn, + + testStopCgrEngine, + } +) + +func TestHTTPJsonMapExport(t *testing.T) { + httpJSONMapConfigDir = "ees" + for _, stest := range sTestsHTTPJsonMap { + t.Run(httpJSONMapConfigDir, stest) + } +} + +func testHTTPJsonMapLoadConfig(t *testing.T) { + var err error + httpJSONMapCfgPath = path.Join(*dataDir, "conf", "samples", httpJSONMapConfigDir) + if httpJSONMapCfg, err = config.NewCGRConfigFromPath(httpJSONMapCfgPath); err != nil { + t.Error(err) + } +} + +func testHTTPJsonMapResetDataDB(t *testing.T) { + if err := engine.InitDataDb(httpJSONMapCfg); err != nil { + t.Fatal(err) + } +} + +func testHTTPJsonMapResetStorDb(t *testing.T) { + if err := engine.InitStorDb(httpJSONMapCfg); err != nil { + t.Fatal(err) + } +} + +func testHTTPJsonMapStartEngine(t *testing.T) { + if _, err := engine.StopStartEngine(httpJSONMapCfgPath, *waitRater); err != nil { + t.Fatal(err) + } +} + +func testHTTPJsonMapRPCConn(t *testing.T) { + var err error + httpJSONMapRpc, err = newRPCClient(httpJSONMapCfg.ListenCfg()) + if err != nil { + t.Fatal(err) + } +} diff --git a/ees/httppost_it_test.go b/ees/httppost_it_test.go new file mode 100644 index 000000000..76c22f3c6 --- /dev/null +++ b/ees/httppost_it_test.go @@ -0,0 +1,88 @@ +// +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 ees + +import ( + "net/rpc" + "path" + "testing" + + "github.com/cgrates/cgrates/config" + "github.com/cgrates/cgrates/engine" +) + +var ( + httpPostConfigDir string + httpPostCfgPath string + httpPostCfg *config.CGRConfig + httpPostRpc *rpc.Client + + sTestsHTTPPost = []func(t *testing.T){ + testHTTPPostLoadConfig, + testHTTPPostResetDataDB, + testHTTPPostResetStorDb, + testHTTPPostStartEngine, + testHTTPPostRPCConn, + + testStopCgrEngine, + } +) + +func TestHTTPPostExport(t *testing.T) { + httpPostConfigDir = "ees" + for _, stest := range sTestsHTTPPost { + t.Run(httpPostConfigDir, stest) + } +} + +func testHTTPPostLoadConfig(t *testing.T) { + var err error + httpPostCfgPath = path.Join(*dataDir, "conf", "samples", httpPostConfigDir) + if httpPostCfg, err = config.NewCGRConfigFromPath(httpPostCfgPath); err != nil { + t.Error(err) + } +} + +func testHTTPPostResetDataDB(t *testing.T) { + if err := engine.InitDataDb(httpPostCfg); err != nil { + t.Fatal(err) + } +} + +func testHTTPPostResetStorDb(t *testing.T) { + if err := engine.InitStorDb(httpPostCfg); err != nil { + t.Fatal(err) + } +} + +func testHTTPPostStartEngine(t *testing.T) { + if _, err := engine.StopStartEngine(httpPostCfgPath, *waitRater); err != nil { + t.Fatal(err) + } +} + +func testHTTPPostRPCConn(t *testing.T) { + var err error + httpPostRpc, err = newRPCClient(httpPostCfg.ListenCfg()) + if err != nil { + t.Fatal(err) + } +} diff --git a/ees/lib_test.go b/ees/lib_test.go index 07701c099..f4a06c2ae 100644 --- a/ees/lib_test.go +++ b/ees/lib_test.go @@ -26,6 +26,8 @@ import ( "os" "testing" + "github.com/cgrates/cgrates/engine" + "github.com/cgrates/cgrates/config" "github.com/cgrates/cgrates/utils" ) @@ -67,3 +69,9 @@ func testCleanDirectory(t *testing.T) { } } } + +func testStopCgrEngine(t *testing.T) { + if err := engine.KillEngine(100); err != nil { + t.Error(err) + } +}