...
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 in Hive:
...
Normal Unit Test
These are used by testing a particular component of Hive.
- We just need to add Add a new class (name must start with "
Test
") in*/src/test
directory. - We can run "Run
mvn test -Dtest=TestAbc
" whereTestAbc
is the name of the new class . This will to test only the new testcase, which will be faster than "mvn test
" which tests all testcases.
A
...
New Query
If the new feature can be tested using Hive command line, we just need to add a new *.q
file and a new *.q.out
file
...
.
If the feature is added in ql
:
- Add a new
XXXXXX.q
file inql/src/test/queries/clientpositive
. - 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 specifying "join*.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-Hive 0.11.0 or later, you can specify "
-Dmodule=ql
".
If the feature is added in contrib
:
- Do the steps above, replacing "
ql
" with "contrib
", and "TestCliDriver
" with "TestContribCliDriver
". - If you are using hive-Hive 0.11.0 or later, you can specify "
-Dmodule=contrib
".
Debugging
Please see Debugging Hive code in Development Guide.
...