From 3e13436e138f912d1f6fe11ac5bd46788fde5a3b Mon Sep 17 00:00:00 2001 From: porosnicuadrian Date: Wed, 7 Jul 2021 15:21:46 +0300 Subject: [PATCH] Changed args type for stop profiling apis --- apier/v1/core.go | 4 ++-- apier/v1/core_it_test.go | 8 ++++---- apier/v1/dispatcher.go | 4 ++-- dispatchers/core.go | 4 ++-- dispatchers/core_it_test.go | 11 ++++------- 5 files changed, 14 insertions(+), 17 deletions(-) diff --git a/apier/v1/core.go b/apier/v1/core.go index d6f0fdbab..a3aa34157 100644 --- a/apier/v1/core.go +++ b/apier/v1/core.go @@ -69,7 +69,7 @@ func (cS *CoreSv1) StartCPUProfiling(args *utils.DirectoryArgs, reply *string) e // StopCPUProfiling is used to stop CPUProfiling. The file should be written on the path // where the CPUProfiling already started -func (cS *CoreSv1) StopCPUProfiling(_ *utils.DirectoryArgs, reply *string) error { +func (cS *CoreSv1) StopCPUProfiling(_ *utils.TenantWithAPIOpts, reply *string) error { if err := cS.cS.StopCPUProfiling(); err != nil { return err } @@ -88,7 +88,7 @@ func (cS *CoreSv1) StartMemoryProfiling(args *utils.MemoryPrf, reply *string) er // StopMemoryProfiling is used to stop MemoryProfiling. The file should be written on the path // where the MemoryProfiling already started -func (cS *CoreSv1) StopMemoryProfiling(_ *utils.MemoryPrf, reply *string) error { +func (cS *CoreSv1) StopMemoryProfiling(_ *utils.TenantWithAPIOpts, reply *string) error { if err := cS.cS.StopMemoryProfiling(); err != nil { return err } diff --git a/apier/v1/core_it_test.go b/apier/v1/core_it_test.go index 1be6b3c88..ef6be309b 100644 --- a/apier/v1/core_it_test.go +++ b/apier/v1/core_it_test.go @@ -170,7 +170,7 @@ func testCoreSv1StopMemProfilingBeforeStart(t *testing.T) { var reply string expectedErr := " Memory Profiling is not started" if err := coreV1Rpc.Call(utils.CoreSv1StopMemoryProfiling, - new(utils.MemoryPrf), &reply); err == nil || err.Error() != expectedErr { + new(utils.TenantWithAPIOpts), &reply); err == nil || err.Error() != expectedErr { t.Errorf("Expected %+q, received %+q", expectedErr, err) } } @@ -200,7 +200,7 @@ func testCoreSv1StartEngineByExecWIthMemProfiling(t *testing.T) { func testCoreSv1StopMemoryProfiling(t *testing.T) { var reply string if err := coreV1Rpc.Call(utils.CoreSv1StopMemoryProfiling, - new(utils.MemoryPrf), &reply); err != nil { + new(utils.TenantWithAPIOpts), &reply); err != nil { t.Error(err) } else if reply != utils.OK { t.Errorf("Unexpected reply returned") @@ -267,7 +267,7 @@ func testCoreSv1StopCPUProfilingBeforeStart(t *testing.T) { var reply string expectedErr := " cannot stop because CPUProfiling is not active" if err := coreV1Rpc.Call(utils.CoreSv1StopCPUProfiling, - new(utils.DirectoryArgs), &reply); err == nil || err.Error() != expectedErr { + new(utils.TenantWithAPIOpts), &reply); err == nil || err.Error() != expectedErr { t.Errorf("Expected %+q, received %+q", expectedErr, err) } } @@ -301,7 +301,7 @@ func testCoreSv1Sleep(t *testing.T) { func testCoreSv1StopCPUProfiling(t *testing.T) { var reply string if err := coreV1Rpc.Call(utils.CoreSv1StopCPUProfiling, - new(utils.DirectoryArgs), &reply); err != nil { + new(utils.TenantWithAPIOpts), &reply); err != nil { t.Error(err) } else if reply != utils.OK { t.Errorf("Unexpected reply returned") diff --git a/apier/v1/dispatcher.go b/apier/v1/dispatcher.go index 775bb9b20..83e69f55e 100644 --- a/apier/v1/dispatcher.go +++ b/apier/v1/dispatcher.go @@ -896,7 +896,7 @@ func (dS *DispatcherCoreSv1) StartCPUProfiling(args *utils.DirectoryArgs, reply return dS.dS.CoreSv1StartCPUProfiling(args, reply) } -func (dS *DispatcherCoreSv1) StopCPUProfiling(args *utils.DirectoryArgs, reply *string) error { +func (dS *DispatcherCoreSv1) StopCPUProfiling(args *utils.TenantWithAPIOpts, reply *string) error { return dS.dS.CoreSv1StopCPUProfiling(args, reply) } @@ -904,7 +904,7 @@ func (dS *DispatcherCoreSv1) StartMemoryProfiling(args *utils.MemoryPrf, reply * return dS.dS.CoreSv1StartMemoryProfiling(args, reply) } -func (dS *DispatcherCoreSv1) StopMemoryProfiling(args *utils.MemoryPrf, reply *string) error { +func (dS *DispatcherCoreSv1) StopMemoryProfiling(args *utils.TenantWithAPIOpts, reply *string) error { return dS.dS.CoreSv1StopMemoryProfiling(args, reply) } diff --git a/dispatchers/core.go b/dispatchers/core.go index 5c52bdf84..d66f506ae 100644 --- a/dispatchers/core.go +++ b/dispatchers/core.go @@ -92,7 +92,7 @@ func (dS *DispatcherService) CoreSv1StartCPUProfiling(args *utils.DirectoryArgs, }, utils.MetaCore, utils.CoreSv1StartCPUProfiling, args, reply) } -func (dS *DispatcherService) CoreSv1StopCPUProfiling(args *utils.DirectoryArgs, +func (dS *DispatcherService) CoreSv1StopCPUProfiling(args *utils.TenantWithAPIOpts, reply *string) (err error) { tnt := dS.cfg.GeneralCfg().DefaultTenant if args.Tenant != utils.EmptyString { @@ -128,7 +128,7 @@ func (dS *DispatcherService) CoreSv1StartMemoryProfiling(args *utils.MemoryPrf, }, utils.MetaCore, utils.CoreSv1StartMemoryProfiling, args, reply) } -func (dS *DispatcherService) CoreSv1StopMemoryProfiling(args *utils.MemoryPrf, +func (dS *DispatcherService) CoreSv1StopMemoryProfiling(args *utils.TenantWithAPIOpts, reply *string) (err error) { tnt := dS.cfg.GeneralCfg().DefaultTenant if args.Tenant != utils.EmptyString { diff --git a/dispatchers/core_it_test.go b/dispatchers/core_it_test.go index e32c51c72..270b69f9f 100644 --- a/dispatchers/core_it_test.go +++ b/dispatchers/core_it_test.go @@ -135,13 +135,13 @@ func testDspCoreCPUProfile(t *testing.T) { t.Errorf("Unexpected reply returned") } - args = &utils.DirectoryArgs{ + argsStop := &utils.TenantWithAPIOpts{ APIOpts: map[string]interface{}{ utils.OptsAPIKey: "core12345", }, } if err := dispEngine.RPC.Call(utils.CoreSv1StopCPUProfiling, - args, &reply); err != nil { + argsStop, &reply); err != nil { t.Error(err) } else if reply != utils.OK { t.Errorf("Unexpected reply returned") @@ -210,16 +210,13 @@ func testDspCoreMemoryProfile(t *testing.T) { t.Errorf("Unexpected reply returned") } - args = &utils.MemoryPrf{ - DirPath: "/tmp", - Interval: 100 * time.Millisecond, - NrFiles: 2, + argsStop := &utils.TenantWithAPIOpts{ APIOpts: map[string]interface{}{ utils.OptsAPIKey: "core12345", }, } if err := dispEngine.RPC.Call(utils.CoreSv1StopMemoryProfiling, - args, &reply); err != nil { + argsStop , &reply); err != nil { t.Error(err) } else if reply != utils.OK { t.Errorf("Unexpected reply returned")