Files
impala/tests/query_test/test_invalid_test_header.py
Lars Volker 6b566a2d35 IMPALA-3004: Fix QueryTest tests
Test files in testdata/workloads/functional-query/queries/QueryTest
are parsed by test_file_parser.py, which used to ignore everything
before the first ==== line as a file header. This change fixes all
affected files.

This change also modifies the test file parser to forbid headers
starting with what looks like a subsection title ('----'), which
should prevent the reintroduction of similar errors in the future.

Change-Id: Iaa1bc5ffd02782e24289c7843dcb35401c334519
Reviewed-on: http://gerrit.cloudera.org:8080/2220
Reviewed-by: Lars Volker <lv@cloudera.com>
Tested-by: Internal Jenkins
2016-02-19 00:03:15 -08:00

40 lines
1.5 KiB
Python

# Copyright (c) 2016 Cloudera, Inc. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import pytest
from tests.common.impala_test_suite import ImpalaTestSuite
class TestInvalidTestHeader(ImpalaTestSuite):
"""Test correct handling of .test files with malformed header."""
@classmethod
def add_test_dimensions(cls):
super(TestInvalidTestHeader, cls).add_test_dimensions()
# It's sufficient to run this test once.
cls.TestMatrix.add_constraint(lambda v:\
v.get_value('table_format').file_format == 'text' and\
v.get_value('table_format').compression_codec == 'none')
@classmethod
def get_workload(cls):
return 'functional-query'
def test_invalid_test_header(self, vector):
"""Test that running a test file with an invalid header results in the right exception
being thrown."""
with pytest.raises(RuntimeError) as e:
self.run_test_case('QueryTest/invalid_header', vector)
assert 'Header must not start with' in str(e.value)