Example #1
0
  def run_from_argv(self, argv):
    """
    Runs the tests.

    This management command is unusual in that it doesn't
    use Django's normal argument handling.  (If it did, this
    method would be callled handle().)  We do so to more
    easily pass arbitrary arguments to nose.
    """
    args = argv[2:] # First two are "desktop" and "test"

    # Patch South things in
    south.management.commands.patch_for_test_db_setup()
    south_logger = logging.getLogger('south')
    south_logger.setLevel(logging.INFO)

    if len(args) == 0:
      print self.help
      sys.exit(1)

    nose_args = None
    all_apps = [ app.module.__name__ for app in appmanager.DESKTOP_MODULES ]

    if args[0] == "all":
      nose_args = args + all_apps
    elif args[0] == "impala":
      if len(args) > 1:
        from impala.conf import SERVER_HOST
        SERVER_HOST.set_for_testing(args[1])
      nose_args = ["specific", "impala"]
      args = ["specific"]
    elif args[0] == "fast":
      nose_args = args + all_apps + ["-a", "!requires_hadoop"]
    elif args[0] == "windmill":
      args = args[1:]
      ret = test_windmill.Command().handle(*args)
    elif args[0] in ("specific", "nose"):
      nose_args = args
    else:
      print self.help
      sys.exit(1)

    if nose_args:
      TestRunner = get_runner(settings)
      test_runner = TestRunner(verbosity=1, interactive=False)
      nose_args.remove(args[0])
      ret = test_runner.run_tests(nose_args)

    logging.info("Tests (%s) returned %s" % (' '.join(nose_args), ret))

    if ret != 0:
      sys.exit(1)
Example #2
0
    def setUp(self):
        self.finish = []

        # We need a real Impala cluster currently
        if not 'impala' in sys.argv and not os.environ.get(
                'TEST_IMPALAD_HOST'):
            raise SkipTest

        if os.environ.get('TEST_IMPALAD_HOST'):
            self.finish.append(
                SERVER_HOST.set_for_testing(
                    os.environ.get('TEST_IMPALAD_HOST')))

        self.client = make_logged_in_client()
        self.user = User.objects.get(username='******')
        add_to_group('test')
        self.db = dbms.get(self.user, get_query_server_config(name='impala'))

        hql = """
      USE default;
      DROP TABLE IF EXISTS %(db)s.tweets;
      DROP DATABASE IF EXISTS %(db)s;
      CREATE DATABASE %(db)s;

      USE %(db)s;
    """ % {
            'db': self.DATABASE
        }

        resp = _make_query(self.client,
                           hql,
                           database='default',
                           local=False,
                           server_name='impala')
        resp = wait_for_query_to_finish(self.client, resp, max=30.0)

        hql = """
      CREATE TABLE tweets (row_num INTEGER, id_str STRING, text STRING) STORED AS PARQUET;

      INSERT INTO TABLE tweets VALUES (1, "531091827395682000", "My dad looks younger than costa");
      INSERT INTO TABLE tweets VALUES (2, "531091827781550000", "There is a thin line between your partner being vengeful and you reaping the consequences of your bad actions towards your partner.");
      INSERT INTO TABLE tweets VALUES (3, "531091827768979000", "@Mustang_Sally83 and they need to get into you :))))");
      INSERT INTO TABLE tweets VALUES (4, "531091827114668000", "@RachelZJohnson thank you rach!xxx");
      INSERT INTO TABLE tweets VALUES (5, "531091827949309000", "i think @WWERollins was robbed of the IC title match this week on RAW also i wonder if he will get a rematch i hope so @WWE");
    """

        resp = _make_query(self.client,
                           hql,
                           database=self.DATABASE,
                           local=False,
                           server_name='impala')
        resp = wait_for_query_to_finish(self.client, resp, max=30.0)

        def tearDown(self):
            for f in self.finish:
                f()
Example #3
0
File: tests.py Project: erickt/hue
  def setUp(self):
    self.finish = []

    # We need a real Impala cluster currently
    if not 'impala' in sys.argv and not os.environ.get('TEST_IMPALAD_HOST'):
      raise SkipTest

    if os.environ.get('TEST_IMPALAD_HOST'):
      self.finish.append(SERVER_HOST.set_for_testing(os.environ.get('TEST_IMPALAD_HOST')))

    self.client = make_logged_in_client()
    self.user = User.objects.get(username='******')
    add_to_group('test')
    self.db = dbms.get(self.user, get_query_server_config(name='impala'))

    hql = """
      USE default;
      DROP TABLE IF EXISTS %(db)s.tweets;
      DROP DATABASE IF EXISTS %(db)s;
      CREATE DATABASE %(db)s;

      USE %(db)s;
    """ % {'db': self.DATABASE}

    resp = _make_query(self.client, hql, database='default', local=False, server_name='impala')
    resp = wait_for_query_to_finish(self.client, resp, max=30.0)

    hql = """
      CREATE TABLE tweets (row_num INTEGER, id_str STRING, text STRING) STORED AS PARQUET;

      INSERT INTO TABLE tweets VALUES (1, "531091827395682000", "My dad looks younger than costa");
      INSERT INTO TABLE tweets VALUES (2, "531091827781550000", "There is a thin line between your partner being vengeful and you reaping the consequences of your bad actions towards your partner.");
      INSERT INTO TABLE tweets VALUES (3, "531091827768979000", "@Mustang_Sally83 and they need to get into you :))))");
      INSERT INTO TABLE tweets VALUES (4, "531091827114668000", "@RachelZJohnson thank you rach!xxx");
      INSERT INTO TABLE tweets VALUES (5, "531091827949309000", "i think @WWERollins was robbed of the IC title match this week on RAW also i wonder if he will get a rematch i hope so @WWE");
    """

    resp = _make_query(self.client, hql, database=self.DATABASE, local=False, server_name='impala')
    resp = wait_for_query_to_finish(self.client, resp, max=30.0)

    def tearDown(self):
      for f in self.finish:
        f()