Uploaded image for project: 'Tajo (Retired)'
  1. Tajo (Retired)
  2. TAJO-476

Add a test development kit for unit tests based on executions of queries

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • None
    • 0.8.0
    • None
    • None

    Description

      Relational algebra has numerous combinations, so SQL queries also have numerous cases that we can't figure out. One nice way of various ways to make and keep Tajo stable is to add lots of unit tests that cover many cases.

      In many unit tests, we use front-end tests which execute SQL queries and verify their results. So far, we have implemented Java code to verify them. I think that its productivity is bad. It finally make us lazy to add various cases.

      This patch adds QueryCaseTestBase class to help developers to add unit tests with little effort. QueryTestCaseBase provides useful methods to easily execute queries and verify their results.

      It uses four resource directories:

      • src/test/resources/dataset - contains a set of data files. It contains sub directories, each of which corresponds each test class. All data files in each sub directory can be used in the corresponding test class.
      • src/test/resources/queries - This is the query directory. It contains sub directories, each of which corresponds each test class. All query files in each sub directory can be used in the corresponding test class.
      • src/test/resources/results - This is the result directory. It contains sub directories, each of which corresponds each test class. All result files in each sub directory can be used in the corresponding test class.

      For example, if you create a test class named TestJoinQuery, you should create a pair of query and result set directories as follows:

          src-|
              |- resources
                    |- dataset
                    |     |- TestJoinQuery
                    |              |- table1.tbl
                    |              |- table2.tbl
                    |
                    |- queries
                    |     |- TestJoinQuery
                    |              |- TestInnerJoin.sql
                    |              |- table1_ddl.sql
                    |              |- table2_ddl.sql
                    |
                    |- results
                          |- TestJoinQuery
                                   |- TestInnerJoin.result
      

      QueryTestCaseBase basically provides the following methods:

      • executeQuery() - executes a corresponding query and returns an ResultSet instance
      • executeQuery(String fileName) - executes a given query file included in the corresponding query file in the current class's query directory
      • assertResultSet() - check if the query result is equivalent to the expected result included in the corresponding result file in the current class's result directory.
      • cleanQuery() - clean up all resources
      • executeDDL() - execute a DDL query like create or drop table.

      In order to make use of the above methods, query files and results file must be as follows:

      • Each query file must be located on the subdirectory whose structure must be src/resources/queries/${ClassName}, where ${ClassName} indicates an actual test class's simple name.
      • Each result file must be located on the subdirectory whose structure must be src/resources/results/${ClassName}, where ${ClassName} indicates an actual test class's simple name.

      Especially, executeQuery() and assertResultSet(ResultSet) methods automatically finds a query file to be executed and a result to be compared, which are corresponding to the running class and method. For them, query and result files must additionally comply the followings:

      • Each result file must have the file extension '.result'
      • Each query file must have the file extension '.sql'.

      Attachments

        1. TAJO-476_20140106_14:50:26.patch
          270 kB
          Hyunsik Choi
        2. TAJO-476.patch
          255 kB
          Hyunsik Choi

        Activity

          People

            hyunsik Hyunsik Choi
            hyunsik Hyunsik Choi
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: