2 @message |
assert
- Fetches ratio expected.
+ Fetches ratio between 1st and 2nd requests to PP = 0 - UNEXPECTED:
+ Request #1: 47645
+ Request #2: 115943
LOG DETAILS:
2024-05-09 00:16:57.593
2024-05-09 00:16:57.599 act = <firebird.qa.plugin.Action object at [hex]>
2024-05-09 00:16:57.606 capsys = <_pytest.capture.CaptureFixture object at [hex]>
2024-05-09 00:16:57.613
2024-05-09 00:16:57.618 @pytest.mark.version('>=4.0.5')
2024-05-09 00:16:57.623 def test_1(act: Action, capsys):
2024-05-09 00:16:57.629
2024-05-09 00:16:57.637 get_last_pp_for_table = f"""
2024-05-09 00:16:57.641 select p.rdb$relation_id, p.rdb$page_sequence
2024-05-09 00:16:57.646 from rdb$pages p join rdb$relations r on p.rdb$relation_id = r.rdb$relation_id
2024-05-09 00:16:57.651 where r.rdb$relation_name = '{TAB_NAME}' and p.rdb$page_type = 4
2024-05-09 00:16:57.656 order by 2 desc
2024-05-09 00:16:57.660 rows 1
2024-05-09 00:16:57.666 """
2024-05-09 00:16:57.674 rel_id, max_pp = -1, -1
2024-05-09 00:16:57.680 with act.db.connect(no_gc = True) as con:
2024-05-09 00:16:57.685 cur = con.cursor()
2024-05-09 00:16:57.690 cur.execute(get_last_pp_for_table)
2024-05-09 00:16:57.694 for r in cur:
2024-05-09 00:16:57.702 rel_id, max_pp = r[:2]
2024-05-09 00:16:57.708 assert rel_id > 0 and max_pp > 0
2024-05-09 00:16:57.714 #--------------------------------
2024-05-09 00:16:57.721
2024-05-09 00:16:57.727 # Subsequent number of PP that we want to check ('20' in the ticket):
2024-05-09 00:16:57.732 ##########
2024-05-09 00:16:57.737 chk_pp = 0
2024-05-09 00:16:57.742 ##########
2024-05-09 00:16:57.747
2024-05-09 00:16:57.752 read_records_for_chk_pp = f"""
2024-05-09 00:16:57.757 select count(*), min(id), max(id)
2024-05-09 00:16:57.762 from t1
2024-05-09 00:16:57.768 where
2024-05-09 00:16:57.773 rdb$db_key >= make_dbkey({rel_id}, 0, 0, {chk_pp})
2024-05-09 00:16:57.778 and rdb$db_key < make_dbkey({rel_id}, 0, 0, {chk_pp+1})
2024-05-09 00:16:57.784 """
2024-05-09 00:16:57.790
2024-05-09 00:16:57.795 fetches_ini = con.info.fetches
2024-05-09 00:16:57.802 # read records from selected PP only -- FIRST TIME
2024-05-09 00:16:57.807 cur.execute(read_records_for_chk_pp)
2024-05-09 00:16:57.814 cur.fetchall()
2024-05-09 00:16:57.820 fetches_1 = con.info.fetches - fetches_ini
2024-05-09 00:16:57.825
2024-05-09 00:16:57.830 #----------------------------------
2024-05-09 00:16:57.835
2024-05-09 00:16:57.840 # delete records from selected PP and up to the end
2024-05-09 00:16:57.845 del_rows_starting_from_chk_pp = f"""
2024-05-09 00:16:57.850 delete from t1
2024-05-09 00:16:57.854 where rdb$db_key >= make_dbkey({rel_id}, 0, 0, {chk_pp})
2024-05-09 00:16:57.861 """
2024-05-09 00:16:57.866 con.execute_immediate(del_rows_starting_from_chk_pp)
2024-05-09 00:16:57.870
2024-05-09 00:16:57.875 #----------------------------------
2024-05-09 00:16:57.879
2024-05-09 00:16:57.887 fetches_ini = con.info.fetches
2024-05-09 00:16:57.898 # read records from selected PP only -- SECOND TIME
2024-05-09 00:16:57.907 cur.execute(read_records_for_chk_pp)
2024-05-09 00:16:57.915 cur.fetchall()
2024-05-09 00:16:57.922 fetches_2 = con.info.fetches - fetches_ini
2024-05-09 00:16:57.930
2024-05-09 00:16:57.936 expected_msg = 'Fetches ratio expected.'
2024-05-09 00:16:57.942
2024-05-09 00:16:57.948 if fetches_2 <= fetches_1:
2024-05-09 00:16:57.954 print(expected_msg)
2024-05-09 00:16:57.960 else:
2024-05-09 00:16:57.966 print(f'Fetches ratio between 1st and 2nd requests to PP = {chk_pp} - UNEXPECTED:')
2024-05-09 00:16:57.971 print('Request #1:', fetches_1)
2024-05-09 00:16:57.977 print('Request #2:', fetches_2)
2024-05-09 00:16:57.984
2024-05-09 00:16:57.990 act.expected_stdout = f"""
2024-05-09 00:16:57.996 {expected_msg}
2024-05-09 00:16:58.002 """
2024-05-09 00:16:58.008 act.stdout = capsys.readouterr().out
2024-05-09 00:16:58.013 > assert act.clean_stdout == act.clean_expected_stdout
2024-05-09 00:16:58.019 E assert
2024-05-09 00:16:58.023 E - Fetches ratio expected.
2024-05-09 00:16:58.028 E + Fetches ratio between 1st and 2nd requests to PP = 0 - UNEXPECTED:
2024-05-09 00:16:58.033 E + Request #1: 47645
2024-05-09 00:16:58.037 E + Request #2: 115943
2024-05-09 00:16:58.042
2024-05-09 00:16:58.046 tests/bugs/gh_8104_test.py:116: AssertionError
2024-05-09 00:16:58.051 ---------------------------- Captured stdout setup -----------------------------
2024-05-09 00:16:58.056 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: 47645
E + Request #2: 115943
tests/bugs/gh_8104_test.py:116: AssertionError
|