提交 99c0648e 编写于 作者: C Chumki Roy

Fixed schema level dump with prefix option

上级 1559dba0
......@@ -877,6 +877,7 @@ class DumpDatabase(Operation):
These options get passed-through gp_dump to gp_dump_agent.
Commented out lines use escaping that would be reasonable, if gp_dump escaped properly.
"""
should_dump_schema = self.include_schema_file is not None
if self.dump_schema:
logger.info("Adding schema name %s" % self.dump_schema)
dump_line += " -n \"\\\"%s\\\"\"" % self.dump_schema
......@@ -893,11 +894,11 @@ class DumpDatabase(Operation):
schema, table = split_fqn(dump_table)
dump_line += " --exclude-table=\"\\\"%s\\\"\".\"\\\"%s\\\"\"" % (schema, table)
#dump_line += " --exclude-table=\"%s\".\"%s\"" % (schema, table)
if self.include_dump_tables_file is not None:
if self.include_dump_tables_file is not None and not should_dump_schema:
dump_line += " --table-file=%s" % self.include_dump_tables_file
if self.exclude_dump_tables_file is not None:
dump_line += " --exclude-table-file=%s" % self.exclude_dump_tables_file
if self.include_schema_file is not None and not self.dump_prefix:
if should_dump_schema:
dump_line += " --schema-file=%s" % self.include_schema_file
for opt in self.output_options:
......
......@@ -985,9 +985,9 @@ class DumpTestCase(unittest.TestCase):
self.assertEqual(ts_key[0:8], DUMP_DATE)
def test_create_dump_line_00(self):
self.dumper.include_schema_file = '/tmp/foo'
self.dumper.include_schema_file = '/tmp/schema_file'
output = self.dumper.create_dump_string('dcddev', '20121212', '01234567891234')
expected_output = """gp_dump -p 0 -U dcddev --gp-d=/data/master/p1/db_dumps/20121212 --gp-r=/data/master/p1/db_dumps/20121212 --gp-s=p --gp-k=01234567891234 --no-lock --gp-c --no-expand-children -n "\\"testschema\\"" "testdb" --table-file=/tmp/table_list.txt --schema-file=/tmp/foo"""
expected_output = """gp_dump -p 0 -U dcddev --gp-d=/data/master/p1/db_dumps/20121212 --gp-r=/data/master/p1/db_dumps/20121212 --gp-s=p --gp-k=01234567891234 --no-lock --gp-c --no-expand-children -n "\\"testschema\\"" "testdb" --schema-file=/tmp/schema_file"""
self.assertEquals(output, expected_output)
def test00_create_dump_line_with_prefix(self):
......@@ -1019,6 +1019,13 @@ class DumpTestCase(unittest.TestCase):
expected_output = """gp_dump -p 0 -U dcddev --gp-d=/data/master/p1/db_dumps/20121212 --gp-r=/data/master/p1/db_dumps/20121212 --gp-s=p --gp-k=01234567891234 --no-lock --gp-c --no-expand-children -n "\\"testschema\\"" "testdb" --netbackup-service-host=mdw --netbackup-policy=test_policy --netbackup-schedule=test_schedule"""
self.assertEquals(output, expected_output)
def test_create_dump_line_with_prefix_schema_level_dump(self):
self.dumper.dump_prefix = 'foo_'
self.dumper.include_schema_file = '/tmp/schema_file '
output = self.dumper.create_dump_string('dcddev', '20121212', '01234567891234')
expected_output = """gp_dump -p 0 -U dcddev --gp-d=/data/master/p1/db_dumps/20121212 --gp-r=/data/master/p1/db_dumps/20121212 --gp-s=p --gp-k=01234567891234 --no-lock --gp-c --prefix=foo_ --no-expand-children -n "\\"testschema\\"" "testdb" --schema-file=/tmp/schema_file """
self.assertEquals(output, expected_output)
def test_get_backup_dir_with_master_data_dir(self):
master_datadir = '/foo'
backup_dir = None
......
......@@ -3362,6 +3362,26 @@ Feature: Validate command line arguments
Then gpdbrestore should print Table public.heap_table2 not found in backup to stdout
Then gpdbrestore should not print Issue with 'ANALYZE' of restored table 'public.heap_table2' in 'bkdb' database to stdout
@backupfire
Scenario: Full Backup with option --schema-file with prefix option and Restore
Given the test is initialized
And the prefix "foo" is stored
And there is schema "schema_heap, schema_ao, testschema" exists in "bkdb"
And there is a "heap" table "schema_heap.heap_table" in "bkdb" with data
And there is a "heap" table "testschema.heap_table" in "bkdb" with data
And there is a "ao" partition table "schema_ao.ao_part_table" in "bkdb" with data
And there is a backupfile of tables "schema_heap.heap_table, schema_ao.ao_part_table, testschema.heap_table" in "bkdb" exists for validation
And there is a file "include_file" with tables "schema_heap|schema_ao"
When the user runs "gpcrondump -a -x bkdb --schema-file include_file --prefix=foo"
Then gpcrondump should return a return code of 0
And the timestamp from gpcrondump is stored
And verify that the "report" file in " " dir contains "Backup Type: Full"
When the user runs gpdbrestore with the stored timestamp and options "--prefix=foo"
Then gpdbrestore should return a return code of 0
And verify that there is a "heap" table "schema_heap.heap_table" in "bkdb" with data
And verify that there is a "ao" table "schema_ao.ao_part_table" in "bkdb" with data
And verify that there is no table "testschema.heap_table" in "bkdb"
# THIS SHOULD BE THE LAST TEST
@backupfire
Scenario: cleanup for backup feature
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册