org.apache.hadoop.hive.ql
Class QTestUtil

java.lang.Object
  extended by org.apache.hadoop.hive.ql.QTestUtil
Direct Known Subclasses:
TestLocationQueries.CheckResults

public class QTestUtil
extends Object

QTestUtil.


Nested Class Summary
static class QTestUtil.QTestSetup
          QTestSetup defines test fixtures which are reused across testcases, and are needed before any test can be run
static class QTestUtil.QTRunner
          QTRunner: Runnable class for running a a single query file.
 
Field Summary
protected  HiveConf conf
           
protected  String logDir
           
protected  String outDir
           
protected  boolean overWrite
           
static HashSet<String> srcTables
           
 
Constructor Summary
QTestUtil(String outDir, String logDir)
           
QTestUtil(String outDir, String logDir, boolean miniMr, String hadoopVer)
           
 
Method Summary
 void addFile(File qf)
           
 void addFile(String qFile)
           
 List<Task<? extends Serializable>> analyzeAST(ASTNode ast)
           
 int checkCliDriverResults(String tname)
           
 int checkNegativeResults(String tname, Exception e)
           
 int checkParseResults(String tname, ASTNode tree)
           
 int checkPlan(String tname, List<Task<? extends Serializable>> tasks)
           
 void cleanUp()
           
 void clearPostTestEffects()
          Clear out any side effects of running tests
 void clearTestSideEffects()
          Clear out any side effects of running tests
 void cliInit(String tname)
           
 void cliInit(String tname, boolean recreate)
           
 void convertSequenceFileToTextFile()
           
 void copyDirectoryToLocal(org.apache.hadoop.fs.Path src, org.apache.hadoop.fs.Path dest)
           
 void createSources()
           
 boolean deleteDirectory(File path)
           
 int execute(String tname)
           
 int executeClient(String tname)
           
 int executeOne(String tname)
           
 String getLogDirectory()
           
 String getOutputDirectory()
           
 TreeMap<String,String> getQMap()
           
 void init()
           
 void init(String tname)
           
 void initConf()
           
 void normalizeNames(File path)
           
 String outPath(String outDir, String testName)
          Given the current configurations (e.g., hadoop version and execution mode), return the correct file name to compare with the current test run output.
static void outputTestFailureHelpMessage()
           
 ASTNode parseQuery(String tname)
           
static boolean queryListRunnerMultiThreaded(File[] qfiles, QTestUtil[] qt)
          Executes a set of query files parallel.
static QTestUtil[] queryListRunnerSetup(File[] qfiles, String resDir, String logDir)
          Setup to execute a set of query files.
static boolean queryListRunnerSingleThreaded(File[] qfiles, QTestUtil[] qt)
          Executes a set of query files in sequence.
 void resetParser()
           
 boolean shouldBeSkipped(String tname)
           
 void shutdown()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

outDir

protected final String outDir

logDir

protected final String logDir

srcTables

public static final HashSet<String> srcTables

conf

protected HiveConf conf

overWrite

protected final boolean overWrite
Constructor Detail

QTestUtil

public QTestUtil(String outDir,
                 String logDir)
          throws Exception
Throws:
Exception

QTestUtil

public QTestUtil(String outDir,
                 String logDir,
                 boolean miniMr,
                 String hadoopVer)
          throws Exception
Throws:
Exception
Method Detail

deleteDirectory

public boolean deleteDirectory(File path)

copyDirectoryToLocal

public void copyDirectoryToLocal(org.apache.hadoop.fs.Path src,
                                 org.apache.hadoop.fs.Path dest)
                          throws Exception
Throws:
Exception

normalizeNames

public void normalizeNames(File path)
                    throws Exception
Throws:
Exception

getOutputDirectory

public String getOutputDirectory()

getLogDirectory

public String getLogDirectory()

initConf

public void initConf()
              throws Exception
Throws:
Exception

shutdown

public void shutdown()
              throws Exception
Throws:
Exception

addFile

public void addFile(String qFile)
             throws Exception
Throws:
Exception

addFile

public void addFile(File qf)
             throws Exception
Throws:
Exception

clearPostTestEffects

public void clearPostTestEffects()
                          throws Exception
Clear out any side effects of running tests

Throws:
Exception

clearTestSideEffects

public void clearTestSideEffects()
                          throws Exception
Clear out any side effects of running tests

Throws:
Exception

cleanUp

public void cleanUp()
             throws Exception
Throws:
Exception

createSources

public void createSources()
                   throws Exception
Throws:
Exception

init

public void init()
          throws Exception
Throws:
Exception

init

public void init(String tname)
          throws Exception
Throws:
Exception

cliInit

public void cliInit(String tname)
             throws Exception
Throws:
Exception

cliInit

public void cliInit(String tname,
                    boolean recreate)
             throws Exception
Throws:
Exception

executeOne

public int executeOne(String tname)

execute

public int execute(String tname)

executeClient

public int executeClient(String tname)

shouldBeSkipped

public boolean shouldBeSkipped(String tname)

convertSequenceFileToTextFile

public void convertSequenceFileToTextFile()
                                   throws Exception
Throws:
Exception

checkNegativeResults

public int checkNegativeResults(String tname,
                                Exception e)
                         throws Exception
Throws:
Exception

checkParseResults

public int checkParseResults(String tname,
                             ASTNode tree)
                      throws Exception
Throws:
Exception

checkPlan

public int checkPlan(String tname,
                     List<Task<? extends Serializable>> tasks)
              throws Exception
Throws:
Exception

outPath

public String outPath(String outDir,
                      String testName)
Given the current configurations (e.g., hadoop version and execution mode), return the correct file name to compare with the current test run output.

Parameters:
outDir - The directory where the reference log files are stored.
testName - The test file name (terminated by ".out").
Returns:
The file name appended with the configuration values if it exists.

checkCliDriverResults

public int checkCliDriverResults(String tname)
                          throws Exception
Throws:
Exception

parseQuery

public ASTNode parseQuery(String tname)
                   throws Exception
Throws:
Exception

resetParser

public void resetParser()
                 throws SemanticException
Throws:
SemanticException

analyzeAST

public List<Task<? extends Serializable>> analyzeAST(ASTNode ast)
                                              throws Exception
Throws:
Exception

getQMap

public TreeMap<String,String> getQMap()

queryListRunnerSetup

public static QTestUtil[] queryListRunnerSetup(File[] qfiles,
                                               String resDir,
                                               String logDir)
                                        throws Exception
Setup to execute a set of query files. Uses QTestUtil to do so.

Parameters:
qfiles - array of input query files containing arbitrary number of hive queries
resDir - output directory
logDir - log directory
Returns:
one QTestUtil for each query file
Throws:
Exception

queryListRunnerSingleThreaded

public static boolean queryListRunnerSingleThreaded(File[] qfiles,
                                                    QTestUtil[] qt)
                                             throws Exception
Executes a set of query files in sequence.

Parameters:
qfiles - array of input query files containing arbitrary number of hive queries
qt - array of QTestUtils, one per qfile
Returns:
true if all queries passed, false otw
Throws:
Exception

queryListRunnerMultiThreaded

public static boolean queryListRunnerMultiThreaded(File[] qfiles,
                                                   QTestUtil[] qt)
                                            throws Exception
Executes a set of query files parallel. Each query file is run in a separate thread. The caller has to arrange that different query files do not collide (in terms of destination tables)

Parameters:
qfiles - array of input query files containing arbitrary number of hive queries
qt - array of QTestUtils, one per qfile
Returns:
true if all queries passed, false otw
Throws:
Exception

outputTestFailureHelpMessage

public static void outputTestFailureHelpMessage()


Copyright © 2013 The Apache Software Foundation