提交 f5c7a194 编写于 作者: J Jamie McAtamney 提交者: Karen Huddleston

Modified special character backup tests to use environment variables instead of in-feature escaping

上级 1eca938e
......@@ -1626,121 +1626,95 @@ Feature: Validate command line arguments
Scenario: 120 Simple full backup and restore with special character
Given the backup test is initialized for special characters
When the user runs command "gpcrondump -a -x " DB\`~@#\$%^&*()_-+[{]}|\\;: \\'/?><;1 ""
When the user runs command "gpcrondump -a -x "$SP_CHAR_DB""
And the timestamp from gpcrondump is stored
Then gpcrondump should return a return code of 0
When the user runs command "psql -f test/behave/mgmt_utils/steps/data/special_chars/select_from_special_table.sql " DB\`~@#\$%^&*()_-+[{]}|\\;: \\'/?><;1 " > /tmp/120_special_table_data.ans"
When the user runs command "psql -f test/behave/mgmt_utils/steps/data/special_chars/select_from_special_table.sql "$SP_CHAR_DB" > /tmp/120_special_table_data.ans"
Scenario: 121 gpcrondump with -T option where table name, schema name and database name contains special character
Given the backup test is initialized for special characters
And a list of files "121_ao,121_heap" of tables " S`~@#$%^&*()-+[{]}|\;: \'"/?><1 . ao_T`~@#$%^&*()-+[{]}|\;: \'"/?><1 , S`~@#$%^&*()-+[{]}|\;: \'"/?><1 . heap_T`~@#$%^&*()-+[{]}|\;: \'"/?><1 " in " DB`~@#$%^&*()_-+[{]}|\;: \'/?><;1 " exists for validation
When the user runs command "gpcrondump -a -x " DB\`~@#\$%^&*()_-+[{]}|\\;: \\'/?><;1 " -T " S\`~@#\$%^&*()-+[{]}|\\;: \\'\"/?><1 "." co_T\`~@#\$%^&*()-+[{]}|\\;: \\'\"/?><1 ""
And a list of files "121_ao,121_heap" of tables "$SP_CHAR_SCHEMA.$SP_CHAR_AO,$SP_CHAR_SCHEMA.$SP_CHAR_HEAP" in "$SP_CHAR_DB" exists for validation
When the user runs command "gpcrondump -a -x "$SP_CHAR_DB" -T "$SP_CHAR_SCHEMA"."$SP_CHAR_CO""
Then gpcrondump should return a return code of 0
And the timestamp from gpcrondump is stored
Scenario: 122 gpcrondump with --exclude-table-file option where table name, schema name and database name contains special character
Given the backup test is initialized for special characters
And a list of files "122_ao,122_heap" of tables " S`~@#$%^&*()-+[{]}|\;: \'"/?><1 . ao_T`~@#$%^&*()-+[{]}|\;: \'"/?><1 , S`~@#$%^&*()-+[{]}|\;: \'"/?><1 . heap_T`~@#$%^&*()-+[{]}|\;: \'"/?><1 " in " DB`~@#$%^&*()_-+[{]}|\;: \'/?><;1 " exists for validation
When the user runs command "gpcrondump -a -x " DB\`~@#\$%^&*()_-+[{]}|\\;: \\'/?><;1 " --exclude-table-file test/behave/mgmt_utils/steps/data/special_chars/exclude-table-file.txt"
And a list of files "122_ao,122_heap" of tables "$SP_CHAR_SCHEMA.$SP_CHAR_AO,$SP_CHAR_SCHEMA.$SP_CHAR_HEAP" in "$SP_CHAR_DB" exists for validation
When the user runs command "gpcrondump -a -x "$SP_CHAR_DB" --exclude-table-file test/behave/mgmt_utils/steps/data/special_chars/exclude-table-file.txt"
Then gpcrondump should return a return code of 0
And the timestamp from gpcrondump is stored
Scenario: 123 gpcrondump with --table-file option where table name, schema name and database name contains special character
Given the backup test is initialized for special characters
And a list of files "123_ao,123_heap" of tables " S`~@#$%^&*()-+[{]}|\;: \'"/?><1 . ao_T`~@#$%^&*()-+[{]}|\;: \'"/?><1 , S`~@#$%^&*()-+[{]}|\;: \'"/?><1 . heap_T`~@#$%^&*()-+[{]}|\;: \'"/?><1 " in " DB`~@#$%^&*()_-+[{]}|\;: \'/?><;1 " exists for validation
When the user runs command "gpcrondump -a -x " DB\`~@#\$%^&*()_-+[{]}|\\;: \\'/?><;1 " --table-file test/behave/mgmt_utils/steps/data/special_chars/table-file.txt"
And a list of files "123_ao,123_heap" of tables "$SP_CHAR_SCHEMA.$SP_CHAR_AO,$SP_CHAR_SCHEMA.$SP_CHAR_HEAP" in "$SP_CHAR_DB" exists for validation
When the user runs command "gpcrondump -a -x "$SP_CHAR_DB" --table-file test/behave/mgmt_utils/steps/data/special_chars/table-file.txt"
Then gpcrondump should return a return code of 0
And the timestamp from gpcrondump is stored
Scenario: 124 gpcrondump with -t option where table name, schema name and database name contains special character
Given the backup test is initialized for special characters
And a list of files "124_ao" of tables " S`~@#$%^&*()-+[{]}|\;: \'"/?><1 . ao_T`~@#$%^&*()-+[{]}|\;: \'"/?><1 " in " DB`~@#$%^&*()_-+[{]}|\;: \'/?><;1 " exists for validation
When the user runs command "gpcrondump -a -x " DB\`~@#\$%^&*()_-+[{]}|\\;: \\'/?><;1 " -t " S\`~@#\$%^&*()-+[{]}|\\;: \\'\"/?><1 "." ao_T\`~@#\$%^&*()-+[{]}|\\;: \\'\"/?><1 ""
And a list of files "124_ao" of tables "$SP_CHAR_SCHEMA.$SP_CHAR_AO" in "$SP_CHAR_DB" exists for validation
When the user runs "gpcrondump -a -x "$SP_CHAR_DB" -t "$SP_CHAR_SCHEMA"."$SP_CHAR_AO""
Then gpcrondump should return a return code of 0
And the timestamp from gpcrondump is stored
Scenario: 125 gpcrondump with --schema-file option when schema name and database name contains special character
Given the backup test is initialized for special characters
When the user runs command "gpcrondump -a -x " DB\`~@#\$%^&*()_-+[{]}|\\;: \\'/?><;1 " --schema-file test/behave/mgmt_utils/steps/data/special_chars/schema-file.txt"
When the user runs command "gpcrondump -a -x "$SP_CHAR_DB" --schema-file test/behave/mgmt_utils/steps/data/special_chars/schema-file.txt"
Then gpcrondump should return a return code of 0
And the timestamp from gpcrondump is stored
And the user runs command "psql -f test/behave/mgmt_utils/steps/data/special_chars/select_from_special_table.sql " DB\`~@#\$%^&*()_-+[{]}|\\;: \\'/?><;1 " > /tmp/125_special_table_data.ans"
And the user runs command "psql -f test/behave/mgmt_utils/steps/data/special_chars/select_from_special_table.sql "$SP_CHAR_DB" > /tmp/125_special_table_data.ans"
Scenario: 126 gpcrondump with -s option when schema name and database name contains special character
Given the backup test is initialized for special characters
When the user runs command "gpcrondump -a -x " DB\`~@#\$%^&*()_-+[{]}|\\;: \\'/?><;1 " -s " S\`~@#\$%^&*()-+[{]}|\\;: \\'\"/?><1 ""
When the user runs "gpcrondump -a -x "$SP_CHAR_DB" -s "$SP_CHAR_SCHEMA""
Then gpcrondump should return a return code of 0
And the timestamp from gpcrondump is stored
And the user runs command "psql -f test/behave/mgmt_utils/steps/data/special_chars/select_from_special_table.sql " DB\`~@#\$%^&*()_-+[{]}|\\;: \\'/?><;1 " > /tmp/126_special_table_data.ans"
And the user runs command "psql -f test/behave/mgmt_utils/steps/data/special_chars/select_from_special_table.sql "$SP_CHAR_DB" > /tmp/126_special_table_data.ans"
Scenario: 127 gpcrondump with --exclude-schema-file option when schema name and database name contains special character
Given the backup test is initialized for special characters
When the user runs command "gpcrondump -a -x " DB\`~@#\$%^&*()_-+[{]}|\\;: \\'/?><;1 " --exclude-schema-file test/behave/mgmt_utils/steps/data/special_chars/schema-file.txt"
When the user runs command "gpcrondump -a -x "$SP_CHAR_DB" --exclude-schema-file test/behave/mgmt_utils/steps/data/special_chars/schema-file.txt"
Then gpcrondump should return a return code of 0
And the timestamp from gpcrondump is stored
Scenario: 128 gpcrondump with -S option when schema name and database name contains special character
Given the backup test is initialized for special characters
When the user runs command "gpcrondump -a -x " DB\`~@#\$%^&*()_-+[{]}|\\;: \\'/?><;1 " -S " S\`~@#\$%^&*()-+[{]}|\\;: \\'\"/?><1 ""
Then gpcrondump should return a return code of 0
And the timestamp from gpcrondump is stored
Scenario: 129 Gpdbrestore with --table-file option when table name, schema name and database name contains special character
Given the backup test is initialized for special characters
And a list of files "129_ao,129_heap" of tables " S`~@#$%^&*()-+[{]}|\;: \'"/?><1 . ao_T`~@#$%^&*()-+[{]}|\;: \'"/?><1 , S`~@#$%^&*()-+[{]}|\;: \'"/?><1 . heap_T`~@#$%^&*()-+[{]}|\;: \'"/?><1 " in " DB`~@#$%^&*()_-+[{]}|\;: \'/?><;1 " exists for validation
When the user runs command "gpcrondump -a -x " DB\`~@#\$%^&*()_-+[{]}|\\;: \\'/?><;1 ""
When the user runs command "gpcrondump -a -x "$SP_CHAR_DB" -S "$SP_CHAR_SCHEMA""
Then gpcrondump should return a return code of 0
And the timestamp from gpcrondump is stored
Scenario: 130 Gpdbrestore with -T, --truncate, and --change-schema options when table name, schema name and database name contains special character
Given the backup test is initialized for special characters
And the user runs command "psql -f psql -c """select * from \" S\`~@#\$%^&*()-+[{]}|\\;: \\'\"\"/?><1 \".\" ao_T\`~@#\$%^&*()-+[{]}|\\;: \\'\"\"/?><1 \" order by 1""" -d " DB\`~@#\$%^&*()_-+[{]}|\\;: \\'/?><;1 " > /tmp/130_table_data.ans"
And the user runs command "gpcrondump -a -x " DB\`~@#\$%^&*()_-+[{]}|\\;: \\'/?><;1 ""
And the user runs command "psql -f psql -c """select * from \"$SP_CHAR_SCHEMA\".\"$SP_CHAR_AO\" order by 1""" -d "$SP_CHAR_DB" > /tmp/130_table_data.ans"
And the user runs command "gpcrondump -a -x "$SP_CHAR_DB""
Then gpcrondump should return a return code of 0
And the timestamp from gpcrondump is stored
Scenario: 131 gpcrondump with --incremental option when table name, schema name and database name contains special character
Given the backup test is initialized for special characters
When the user runs command "gpcrondump -a -x " DB\`~@#\$%^&*()_-+[{]}|\\;: \\'/?><;1 ""
When the user runs command "gpcrondump -a -x "$SP_CHAR_DB""
Then gpcrondump should return a return code of 0
Given the user runs "psql -f test/behave/mgmt_utils/steps/data/special_chars/insert_into_special_table.sql template1"
When the user runs command "gpcrondump -a -x " DB\`~@#\$%^&*()_-+[{]}|\\;: \\'/?><;1 " --incremental"
When the user runs command "gpcrondump -a -x "$SP_CHAR_DB" --incremental"
Then gpcrondump should return a return code of 0
And the timestamp from gpcrondump is stored
When the user runs command "psql -f test/behave/mgmt_utils/steps/data/special_chars/select_from_special_table.sql " DB\`~@#\$%^&*()_-+[{]}|\\;: \\'/?><;1 " > /tmp/131_special_table_data.ans"
When the user runs command "psql -f test/behave/mgmt_utils/steps/data/special_chars/select_from_special_table.sql "$SP_CHAR_DB" > /tmp/131_special_table_data.ans"
Scenario: 132 gpdbrestore with --redirect option with special db name, and all table name, schema name and database name contain special character
Given the backup test is initialized for special characters
When the user runs command "gpcrondump -a -x " DB\`~@#\$%^&*()_-+[{]}|\\;: \\'/?><;1 ""
When the user runs command "gpcrondump -a -x "$SP_CHAR_DB""
Then gpcrondump should return a return code of 0
And the timestamp from gpcrondump is stored
When the user runs command "psql -f test/behave/mgmt_utils/steps/data/special_chars/select_from_special_table.sql " DB\`~@#\$%^&*()_-+[{]}|\\;: \\'/?><;1 " > /tmp/132_special_table_data.ans"
When the user runs command "psql -f test/behave/mgmt_utils/steps/data/special_chars/select_from_special_table.sql "$SP_CHAR_DB" > /tmp/132_special_table_data.ans"
Scenario: 133 gpdbrestore, -S option, -S truncate option schema level restore with special chars in schema name
Given the backup test is initialized for special characters
When the user runs command "gpcrondump -a -x " DB\`~@#\$%^&*()_-+[{]}|\\;: \\'/?><;1 ""
Then gpcrondump should return a return code of 0
And the timestamp from gpcrondump is stored
When the user runs command "psql -f test/behave/mgmt_utils/steps/data/special_chars/select_from_special_table.sql " DB\`~@#\$%^&*()_-+[{]}|\\;: \\'/?><;1 " > /tmp/133_special_table_data.ans"
Scenario: 134 gpdbrestore, --noplan option with special chars in database name, schema name, and table name
Given the backup test is initialized for special characters
When the user runs command "gpcrondump -a -x " DB\`~@#\$%^&*()_-+[{]}|\\;: \\'/?><;1 ""
Then gpcrondump should return a return code of 0
Given the user runs "psql -f test/behave/mgmt_utils/steps/data/special_chars/insert_into_special_ao_table.sql template1"
When the user runs command "gpcrondump -a -x " DB\`~@#\$%^&*()_-+[{]}|\\;: \\'/?><;1 " --incremental"
Then gpcrondump should return a return code of 0
And the timestamp from gpcrondump is stored
When the user runs command "psql -f test/behave/mgmt_utils/steps/data/special_chars/select_from_special_ao_table.sql " DB\`~@#\$%^&*()_-+[{]}|\\;: \\'/?><;1 " > /tmp/134_special_ao_table_data.ans"
Scenario: 135 Gpdbrestore, --change-schema option does not work with -S schema level restore option
Given the backup test is initialized for special characters
And the user runs "psql -f test/behave/mgmt_utils/steps/data/special_chars/create_special_database.sql template1"
And the user runs "psql -f test/behave/mgmt_utils/steps/data/special_chars/create_special_schema.sql template1"
And the user runs "psql -f test/behave/mgmt_utils/steps/data/special_chars/create_special_table.sql template1"
When the user runs command "gpcrondump -a -x " DB\`~@#\$%^&*()_-+[{]}|\\;: \\'/?><;1 ""
When the user runs command "gpcrondump -a -x "$SP_CHAR_DB""
Then gpcrondump should return a return code of 0
And the timestamp from gpcrondump is stored
When the user runs command "psql -f test/behave/mgmt_utils/steps/data/special_chars/select_from_special_table.sql "$SP_CHAR_DB" > /tmp/133_special_table_data.ans"
@skip_for_gpdb_43
Scenario: 136 Backup and restore CAST, with associated function in restored schema, base_file_name=dump_func_name
......
......@@ -575,30 +575,29 @@ Feature: Validate command line arguments
And gpcrondump should print "file is not formatted properly" to stdout
And the mail_contacts file does not exist
Scenario: Gpcrondump, --table-file, --exclude-table-file, --schema-file and --exclude-schema-file if file contains double quoted table and schema name then gpcrondump should error out finding table does not exists
Scenario: If file contains double quoted table and schema name then gpcrondump should error out finding table does not exist
Given the backup test is initialized with no backup files
And the user runs "psql -f test/behave/mgmt_utils/steps/data/special_chars/create_special_database.sql template1"
And the user runs "psql -f test/behave/mgmt_utils/steps/data/special_chars/create_special_schema.sql template1"
And the user runs "psql -f test/behave/mgmt_utils/steps/data/special_chars/create_special_table.sql template1"
# --table-file=<filename> option
When the user runs command "gpcrondump -a -x " DB\`~@#\$%^&*()_-+[{]}|\\;: \\'/?><;1 " --table-file test/behave/mgmt_utils/steps/data/special_chars/table-file-double-quote.txt"
When the user runs command "gpcrondump -a -x "$SP_CHAR_DB" --table-file test/behave/mgmt_utils/steps/data/special_chars/table-file-double-quote.txt"
Then gpcrondump should return a return code of 2
And gpcrondump should print "does not exist" to stdout
# --exclude-table-file=<filename> option
When the user runs command "gpcrondump -a -x " DB\`~@#\$%^&*()_-+[{]}|\\;: \\'/?><;1 " --exclude-table-file test/behave/mgmt_utils/steps/data/special_chars/table-file-double-quote.txt"
When the user runs command "gpcrondump -a -x "$SP_CHAR_DB" --exclude-table-file test/behave/mgmt_utils/steps/data/special_chars/table-file-double-quote.txt"
Then gpcrondump should return a return code of 0
And gpcrondump should print "does not exist" to stdout
And gpcrondump should print "All exclude table names have been removed due to issues" to stdout
# --schema-file
When the user runs command "gpcrondump -a -x " DB\`~@#\$%^&*()_-+[{]}|\\;: \\'/?><;1 " --schema-file test/behave/mgmt_utils/steps/data/special_chars/schema-file-double-quote.txt"
When the user runs command "gpcrondump -a -x "$SP_CHAR_DB" --schema-file test/behave/mgmt_utils/steps/data/special_chars/schema-file-double-quote.txt"
Then gpcrondump should return a return code of 2
And gpcrondump should print "does not exist" to stdout
# --exclude-schema-file
When the user runs command "gpcrondump -a -x " DB\`~@#\$%^&*()_-+[{]}|\\;: \\'/?><;1 " --exclude-schema-file test/behave/mgmt_utils/steps/data/special_chars/schema-file-double-quote.txt"
When the user runs command "gpcrondump -a -x "$SP_CHAR_DB" --exclude-schema-file test/behave/mgmt_utils/steps/data/special_chars/schema-file-double-quote.txt"
Then gpcrondump should return a return code of 0
And the user runs "psql -f test/behave/mgmt_utils/steps/data/special_chars/drop_special_database.sql template1"
Scenario: Absolute path should be provided with -u option for gpcrondump
Given the backup test is initialized with no backup files
And there is a "heap" table "heap_table" in "bkdb" with data
......
......@@ -7,11 +7,6 @@ Feature: Validate command line arguments
Then gpdbrestore should return a return code of 2
And gpdbrestore should print "Cannot specify --list-backup and -e together" to stdout
Scenario: gpdbrestore, -s option with special chars
Given the backup test is initialized with no backup files
When the user runs command "gpdbrestore -s " DB\`~@#\$%^&*()_-+[{]}|\\;:.;\n\t \\'/?><;2 ""
Then gpdbrestore should print "Name has an invalid character" to stdout
Scenario: Funny characters in the table name or schema name for gpdbrestore
Given the backup test is initialized with no backup files
And database "testdb" exists
......
......@@ -412,12 +412,17 @@ def impl(context, role_name, dbname):
def impl(context, filenames, table_list, dbname):
files = [f for f in filenames.split(',')]
tables = [t for t in table_list.split(',')]
dbname = replace_special_char_env(dbname)
for t,f in zip(tables,files):
t = replace_special_char_env(t)
f = replace_special_char_env(f)
backup_data_to_file(context, t, dbname, f)
@when('verify with backedup file "{filename}" that there is a "{table_type}" table "{tablename}" in "{dbname}" with data')
@then('verify with backedup file "{filename}" that there is a "{table_type}" table "{tablename}" in "{dbname}" with data')
def impl(context, filename, table_type, tablename, dbname):
dbname = replace_special_char_env(dbname)
tablename = replace_special_char_env(tablename)
if not check_table_exists(context, dbname=dbname, table_name=tablename, table_type=table_type):
raise Exception("Table '%s' does not exist when it should" % tablename)
validate_restore_data_in_file(context, tablename, dbname, filename)
......
......@@ -1088,6 +1088,8 @@ def impl(context, options):
@then('verify that there is no table "{tablename}" in "{dbname}"')
def impl(context, tablename, dbname):
dbname = replace_special_char_env(dbname)
tablename = replace_special_char_env(tablename)
if check_table_exists(context, dbname=dbname, table_name=tablename):
raise Exception("Table '%s' still exists when it should not" % tablename)
......@@ -4404,6 +4406,12 @@ def impl(context, dbname):
@given('the backup test is initialized for special characters')
def impl(context):
os.environ["SP_CHAR_DB"] = """ DB`~@#$%^&*()_-+[{]}|\;: \\'/?><;1 """
os.environ["SP_CHAR_SCHEMA"] = """ S`~@#$%^&*()-+[{]}|\;: \\'"/?><1 """
os.environ["SP_CHAR_SCHEMA2"] = """ S`~@#$%^&*()_-+[{]}|\;: \\'"/?><2 """
os.environ["SP_CHAR_HEAP"] = """ heap_T`~@#$%^&*()-+[{]}|\;: \\'"/?><1 """
os.environ["SP_CHAR_AO"] = """ ao_T`~@#$%^&*()-+[{]}|\;: \\'"/?><1 """
os.environ["SP_CHAR_CO"] = """ co_T`~@#$%^&*()-+[{]}|\;: \\'"/?><1 """
context.execute_steps(u'''
Given the database is running
And the user runs "psql -f test/behave/mgmt_utils/steps/data/special_chars/create_special_database.sql template1"
......
......@@ -1651,3 +1651,10 @@ def is_process_running(proc_name):
def file_contains_line(filepath, target_line):
with open(filepath, 'r') as myfile:
return target_line in myfile.read().splitlines()
def replace_special_char_env(str):
for var in ["SP_CHAR_DB", "SP_CHAR_SCHEMA", "SP_CHAR_AO", "SP_CHAR_CO", "SP_CHAR_HEAP"]:
if var in os.environ:
str = str.replace("$%s" % var, os.environ[var])
return str
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册