From 92fcac0cebe237b30c1c07c5174149f2fad1c2b5 Mon Sep 17 00:00:00 2001 From: pavel-zotov Date: Tue, 24 Dec 2024 11:06:28 +0300 Subject: [PATCH] Added/Updated tests\bugs\gh_6609_test.py: Separated definition of max ratio thresholds according to FB fork ('standard', 'HQbird', 'RedDatabase'). --- tests/bugs/gh_6609_test.py | 59 ++++++++++++++++++++++++++++---------- 1 file changed, 44 insertions(+), 15 deletions(-) diff --git a/tests/bugs/gh_6609_test.py b/tests/bugs/gh_6609_test.py index 1c9fa40f..2f31f847 100644 --- a/tests/bugs/gh_6609_test.py +++ b/tests/bugs/gh_6609_test.py @@ -19,6 +19,10 @@ NOTES: 4.0.5.3099, mon$memo_used ratio for CS: 1.01; SS: 1.00 5.0.1.1399, mon$memo_used ratio for CS: 1.11; SS: 1.02 6.0.0.351, mon$memo_used ratio for CS: 1.11; SS: 1.02 + + [24.12.2024] pzotov + Separated definition of max ratio thresholds according to FB fork ('standard', 'HQbird', 'RedDatabase'). + Requested by Anton Zuev, RedBase. """ import pytest @@ -41,24 +45,49 @@ act = python_act('db') @pytest.mark.version('>=3.0.0') def test_1(act: Action, capsys): - #if act.platform == 'Windows': - # pytest.skip('Could not reproduce bug on Windows') - - if act.get_server_architecture() == 'SuperServer': - MON_QUERY = 'select mon$memory_used from mon$memory_usage where mon$stat_group = 0' - MAX_THRESHOLD = 1.10 - else: - MON_QUERY = """ - select m.mon$memory_used - from mon$attachments a - join mon$memory_usage m on a.mon$stat_id = m.mon$stat_id - where a.mon$attachment_id = current_connection and m.mon$stat_group = 1; - """ - MAX_THRESHOLD = 1.20 - mon_memo_beg = 1 mon_memo_end = 9999999 with act.db.connect() as con: + + # con.info.server_version output examples: + # Standard: 'WI-V6.3.2.1580 Firebird 5.0 7961de2' + # HQbird: 'WI-V6.3.2.1575 Firebird 5.0 HQbird' + # RedDatabase: 'LI-V6.3.2.0 RedDatabase 5.0 SNAPSHOT.15 ()' + # + fb_vers_txt = con.info.server_version + if 'RedDatabase' in fb_vers_txt: + fb_vers_key = 'red' + elif 'HQbird' in fb_vers_txt: + fb_vers_key = 'hqb' + else: + fb_vers_key = 'std' + + ############################### + ### T H R E S H O L D S ### + ############################### + # Requested by Anton Zuev, RedBase: + max_memo_ratios_map = { + ('std', 'SuperServer') : 1.1 + ,('hqb', 'SuperServer') : 1.1 + ,('red', 'SuperServer') : 1.1 + ,('std', 'Classic') : 1.20 + ,('hqb', 'Classic') : 1.20 + ,('red', 'Classic') : 1.30 + } + + fb_mode = act.get_server_architecture() + MAX_THRESHOLD = max_memo_ratios_map[ fb_vers_key, fb_mode] + + if fb_mode == 'SuperServer': + MON_QUERY = 'select mon$memory_used from mon$memory_usage where mon$stat_group = 0' + else: + MON_QUERY = """ + select m.mon$memory_used + from mon$attachments a + join mon$memory_usage m on a.mon$stat_id = m.mon$stat_id + where a.mon$attachment_id = current_connection and m.mon$stat_group = 1; + """ + cur = con.cursor() cur.execute(MON_QUERY) mon_memo_beg = int(cur.fetchone()[0])