Add Reverse Engineered SQL tests for FTS Parsers. Fixes #4471

This commit is contained in:
Shubham Agarwal 2019-07-15 12:02:44 +01:00 committed by Dave Page
parent 1831c9e70a
commit 809e0682bd
5 changed files with 77 additions and 3 deletions

View File

@ -26,6 +26,8 @@ Housekeeping
| `Issue #4463 <https://redmine.postgresql.org/issues/4463>`_ - Add Reverse Engineered SQL tests for Domains. | `Issue #4463 <https://redmine.postgresql.org/issues/4463>`_ - Add Reverse Engineered SQL tests for Domains.
| `Issue #4464 <https://redmine.postgresql.org/issues/4464>`_ - Add Reverse Engineered SQL tests for Collations. | `Issue #4464 <https://redmine.postgresql.org/issues/4464>`_ - Add Reverse Engineered SQL tests for Collations.
| `Issue #4468 <https://redmine.postgresql.org/issues/4468>`_ - Add Reverse Engineered SQL tests for Types. | `Issue #4468 <https://redmine.postgresql.org/issues/4468>`_ - Add Reverse Engineered SQL tests for Types.
| `Issue #4471 <https://redmine.postgresql.org/issues/4471>`_ - Add Reverse Engineered SQL tests for FTS Parsers.
Bug fixes Bug fixes
********* *********

View File

@ -0,0 +1,13 @@
-- Text Search Parser: public."test_fts_parser_updated_$%{}[]()&*^!@""'`\/#"
-- DROP TEXT SEARCH PARSER public."test_fts_parser_updated_$%{}[]()&*^!@""'`\/#"
CREATE TEXT SEARCH PARSER public."test_fts_parser_updated_$%{}[]()&*^!@""'`\/#" (
START = prsd_start,
GETTOKEN = prsd_nexttoken,
END = void_recv,
LEXTYPES = dispell_init,
HEADLINE = prsd_headline
);
COMMENT ON TEXT SEARCH PARSER public."test_fts_parser_updated_$%{}[]()&*^!@""'`\/#" IS 'Updating test fts parser';

View File

@ -0,0 +1,13 @@
-- Text Search Parser: public."test_fts_parser_$%{}[]()&*^!@""'`\/#"
-- DROP TEXT SEARCH PARSER public."test_fts_parser_$%{}[]()&*^!@""'`\/#"
CREATE TEXT SEARCH PARSER public."test_fts_parser_$%{}[]()&*^!@""'`\/#" (
START = prsd_start,
GETTOKEN = prsd_nexttoken,
END = void_recv,
LEXTYPES = dispell_init,
HEADLINE = prsd_headline
);
COMMENT ON TEXT SEARCH PARSER public."test_fts_parser_$%{}[]()&*^!@""'`\/#" IS 'Creating test fts parser';

View File

@ -0,0 +1,40 @@
{
"scenarios": [
{
"type": "create",
"name": "Create FTS parser",
"endpoint": "NODE-fts_parser.obj",
"sql_endpoint": "NODE-fts_parser.sql_id",
"data": {
"name": "test_fts_parser_$%{}[]()&*^!@\"'`\\/#",
"description": "Creating test fts parser",
"schema": "public",
"schema_id": "<SCHEMA_ID>",
"prsstart": "prsd_start",
"prstoken": "prsd_nexttoken",
"prsend": "void_recv",
"prslextype": "dispell_init",
"prsheadline": "prsd_headline"
},
"expected_sql_file": "create_fts_parser.sql"
},
{
"type": "alter",
"name": "Alter FTS parser",
"endpoint": "NODE-fts_parser.obj_id",
"sql_endpoint": "NODE-fts_parser.sql_id",
"data":{
"name": "test_fts_parser_updated_$%{}[]()&*^!@\"'`\\/#",
"description":"Updating test fts parser"},
"expected_sql_file": "alter_fts_parser.sql"
},
{
"type": "delete",
"name": "Drop FTS Parser",
"endpoint": "NODE-fts_parser.delete_id",
"data": {
"name": "test_fts_configuration_def2"
}
}
]
}

View File

@ -337,9 +337,15 @@ class ReverseEngineeredSQLTestCases(BaseTestGenerator):
self.final_test_status = False self.final_test_status = False
print(scenario['name'] + "... FAIL") print(scenario['name'] + "... FAIL")
traceback.print_exc() traceback.print_exc()
try:
resp = json.loads(response.data) if type(response.data) == bytes:
resp_sql = resp['data'] response_data = response.data.decode('utf8')
resp = json.loads(response_data)
else:
resp = json.loads(response.data)
resp_sql = resp['data']
except Exception:
print("Unable to decode the response data from url: ", url)
# Remove first and last double quotes # Remove first and last double quotes
if resp_sql.startswith('"') and resp_sql.endswith('"'): if resp_sql.startswith('"') and resp_sql.endswith('"'):