Esempio n. 1
0
def set_options(opts):
    global options
    options = opts

    set_mysql_flavor(options.mysql_flavor)
    set_protocols_flavor(options.protocols_flavor)
    set_topo_server_flavor(options.topo_server_flavor)
Esempio n. 2
0
def set_options(opts):
  global options
  options = opts

  set_mysql_flavor(options.mysql_flavor)
  set_protocols_flavor(options.protocols_flavor)
  set_topo_server_flavor(options.topo_server_flavor)
Esempio n. 3
0
def main(mod=None):
  if mod == None:
    mod = sys.modules['__main__']

  global options

  parser = optparse.OptionParser(usage="usage: %prog [options] [test_names]")
  parser.add_option('-d', '--debug', action='store_true', help='utils.pause() statements will wait for user input')
  parser.add_option('--skip-teardown', action='store_true')
  parser.add_option('-k', '--keep-logs', action='store_true',
                    help="Don't delete log files on teardown.")
  parser.add_option("-q", "--quiet", action="store_const", const=0, dest="verbose", default=1)
  parser.add_option("-v", "--verbose", action="store_const", const=2, dest="verbose", default=1)
  parser.add_option("--mysql-flavor", action="store", type="string")

  (options, args) = parser.parse_args()

  if options.verbose == 0:
    level = logging.WARNING
  elif options.verbose == 1:
    level = logging.INFO
  else:
    level = logging.DEBUG
  logging.getLogger().setLevel(level)
  logging.basicConfig(format='-- %(asctime)s %(module)s:%(lineno)d %(levelname)s %(message)s')

  set_mysql_flavor(options.mysql_flavor)

  try:
    suite = unittest.TestSuite()
    if not args:
      # this will run the setup and teardown
      suite.addTests(unittest.TestLoader().loadTestsFromModule(mod))
    else:
      if args[0] == 'teardown':
        mod.tearDownModule()

      elif args[0] == 'setup':
        mod.setUpModule()

      else:
        for arg in args:
          # this will run the setup and teardown
          suite.addTests(unittest.TestLoader().loadTestsFromName(arg, mod))

    if suite.countTestCases() > 0:
      logger = LoggingStream()
      result = unittest.TextTestRunner(stream=logger, verbosity=options.verbose, failfast=True).run(suite)
      if not result.wasSuccessful():
        sys.exit(-1)
  except KeyboardInterrupt:
    logging.warning("======== Tests interrupted, cleaning up ========")
    mod.tearDownModule()
    # If you interrupt a test, you probably want to stop evaluating the rest.
    sys.exit(1)
  finally:
    if options.keep_logs:
      logging.warning("Leaving temporary files behind (--keep-logs), please "
                      "clean up before next run: " + os.environ["VTDATAROOT"])
Esempio n. 4
0
def set_options(opts):
    global options
    options = opts

    set_mysql_flavor(options.mysql_flavor)
    set_protocols_flavor(options.protocols_flavor)
    set_topo_server_flavor(options.topo_server_flavor)
    environment.skip_build = options.skip_build
Esempio n. 5
0
def set_options(opts):
  global options
  options = opts

  set_mysql_flavor(options.mysql_flavor)
  set_protocols_flavor(options.protocols_flavor)
  set_topo_server_flavor(options.topo_server_flavor)
  environment.skip_build = options.skip_build
Esempio n. 6
0
if __name__ == "__main__":
  parser = optparse.OptionParser(usage="usage: %prog [options] [test_names]")
  parser.add_option("-m", "--memcache", action="store_true", default=False,
                    help="starts a memcache d, and tests rowcache")
  parser.add_option("-e", "--env", default='vttablet',
                    help="Environment that will be used. Valid options: vttablet, vtocc")
  parser.add_option("-q", "--quiet", action="store_const", const=0, dest="verbose", default=1)
  parser.add_option("-v", "--verbose", action="store_const", const=2, dest="verbose", default=0)
  parser.add_option('--skip-teardown', action='store_true')
  parser.add_option("--mysql-flavor", action="store", type="string")
  (options, args) = parser.parse_args()

  utils.options = options
  logging.getLogger().setLevel(logging.ERROR)
  set_mysql_flavor(options.mysql_flavor)

  suite = unittest.TestSuite()
  if args:
    if args[0] == 'teardown':
      test_env.TestEnv(options.env).tearDown()
      exit(0)
    for arg in args:
      if hasattr(nocache_tests.TestNocache, arg):
        suite.addTest(nocache_tests.TestNocache(arg))
      elif hasattr(stream_tests.TestStream, arg):
        suite.addTest(stream_tests.TestStream(arg))
      elif hasattr(cache_tests.TestCache, arg) and options.memcache:
        suite.addTest(cache_tests.TestCache(arg))
      elif hasattr(cache_tests.TestWillNotBeCached, arg) and options.memcache:
        suite.addTest(cache_tests.TestWillNotBeCached(arg))
Esempio n. 7
0
  parser = optparse.OptionParser(usage="usage: %prog [options] [test_names]")
  parser.add_option("-m", "--memcache", action="store_true", default=False,
                    help="starts a memcache d, and tests rowcache")
  parser.add_option("-e", "--env", default='vttablet',
                    help="Environment that will be used. Valid options: vttablet, vtocc")
  parser.add_option("-q", "--quiet", action="store_const", const=0, dest="verbose", default=1)
  parser.add_option("-v", "--verbose", action="store_const", const=2, dest="verbose", default=0)
  parser.add_option('--skip-teardown', action='store_true')
  parser.add_option('-k', '--keep-logs', action='store_true',
                    help="Don't delete log files on teardown.")
  parser.add_option("--mysql-flavor", action="store", type="string")
  (options, args) = parser.parse_args()

  utils.options = options
  logging.getLogger().setLevel(logging.ERROR)
  set_mysql_flavor(options.mysql_flavor)

  suite = unittest.TestSuite()
  if args:
    if args[0] == 'teardown':
      test_env.TestEnv(options.env).tearDown()
      exit(0)
    for arg in args:
      if hasattr(nocache_tests.TestNocache, arg):
        suite.addTest(nocache_tests.TestNocache(arg))
      elif hasattr(stream_tests.TestStream, arg):
        suite.addTest(stream_tests.TestStream(arg))
      elif hasattr(cache_tests.TestCache, arg) and options.memcache:
        suite.addTest(cache_tests.TestCache(arg))
      elif hasattr(cache_tests.TestWillNotBeCached, arg) and options.memcache:
        suite.addTest(cache_tests.TestWillNotBeCached(arg))
Esempio n. 8
0
def main(mod=None):
    if mod == None:
        mod = sys.modules['__main__']

    global options

    parser = optparse.OptionParser(usage="usage: %prog [options] [test_names]")
    parser.add_option('-d',
                      '--debug',
                      action='store_true',
                      help='utils.pause() statements will wait for user input')
    parser.add_option('--skip-teardown', action='store_true')
    parser.add_option("-q",
                      "--quiet",
                      action="store_const",
                      const=0,
                      dest="verbose",
                      default=1)
    parser.add_option("-v",
                      "--verbose",
                      action="store_const",
                      const=2,
                      dest="verbose",
                      default=1)
    parser.add_option("--mysql-flavor", action="store", type="string")

    (options, args) = parser.parse_args()

    if options.verbose == 0:
        level = logging.WARNING
    elif options.verbose == 1:
        level = logging.INFO
    else:
        level = logging.DEBUG
    logging.basicConfig(
        format='-- %(asctime)s %(module)s:%(lineno)d %(levelname)s %(message)s',
        level=level)

    set_mysql_flavor(options.mysql_flavor)

    try:
        suite = unittest.TestSuite()
        if not args:
            # this will run the setup and teardown
            suite.addTests(unittest.TestLoader().loadTestsFromModule(mod))
        else:
            if args[0] == 'teardown':
                mod.tearDownModule()

            elif args[0] == 'setup':
                mod.setUpModule()

            else:
                for arg in args:
                    # this will run the setup and teardown
                    suite.addTests(unittest.TestLoader().loadTestsFromName(
                        arg, mod))

        if suite.countTestCases() > 0:
            logger = LoggingStream()
            result = unittest.TextTestRunner(stream=logger,
                                             verbosity=options.verbose,
                                             failfast=True).run(suite)
            if not result.wasSuccessful():
                sys.exit(-1)
    except KeyboardInterrupt:
        logging.warning("======== Tests interrupted, cleaning up ========")
        mod.tearDownModule()
        # If you interrupt a test, you probably want to stop evaluating the rest.
        sys.exit(1)