Because SQL-MapReduce functions are built to run on data in an Aster instance, testing them locally requires a test program that can simulate the data and services of the cluster. The SDK provides this in the form of the TestRunner (the actual library path and name is sqlmr-sdk/lib/libsqlmr-testrunner.so).
Detailed reference documentation for TestRunner is provided in the header files in sqlmr-sdk/include/sqlmr/testrunner/c/SimpleTest.h and in the supporting headers TestArgumentClause.h and TestColumnDefinition.h.
TestRunner allows you to write a test that:
- Runs an SQL-MapReduce function contained in a specified SQL-MapReduce C executable file (a .so library).
- Provides test input data to the function, using a data input file you specify.
- Simulates other SQL-MapReduce services, such as installed files or temporary storage.
- Writes the test output to files you specify:
The completed runtime contract file provides a list of the output columns of your SQL-MapReduce function, and the datatype of each. For example, if you have built the "test" target in the echo_input example, you will see sqlmr-sdk/example/c/echo_input/build/testoutput/contract.out
The output data file contains the actual output your function produced based on the test input data. For example, (assuming you have built the "test" target), you will see, sqlmr-sdk/example/c/echo_input/build/testoutput/testrun.out
After running the function, the test can then verify the contents of the created output files (for the completed contract and output data).