2 @message |
assert
- EXPECTED: gbak total statistics for writes NOT LESS than ratio DB_FILE_SIZE / PAGE_SIZE
+ UNEXPECTED: gbak_total_writes=1001 -- LESS than restored_file_size/PAGE_SIZE=2638.0
LOG DETAILS:
2025-02-06 11:45:14.160
2025-02-06 11:45:14.160 act = <firebird.qa.plugin.Action object at [hex]>
2025-02-06 11:45:14.160 tmp_fbk = WindowsPath('H:/QA/temp/qa2024.tmp/fbqa/test_11703/tmp_gh_8391.restored.fbk')
2025-02-06 11:45:14.160 tmp_log = WindowsPath('H:/QA/temp/qa2024.tmp/fbqa/test_11703/tmp_gh_8391.restored.log')
2025-02-06 11:45:14.160 capsys = <_pytest.capture.CaptureFixture object at [hex]>
2025-02-06 11:45:14.160
2025-02-06 11:45:14.160 @pytest.mark.version('>=4.0.6')
2025-02-06 11:45:14.160 def test_1(act: Action, tmp_fbk: Path, tmp_log: Path, capsys):
2025-02-06 11:45:14.160
2025-02-06 11:45:14.160 if act.get_server_architecture() != 'SuperServer':
2025-02-06 11:45:14.160 pytest.skip('Applies only to SuperServer')
2025-02-06 11:45:14.160
2025-02-06 11:45:14.160 # Scan line-by-line through databases.conf, find line starting with REQUIRED_ALIAS and extract name of file that
2025-02-06 11:45:14.160 # must be created in the $(dir_sampleDb)/qa/ folder.
2025-02-06 11:45:14.160 # NOTE: we have to SKIP lines which are commented out, i.e. if they starts with '#':
2025-02-06 11:45:14.160 p_required_alias_ptn = re.compile( '^(?!#)((^|\\s+)' + REQUIRED_ALIAS + ')\\s*=\\s*\\$\\(dir_sampleDb\\)/qa/', re.IGNORECASE )
2025-02-06 11:45:14.160 fname_in_dbconf = None
2025-02-06 11:45:14.160
2025-02-06 11:45:14.161 with open(act.home_dir/'databases.conf', 'r') as f:
2025-02-06 11:45:14.161 for line in f:
2025-02-06 11:45:14.161 if p_required_alias_ptn.search(line):
2025-02-06 11:45:14.161 # If databases.conf contains line like this:
2025-02-06 11:45:14.161 # tmp_8391_alias = $(dir_sampleDb)/qa/tmp_qa_8391.fdb
2025-02-06 11:45:14.161 # - then we extract filename: 'tmp_qa_8391.fdb' (see below):
2025-02-06 11:45:14.161 fname_in_dbconf = Path(line.split('=')[1].strip()).name
2025-02-06 11:45:14.161 break
2025-02-06 11:45:14.161
2025-02-06 11:45:14.161 # if 'fname_in_dbconf' remains undefined here then propably REQUIRED_ALIAS not equals to specified in the databases.conf!
2025-02-06 11:45:14.161 #
2025-02-06 11:45:14.161 assert fname_in_dbconf
2025-02-06 11:45:14.161
2025-02-06 11:45:14.161 test_sql = f"""
2025-02-06 11:45:14.161 set list on;
2025-02-06 11:45:14.161 create database '{REQUIRED_ALIAS}' user {act.db.user} password '{act.db.password}' page_size {PAGE_SIZE};
2025-02-06 11:45:14.161 commit;
2025-02-06 11:45:14.161 recreate sequence g;
2025-02-06 11:45:14.161 recreate table test(id int, b blob);
2025-02-06 11:45:14.162
2025-02-06 11:45:14.162 set autoterm on;
2025-02-06 11:45:14.162 execute block as
2025-02-06 11:45:14.162 declare n int;
2025-02-06 11:45:14.162 begin
2025-02-06 11:45:14.162 insert into test(id, b) values(gen_id(g,1), gen_uuid());
2025-02-06 11:45:14.162 insert into test(id, b)
2025-02-06 11:45:14.162 values(
2025-02-06 11:45:14.162 gen_id(g,1)
2025-02-06 11:45:14.162 ,(select list(gen_uuid()) as s from rdb$types,rdb$types)
2025-02-06 11:45:14.162 );
2025-02-06 11:45:14.162
2025-02-06 11:45:14.162 insert into test(id, b)
2025-02-06 11:45:14.162 values(
2025-02-06 11:45:14.162 gen_id(g,1)
2025-02-06 11:45:14.162 ,(select list(gen_uuid()) as s from (select 1 x from rdb$types,rdb$types,rdb$types rows 800000))
2025-02-06 11:45:14.162 );
2025-02-06 11:45:14.162 end
2025-02-06 11:45:14.162 ;
2025-02-06 11:45:14.162 commit;
2025-02-06 11:45:14.163 select mon$database_name, mon$page_buffers from mon$database;
2025-02-06 11:45:14.163 """
2025-02-06 11:45:14.163
2025-02-06 11:45:14.163 test_fdb_file = 'UNDEFINED'
2025-02-06 11:45:14.163 act.isql(switches=['-q'], input = test_sql, connect_db = False, credentials = False, combine_output = True, io_enc = locale.getpreferredencoding())
2025-02-06 11:45:14.163 for line in act.stdout.splitlines():
2025-02-06 11:45:14.163 if line.startswith('mon$database_name'.upper()):
2025-02-06 11:45:14.163 test_fdb_file = line.split()[1]
2025-02-06 11:45:14.163 if line.startswith('mon$page_buffers'.upper()):
2025-02-06 11:45:14.163 test_fdb_buffers = int(line.split()[1])
2025-02-06 11:45:14.163
2025-02-06 11:45:14.163 assert test_fdb_buffers == 128
2025-02-06 11:45:14.163 act.reset()
2025-02-06 11:45:14.163
2025-02-06 11:45:14.163 act.gbak(switches=['-b', act.db.dsn, str(tmp_fbk)], combine_output = True, io_enc = locale.getpreferredencoding())
2025-02-06 11:45:14.163 assert act.clean_stdout == ''
2025-02-06 11:45:14.163 act.reset()
2025-02-06 11:45:14.164
2025-02-06 11:45:14.164 act.gbak(switches=['-rep', '-v', '-st', 'w', str(tmp_fbk), REQUIRED_ALIAS], combine_output = True, io_enc = locale.getpreferredencoding())
2025-02-06 11:45:14.164
2025-02-06 11:45:14.164 # gbak: NNNN total statistics
2025-02-06 11:45:14.164 gbak_write_total_stat_ptn = re.compile( r'gbak(:)?\s+\d+\s+total\s+statistics', re.IGNORECASE )
2025-02-06 11:45:14.164
2025-02-06 11:45:14.164 EXPECTED_MSG = 'EXPECTED: gbak total statistics for writes NOT LESS than ratio DB_FILE_SIZE / PAGE_SIZE'
2025-02-06 11:45:14.164 for line in act.stdout.splitlines():
2025-02-06 11:45:14.164 if gbak_write_total_stat_ptn.search(line):
2025-02-06 11:45:14.164 gbak_total_writes = int(line.split()[1])
2025-02-06 11:45:14.164 restored_file_size = os.stat(test_fdb_file).st_size
2025-02-06 11:45:14.164 if gbak_total_writes >= restored_file_size / PAGE_SIZE:
2025-02-06 11:45:14.164 print(EXPECTED_MSG)
2025-02-06 11:45:14.164 else:
2025-02-06 11:45:14.164 print(f'UNEXPECTED: {gbak_total_writes=} -- LESS than {restored_file_size/PAGE_SIZE=}')
2025-02-06 11:45:14.164
2025-02-06 11:45:14.164 act.expected_stdout = EXPECTED_MSG
2025-02-06 11:45:14.164 act.stdout = capsys.readouterr().out
2025-02-06 11:45:14.164 > assert act.clean_stdout == act.clean_expected_stdout
2025-02-06 11:45:14.165 E assert
2025-02-06 11:45:14.165 E - EXPECTED: gbak total statistics for writes NOT LESS than ratio DB_FILE_SIZE / PAGE_SIZE
2025-02-06 11:45:14.165 E + UNEXPECTED: gbak_total_writes=1001 -- LESS than restored_file_size/PAGE_SIZE=2638.0
2025-02-06 11:45:14.165
2025-02-06 11:45:14.165 tests\bugs\gh_8391_test.py:136: AssertionError
|
3 #text |
act = <firebird.qa.plugin.Action pytest object at [hex]>
tmp_fbk = WindowsPath('H:/QA/temp/qa2024.tmp/fbqa/test_11703/tmp_gh_8391.restored.fbk')
tmp_log = WindowsPath('H:/QA/temp/qa2024.tmp/fbqa/test_11703/tmp_gh_8391.restored.log')
capsys = <_pytest.capture.CaptureFixture pytest object at [hex]>
@pytest.mark.version('>=4.0.6')
def test_1(act: Action, tmp_fbk: Path, tmp_log: Path, capsys):
if act.get_server_architecture() != 'SuperServer':
pytest.skip('Applies only to SuperServer')
# Scan line-by-line through databases.conf, find line starting with REQUIRED_ALIAS and extract name of file that
# must be created in the $(dir_sampleDb)/qa/ folder.
# NOTE: we have to SKIP lines which are commented out, i.e. if they starts with '#':
p_required_alias_ptn = re.compile( '^(?!#)((^|\\s+)' + REQUIRED_ALIAS + ')\\s*=\\s*\\$\\(dir_sampleDb\\)/qa/', re.IGNORECASE )
fname_in_dbconf = None
with open(act.home_dir/'databases.conf', 'r') as f:
for line in f:
if p_required_alias_ptn.search(line):
# If databases.conf contains line like this:
# tmp_8391_alias = $(dir_sampleDb)/qa/tmp_qa_8391.fdb
# - then we extract filename: 'tmp_qa_8391.fdb' (see below):
fname_in_dbconf = Path(line.split('=')[1].strip()).name
break
# if 'fname_in_dbconf' remains undefined here then propably REQUIRED_ALIAS not equals to specified in the databases.conf!
#
assert fname_in_dbconf
test_sql = f"""
set list on;
create database '{REQUIRED_ALIAS}' user {act.db.user} password '{act.db.password}' page_size {PAGE_SIZE};
commit;
recreate sequence g;
recreate table test(id int, b blob);
set autoterm on;
execute block as
declare n int;
begin
insert into test(id, b) values(gen_id(g,1), gen_uuid());
insert into test(id, b)
values(
gen_id(g,1)
,(select list(gen_uuid()) as s from rdb$types,rdb$types)
);
insert into test(id, b)
values(
gen_id(g,1)
,(select list(gen_uuid()) as s from (select 1 x from rdb$types,rdb$types,rdb$types rows 800000))
);
end
;
commit;
select mon$database_name, mon$page_buffers from mon$database;
"""
test_fdb_file = 'UNDEFINED'
act.isql(switches=['-q'], input = test_sql, connect_db = False, credentials = False, combine_output = True, io_enc = locale.getpreferredencoding())
for line in act.stdout.splitlines():
if line.startswith('mon$database_name'.upper()):
test_fdb_file = line.split()[1]
if line.startswith('mon$page_buffers'.upper()):
test_fdb_buffers = int(line.split()[1])
assert test_fdb_buffers == 128
act.reset()
act.gbak(switches=['-b', act.db.dsn, str(tmp_fbk)], combine_output = True, io_enc = locale.getpreferredencoding())
assert act.clean_stdout == ''
act.reset()
act.gbak(switches=['-rep', '-v', '-st', 'w', str(tmp_fbk), REQUIRED_ALIAS], combine_output = True, io_enc = locale.getpreferredencoding())
# gbak: NNNN total statistics
gbak_write_total_stat_ptn = re.compile( r'gbak(:)?\s+\d+\s+total\s+statistics', re.IGNORECASE )
EXPECTED_MSG = 'EXPECTED: gbak total statistics for writes NOT LESS than ratio DB_FILE_SIZE / PAGE_SIZE'
for line in act.stdout.splitlines():
if gbak_write_total_stat_ptn.search(line):
gbak_total_writes = int(line.split()[1])
restored_file_size = os.stat(test_fdb_file).st_size
if gbak_total_writes >= restored_file_size / PAGE_SIZE:
print(EXPECTED_MSG)
else:
print(f'UNEXPECTED: {gbak_total_writes=} -- LESS than {restored_file_size/PAGE_SIZE=}')
act.expected_stdout = EXPECTED_MSG
act.stdout = capsys.readouterr().out
> assert act.clean_stdout == act.clean_expected_stdout
E assert
E - EXPECTED: gbak total statistics for writes NOT LESS than ratio DB_FILE_SIZE / PAGE_SIZE
E + UNEXPECTED: gbak_total_writes=1001 -- LESS than restored_file_size/PAGE_SIZE=2638.0
tests\bugs\gh_8391_test.py:136: AssertionError
|