提交 92fcd8ae 编写于 作者: D Dhanashree Kashid

Analyzedb - add test case for analyze root partition

Added a test for following scenario:
When analyzedb is run without --skip_root_partition flag like below,
it should also analyze the root partitions.

`analyzedb -d <dbname> -s <schema> -a`

The root parition table gets listed only in the report file (and not in
any state files), hence added appropriate routines for checking the root
partition in the report file.
Signed-off-by: NJemish Patel <jpatel@pivotal.io>
上级 0d924f2c
......@@ -1684,6 +1684,16 @@ Feature: Incrementally analyze the database
And "public.sales_1_prt_2" should appear in the latest state files
And "public.sales_1_prt_3" should appear in the latest state files
@analyzedb_core @analyzedb_root_and_partition_tables @refresh_root_stats
Scenario: Partition tables, (entries for all parts, no change, some parts, root parts), request root stats
Given no state files exist for database "incr_analyze"
And the user runs "analyzedb -a -d incr_analyze -t public.sales"
When the user runs "analyzedb -a -d incr_analyze -t public.sales"
Then analyzedb should print There are no tables or partitions to be analyzed to stdout
And "public.sales_1_prt_2" should appear in the latest state files
And "public.sales_1_prt_3" should appear in the latest state files
And "public.sales" should appear in the latest report file
# request mid-level
@analyzedb_core @analyzedb_partition_tables
Scenario: Multi-level partition and request mid-level
......
import re
import os
import shutil
from gppylib.db import dbconn
......@@ -101,6 +102,13 @@ def impl(context, col_name, qualified_table):
else:
assert False, "unexpected column %s of table %s found in state file %s" % (column, qualified_table, os.path.basename(filename))
@given('"{qualified_table}" appears in the latest report file')
@then('"{qualified_table}" should appear in the latest report file')
def impl(context, qualified_table):
found,filename = table_found_in_report_file(context.dbname, qualified_table)
if not found:
assert False, "table %s not found in report file %s" % (qualified_table, os.path.basename(filename))
@then('output should contain either "{output1}" or "{output2}"')
def impl(context, output1, output2):
pat1 = re.compile(output1)
......@@ -155,6 +163,15 @@ def table_found_in_state_file(dbname, qualified_table):
return False,state_file
return True,state_file
def table_found_in_report_file(dbname, qualified_table):
report_file = get_latest_analyze_report_file(dbname)
found = False
for line in get_lines_from_file(report_file):
if qualified_table == line:
return True,report_file
return False,report_file
def column_found_in_state_file(dbname, qualified_table, col_name_list):
comma_name = ','.join(qualified_table.split('.'))
files = get_latest_analyze_state_files(dbname)
......@@ -207,6 +224,28 @@ def get_latest_analyze_state_files(dbname):
ret.append(os.path.join(state_files_dir, f))
return ret
def get_latest_analyze_report_file(dbname):
"""
return the latest report file (absolute path)
"""
master_data_dir = os.environ.get('MASTER_DATA_DIRECTORY')
analyze_dir = os.path.join(master_data_dir, 'db_analyze', dbname)
if not os.path.exists(analyze_dir):
return []
folders = sorted(os.listdir(analyze_dir), reverse=True)
if len(folders) == 0:
return []
report_file_dir = os.path.join(analyze_dir, folders[0])
files = os.listdir(report_file_dir)
for f in files:
if 'report' in f:
return os.path.join(report_file_dir, f)
raise Exception("Missing report file in folder %s" % report_file_dir)
def create_table_with_column_list(conn, storage_type, schemaname, tablename, col_name_list, col_type_list):
col_name_list = col_name_list.strip().split(',')
col_type_list = col_type_list.strip().split(',')
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册