...
Unit tests take a long time (several hours) to run sequentially even on a very fast machine; for information on how to run them in parallel, see Hive PreCommit Patch Testing.
Add a Unit Test
...
There are two kinds of unit tests that can be added: those that test an entire component of Hive, and those that run a query to test a feature.
Java Unit Test
These are used by testing To test a particular component of Hive.:
- Add a new class (name must start with
Test
) in the component's*/src/test
directory. - To test only the new testcase, run Run
mvn test -Dtest=TestAbc
(whereTestAbc
is the name of the new class to test only the new testcase), which will be faster thanmvn test
which tests all testcases.
...
Query Unit Test
If the new feature can be tested using a Hive query in the command line, we just need to add a new *.q
file and a new *.q.out
file.
If the feature is added in ql
(query language):
- Add a new
XXXXXX.q
file inql/src/test/queries/clientpositive
. (Optionally, add a newXXXXXX.q
file for a query that is expected to fail inql/src/test/queries/clientnegative
.) - Run
mvn test -Dtest=TestCliDriver -Dqfile=XXXXXX.q -Dtest.output.overwrite=true
. This will generate a newXXXXXX.q.out
file inql/src/test/results/clientpositive
.- If you want to run multiple .q files in the test run, you can specify comma separated .q files, for example
-Dqfile="X1.q,X2.q"
. You can also specify a Java regex, for example-Dqfile_regex='join.*'
. (Note that it takes Java regex, i.e.,'join.*
and not'
'join*'
.) . The regex match first removes the.q
from the file name before matching regex, so specifyingjoin*.q
will not work.
- If you want to run multiple .q files in the test run, you can specify comma separated .q files, for example
- If you are using Hive 0.11.0 or later, you can specify
-Dmodule=ql
.
...