IMPALA-3491: Use unique database fixture in test_ddl.py.

Adds new parametrization to the unique database fixture:
- num_dbs: allows creating multiple unique databases at once;
  the 2nd, 3rd, etc. datbase name is generated by appending
  "2", "3", etc., to the first database name
- sync_ddl: allows creating the dabatases(s) with sync_ddl
  which is needed by most tests in test_ddl.py

Testing: I ran debug/core and debug/exhaustive on HDFS and
core/debug on S3. Also ran the test locally in a loop on
exhaustive.

Change-Id: Idf667dd5e960768879c019e2037cf48ad4e4241b
Reviewed-on: http://gerrit.cloudera.org:8080/4155
Reviewed-by: Alex Behm <alex.behm@cloudera.com>
Tested-by: Internal Jenkins
This commit is contained in:
Alex Behm
2016-05-10 01:01:32 -07:00
committed by Internal Jenkins
parent 16f1c8d8de
commit ab9e54bc42
13 changed files with 566 additions and 740 deletions

View File

@@ -1,65 +1,58 @@
====
---- QUERY
create database create_db_test comment "For testing"
create database $DATABASE_2 comment "For testing"
---- RESULTS
====
---- QUERY
show databases like "create_db_test"
show databases like "$DATABASE_2"
---- RESULTS
'create_db_test','For testing'
'$DATABASE_2','For testing'
---- TYPES
STRING, STRING
====
---- QUERY
# Make sure creating a database with the same name doesn't throw an error when
# IF NOT EXISTS is specified.
create database if not exists create_db_test
create database if not exists $DATABASE_2
---- RESULTS
====
---- QUERY
# Test dropping the database.
drop database create_db_test
drop database $DATABASE_2
---- RESULTS
====
---- QUERY
show databases like "create_db_test"
show databases like "$DATABASE_2"
---- RESULTS
---- TYPES
STRING, STRING
====
---- QUERY
# Dropping a non-existent databases is ok with IF EXISTS
drop database if exists create_db_test
drop database if exists $DATABASE_2
---- RESULTS
====
---- QUERY
# Test DROP DATABASE ... CASCADE
create database if not exists test_drop_cascade_db
create database if not exists $DATABASE_cascade
====
---- QUERY
show databases like 'test_drop_cascade_db'
---- RESULTS
'test_drop_cascade_db',''
---- TYPES
STRING,STRING
====
---- QUERY
create table if not exists test_drop_cascade_db.t1 (i int);
create table if not exists test_drop_cascade_db.t2 (i int)
create table if not exists $DATABASE_cascade.t1 (i int);
create table if not exists $DATABASE_cascade.t2 (i int)
partitioned by (year smallint, month smallint);
insert into test_drop_cascade_db.t2 partition (year=2015, month=8) values(1);
create external table if not exists test_drop_cascade_db.t3 like functional.alltypes
insert into $DATABASE_cascade.t2 partition (year=2015, month=8) values(1);
create external table if not exists $DATABASE_cascade.t3 like functional.alltypes
location '$FILESYSTEM_PREFIX/test-warehouse/alltypes_external';
create view if not exists test_drop_cascade_db.v1 as
create view if not exists $DATABASE_cascade.v1 as
select int_col from functional.alltypes;
create function if not exists test_drop_cascade_db.f1() returns string
create function if not exists $DATABASE_cascade.f1() returns string
location '$FILESYSTEM_PREFIX/test-warehouse/libTestUdfs.so' symbol='NoArgs';
create aggregate function if not exists test_drop_cascade_db.f2(int, string) RETURNS int
create aggregate function if not exists $DATABASE_cascade.f2(int, string) RETURNS int
location '$FILESYSTEM_PREFIX/test-warehouse/libTestUdas.so' UPDATE_FN='TwoArgUpdate'
---- RESULTS
====
---- QUERY
show tables in test_drop_cascade_db
show tables in $DATABASE_cascade
---- RESULTS
't1'
't2'
@@ -69,14 +62,14 @@ show tables in test_drop_cascade_db
STRING
====
---- QUERY
show functions in test_drop_cascade_db
show functions in $DATABASE_cascade
---- RESULTS
'STRING','f1()','NATIVE','true'
---- TYPES
STRING, STRING, STRING, STRING
====
---- QUERY
show aggregate functions in test_drop_cascade_db
show aggregate functions in $DATABASE_cascade
---- RESULTS
'INT','f2(INT, STRING)','NATIVE','true'
---- TYPES
@@ -85,29 +78,29 @@ STRING, STRING, STRING, STRING
---- QUERY
# Should drop all tables, functions, and aggregate functions, as well
# as the database itself.
drop database test_drop_cascade_db cascade
drop database $DATABASE_cascade cascade
---- RESULTS
====
---- QUERY
show databases like 'test_drop_cascade_db'
show databases like '$DATABASE_cascade'
---- RESULTS
====
---- QUERY
# Test that DROP DATABASE ... RESTRICT executes ok.
create database if not exists test_drop_restrict_db
create database if not exists $DATABASE_restrict
====
---- QUERY
show databases like 'test_drop_restrict_db'
show databases like '$DATABASE_restrict'
---- RESULTS
'test_drop_restrict_db',''
'$DATABASE_restrict',''
---- TYPES
STRING,STRING
====
---- QUERY
drop database test_drop_restrict_db restrict
drop database $DATABASE_restrict restrict
---- RESULTS
====
---- QUERY
show databases like 'test_drop_restrict_db'
show databases like '$DATABASE_restrict'
---- RESULTS
====