Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Minor improvements to Add a Unit Test

...

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 (where TestAbc is the name of the new class to test only the new testcase), which will be faster than mvn 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 in ql/src/test/queries/clientpositive. (Optionally, add a new XXXXXX.q file for a query that is expected to fail in ql/src/test/queries/clientnegative.)
  • Run mvn test -Dtest=TestCliDriver -Dqfile=XXXXXX.q -Dtest.output.overwrite=true. This will generate a new XXXXXX.q.out file in ql/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 are using Hive 0.11.0 or later, you can specify -Dmodule=ql.

...