mirror of
https://github.com/FirebirdSQL/firebird-qa.git
synced 2025-02-02 10:50:42 +01:00
Added/Updated tests\bugs\core_5470_test.py: Reimplementedб ыуу тщеуы шт еру еуые ыщгксу
This commit is contained in:
parent
96ef8484d4
commit
db76332dc5
@ -1,72 +1,114 @@
|
||||
#coding:utf-8
|
||||
|
||||
"""
|
||||
ID: issue-5740-A
|
||||
ISSUE: 5740-A
|
||||
ID: issue-5740
|
||||
ISSUE: https://github.com/FirebirdSQL/firebird/issues/5740
|
||||
TITLE: Trace INCLUDE_FILTER with [[:WHITESPACE:]]+ does not work when statement contains newline is issued
|
||||
DESCRIPTION:
|
||||
We create a list of several DDLs which all contain NEWLINE character(s) between keyword and name of DB object.
|
||||
Then we launch trace session and execute all these DDLs.
|
||||
Finally we check whether trace log contains every DDL or not.
|
||||
Expected result: text of every DDL should be FOUND in the trace log.
|
||||
We create a list of several DDLs which all contain NEWLINE character(s) between keyword and name of DB object.
|
||||
Then we launch trace session and execute all these DDLs.
|
||||
Finally we check whether trace log contains every DDL or not.
|
||||
Expected result: text of every DDL should be FOUND in the trace log.
|
||||
JIRA: CORE-5470
|
||||
FBTEST: bugs.core_5470
|
||||
NOTES:
|
||||
[04.03.2023] pzotov
|
||||
Reimplemented because on Windows act.trace_log ends with *weird* sequence of characters: chr(13) + SPACE + chr(10).
|
||||
This causes to incorrect result of act.stdout.find(cmd): it returns -1 for every DDL command and test fails
|
||||
(because every <cmd> is multi-line text with correct EOL delimiters).
|
||||
In order to check that trace contains all lines of every DDL statement, we add 'tags' into each of these lines,
|
||||
and check that final trace output contains all these tags: "ddl_1 line_1", "ddl_1 line_2" etc.
|
||||
|
||||
Confirmed bug on 3.0.1.32609 (27-sep-2016) -- act.trace_log is empty list
|
||||
Checked on:
|
||||
3.0.2.32703 (21-mar-2017); 3.0.11.33665; 4.0.3.2904; 5.0.0.970 -- all fine.
|
||||
"""
|
||||
|
||||
import os
|
||||
import pytest
|
||||
from firebird.qa import *
|
||||
from pathlib import Path
|
||||
import time
|
||||
|
||||
db = db_factory()
|
||||
|
||||
act = python_act('db')
|
||||
act = python_act('db', substitutions = [('^((?!ddl_).)*$', '')])
|
||||
|
||||
ddl_lst = ["""recreate
|
||||
tmp_file = temp_file('tmp_trace_5470.txt')
|
||||
|
||||
table
|
||||
ddl_lst = ["""recreate /* ddl_1 line_1 */
|
||||
|
||||
table /* ddl_1 line_2 */
|
||||
|
||||
|
||||
|
||||
t_test(x int)
|
||||
t_test /* ddl_1 line_3 */ (x int)
|
||||
""",
|
||||
"""comment on
|
||||
table
|
||||
"""comment on /* ddl_2 line_1 */
|
||||
table /* ddl_2 line_2 */
|
||||
|
||||
|
||||
t_test is
|
||||
'foo
|
||||
bar'
|
||||
t_test is /* ddl_2 line_3 */
|
||||
'foo /* ddl_2 line_4 */
|
||||
/* ddl_2 line_4 */ bar'
|
||||
""",
|
||||
"""
|
||||
|
||||
create
|
||||
or
|
||||
create /* ddl_3 line_1 */
|
||||
or /* ddl_3 line_2 */
|
||||
|
||||
alter
|
||||
view
|
||||
alter /* ddl_3 line_3 */
|
||||
view /* ddl_3 line_4 */
|
||||
|
||||
v_rio
|
||||
v_rio /* ddl_3 line_5 */
|
||||
|
||||
as
|
||||
select *
|
||||
from
|
||||
as /* ddl_3 line_6 */
|
||||
select * /* ddl_3 line_6 */
|
||||
from /* ddl_3 line_7 */
|
||||
|
||||
rdb$database
|
||||
rdb$database /* ddl_3 line_8 */
|
||||
"""]
|
||||
|
||||
trace = ['time_threshold = 0',
|
||||
'log_initfini = false',
|
||||
'log_errors = true',
|
||||
#'log_initfini = false',
|
||||
#'log_errors = true',
|
||||
'log_statement_finish = true',
|
||||
'include_filter = "%(recreate|create|alter|drop|comment on)[[:WHITESPACE:]]+(domain|generator|sequence|exception|procedure|function|table|index|view|trigger|role|filter|external function)%"',
|
||||
'max_sql_length = 32768', # <<< !!! <<<
|
||||
'include_filter = "%(ddl_[[:DIGIT:]]+[[:WHITESPACE:]]+line_[[:DIGIT:]]+)%"',
|
||||
]
|
||||
|
||||
@pytest.mark.version('>=3')
|
||||
def test_1(act: Action):
|
||||
expected_trace_log = """
|
||||
recreate /* ddl_1 line_1 */
|
||||
table /* ddl_1 line_2 */
|
||||
t_test /* ddl_1 line_3 */ (x int)
|
||||
|
||||
comment on /* ddl_2 line_1 */
|
||||
table /* ddl_2 line_2 */
|
||||
t_test is /* ddl_2 line_3 */
|
||||
'foo /* ddl_2 line_4 */
|
||||
/* ddl_2 line_4 */ bar'
|
||||
|
||||
create /* ddl_3 line_1 */
|
||||
or /* ddl_3 line_2 */
|
||||
alter /* ddl_3 line_3 */
|
||||
view /* ddl_3 line_4 */
|
||||
v_rio /* ddl_3 line_5 */
|
||||
as /* ddl_3 line_6 */
|
||||
select * /* ddl_3 line_6 */
|
||||
from /* ddl_3 line_7 */
|
||||
rdb$database /* ddl_3 line_8 */
|
||||
"""
|
||||
|
||||
@pytest.mark.version('>=3.0.2')
|
||||
def test_1(act: Action, tmp_file: Path, capsys):
|
||||
with act.trace(db_events=trace), act.db.connect() as con:
|
||||
for cmd in ddl_lst:
|
||||
con.execute_immediate(cmd)
|
||||
con.commit()
|
||||
# Check
|
||||
act.trace_to_stdout()
|
||||
for cmd in ddl_lst:
|
||||
assert act.stdout.find(cmd) > 0
|
||||
|
||||
act.trace_to_stdout() # '\n'.join( [x.replace('\r','').replace('\n','') for x in act.trace_log] )
|
||||
for line in act.stdout.split('\n'):
|
||||
print(line)
|
||||
|
||||
act.expected_stdout = expected_trace_log
|
||||
act.stdout = capsys.readouterr().out
|
||||
assert act.clean_stdout == act.clean_expected_stdout
|
||||
|
Loading…
Reference in New Issue
Block a user