2 @message |
assert
- Fetches ratio expected.
+ Fetches ratio between 1st and 2nd requests to PP = 0 - UNEXPECTED:
+ Request #1: 47670
+ Request #2: 115943
LOG DETAILS:
2024-05-08 23:21:30.904
2024-05-08 23:21:30.910 act = <firebird.qa.plugin.Action object at [hex]>
2024-05-08 23:21:30.915 capsys = <_pytest.capture.CaptureFixture object at [hex]>
2024-05-08 23:21:30.920
2024-05-08 23:21:30.926 @pytest.mark.version('>=4.0.5')
2024-05-08 23:21:30.931 def test_1(act: Action, capsys):
2024-05-08 23:21:30.936
2024-05-08 23:21:30.942 get_last_pp_for_table = f"""
2024-05-08 23:21:30.947 select p.rdb$relation_id, p.rdb$page_sequence
2024-05-08 23:21:30.951 from rdb$pages p join rdb$relations r on p.rdb$relation_id = r.rdb$relation_id
2024-05-08 23:21:30.956 where r.rdb$relation_name = '{TAB_NAME}' and p.rdb$page_type = 4
2024-05-08 23:21:30.961 order by 2 desc
2024-05-08 23:21:30.967 rows 1
2024-05-08 23:21:30.971 """
2024-05-08 23:21:30.976 rel_id, max_pp = -1, -1
2024-05-08 23:21:30.982 with act.db.connect(no_gc = True) as con:
2024-05-08 23:21:30.988 cur = con.cursor()
2024-05-08 23:21:30.994 cur.execute(get_last_pp_for_table)
2024-05-08 23:21:31.000 for r in cur:
2024-05-08 23:21:31.006 rel_id, max_pp = r[:2]
2024-05-08 23:21:31.011 assert rel_id > 0 and max_pp > 0
2024-05-08 23:21:31.016 #--------------------------------
2024-05-08 23:21:31.021
2024-05-08 23:21:31.026 # Subsequent number of PP that we want to check ('20' in the ticket):
2024-05-08 23:21:31.031 ##########
2024-05-08 23:21:31.036 chk_pp = 0
2024-05-08 23:21:31.041 ##########
2024-05-08 23:21:31.047
2024-05-08 23:21:31.053 read_records_for_chk_pp = f"""
2024-05-08 23:21:31.060 select count(*), min(id), max(id)
2024-05-08 23:21:31.067 from t1
2024-05-08 23:21:31.073 where
2024-05-08 23:21:31.080 rdb$db_key >= make_dbkey({rel_id}, 0, 0, {chk_pp})
2024-05-08 23:21:31.086 and rdb$db_key < make_dbkey({rel_id}, 0, 0, {chk_pp+1})
2024-05-08 23:21:31.093 """
2024-05-08 23:21:31.099
2024-05-08 23:21:31.106 fetches_ini = con.info.fetches
2024-05-08 23:21:31.117 # read records from selected PP only -- FIRST TIME
2024-05-08 23:21:31.124 cur.execute(read_records_for_chk_pp)
2024-05-08 23:21:31.130 cur.fetchall()
2024-05-08 23:21:31.135 fetches_1 = con.info.fetches - fetches_ini
2024-05-08 23:21:31.140
2024-05-08 23:21:31.145 #----------------------------------
2024-05-08 23:21:31.150
2024-05-08 23:21:31.156 # delete records from selected PP and up to the end
2024-05-08 23:21:31.161 del_rows_starting_from_chk_pp = f"""
2024-05-08 23:21:31.167 delete from t1
2024-05-08 23:21:31.172 where rdb$db_key >= make_dbkey({rel_id}, 0, 0, {chk_pp})
2024-05-08 23:21:31.177 """
2024-05-08 23:21:31.182 con.execute_immediate(del_rows_starting_from_chk_pp)
2024-05-08 23:21:31.187
2024-05-08 23:21:31.192 #----------------------------------
2024-05-08 23:21:31.197
2024-05-08 23:21:31.202 fetches_ini = con.info.fetches
2024-05-08 23:21:31.207 # read records from selected PP only -- SECOND TIME
2024-05-08 23:21:31.212 cur.execute(read_records_for_chk_pp)
2024-05-08 23:21:31.217 cur.fetchall()
2024-05-08 23:21:31.223 fetches_2 = con.info.fetches - fetches_ini
2024-05-08 23:21:31.229
2024-05-08 23:21:31.235 expected_msg = 'Fetches ratio expected.'
2024-05-08 23:21:31.240
2024-05-08 23:21:31.245 if fetches_2 <= fetches_1:
2024-05-08 23:21:31.249 print(expected_msg)
2024-05-08 23:21:31.254 else:
2024-05-08 23:21:31.259 print(f'Fetches ratio between 1st and 2nd requests to PP = {chk_pp} - UNEXPECTED:')
2024-05-08 23:21:31.265 print('Request #1:', fetches_1)
2024-05-08 23:21:31.270 print('Request #2:', fetches_2)
2024-05-08 23:21:31.277
2024-05-08 23:21:31.285 act.expected_stdout = f"""
2024-05-08 23:21:31.292 {expected_msg}
2024-05-08 23:21:31.297 """
2024-05-08 23:21:31.302 act.stdout = capsys.readouterr().out
2024-05-08 23:21:31.306 > assert act.clean_stdout == act.clean_expected_stdout
2024-05-08 23:21:31.311 E assert
2024-05-08 23:21:31.316 E - Fetches ratio expected.
2024-05-08 23:21:31.323 E + Fetches ratio between 1st and 2nd requests to PP = 0 - UNEXPECTED:
2024-05-08 23:21:31.328 E + Request #1: 47670
2024-05-08 23:21:31.332 E + Request #2: 115943
2024-05-08 23:21:31.337
2024-05-08 23:21:31.342 tests/bugs/gh_8104_test.py:116: AssertionError
2024-05-08 23:21:31.348 ---------------------------- Captured stdout setup -----------------------------
2024-05-08 23:21:31.353 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: 47670
E + Request #2: 115943
tests/bugs/gh_8104_test.py:116: AssertionError
|