IMPALA-3491: Use unique_database fixture in test_delimited_text.py.

Testing: Ran the test locally 10 times in a loop on exhaustive.

Change-Id: Idedd5f03984e41a4b3ebf271e50863e980c66cb6
Reviewed-on: http://gerrit.cloudera.org:8080/3096
Reviewed-by: Alex Behm <[email protected]>
Tested-by: Alex Behm <[email protected]>


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

Branch: refs/heads/master
Commit: 95064359cc5948d043e271fbb18621fb1dffc02f
Parents: a9f7cf5
Author: Alex Behm <[email protected]>
Authored: Mon May 16 20:06:13 2016 -0700
Committer: Tim Armstrong <[email protected]>
Committed: Tue Jun 7 09:34:30 2016 -0700

----------------------------------------------------------------------
 .../queries/QueryTest/delimited-latin-text.test |  8 ++---
 .../queries/QueryTest/delimited-text.test       | 16 ++++-----
 tests/query_test/test_delimited_text.py         | 38 ++++++--------------
 3 files changed, 22 insertions(+), 40 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-impala/blob/95064359/testdata/workloads/functional-query/queries/QueryTest/delimited-latin-text.test
----------------------------------------------------------------------
diff --git 
a/testdata/workloads/functional-query/queries/QueryTest/delimited-latin-text.test
 
b/testdata/workloads/functional-query/queries/QueryTest/delimited-latin-text.test
index a518270..460aaac 100644
--- 
a/testdata/workloads/functional-query/queries/QueryTest/delimited-latin-text.test
+++ 
b/testdata/workloads/functional-query/queries/QueryTest/delimited-latin-text.test
@@ -4,7 +4,7 @@
 # fields terminated by '-2' -- thorn character
 # escaped by '-22' -- lowercase e with circumflex
 # lines terminated by '\n'
-select * from text_thorn_ecirc_newline
+select * from functional.text_thorn_ecirc_newline
 ---- RESULTS
 'one','two',3,4
 'one\xfeone','two',3,4
@@ -16,7 +16,7 @@ STRING,STRING,INT,INT
 ====
 ---- QUERY
 # create new tables like the ones above to test inserting
-create table delim_text_test_db.tecn like text_thorn_ecirc_newline;
+create table tecn like functional.text_thorn_ecirc_newline;
 ---- RESULTS
 ====
 ---- QUERY
@@ -24,12 +24,12 @@ create table delim_text_test_db.tecn like 
text_thorn_ecirc_newline;
 # TODO: Expand verification to cover inserting a field terminator and escape 
character.
 # Some additional work needs to be done in the test framework to properly 
encode/decode
 # the values going into the INSERT query before this will work.
-insert overwrite delim_text_test_db.tecn values
+insert overwrite tecn values
 ('abc', 'xyz', 1, 2),
 ('efg', 'xyz', 3, 4)
 ====
 ---- QUERY
-select * from delim_text_test_db.tecn
+select * from tecn
 ---- RESULTS
 'abc','xyz',1,2
 'efg','xyz',3,4

http://git-wip-us.apache.org/repos/asf/incubator-impala/blob/95064359/testdata/workloads/functional-query/queries/QueryTest/delimited-text.test
----------------------------------------------------------------------
diff --git 
a/testdata/workloads/functional-query/queries/QueryTest/delimited-text.test 
b/testdata/workloads/functional-query/queries/QueryTest/delimited-text.test
index 46ce55a..188d54d 100644
--- a/testdata/workloads/functional-query/queries/QueryTest/delimited-text.test
+++ b/testdata/workloads/functional-query/queries/QueryTest/delimited-text.test
@@ -4,7 +4,7 @@
 # fields terminated by ','
 # escaped by '\\'
 # lines terminated by '\n'
-select * from text_comma_backslash_newline
+select * from functional.text_comma_backslash_newline
 ---- RESULTS
 'one','two',3,4
 'one,one','two',3,4
@@ -19,7 +19,7 @@ STRING,STRING,INT,INT
 # fields terminated by '$'
 # escaped by '#'
 # lines terminated by '|'
-select * from text_dollar_hash_pipe
+select * from functional.text_dollar_hash_pipe
 ---- RESULTS
 'one','two',3,4
 'one$one','two',3,4
@@ -31,13 +31,13 @@ STRING,STRING,INT,INT
 ====
 ---- QUERY
 # create new tables like the ones above to test inserting
-create table delim_text_test_db.cbn like text_comma_backslash_newline;
-create table delim_text_test_db.dhp like text_dollar_hash_pipe;
+create table cbn like functional.text_comma_backslash_newline;
+create table dhp like functional.text_dollar_hash_pipe;
 ---- RESULTS
 ====
 ---- QUERY
 # insert data into cbn table and check results
-insert into delim_text_test_db.cbn values
+insert into cbn values
 ('abc , abc', 'xyz \\ xyz', 1, 2),
 ('abc ,,, abc', 'xyz \\\\\\ xyz', 3, 4),
 ('abc \\,\\, abc', 'xyz ,\\,\\ xyz', 5, 6)
@@ -45,7 +45,7 @@ insert into delim_text_test_db.cbn values
 : 3
 ====
 ---- QUERY
-select * from delim_text_test_db.cbn
+select * from cbn
 ---- RESULTS
 'abc , abc','xyz \\ xyz',1,2
 'abc ,,, abc','xyz \\\\\\ xyz',3,4
@@ -55,7 +55,7 @@ STRING,STRING,INT,INT
 ====
 ---- QUERY
 # insert data into dhp table and check results
-insert into delim_text_test_db.dhp values
+insert into dhp values
 ('abc $ abc', 'xyz # xyz', 1, 2),
 ('abc $$$ abc', 'xyz ### xyz', 3, 4),
 ('abc #$#$ abc', 'xyz $#$# xyz', 5, 6)
@@ -63,7 +63,7 @@ insert into delim_text_test_db.dhp values
 : 3
 ====
 ---- QUERY
-select * from delim_text_test_db.dhp
+select * from dhp
 ---- RESULTS
 'abc $ abc','xyz # xyz',1,2
 'abc $$$ abc','xyz ### xyz',3,4

http://git-wip-us.apache.org/repos/asf/incubator-impala/blob/95064359/tests/query_test/test_delimited_text.py
----------------------------------------------------------------------
diff --git a/tests/query_test/test_delimited_text.py 
b/tests/query_test/test_delimited_text.py
index 371b7f4..5dee745 100644
--- a/tests/query_test/test_delimited_text.py
+++ b/tests/query_test/test_delimited_text.py
@@ -14,8 +14,6 @@ class TestDelimitedText(ImpalaTestSuite):
   and escape characters.
   """
 
-  TEST_DB_NAME = "delim_text_test_db"
-
   @classmethod
   def get_workload(self):
     return 'functional-query'
@@ -27,26 +25,10 @@ class TestDelimitedText(ImpalaTestSuite):
     # Only run on delimited text with no compression.
     
cls.TestMatrix.add_dimension(create_uncompressed_text_dimension(cls.get_workload()))
 
-  def setup_method(self, method):
-    # cleanup and create a fresh test database
-    self.__cleanup()
-    self.execute_query("create database %s" % self.TEST_DB_NAME)
-
-  def teardown_method(self, method):
-    self.__cleanup()
-
-  def __cleanup(self):
-    self.client.execute('use default')
-    self.client.execute('drop table if exists %s.cbn' % self.TEST_DB_NAME)
-    self.client.execute('drop table if exists %s.dhp' % self.TEST_DB_NAME)
-    self.client.execute('drop table if exists %s.tecn' % self.TEST_DB_NAME)
-    self.client.execute('drop table if exists %s.nl_queries' % 
self.TEST_DB_NAME)
-    self.client.execute('drop database if exists %s' % self.TEST_DB_NAME)
-
-  def test_delimited_text(self, vector):
-    self.run_test_case('QueryTest/delimited-text', vector)
+  def test_delimited_text(self, vector, unique_database):
+    self.run_test_case('QueryTest/delimited-text', vector, unique_database)
 
-  def test_delimited_text_newlines(self, vector):
+  def test_delimited_text_newlines(self, vector, unique_database):
     """ Test text with newlines in strings - IMPALA-1943. Execute queries from 
Python to
     avoid issues with newline handling in test file format. """
     self.execute_query_expect_success(self.client, """
@@ -56,24 +38,24 @@ class TestDelimitedText(ImpalaTestSuite):
       fields terminated by '\002'
       lines terminated by '\001'
       stored as textfile
-      """ % self.TEST_DB_NAME)
+      """ % unique_database)
     # Create test data with newlines in various places
     self.execute_query_expect_success(self.client, """
       insert into %s.nl_queries
       values ("the\\n","\\nquick\\nbrown","fox\\n"),
-             ("\\njumped","over the lazy\\n","\\ndog")""" % self.TEST_DB_NAME)
-    result = self.execute_query("select * from %s.nl_queries" % 
self.TEST_DB_NAME)
+             ("\\njumped","over the lazy\\n","\\ndog")""" % unique_database)
+    result = self.execute_query("select * from %s.nl_queries" % 
unique_database)
     assert len(result.data) == 2
     assert result.data[0].split("\t") == ["the\n", "\nquick\nbrown", "fox\n"]
     assert result.data[1].split("\t") == ["\njumped","over the lazy\n","\ndog"]
     # The row count may be computed without parsing each row, so could be 
inconsistent.
-    result = self.execute_query("select count(*) from %s.nl_queries" % 
self.TEST_DB_NAME)
+    result = self.execute_query("select count(*) from %s.nl_queries" % 
unique_database)
     assert len(result.data) == 1
     assert result.data[0] == "2"
 
-  @pytest.mark.execute_serially
-  def test_delimited_text_latin_chars(self, vector):
+  def test_delimited_text_latin_chars(self, vector, unique_database):
     """Verifies Impala is able to properly handle delimited text that contains
     extended ASCII/latin characters. Marked as running serial because of shared
     cleanup/setup"""
-    self.run_test_case('QueryTest/delimited-latin-text', vector, 
encoding="latin-1")
+    self.run_test_case('QueryTest/delimited-latin-text', vector, 
unique_database,
+      encoding="latin-1")

Reply via email to