def test_profile_cputime_twice_by_samedecorator(self): helper.profile_cputime(self.example_package + 'example_a', self.example_package + 'example_cpu_profile_decorator', True) self.assertEqual(len(profile_cpu.modules), 1) helper.profile_cputime(self.example_package + 'example_a', self.example_package + 'example_cpu_profile_decorator', False) self.assertEqual(len(profile_cpu.modules), 0)
def profile_cputime(self, context, module, decorator, status): LOG.info( _( "Received the message for enabling/disabling\ cputime profiling for module %s" ), module, ) helper.profile_cputime(module, decorator, status)
def test_profile_cputime_twice_by_samedecorator(self): helper.profile_cputime( self.example_package + 'example_a', self.example_package + 'example_cpu_profile_decorator', True) self.assertEqual(len(profile_cpu.modules), 1) helper.profile_cputime( self.example_package + 'example_a', self.example_package + 'example_cpu_profile_decorator', False) self.assertEqual(len(profile_cpu.modules), 0)
def test_profile_cputime(self): self._createInvCache() self.mox.StubOutWithMock(helper, 'profile_cputime') helper.profile_cputime(mox.IgnoreArg(), mox.IgnoreArg(), mox.IgnoreArg()) self.mox.ReplayAll() self.manager.profile_cputime(self.context, 'test_name', 'test_decorator', True) self.mox.VerifyAll() self.mox.UnsetStubs()
def test_profile_cputime(self): self._createInvCache() self.mox.StubOutWithMock(helper, 'profile_cputime') helper.profile_cputime( mox.IgnoreArg(), mox.IgnoreArg(), mox.IgnoreArg()) self.mox.ReplayAll() self.manager.profile_cputime( self.context, 'test_name', 'test_decorator', True) self.mox.VerifyAll() self.mox.UnsetStubs()
def test_profile_cputime_throw_excsption(self): helper.profile_cputime( self.example_package + 'example_a_not_available', self.example_package + 'example_cpu_profile_decorator', True) healthnmon.tests.profiler.CPU_PROFILE_CALLED_FUNCTION = [] package_a = self.example_package + 'example_a.' self.assertFalse(package_a + 'example_function_a' in healthnmon.tests.profiler.CPU_PROFILE_CALLED_FUNCTION) self.assertFalse(package_a + 'ExampleClassA.example_method' in healthnmon.tests.profiler.CPU_PROFILE_CALLED_FUNCTION) self.assertFalse(package_a + 'ExampleClassA.example_method_add' in healthnmon.tests.profiler.CPU_PROFILE_CALLED_FUNCTION)
def test_disable_profile_cputime_by_decorator(self): helper.profile_cputime(self.example_package + 'example_a', self.example_package + 'example_cpu_profile_decorator', False) healthnmon.tests.profiler.CPU_PROFILE_CALLED_FUNCTION = [] self.assertEqual('Example function', example_a.example_function_a()) exampleA = example_a.ExampleClassA() exampleA.example_method() ret_a = exampleA.example_method_add(3, 5) self.assertEqual(ret_a, 8) package_a = self.example_package + 'example_a.' self.assertTrue(package_a + 'example_function_a' in healthnmon.tests.profiler.CPU_PROFILE_CALLED_FUNCTION) self.assertTrue(package_a + 'ExampleClassA.example_method' in healthnmon.tests.profiler.CPU_PROFILE_CALLED_FUNCTION) self.assertTrue(package_a + 'ExampleClassA.example_method_add' in healthnmon.tests.profiler.CPU_PROFILE_CALLED_FUNCTION) self.assertEqual(len(profile_cpu.modules), 0)
def test_disable_profile_cputime_by_decorator(self): helper.profile_cputime( self.example_package + 'example_a', self.example_package + 'example_cpu_profile_decorator', False) healthnmon.tests.profiler.CPU_PROFILE_CALLED_FUNCTION = [] self.assertEqual('Example function', example_a.example_function_a()) exampleA = example_a.ExampleClassA() exampleA.example_method() ret_a = exampleA.example_method_add(3, 5) self.assertEqual(ret_a, 8) package_a = self.example_package + 'example_a.' self.assertTrue(package_a + 'example_function_a' in healthnmon.tests.profiler.CPU_PROFILE_CALLED_FUNCTION) self.assertTrue(package_a + 'ExampleClassA.example_method' in healthnmon.tests.profiler.CPU_PROFILE_CALLED_FUNCTION) self.assertTrue(package_a + 'ExampleClassA.example_method_add' in healthnmon.tests.profiler.CPU_PROFILE_CALLED_FUNCTION) self.assertEqual(len(profile_cpu.modules), 0)