tajo-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Hyunsik Choi (JIRA)" <j...@apache.org>
Subject [jira] [Updated] (TAJO-476) Add a test development kit for unit tests based on executions of queries
Date Sat, 04 Jan 2014 12:26:50 GMT

     [ https://issues.apache.org/jira/browse/TAJO-476?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Hyunsik Choi updated TAJO-476:
------------------------------

    Attachment: TAJO-476.patch

> Add a test development kit for unit tests based on executions of queries
> ------------------------------------------------------------------------
>
>                 Key: TAJO-476
>                 URL: https://issues.apache.org/jira/browse/TAJO-476
>             Project: Tajo
>          Issue Type: Improvement
>            Reporter: Hyunsik Choi
>            Assignee: Hyunsik Choi
>             Fix For: 0.8-incubating
>
>         Attachments: TAJO-476.patch
>
>
> 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:
> {noformat}
>     src-|
>         |- resources
>               |- dataset
>               |     |- TestJoinQuery
>               |              |- table1.tbl
>               |              |- table2.tbl
>               |
>               |- queries
>               |     |- TestJoinQuery
>               |              |- TestInnerJoin.sql
>               |              |- table1_ddl.sql
>               |              |- table2_ddl.sql
>               |
>               |- results
>                     |- TestJoinQuery
>                              |- TestInnerJoin.result
> {noformat}
> 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'.



--
This message was sent by Atlassian JIRA
(v6.1.5#6160)

Mime
View raw message