2 @message |
assert
- Fetches ratio expected.
+ Fetches ratio between 1st and 2nd requests to PP = 0 - UNEXPECTED:
+ Request #1: 47631
+ Request #2: 115943
LOG DETAILS:
2024-05-09 21:54:22.853
2024-05-09 21:54:22.853 act = <firebird.qa.plugin.Action object at [hex]>
2024-05-09 21:54:22.853 capsys = <_pytest.capture.CaptureFixture object at [hex]>
2024-05-09 21:54:22.853
2024-05-09 21:54:22.853 @pytest.mark.version('>=4.0.5')
2024-05-09 21:54:22.853 def test_1(act: Action, capsys):
2024-05-09 21:54:22.853
2024-05-09 21:54:22.853 get_last_pp_for_table = f"""
2024-05-09 21:54:22.853 select p.rdb$relation_id, p.rdb$page_sequence
2024-05-09 21:54:22.853 from rdb$pages p join rdb$relations r on p.rdb$relation_id = r.rdb$relation_id
2024-05-09 21:54:22.853 where r.rdb$relation_name = '{TAB_NAME}' and p.rdb$page_type = 4
2024-05-09 21:54:22.853 order by 2 desc
2024-05-09 21:54:22.853 rows 1
2024-05-09 21:54:22.853 """
2024-05-09 21:54:22.853 rel_id, max_pp = -1, -1
2024-05-09 21:54:22.853 with act.db.connect(no_gc = True) as con:
2024-05-09 21:54:22.853 cur = con.cursor()
2024-05-09 21:54:22.853 cur.execute(get_last_pp_for_table)
2024-05-09 21:54:22.853 for r in cur:
2024-05-09 21:54:22.853 rel_id, max_pp = r[:2]
2024-05-09 21:54:22.853 assert rel_id > 0 and max_pp > 0
2024-05-09 21:54:22.853 #--------------------------------
2024-05-09 21:54:22.853
2024-05-09 21:54:22.853 # Subsequent number of PP that we want to check ('20' in the ticket):
2024-05-09 21:54:22.854 ##########
2024-05-09 21:54:22.854 chk_pp = 0
2024-05-09 21:54:22.854 ##########
2024-05-09 21:54:22.854
2024-05-09 21:54:22.854 read_records_for_chk_pp = f"""
2024-05-09 21:54:22.854 select count(*), min(id), max(id)
2024-05-09 21:54:22.854 from t1
2024-05-09 21:54:22.854 where
2024-05-09 21:54:22.854 rdb$db_key >= make_dbkey({rel_id}, 0, 0, {chk_pp})
2024-05-09 21:54:22.854 and rdb$db_key < make_dbkey({rel_id}, 0, 0, {chk_pp+1})
2024-05-09 21:54:22.854 """
2024-05-09 21:54:22.854
2024-05-09 21:54:22.854 fetches_ini = con.info.fetches
2024-05-09 21:54:22.854 # read records from selected PP only -- FIRST TIME
2024-05-09 21:54:22.854 cur.execute(read_records_for_chk_pp)
2024-05-09 21:54:22.854 cur.fetchall()
2024-05-09 21:54:22.854 fetches_1 = con.info.fetches - fetches_ini
2024-05-09 21:54:22.854
2024-05-09 21:54:22.854 #----------------------------------
2024-05-09 21:54:22.854
2024-05-09 21:54:22.854 # delete records from selected PP and up to the end
2024-05-09 21:54:22.854 del_rows_starting_from_chk_pp = f"""
2024-05-09 21:54:22.854 delete from t1
2024-05-09 21:54:22.854 where rdb$db_key >= make_dbkey({rel_id}, 0, 0, {chk_pp})
2024-05-09 21:54:22.854 """
2024-05-09 21:54:22.854 con.execute_immediate(del_rows_starting_from_chk_pp)
2024-05-09 21:54:22.854
2024-05-09 21:54:22.855 #----------------------------------
2024-05-09 21:54:22.855
2024-05-09 21:54:22.855 fetches_ini = con.info.fetches
2024-05-09 21:54:22.855 # read records from selected PP only -- SECOND TIME
2024-05-09 21:54:22.855 cur.execute(read_records_for_chk_pp)
2024-05-09 21:54:22.855 cur.fetchall()
2024-05-09 21:54:22.855 fetches_2 = con.info.fetches - fetches_ini
2024-05-09 21:54:22.855
2024-05-09 21:54:22.855 expected_msg = 'Fetches ratio expected.'
2024-05-09 21:54:22.855
2024-05-09 21:54:22.855 if fetches_2 <= fetches_1:
2024-05-09 21:54:22.855 print(expected_msg)
2024-05-09 21:54:22.855 else:
2024-05-09 21:54:22.855 print(f'Fetches ratio between 1st and 2nd requests to PP = {chk_pp} - UNEXPECTED:')
2024-05-09 21:54:22.855 print('Request #1:', fetches_1)
2024-05-09 21:54:22.855 print('Request #2:', fetches_2)
2024-05-09 21:54:22.855
2024-05-09 21:54:22.855 act.expected_stdout = f"""
2024-05-09 21:54:22.855 {expected_msg}
2024-05-09 21:54:22.855 """
2024-05-09 21:54:22.855 act.stdout = capsys.readouterr().out
2024-05-09 21:54:22.855 > assert act.clean_stdout == act.clean_expected_stdout
2024-05-09 21:54:22.855 E assert
2024-05-09 21:54:22.855 E - Fetches ratio expected.
2024-05-09 21:54:22.855 E + Fetches ratio between 1st and 2nd requests to PP = 0 - UNEXPECTED:
2024-05-09 21:54:22.855 E + Request #1: 47631
2024-05-09 21:54:22.855 E + Request #2: 115943
2024-05-09 21:54:22.855
2024-05-09 21:54:22.855 tests\bugs\gh_8104_test.py:128: AssertionError
2024-05-09 21:54:22.855 ---------------------------- Captured stdout setup ----------------------------
2024-05-09 21:54:22.855 Cached db: db-13.0-None-None-NONE.fdb [page_size=None, sql_dialect=None, charset='NONE'
|
3 #text |
act = <firebird.qa.plugin.Action pytest object at [hex]>
capsys = <_pytest.capture.CaptureFixture pytest object at [hex]>
@pytest.mark.version('>=4.0.5')
def test_1(act: Action, capsys):
get_last_pp_for_table = f"""
select p.rdb$relation_id, p.rdb$page_sequence
from rdb$pages p join rdb$relations r on p.rdb$relation_id = r.rdb$relation_id
where r.rdb$relation_name = '{TAB_NAME}' and p.rdb$page_type = 4
order by 2 desc
rows 1
"""
rel_id, max_pp = -1, -1
with act.db.connect(no_gc = True) as con:
cur = con.cursor()
cur.execute(get_last_pp_for_table)
for r in cur:
rel_id, max_pp = r[:2]
assert rel_id > 0 and max_pp > 0
#--------------------------------
# Subsequent number of PP that we want to check ('20' in the ticket):
##########
chk_pp = 0
##########
read_records_for_chk_pp = f"""
select count(*), min(id), max(id)
from t1
where
rdb$db_key >= make_dbkey({rel_id}, 0, 0, {chk_pp})
and rdb$db_key < make_dbkey({rel_id}, 0, 0, {chk_pp+1})
"""
fetches_ini = con.info.fetches
# read records from selected PP only -- FIRST TIME
cur.execute(read_records_for_chk_pp)
cur.fetchall()
fetches_1 = con.info.fetches - fetches_ini
#----------------------------------
# delete records from selected PP and up to the end
del_rows_starting_from_chk_pp = f"""
delete from t1
where rdb$db_key >= make_dbkey({rel_id}, 0, 0, {chk_pp})
"""
con.execute_immediate(del_rows_starting_from_chk_pp)
#----------------------------------
fetches_ini = con.info.fetches
# read records from selected PP only -- SECOND TIME
cur.execute(read_records_for_chk_pp)
cur.fetchall()
fetches_2 = con.info.fetches - fetches_ini
expected_msg = 'Fetches ratio expected.'
if fetches_2 <= fetches_1:
print(expected_msg)
else:
print(f'Fetches ratio between 1st and 2nd requests to PP = {chk_pp} - UNEXPECTED:')
print('Request #1:', fetches_1)
print('Request #2:', fetches_2)
act.expected_stdout = f"""
{expected_msg}
"""
act.stdout = capsys.readouterr().out
> assert act.clean_stdout == act.clean_expected_stdout
E assert
E - Fetches ratio expected.
E + Fetches ratio between 1st and 2nd requests to PP = 0 - UNEXPECTED:
E + Request #1: 47631
E + Request #2: 115943
tests\bugs\gh_8104_test.py:128: AssertionError
|