def testLoggingConfigPath(self):
     # getLoggingConfTemplatePath() should return path to ../logging.conf
     tempLS = LS()
     tempLS.initLogging()
     self.assertEqual(
         os.path.join(logging_support_raw._APPLICATION_CONF_DIR,
                      "logging.conf"), tempLS.getLoggingConfTemplatePath())
Exemplo n.º 2
0
 def testLoggingRootPath(self):
   # getLoggingRootDir() should return the temp path
   with self._redirectLogBase("logging_example", _SAMPLE_CONNECTION_CONTENTS):
     tempLS = LS()
     tempLS.initLogging("DEBUG", "stderr", True)
     self.assertEqual(tempLS.getLoggingRootDir(),
                      os.path.join(self._tempDir, "log"))
Exemplo n.º 3
0
 def testLogFilePathExists(self):
   # Directory containing the log file should be created; loggin_support.py line 250-257
   with self._redirectLogBase("logging_example", _SAMPLE_CONNECTION_CONTENTS):
     temp_ls = LS()
     temp_ls.initLogging("DEBUG", "stderr", True)
     path = temp_ls.getApplicationLogFilePath()
     self.assertTrue(os.path.isdir(os.path.dirname(path)))
Exemplo n.º 4
0
 def testLoggingAppPath(self):
   # getApplicationLogFilePath() should return path to ../app_name.log
   app_name = "py"  # Because called with py.test
   with self._redirectLogBase(app_name, _SAMPLE_CONNECTION_CONTENTS):
     temp_ls = LS()
     temp_ls.initLogging("DEBUG", "stderr", True)
     self.assertEqual(os.path.abspath(os.path.join(temp_ls.getLoggingRootDir(), "processes", app_name + ".log")), temp_ls.getApplicationLogFilePath())
Exemplo n.º 5
0
 def testLoggingAppPath(self):
   # getApplicationLogFilePath() should return path to ../app_name.log
   app_name = "py"  # Because called with py.test
   with self._redirectLogBase(app_name, _SAMPLE_CONNECTION_CONTENTS):
     temp_ls = LS()
     temp_ls.initLogging("DEBUG", "stderr", True)
     self.assertEqual(os.path.abspath(os.path.join(temp_ls.getLoggingRootDir(), "processes", app_name + ".log")), temp_ls.getApplicationLogFilePath())
Exemplo n.º 6
0
 def testLogFilePathExists(self):
   # Directory containing the log file should be created; loggin_support.py line 250-257
   with self._redirectLogBase("logging_example", _SAMPLE_CONNECTION_CONTENTS):
     temp_ls = LS()
     temp_ls.initLogging("DEBUG", "stderr", True)
     path = temp_ls.getApplicationLogFilePath()
     self.assertTrue(os.path.isdir(os.path.dirname(path)))
Exemplo n.º 7
0
 def testLoggingConfigPath(self):
   # getLoggingConfTemplatePath() should return path to ../logging.conf
   tempLS = LS()
   tempLS.initLogging()
   self.assertEqual(os.path.join(logging_support_raw._APPLICATION_CONF_DIR,
                                 "logging.conf"),
                    tempLS.getLoggingConfTemplatePath())
Exemplo n.º 8
0
 def testInitLoggingInputs(self):
   # Invalid loggingLevel throws a ValueError
   temp_ls = LS()
   with self.assertRaises(ValueError):
     temp_ls.initLogging("DEBUGGING")
   # Invalid console throws a ValueError
   with self.assertRaises(ValueError):
     temp_ls.initLogging("DEBUG", "stderror")
 def testLoggingRootPath(self):
     # getLoggingRootDir() should return the temp path
     with self._redirectLogBase("logging_example",
                                _SAMPLE_CONNECTION_CONTENTS):
         tempLS = LS()
         tempLS.initLogging("DEBUG", "stderr", True)
         self.assertEqual(tempLS.getLoggingRootDir(),
                          os.path.join(self._tempDir, "log"))
 def testInitLoggingInputs(self):
     # Invalid loggingLevel throws a ValueError
     tempLS = LS()
     with self.assertRaises(ValueError):
         tempLS.initLogging("DEBUGGING")
     # Invalid console throws a ValueError
     with self.assertRaises(ValueError):
         tempLS.initLogging("DEBUG", "stderror")
Exemplo n.º 11
0
 def testInitLoggingNullHandlers(self):
   # Null handlers should throw ConfigParser.NoOptionError and print a
   # sys.stderr message
   tempLS = LS()
   with self.assertRaises(ConfigParser.NoOptionError):
     tempLS.initLogging(None, None)
     self.assertEqual(sys.stderr.getvalue(),
                      ("WARNING: logging_support is disabling logging output "
                       "because all output handlers are disabled"))
Exemplo n.º 12
0
 def testInitLoggingNullHandlers(self):
     # Null handlers should throw ConfigParser.NoOptionError and print a sys.stderr message
     temp_ls = LS()
     with self.assertRaises(ConfigParser.NoOptionError):
         temp_ls.initLogging(None, None)
         assertEqual(
             sys.stderr.getvalue(),
             "WARNING: logging_support is disabling logging output because all output handlers are disabled"
         )
Exemplo n.º 13
0
 def testLoggingAppPath(self):
   # getApplicationLogFilePath() should return path to ../appName.log
   appName = os.path.splitext(os.path.basename(sys.argv[0]))[0]
   with self._redirectLogBase(appName, _SAMPLE_CONNECTION_CONTENTS):
     tempLS = LS()
     tempLS.initLogging("DEBUG", "stderr", True)
     self.assertEqual(os.path.abspath(os.path.join(tempLS.getLoggingRootDir(),
                                                   "processes",
                                                   appName + ".log")),
                      tempLS.getApplicationLogFilePath())
   self.assertIn(appName, ["py", "run_tests"])
 def testLoggingAppPath(self):
     # getApplicationLogFilePath() should return path to ../appName.log
     appName = os.path.splitext(os.path.basename(sys.argv[0]))[0]
     with self._redirectLogBase(appName, _SAMPLE_CONNECTION_CONTENTS):
         tempLS = LS()
         tempLS.initLogging("DEBUG", "stderr", True)
         self.assertEqual(
             os.path.abspath(
                 os.path.join(tempLS.getLoggingRootDir(), "processes",
                              appName + ".log")),
             tempLS.getApplicationLogFilePath())
     self.assertIn(appName, ["py", "run_tests"])
Exemplo n.º 15
0
  def testLoggingInitForUsageExamples(self):
    g_log = logging.getLogger("my_example")
    assert isinstance(g_log, logging.Logger)

    with self._redirectLogBase("logging_example", _SAMPLE_CONNECTION_CONTENTS):
      # Test logging init for a tool
      self.assertEqual(LS.initTool(), LS.initLogging(None, console="stderr", logToFile=True))

      # Test logging init for a service
      self.assertEqual(LS.initService(), LS.initLogging(None, console="stderr", logToFile=False))

      # Test logging init for a test app
      self.assertEqual(LS.initTestApp(), LS.initLogging(None, console="stderr", logToFile=False))
Exemplo n.º 16
0
  def testLoggingInitForUsageExamples(self):
    g_log = logging.getLogger("my_example")
    assert isinstance(g_log, logging.Logger)

    with self._redirectLogBase("logging_example", _SAMPLE_CONNECTION_CONTENTS):
      # Test logging init for a tool
      self.assertEqual(LS.initTool(), LS.initLogging(None, console="stderr", logToFile=True))

      # Test logging init for a service
      self.assertEqual(LS.initService(), LS.initLogging(None, console="stderr", logToFile=False))

      # Test logging init for a test app
      self.assertEqual(LS.initTestApp(), LS.initLogging(None, console="stderr", logToFile=False))
Exemplo n.º 17
0
def setUpModule():
    LoggingSupport.initTestApp()
Exemplo n.º 18
0
def setUpModule():
  LoggingSupport.initTestApp()
  (options, args) = parser.parse_args(argv[1:])
  if len(args) > 0:
    parser.error("Didn't expect any positional args (%r)." % (args,))

  options.concurrency = _getDefaultConcurrency(options.concurrency)

  needRestart = True
  while needRestart:
    with ModelSchedulerService(concurrency=options.concurrency) as scheduler:
      needRestart = scheduler.run()



if __name__ == "__main__":
  LoggingSupport.initService()

  logger = _getLogger()
  logger.setLogPrefix('<%s, SERVICE=SCHED> ' % getStandardLogPrefix())

  try:
    logger.info("{TAG:SWAP.SCHED.START}")
    main(sys.argv)
  except SystemExit as e:
    if e.code != 0:
      logger.exception("{TAG:SWAP.SCHED.STOP.ABORT}")
      raise
  except:
    logger.exception("{TAG:SWAP.SCHED.STOP.ABORT}")
    raise
Exemplo n.º 20
0
    (options, args) = parser.parse_args(argv[1:])
    if len(args) > 0:
        parser.error("Didn't expect any positional args (%r)." % (args, ))

    if options.modelID is None:
        parser.error("Missing model ID in command-line")

    with ModelRunner(modelID=options.modelID) as runner:
        runner.run()


if __name__ == "__main__":
    # NOTE: we initialize logging as a service so that our logging output will be
    # funneled via console to our parent process (model_scheduler service)
    LoggingSupport.initService()

    logger = _getLogger()
    logger.setLogPrefix('<%s, SERVICE=MRUN> ' % getStandardLogPrefix())

    try:
        logger.info("{TAG:SWAP.MR.START} argv=%r", sys.argv)
        main(sys.argv)
    except SystemExit as e:
        if e.code != 0:
            logger.exception("{TAG:SWAP.MR.STOP.ABORT}")
            raise
    except:
        logger.exception("{TAG:SWAP.MR.STOP.ABORT}")
        raise
def setUpModule():
  LoggingSupport.initTestApp()

  global g_log  # pylint: disable=W0603
  g_log = getExtendedLogger("custom_datasource_adapter_test")
Exemplo n.º 22
0
def setUpModule():
    LoggingSupport.initTestApp()

    global g_log  # pylint: disable=W0603
    g_log = getExtendedLogger("custom_datasource_adapter_test")