mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-13 02:56:24 +05:00
Fixed cpuprof apis
This commit is contained in:
committed by
Dan Christian Bogos
parent
047493f5fc
commit
b057552dff
@@ -16,6 +16,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
package apis
|
||||
|
||||
import (
|
||||
"path"
|
||||
"time"
|
||||
|
||||
"github.com/cgrates/birpc/context"
|
||||
@@ -51,15 +52,16 @@ func (cS *CoreSv1) Shutdown(_ *context.Context, _ *utils.CGREvent, reply *string
|
||||
}
|
||||
|
||||
// StartCPUProfiling is used to start CPUProfiling in the given path
|
||||
func (cS *CoreSv1) StartCPUProfiling(_ *context.Context, args string, reply *string) error {
|
||||
if err := cS.cS.StartCPUProfiling(args); err != nil {
|
||||
func (cS *CoreSv1) StartCPUProfiling(_ *context.Context, dirPath string, reply *string) error {
|
||||
if err := cS.cS.StartCPUProfiling(path.Join(dirPath, utils.CpuPathCgr)); err != nil {
|
||||
return err
|
||||
}
|
||||
*reply = utils.OK
|
||||
return nil
|
||||
}
|
||||
|
||||
// StopCPUProfiling is used to stop CPUProfiling in the given path
|
||||
// StopCPUProfiling is used to stop CPUProfiling. The file should be written on the path
|
||||
// where the CPUProfiling already started
|
||||
func (cS *CoreSv1) StopCPUProfiling(_ *context.Context, _ string, reply *string) error {
|
||||
if err := cS.cS.StopCPUProfiling(); err != nil {
|
||||
return err
|
||||
|
||||
@@ -63,7 +63,7 @@ var (
|
||||
)
|
||||
|
||||
func TestCoreItTests(t *testing.T) {
|
||||
argPath = "/tmp/cpu.prof"
|
||||
argPath = "/tmp"
|
||||
switch *dbType {
|
||||
case utils.MetaInternal:
|
||||
coreItDirPath = "all2"
|
||||
@@ -163,7 +163,7 @@ func testCoreItStopCPUProfiling(t *testing.T) {
|
||||
} else if reply != utils.OK {
|
||||
t.Errorf("Unexpected reply returned")
|
||||
}
|
||||
file, err := os.Open(argPath)
|
||||
file, err := os.Open(path.Join(argPath, utils.CpuPathCgr))
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
@@ -177,7 +177,7 @@ func testCoreItStopCPUProfiling(t *testing.T) {
|
||||
t.Errorf("Size of CPUProfile %v is lower that expected", size.Size())
|
||||
}
|
||||
//after we checked that CPUProfile was made successfully, can delete it
|
||||
if err := os.Remove(argPath); err != nil {
|
||||
if err := os.Remove(path.Join(argPath, utils.CpuPathCgr)); err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user