Exemplo n.º 1
0
    def test_profile_memory_twice_by_samedecorator(self):

        helper.profile_memory(
            self.example_package + 'example_a.example_function_a',
            self.example_package + 'example_memory_profile_decorator', True,
            True)

        helper.profile_memory(
            self.example_package + 'example_a.example_function_a',
            self.example_package + 'example_memory_profile_decorator', False,
            True)

        healthnmon.tests.profiler.MEMORY_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.MEMORY_PROFILE_CALLED_FUNCTION)

        self.assertFalse(
            package_a + 'ExampleClassA.example_method' in
            healthnmon.tests.profiler.MEMORY_PROFILE_CALLED_FUNCTION)
        self.assertFalse(
            package_a + 'ExampleClassA.example_method_add' in
            healthnmon.tests.profiler.MEMORY_PROFILE_CALLED_FUNCTION)
Exemplo n.º 2
0
    def test_profile_memory_twice_by_samedecorator(self):

        helper.profile_memory(
            self.example_package + 'example_a.example_function_a',
            self.example_package + 'example_memory_profile_decorator', True, True)

        helper.profile_memory(
            self.example_package + 'example_a.example_function_a',
            self.example_package + 'example_memory_profile_decorator', False, True)

        healthnmon.tests.profiler.MEMORY_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.MEMORY_PROFILE_CALLED_FUNCTION)

        self.assertFalse(package_a + 'ExampleClassA.example_method'
                         in healthnmon.tests.profiler.MEMORY_PROFILE_CALLED_FUNCTION)
        self.assertFalse(package_a + 'ExampleClassA.example_method_add'
                         in healthnmon.tests.profiler.MEMORY_PROFILE_CALLED_FUNCTION)
Exemplo n.º 3
0
    def profile_memory(self, context, method, decorator, status, setref):
        LOG.info(
            _(
                "Received the message for enabling/disabling \
        memory profiling for method %s "
            ),
            method,
        )

        helper.profile_memory(method, decorator, status, setref)
Exemplo n.º 4
0
    def test_profile_memory(self):
        self._createInvCache()
        self.mox.StubOutWithMock(helper, 'profile_memory')
        helper.profile_memory(mox.IgnoreArg(), mox.IgnoreArg(),
                              mox.IgnoreArg(), mox.IgnoreArg())

        self.mox.ReplayAll()
        self.manager.profile_memory(self.context, 'test_name',
                                    'test_decorator', True, True)
        self.mox.VerifyAll()
        self.mox.UnsetStubs()
Exemplo n.º 5
0
    def test_profile_memory(self):
        self._createInvCache()
        self.mox.StubOutWithMock(helper,
                                 'profile_memory')
        helper.profile_memory(mox.IgnoreArg(
        ), mox.IgnoreArg(), mox.IgnoreArg(), mox.IgnoreArg())

        self.mox.ReplayAll()
        self.manager.profile_memory(
            self.context, 'test_name', 'test_decorator', True, True)
        self.mox.VerifyAll()
        self.mox.UnsetStubs()
Exemplo n.º 6
0
    def test_profile_memory_throw_exception(self):
        helper.profile_memory(
            self.example_package + 'example_a.example_a_not_available',
            self.example_package + 'example_memory_profile_decorator', True, True)
        healthnmon.tests.profiler.MEMORY_PROFILE_CALLED_FUNCTION = []

        package_a = self.example_package + 'example_a.'
        self.assertFalse(package_a + 'example_function_a'
                         in healthnmon.tests.profiler.MEMORY_PROFILE_CALLED_FUNCTION)

        self.assertFalse(package_a + 'ExampleClassA.example_method'
                         in healthnmon.tests.profiler.MEMORY_PROFILE_CALLED_FUNCTION)
        self.assertFalse(package_a + 'ExampleClassA.example_method_add'
                         in healthnmon.tests.profiler.MEMORY_PROFILE_CALLED_FUNCTION)
Exemplo n.º 7
0
    def test_profile_memory_throw_exception(self):
        helper.profile_memory(
            self.example_package + 'example_a.example_a_not_available',
            self.example_package + 'example_memory_profile_decorator', True,
            True)
        healthnmon.tests.profiler.MEMORY_PROFILE_CALLED_FUNCTION = []

        package_a = self.example_package + 'example_a.'
        self.assertFalse(package_a + 'example_function_a' in healthnmon.tests.
                         profiler.MEMORY_PROFILE_CALLED_FUNCTION)

        self.assertFalse(
            package_a + 'ExampleClassA.example_method' in
            healthnmon.tests.profiler.MEMORY_PROFILE_CALLED_FUNCTION)
        self.assertFalse(
            package_a + 'ExampleClassA.example_method_add' in
            healthnmon.tests.profiler.MEMORY_PROFILE_CALLED_FUNCTION)