Beispiel #1
0
 def setUp(self):
     super(CinderLoggerTestCase, self).setUp()
     levels = FLAGS.default_log_levels
     levels.append("cinder-test=AUDIT")
     self.flags(default_log_levels=levels,
                verbose=True)
     log.setup()
     self.log = log.getLogger('cinder-test')
Beispiel #2
0
    def test_error_notification(self):
        self.stubs.Set(cinder.flags.FLAGS, 'notification_driver',
            'cinder.notifier.rabbit_notifier')
        self.stubs.Set(cinder.flags.FLAGS, 'publish_errors', True)
        LOG = log.getLogger('cinder')
        log.setup()
        msgs = []

        def mock_notify(context, topic, data):
            msgs.append(data)

        self.stubs.Set(cinder.openstack.common.rpc, 'notify', mock_notify)
        LOG.error('foo')
        self.assertEqual(1, len(msgs))
        msg = msgs[0]
        self.assertEqual(msg['event_type'], 'error_notification')
        self.assertEqual(msg['priority'], 'ERROR')
        self.assertEqual(msg['payload']['error'], 'foo')
Beispiel #3
0
def run():
    # This is a fix to allow the --hide-elapsed flag while accepting
    # arbitrary nosetest flags as well
    argv = [x for x in sys.argv if x != "--hide-elapsed"]
    hide_elapsed = argv != sys.argv
    logging.setup()

    # If any argument looks like a test name but doesn't have "cinder.tests" in
    # front of it, automatically add that so we don't have to type as much
    for i, arg in enumerate(argv):
        if arg.startswith("test_"):
            argv[i] = "cinder.tests.%s" % arg

    testdir = os.path.abspath(os.path.join("cinder", "tests"))
    c = config.Config(
        stream=sys.stdout, env=os.environ, verbosity=3, workingDir=testdir, plugins=core.DefaultPluginManager()
    )

    runner = CinderTestRunner(stream=c.stream, verbosity=c.verbosity, config=c, show_elapsed=not hide_elapsed)
    sys.exit(not core.run(config=c, testRunner=runner, argv=argv))
Beispiel #4
0
 def test_will_not_be_verbose_if_verbose_flag_not_set(self):
     self.flags(verbose=False)
     log.setup()
     self.assertEqual(logging.INFO, self.log.logger.getEffectiveLevel())
Beispiel #5
0
 def test_will_be_verbose_if_verbose_flag_set(self):
     self.flags(verbose=True)
     log.setup()
     self.assertEqual(logging.DEBUG, self.log.logger.getEffectiveLevel())