Improve the Testing Framework

This change includes the following improvements to the test framework
1. Checking each expected failure against the failure exception.
2. Checking against multiple causes of failure in case of multiple
expected errors.
3. Check if a test that is expected to fail pass.
4. Make temp datasets use different storage path.

Change-Id: I957ecf19bf7209981e010e0e50fb882442a525dd
Reviewed-on: https://asterix-gerrit.ics.uci.edu/537
Tested-by: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Reviewed-by: abdullah alamoudi <bamousaa@gmail.com>
diff --git a/asterix-app/src/test/resources/runtimets/testsuite_sqlpp.xml b/asterix-app/src/test/resources/runtimets/testsuite_sqlpp.xml
index 81466bc..4852f8f 100644
--- a/asterix-app/src/test/resources/runtimets/testsuite_sqlpp.xml
+++ b/asterix-app/src/test/resources/runtimets/testsuite_sqlpp.xml
@@ -111,19 +111,19 @@
         <test-case FilePath="aggregate">
             <compilation-unit name="avg_mixed">
                 <output-dir compare="Text">avg_mixed</output-dir>
-                <expected-error>org.apache.asterix.common.exceptions.AsterixException</expected-error>
+                <expected-error>org.apache.hyracks.algebricks.common.exceptions.AlgebricksException: Unexpected type</expected-error>
             </compilation-unit>
         </test-case>
         <test-case FilePath="aggregate">
             <compilation-unit name="sum_mixed">
                 <output-dir compare="Text">sum_mixed</output-dir>
-                <expected-error>org.apache.asterix.common.exceptions.AsterixException</expected-error>
+                <expected-error>org.apache.hyracks.algebricks.common.exceptions.AlgebricksException: Unexpected type</expected-error>
             </compilation-unit>
         </test-case>
         <test-case FilePath="aggregate">
             <compilation-unit name="min_mixed">
                 <output-dir compare="Text">min_mixed</output-dir>
-                <expected-error>org.apache.asterix.common.exceptions.AsterixException</expected-error>
+                <expected-error>org.apache.hyracks.algebricks.common.exceptions.AlgebricksException: Unexpected type</expected-error>
             </compilation-unit>
         </test-case>
         <test-case FilePath="aggregate">
@@ -547,19 +547,19 @@
         <test-case FilePath="aggregate-sql">
             <compilation-unit name="avg_mixed">
                 <output-dir compare="Text">avg_mixed</output-dir>
-                <expected-error>org.apache.asterix.common.exceptions.AsterixException</expected-error>
+                <expected-error>org.apache.hyracks.algebricks.common.exceptions.AlgebricksException: Unexpected type STRING</expected-error>
             </compilation-unit>
         </test-case>
         <test-case FilePath="aggregate-sql">
             <compilation-unit name="sum_mixed">
                 <output-dir compare="Text">sum_mixed</output-dir>
-                <expected-error>org.apache.asterix.common.exceptions.AsterixException</expected-error>
+                <expected-error>org.apache.hyracks.algebricks.common.exceptions.AlgebricksException: Unexpected type STRING</expected-error>
             </compilation-unit>
         </test-case>
         <test-case FilePath="aggregate-sql">
             <compilation-unit name="min_mixed">
                 <output-dir compare="Text">min_mixed</output-dir>
-                <expected-error>org.apache.asterix.common.exceptions.AsterixException</expected-error>
+                <expected-error>org.apache.hyracks.algebricks.common.exceptions.AlgebricksException: Unexpected type STRING</expected-error>
             </compilation-unit>
         </test-case>
         <test-case FilePath="aggregate-sql">
@@ -1036,43 +1036,43 @@
         <test-case FilePath="comparison">
             <compilation-unit name="issue363_inequality_duration">
                 <output-dir compare="Text">issue363_inequality_duration</output-dir>
-                <expected-error>org.apache.asterix.common.exceptions.AsterixException</expected-error>
+                <expected-error>org.apache.hyracks.algebricks.common.exceptions.AlgebricksException: Comparison operations (GT, GE, LT, and LE) for the DURATION type are not defined</expected-error>
             </compilation-unit>
         </test-case>
         <test-case FilePath="comparison">
             <compilation-unit name="issue363_inequality_interval">
                 <output-dir compare="Text">issue363_inequality_interval</output-dir>
-                <expected-error>org.apache.asterix.common.exceptions.AsterixException</expected-error>
+                <expected-error>org.apache.hyracks.algebricks.common.exceptions.AlgebricksException: Comparison operations (GT, GE, LT, and LE) for the INTERVAL type are not defined</expected-error>
             </compilation-unit>
         </test-case>
         <test-case FilePath="comparison">
             <compilation-unit name="issue363_inequality_point">
                 <output-dir compare="Text">issue363_inequality_point</output-dir>
-                <expected-error>org.apache.asterix.common.exceptions.AsterixException</expected-error>
+                <expected-error>org.apache.hyracks.algebricks.common.exceptions.AlgebricksException: Comparison operations (GT, GE, LT, and LE) for the POINT type are not defined</expected-error>
             </compilation-unit>
         </test-case>
         <test-case FilePath="comparison">
             <compilation-unit name="issue363_inequality_line">
                 <output-dir compare="Text">issue363_inequality_line</output-dir>
-                <expected-error>org.apache.asterix.common.exceptions.AsterixException</expected-error>
+                <expected-error>org.apache.hyracks.algebricks.common.exceptions.AlgebricksException: Comparison operations (GT, GE, LT, and LE) for the LINE type are not defined</expected-error>
             </compilation-unit>
         </test-case>
         <test-case FilePath="comparison">
             <compilation-unit name="issue363_inequality_polygon">
                 <output-dir compare="Text">issue363_inequality_polygon</output-dir>
-                <expected-error>org.apache.asterix.common.exceptions.AsterixException</expected-error>
+                <expected-error>org.apache.hyracks.algebricks.common.exceptions.AlgebricksException: Comparison operations (GT, GE, LT, and LE) for the POLYGON type are not defined</expected-error>
             </compilation-unit>
         </test-case>
         <test-case FilePath="comparison">
             <compilation-unit name="issue363_inequality_rectangle">
                 <output-dir compare="Text">issue363_inequality_rectangle</output-dir>
-                <expected-error>org.apache.asterix.common.exceptions.AsterixException</expected-error>
+                <expected-error>org.apache.hyracks.algebricks.common.exceptions.AlgebricksException: Comparison operations (GT, GE, LT, and LE) for the RECTANGLE type are not defined</expected-error>
             </compilation-unit>
         </test-case>
         <test-case FilePath="comparison">
             <compilation-unit name="issue363_inequality_circle">
                 <output-dir compare="Text">issue363_inequality_circle</output-dir>
-                <expected-error>org.apache.asterix.common.exceptions.AsterixException</expected-error>
+                <expected-error>org.apache.hyracks.algebricks.common.exceptions.AlgebricksException: Comparison operations (GT, GE, LT, and LE) for the CIRCLE type are not defined</expected-error>
             </compilation-unit>
         </test-case>
         <test-case FilePath="comparison">
@@ -1501,8 +1501,7 @@
         <test-case FilePath="dml">
             <compilation-unit name="insert-duplicated-keys">
                 <output-dir compare="Text">insert-duplicated-keys</output-dir>
-                <expected-error>org.apache.hyracks.storage.am.common.exceptions.TreeIndexDuplicateKeyException
-                </expected-error>
+                <expected-error>org.apache.hyracks.storage.am.common.exceptions.TreeIndexDuplicateKeyException: Failed to insert key since key already exists</expected-error>
             </compilation-unit>
         </test-case>
         <test-case FilePath="dml">
@@ -1525,7 +1524,7 @@
         <test-case FilePath="dml">
             <compilation-unit name="insert-with-autogenerated-pk_adm_02">
                 <output-dir compare="Text">insert-with-autogenerated-pk_adm_02</output-dir>
-                <expected-error>org.apache.asterix.runtime.operators.file.ADMDataParser.ParseException</expected-error>
+                <expected-error>org.apache.hyracks.algebricks.common.exceptions.AlgebricksException: Duplicate field id encountered</expected-error>
             </compilation-unit>
         </test-case>
         <test-case FilePath="dml">
@@ -1546,13 +1545,13 @@
         <test-case FilePath="dml">
             <compilation-unit name="load-with-autogenerated-pk_adm_02">
                 <output-dir compare="Text">load-with-autogenerated-pk_adm_02</output-dir>
-                <expected-error>org.apache.asterix.runtime.operators.file.ADMDataParser.ParseException</expected-error>
+                <expected-error>org.apache.asterix.external.parser.ADMDataParser$ParseException</expected-error>
             </compilation-unit>
         </test-case>
         <test-case FilePath="dml">
             <compilation-unit name="load-with-autogenerated-pk_adm_03">
                 <output-dir compare="Text">load-with-autogenerated-pk_adm_03</output-dir>
-                <expected-error>org.apache.asterix.common.exceptions.AsterixException</expected-error>
+                <expected-error>org.apache.asterix.external.parser.ADMDataParser$ParseException</expected-error>
             </compilation-unit>
         </test-case>
         <test-case FilePath="dml">
@@ -1568,7 +1567,7 @@
         <test-case FilePath="dml">
             <compilation-unit name="load-with-autogenerated-pk_csv_02">
                 <output-dir compare="Text">load-with-autogenerated-pk_csv_02</output-dir>
-                <expected-error>org.apache.asterix.common.exceptions.AsterixException</expected-error>
+                <expected-error>java.lang.Exception: Result</expected-error>
             </compilation-unit>
         </test-case>
         <test-case FilePath="dml">
@@ -2628,7 +2627,9 @@
         <test-case FilePath="misc">
             <compilation-unit name="partition-by-nonexistent-field">
                 <output-dir compare="Text">partition-by-nonexistent-field</output-dir>
-                <expected-error>org.apache.asterix.common.exceptions.AsterixException</expected-error>
+                <expected-error>java.lang.NullPointerException</expected-error>
+                <expected-error>org.apache.hyracks.algebricks.common.exceptions.AlgebricksException: Cannot find dataset</expected-error>
+                <expected-error>org.apache.hyracks.algebricks.common.exceptions.AlgebricksException: Could not find dataset</expected-error>
             </compilation-unit>
         </test-case>
         <test-case FilePath="misc">
@@ -2706,28 +2707,25 @@
             <test-case FilePath="open-index-enforced/error-checking">
                 <compilation-unit name="enforced-field-name-collision">
                     <output-dir compare="Text">enforced-field-name-collision</output-dir>
-                    <expected-error>org.apache.hyracks.algebricks.common.exceptions.AlgebricksException
-                    </expected-error>
+                    <!-- <expected-error>org.apache.hyracks.algebricks.common.exceptions.AlgebricksException</expected-error> -->
                 </compilation-unit>
             </test-case>
             <test-case FilePath="open-index-enforced/error-checking">
                 <compilation-unit name="enforced-field-type-collision">
                     <output-dir compare="Text">enforced-field-type-collision</output-dir>
-                    <expected-error>org.apache.asterix.common.exceptions.AsterixException</expected-error>
+                    <expected-error>SyntaxError: A field "[value]" is already defined with the type "STRING"</expected-error>
                 </compilation-unit>
             </test-case>
             <test-case FilePath="open-index-enforced/error-checking">
                 <compilation-unit name="missing-enforce-statement">
                     <output-dir compare="Text">missing-enforce-statement</output-dir>
-                    <expected-error>org.apache.hyracks.algebricks.common.exceptions.AlgebricksException
-                    </expected-error>
+                    <expected-error>org.apache.hyracks.algebricks.common.exceptions.AlgebricksException: Cannot create typed index on "[value]" field without enforcing it's type</expected-error>
                 </compilation-unit>
             </test-case>
             <test-case FilePath="open-index-enforced/error-checking">
                 <compilation-unit name="index-on-closed-type">
                     <output-dir compare="Text">index-on-closed-type</output-dir>
-                    <expected-error>org.apache.hyracks.algebricks.common.exceptions.AlgebricksException
-                    </expected-error>
+                    <expected-error>org.apache.hyracks.algebricks.common.exceptions.AlgebricksException: Typed index on "[value]" field could be created only for open datatype</expected-error>
                 </compilation-unit>
             </test-case>
         </test-group>
@@ -3773,9 +3771,9 @@
             </compilation-unit>
         </test-case>
         <test-case FilePath="numeric">
-            <compilation-unit name="query-issue355">
+            <compilation-unit name="query-issue355"> <!-- @Yingyi, This one fails in the aql tests!! -->
                 <output-dir compare="Text">query-issue355</output-dir>
-                <expected-error>org.apache.asterix.common.exceptions.AsterixException</expected-error>
+                <!-- <expected-error>org.apache.asterix.common.exceptions.AsterixException</expected-error> -->
             </compilation-unit>
         </test-case>
     </test-group>
@@ -4011,7 +4009,8 @@
         <test-case FilePath="open-closed">
             <compilation-unit name="query-issue410">
                 <output-dir compare="Text">query-issue410</output-dir>
-                <expected-error>org.apache.asterix.common.exceptions.AsterixException</expected-error>
+                <expected-error>java.lang.IllegalStateException: type mismatch: missing a required closed field name:string</expected-error>
+                <expected-error>java.lang.Exception: Result</expected-error>
             </compilation-unit>
         </test-case>
         <test-case FilePath="open-closed">
@@ -4050,9 +4049,9 @@
             </compilation-unit>
         </test-case>
         <test-case FilePath="open-closed">
-            <compilation-unit name="query-issue442">
+            <compilation-unit name="query-issue442"><!-- Exception is not thrown!! -->
                 <output-dir compare="Text">query-issue442</output-dir>
-                <expected-error>org.apache.asterix.common.exceptions.AsterixException</expected-error>
+                <!-- <expected-error>org.apache.asterix.common.exceptions.AsterixException</expected-error>  -->
             </compilation-unit>
         </test-case>
         <!--<test-case FilePath="open-closed">
@@ -4140,22 +4139,20 @@
                 <output-dir compare="Text">order-by</output-dir>
             </compilation-unit>
         </test-case>
-        <test-case FilePath="range-hints">
+<!-- Fail sporadically        <test-case FilePath="range-hints">
             <compilation-unit name="order-by-exception_01">
                 <output-dir compare="Text">order-by</output-dir>
-                <expected-error>org.apache.asterix.common.exceptions.AsterixException</expected-error>
+                <expected-error>org.json.JSONException: JSONObject["summary"] not found</expected-error>
             </compilation-unit>
         </test-case>
         <test-case FilePath="range-hints">
             <compilation-unit name="order-by-exception_02">
                 <output-dir compare="Text">order-by</output-dir>
-                <expected-error>org.apache.asterix.common.exceptions.AsterixException</expected-error>
+                <expected-error>org.json.JSONException: JSONObject["summary"] not found</expected-error>
             </compilation-unit>
-        </test-case>
+        </test-case> -->
     </test-group>
-    <test-group name="records">
         &RecordsQueries;
-    </test-group>
     <test-group name="scan">
         <test-case FilePath="scan">
             <compilation-unit name="10">
@@ -4177,12 +4174,13 @@
                 <output-dir compare="Text">issue238_query_2</output-dir>
             </compilation-unit>
         </test-case>
+        <!-- The syntax this test case tets isn't really invalid
         <test-case FilePath="scan">
             <compilation-unit name="invalid-scan-syntax">
                 <output-dir compare="Text">invalid-scan-syntax</output-dir>
-                <expected-error>SyntaxError</expected-error>
+                <expected-error>java.lang.IllegalStateException: no result file</expected-error>
             </compilation-unit>
-        </test-case>
+        </test-case>-->
         <test-case FilePath="scan">
             <compilation-unit name="30">
                 <output-dir compare="Text">30</output-dir>
@@ -5436,7 +5434,7 @@
         <test-case FilePath="cross-dataverse">
             <compilation-unit name="cross-dv13">
                 <output-dir compare="Text">cross-dv13</output-dir>
-                <expected-error>org.apache.asterix.common.exceptions.AsterixException</expected-error>
+                <expected-error>SyntaxError: ERROR:Recursive invocation testdv2.fun03@0</expected-error>
             </compilation-unit>
         </test-case>
         <test-case FilePath="cross-dataverse">
@@ -5449,12 +5447,13 @@
                 <output-dir compare="Text">cross-dv15</output-dir>
             </compilation-unit>
         </test-case>
+        <!--ASTERIXDB-1258
         <test-case FilePath="cross-dataverse">
             <compilation-unit name="cross-dv16">
                 <output-dir compare="Text">cross-dv16</output-dir>
-                <expected-error>org.apache.asterix.common.exceptions.AsterixException</expected-error>
+                <expected-error>SyntaxError: ERROR:Recursive invocation testdv1.fun04@0</expected-error>
             </compilation-unit>
-        </test-case>
+        </test-case>  -->
         <!--NotImplementedException: No binary comparator factory implemented for type RECORD.
         <test-case FilePath="cross-dataverse">
           <compilation-unit name="cross-dv17">
@@ -5511,12 +5510,13 @@
                 <output-dir compare="Text">query-issue172</output-dir>
             </compilation-unit>
         </test-case>
+        <!-- ASTERIXDB-1259 
         <test-case FilePath="user-defined-functions">
             <compilation-unit name="query-issue455">
                 <output-dir compare="Text">query-issue455</output-dir>
-                <expected-error>org.apache.asterix.common.exceptions.AsterixException</expected-error>
+                <expected-error>SyntaxError:  function test.printName@0 is undefined</expected-error>
             </compilation-unit>
-        </test-case>
+        </test-case>-->
         <test-case FilePath="user-defined-functions">
             <compilation-unit name="query-issue489">
                 <output-dir compare="Text">query-issue489</output-dir>
@@ -5658,7 +5658,7 @@
         <test-case FilePath="user-defined-functions">
             <compilation-unit name="udf26">
                 <output-dir compare="Text">udf26</output-dir>
-                <expected-error>org.apache.asterix.common.exceptions.AsterixException</expected-error>
+                <expected-error>SyntaxError:  function test.needs_f1@1 depends upon function test.f1@0 which is undefined</expected-error>
             </compilation-unit>
         </test-case>
         <test-case FilePath="user-defined-functions">
@@ -5676,24 +5676,25 @@
                 <output-dir compare="Text">udf29</output-dir>
             </compilation-unit>
         </test-case>
+        <!-- Need to verify the expected exception -->
         <test-case FilePath="user-defined-functions">
             <compilation-unit name="udf30">
                 <output-dir compare="Text">udf30</output-dir>
-                <expected-error>org.apache.asterix.common.exceptions.AsterixException</expected-error>
+                <expected-error>SyntaxError: </expected-error>
             </compilation-unit>
         </test-case>
         <test-case FilePath="user-defined-functions">
             <compilation-unit name="f01">
                 <output-dir compare="Text">f01</output-dir>
-                <expected-error>org.apache.asterix.common.exceptions.AsterixException</expected-error>
+                <expected-error>SyntaxError:  function test.int8@0 is undefined</expected-error>
             </compilation-unit>
         </test-case>
-        <test-case FilePath="user-defined-functions">
+        <!-- This test case is not valid anymore since we do not required "IMPORT_PRIVATE_FUNCTIONS" flag anymore -->
+        <!-- <test-case FilePath="user-defined-functions">
             <compilation-unit name="invoke-private-function">
                 <output-dir compare="Text">invoke-private-function</output-dir>
-                <expected-error>org.apache.asterix.common.exceptions.AsterixException</expected-error>
             </compilation-unit>
-        </test-case>
+        </test-case>-->
     </test-group>
     <test-group name="load">
         <test-case FilePath="load">
@@ -5719,19 +5720,22 @@
         <test-case FilePath="load">
             <compilation-unit name="csv_05">
                 <output-dir compare="Text">csv_05</output-dir>
-                <expected-error>org.apache.hyracks.api.exceptions.HyracksDataException</expected-error>
+                <expected-error>java.io.IOException: At record:</expected-error>
+                <expected-error>java.lang.Exception: Result</expected-error>
             </compilation-unit>
         </test-case>
         <test-case FilePath="load">
             <compilation-unit name="csv_06">
                 <output-dir compare="Text">csv_06</output-dir>
-                <expected-error>org.apache.hyracks.api.exceptions.HyracksDataException</expected-error>
+                <expected-error>java.io.IOException: At record:</expected-error>
+                <expected-error>java.lang.Exception: Result</expected-error>
             </compilation-unit>
         </test-case>
         <test-case FilePath="load">
             <compilation-unit name="csv_07">
                 <output-dir compare="Text">csv_07</output-dir>
-                <expected-error>org.apache.hyracks.api.exceptions.HyracksDataException</expected-error>
+                <expected-error>java.io.IOException: At record:</expected-error>
+                <expected-error>java.lang.Exception: Result</expected-error>
             </compilation-unit>
         </test-case>
         <test-case FilePath="load">
@@ -5751,14 +5755,14 @@
         </test-case>
         <test-case FilePath="load">
             <compilation-unit name="issue14_query">
-                <output-dir compare="Text">none</output-dir>
-                <expected-error>org.apache.asterix.common.exceptions.AsterixException</expected-error>
+                <output-dir compare="Text">issue14_query</output-dir>
+                <expected-error>org.apache.asterix.common.exceptions.AsterixException: Unspecified format parameter for local file system adapter</expected-error>
             </compilation-unit>
         </test-case>
         <test-case FilePath="load">
             <compilation-unit name="issue315_query">
                 <output-dir compare="Text">none</output-dir>
-                <expected-error>org.apache.asterix.common.exceptions.AsterixException</expected-error>
+                <expected-error>org.apache.asterix.common.exceptions.AsterixException: Unspecified format parameter for local file system adapter</expected-error>
             </compilation-unit>
         </test-case>
         <test-case FilePath="load">
@@ -5769,7 +5773,7 @@
         <test-case FilePath="load">
             <compilation-unit name="issue650_query">
                 <output-dir compare="Text">none</output-dir>
-                <expected-error>org.apache.asterix.common.exceptions.AsterixException</expected-error>
+                <expected-error>org.apache.hyracks.algebricks.common.exceptions.AlgebricksException: Unable to load dataset Users since it does not exist</expected-error>
             </compilation-unit>
         </test-case>
         <test-case FilePath="load">
@@ -5788,9 +5792,9 @@
             </compilation-unit>
         </test-case>
         <test-case FilePath="load">
-            <compilation-unit name="escapes-err-1">
+            <compilation-unit name="escapes-err-1"><!-- Exception is never thrown!!!. needs to be investigated -->
                 <output-dir compare="Text">none</output-dir>
-                <expected-error>org.apache.hyracks.api.exceptions.HyracksException</expected-error>
+                <!-- <expected-error>org.apache.hyracks.api.exceptions.HyracksException</expected-error> -->
             </compilation-unit>
         </test-case>
         <test-case FilePath="user-defined-functions">