Exemplo n.º 1
0
  def execute_test_case_setup(self, setup_section, table_format):
    """
    Executes a test case 'SETUP' section

    The test case 'SETUP' section is mainly used for insert tests. These tests need to
    have some actions performed before each test case to ensure the target tables are
    empty. The current supported setup actions:
    RESET <table name> - Drop and recreate the table
    DROP PARTITIONS <table name> - Drop all partitions from the table
    """
    setup_section = QueryTestSectionReader.build_query(setup_section)
    for row in setup_section.split('\n'):
      row = row.lstrip()
      if row.startswith('RESET'):
        db_name, table_name = QueryTestSectionReader.get_table_name_components(\
          table_format, row.split('RESET')[1])
        self.__reset_table(db_name, table_name)
        self.client.execute("invalidate metadata " + db_name + "." + table_name)
      elif row.startswith('DROP PARTITIONS'):
        db_name, table_name = QueryTestSectionReader.get_table_name_components(\
          table_format, row.split('DROP PARTITIONS')[1])
        self.__drop_partitions(db_name, table_name)
        self.client.execute("invalidate metadata " + db_name + "." + table_name)
      else:
        assert False, 'Unsupported setup command: %s' % row
Exemplo n.º 2
0
    def execute_test_case_setup(self, setup_section, table_format):
        """
    Executes a test case 'SETUP' section

    The test case 'SETUP' section is mainly used for insert tests. These tests need to
    have some actions performed before each test case to ensure the target tables are
    empty. The current supported setup actions:
    RESET <table name> - Drop and recreate the table
    DROP PARTITIONS <table name> - Drop all partitions from the table
    """
        setup_section = QueryTestSectionReader.build_query(setup_section)
        for row in setup_section.split('\n'):
            row = row.lstrip()
            if row.startswith('RESET'):
                db_name, table_name = QueryTestSectionReader.get_table_name_components(\
                  table_format, row.split('RESET')[1])
                self.__reset_table(db_name, table_name)
                self.client.execute("invalidate metadata " + db_name + "." +
                                    table_name)
            elif row.startswith('DROP PARTITIONS'):
                db_name, table_name = QueryTestSectionReader.get_table_name_components(\
                  table_format, row.split('DROP PARTITIONS')[1])
                self.__drop_partitions(db_name, table_name)
                self.client.execute("invalidate metadata " + db_name + "." +
                                    table_name)
            else:
                assert False, 'Unsupported setup command: %s' % row