6
0
mirror of https://github.com/FirebirdSQL/firebird-qa.git synced 2025-01-23 14:03:06 +01:00
firebird-qa/tests/bugs/core_2879_test.py

85 lines
2.6 KiB
Python
Raw Normal View History

2021-04-26 20:07:00 +02:00
#coding:utf-8
2022-01-21 18:49:26 +01:00
"""
ID: issue-3263
ISSUE: 3263
TITLE: Sweep could raise error : page 0 is of wrong type (expected 6, found 1)
DESCRIPTION:
Test receives content of firebird.log _before_ and _after_ running query that is show in the ticket.
Then we compare these two files.
Difference between them should relate ONLY to sweep start and finish details, and NOT about page wrong type.
JIRA: CORE-2879
FBTEST: bugs.core_2879
2022-01-21 18:49:26 +01:00
"""
2021-04-26 20:07:00 +02:00
import pytest
2021-11-16 19:44:53 +01:00
import time
import subprocess
from pathlib import Path
from difflib import unified_diff
2022-01-21 18:49:26 +01:00
from firebird.qa import *
2021-04-26 20:07:00 +02:00
2022-01-21 18:49:26 +01:00
db = db_factory()
2021-04-26 20:07:00 +02:00
2022-01-21 18:49:26 +01:00
act = python_act('db', substitutions=[('^((?!start|finish|expected|page|wrong).)*$', '')])
2021-04-26 20:07:00 +02:00
2022-01-21 18:49:26 +01:00
test_script = """
set list on;
set term ^;
execute block returns (dts timestamp, sql varchar(80)) as
declare i int;
declare s varchar(256);
begin
i = 1;
while (i < 32767) do
begin
s = 'tmp' || :i;
dts = 'now';
sql = 'create global temporary table ' || :s || ' (id int);';
execute statement sql with autonomous transaction;
suspend;
2021-04-26 20:07:00 +02:00
2022-01-21 18:49:26 +01:00
dts = 'now';
sql = 'drop table ' || :s || ';';
execute statement sql with autonomous transaction;
suspend;
2021-11-16 19:44:53 +01:00
2022-01-21 18:49:26 +01:00
i = i + 1;
end
end ^
set term ;^
"""
2021-04-26 20:07:00 +02:00
2022-01-21 18:49:26 +01:00
expected_stdout = """
2021-04-26 20:07:00 +02:00
Sweep is started by SYSDBA
Sweep is finished
2021-11-16 19:44:53 +01:00
"""
isql_script = temp_file('test-script.sql')
2022-01-14 14:53:16 +01:00
isql_output = temp_file('test-script.out')
2021-04-26 20:07:00 +02:00
2022-01-21 18:49:26 +01:00
@pytest.mark.version('>=3')
def test_1(act: Action, isql_script: Path, isql_output: Path, capsys):
isql_script.write_text(test_script)
with act.connect_server() as srv:
2021-11-16 19:44:53 +01:00
# Get content of firebird.log BEFORE test
2022-01-21 18:49:26 +01:00
log_before = act.get_firebird_log()
2022-01-14 14:53:16 +01:00
with open(isql_output, mode='w') as isql_out:
2022-01-21 18:49:26 +01:00
p_isql = subprocess.Popen([act.vars['isql'], '-u', act.db.user, '-pas',
act.db.password, act.db.dsn, '-i', str(isql_script)],
2022-01-14 14:53:16 +01:00
stdout=isql_out, stderr=subprocess.STDOUT)
2021-11-16 19:44:53 +01:00
time.sleep(2)
# LAUNCH SWEEP while ISQL is working
2022-01-21 18:49:26 +01:00
srv.database.sweep(database=act.db.db_path)
2021-11-16 19:44:53 +01:00
p_isql.terminate()
# Get content of firebird.log AFTER test
2022-01-21 18:49:26 +01:00
log_after = act.get_firebird_log()
2021-11-16 19:44:53 +01:00
for line in unified_diff(log_before, log_after):
if line.startswith('+') and line.split('+'):
print(line.replace('+', ' '))
2022-01-21 18:49:26 +01:00
act.expected_stdout = expected_stdout
act.stdout = capsys.readouterr().out
assert act.clean_stdout == act.clean_expected_stdout
2021-04-26 20:07:00 +02:00