Exemplo n.º 1
0
    def setUp(self):
        super(BaseTestCase, self).setUp()
        if not self.__setupclass_called:
            raise RuntimeError("setUpClass does not calls the super's "
                               "setUpClass in the " +
                               self.__class__.__name__)
        at_exit_set.add(self.__class__)
        test_timeout = os.environ.get('OS_TEST_TIMEOUT', 0)
        try:
            test_timeout = int(test_timeout) * self.TIMEOUT_SCALING_FACTOR
        except ValueError:
            test_timeout = 0
        if test_timeout > 0:
            self.useFixture(fixtures.Timeout(test_timeout, gentle=True))

        if (os.environ.get('OS_STDOUT_CAPTURE') == 'True' or
                os.environ.get('OS_STDOUT_CAPTURE') == '1'):
            stdout = self.useFixture(fixtures.StringStream('stdout')).stream
            self.useFixture(fixtures.MonkeyPatch('sys.stdout', stdout))
        if (os.environ.get('OS_STDERR_CAPTURE') == 'True' or
                os.environ.get('OS_STDERR_CAPTURE') == '1'):
            stderr = self.useFixture(fixtures.StringStream('stderr')).stream
            self.useFixture(fixtures.MonkeyPatch('sys.stderr', stderr))
        if (os.environ.get('OS_LOG_CAPTURE') != 'False' and
                os.environ.get('OS_LOG_CAPTURE') != '0'):
            self.useFixture(fixtures.LoggerFixture(nuke_handlers=False,
                                                   format=self.log_format,
                                                   level=None))
        if CONF.profiler.key:
            profiler.enable(CONF.profiler.key)
Exemplo n.º 2
0
    def setUp(self):
        super(BaseTestCase, self).setUp()
        if not self.__setupclass_called:
            raise RuntimeError("setUpClass does not calls the super's "
                               "setUpClass in the " +
                               self.__class__.__name__)
        at_exit_set.add(self.__class__)
        test_timeout = os.environ.get('OS_TEST_TIMEOUT', 0)
        try:
            test_timeout = int(test_timeout) * self.TIMEOUT_SCALING_FACTOR
        except ValueError:
            test_timeout = 0
        if test_timeout > 0:
            self.useFixture(fixtures.Timeout(test_timeout, gentle=True))

        if (os.environ.get('OS_STDOUT_CAPTURE') == 'True' or
                os.environ.get('OS_STDOUT_CAPTURE') == '1'):
            stdout = self.useFixture(fixtures.StringStream('stdout')).stream
            self.useFixture(fixtures.MonkeyPatch('sys.stdout', stdout))
        if (os.environ.get('OS_STDERR_CAPTURE') == 'True' or
                os.environ.get('OS_STDERR_CAPTURE') == '1'):
            stderr = self.useFixture(fixtures.StringStream('stderr')).stream
            self.useFixture(fixtures.MonkeyPatch('sys.stderr', stderr))
        if (os.environ.get('OS_LOG_CAPTURE') != 'False' and
                os.environ.get('OS_LOG_CAPTURE') != '0'):
            self.useFixture(fixtures.LoggerFixture(nuke_handlers=False,
                                                   format=self.log_format,
                                                   level=None))
        if CONF.profiler.key:
            profiler.enable(CONF.profiler.key)
Exemplo n.º 3
0
    def test_profiler_lifecycle(self):
        key = 'SECRET_KEY'
        uuid = 'ID'

        self.assertEqual({}, profiler._profiler)

        profiler.enable(key, uuid)
        self.assertEqual({'key': key, 'uuid': uuid}, profiler._profiler)

        profiler.disable()
        self.assertEqual({}, profiler._profiler)
Exemplo n.º 4
0
    def test_profiler_lifecycle(self):
        key = 'SECRET_KEY'
        uuid = 'ID'

        self.assertEqual({}, profiler._profiler)

        profiler.enable(key, uuid)
        self.assertEqual({'key': key, 'uuid': uuid}, profiler._profiler)

        profiler.disable()
        self.assertEqual({}, profiler._profiler)
Exemplo n.º 5
0
    def test_profiler_lifecycle_generate_trace_id(self, generate_uuid_mock):
        key = 'SECRET_KEY'
        uuid = 'ID'
        generate_uuid_mock.return_value = uuid

        self.assertEqual({}, profiler._profiler)

        profiler.enable(key)
        self.assertEqual({'key': key, 'uuid': uuid}, profiler._profiler)

        profiler.disable()
        self.assertEqual({}, profiler._profiler)
Exemplo n.º 6
0
    def test_profiler_lifecycle_generate_trace_id(self, generate_uuid_mock):
        key = 'SECRET_KEY'
        uuid = 'ID'
        generate_uuid_mock.return_value = uuid

        self.assertEqual({}, profiler._profiler)

        profiler.enable(key)
        self.assertEqual({'key': key, 'uuid': uuid}, profiler._profiler)

        profiler.disable()
        self.assertEqual({}, profiler._profiler)