Fix E2E test infrastructure to handle missing exceptions correctly

This change fixes a bug in the E2E infrastructure that handles
the case when an expected exception wasn't thrown. The code was
expecting that test_section['CATCH'] to be a string but in
reality it's a list of strings. It also clarifies the error
message about the missing exception. This change also enforces
that the CATCH subsection in tests cannot be empty.

Change-Id: I7d83c5db59e8a239e4e70694a1e625af6f21419c
Reviewed-on: http://gerrit.cloudera.org:8080/5260
Reviewed-by: Michael Ho <[email protected]>
Tested-by: Internal Jenkins


Project: http://git-wip-us.apache.org/repos/asf/incubator-impala/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-impala/commit/a41918d4
Tree: http://git-wip-us.apache.org/repos/asf/incubator-impala/tree/a41918d4
Diff: http://git-wip-us.apache.org/repos/asf/incubator-impala/diff/a41918d4

Branch: refs/heads/master
Commit: a41918d443217d5e3205f6e9987d0c857f7ef7ef
Parents: f3fe2cf
Author: Michael Ho <[email protected]>
Authored: Mon Nov 28 15:40:16 2016 -0800
Committer: Internal Jenkins <[email protected]>
Committed: Thu Dec 1 23:43:03 2016 +0000

----------------------------------------------------------------------
 tests/common/impala_test_suite.py | 6 +++++-
 tests/util/test_file_parser.py    | 2 ++
 2 files changed, 7 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-impala/blob/a41918d4/tests/common/impala_test_suite.py
----------------------------------------------------------------------
diff --git a/tests/common/impala_test_suite.py 
b/tests/common/impala_test_suite.py
index 222f709..38849db 100644
--- a/tests/common/impala_test_suite.py
+++ b/tests/common/impala_test_suite.py
@@ -329,7 +329,11 @@ class ImpalaTestSuite(BaseTestSuite):
           self.__restore_query_options(query_options_changed, 
target_impalad_client)
 
       if 'CATCH' in test_section:
-        assert test_section['CATCH'].strip() == ''
+        expected_str = " or ".join(test_section['CATCH']).strip() \
+          .replace('$FILESYSTEM_PREFIX', FILESYSTEM_PREFIX) \
+          .replace('$NAMENODE', NAMENODE) \
+          .replace('$IMPALA_HOME', IMPALA_HOME)
+        assert False, "Expected exception: %s" % expected_str
 
       assert result is not None
       assert result.success

http://git-wip-us.apache.org/repos/asf/incubator-impala/blob/a41918d4/tests/util/test_file_parser.py
----------------------------------------------------------------------
diff --git a/tests/util/test_file_parser.py b/tests/util/test_file_parser.py
index 886d8b7..9850b18 100644
--- a/tests/util/test_file_parser.py
+++ b/tests/util/test_file_parser.py
@@ -225,6 +225,8 @@ def parse_test_file_text(text, valid_section_names, 
skip_unknown_sections=True):
           parsed_sections['CATCH'].extend(lines_content)
         else:
           raise RuntimeError, 'Unknown subsection comment: %s' % 
subsection_comment
+        for exception_str in parsed_sections['CATCH']:
+          assert exception_str.strip(), "Empty exception string."
         continue
 
       # The DML_RESULTS section is used to specify what the state of the table 
should be

Reply via email to