6
0
mirror of https://github.com/FirebirdSQL/firebird-qa.git synced 2025-01-23 14:03:06 +01:00
firebird-qa/tests/bugs/core_0959_test.py

74 lines
2.8 KiB
Python
Raw Normal View History

2021-04-26 20:07:00 +02:00
#coding:utf-8
2022-01-18 20:45:21 +01:00
"""
ID: issue-1362
ISSUE: 1362
TITLE: GSTAT does not work using the localhost connection string
DESCRIPTION:
JIRA: CORE-959
FBTEST: bugs.core_0959
2022-01-18 20:45:21 +01:00
"""
2021-04-26 20:07:00 +02:00
import pytest
2022-01-18 20:45:21 +01:00
from firebird.qa import *
2021-11-10 19:02:05 +01:00
import re
2021-04-26 20:07:00 +02:00
2022-01-18 20:45:21 +01:00
init_script = """
2021-04-26 20:07:00 +02:00
create sequence g;
create table test(id int primary key using index test_id_pk);
commit;
insert into test(id) select gen_id(g,1) from rdb$types,rdb$types rows 1000;
commit;
2021-12-22 20:23:11 +01:00
"""
2021-04-26 20:07:00 +02:00
2022-01-18 20:45:21 +01:00
db = db_factory(init=init_script)
2021-04-26 20:07:00 +02:00
2022-01-18 20:45:21 +01:00
substitutions = [('Database ".*', 'Database'),
('Gstat execution time .*', 'Gstat execution time'),
('Attributes .*', 'Attributes'),
('Primary pointer page: \\d+, Index root page: \\d+\\s*', 'Primary pointer page, Index root page'),
('Data pages: \\d+, average fill: \\d+[percent_sign]', 'Data pages, average fill'),
('Root page: \\d+, depth: \\d+, leaf buckets: \\d+, nodes: \\d+\\s*', 'Root page, depth, leaf buckets, nodes'),
('Gstat completion time .*', 'Gstat completion time')]
2021-11-10 19:02:05 +01:00
2022-01-18 20:45:21 +01:00
act = python_act('db', substitutions=substitutions)
2021-04-26 20:07:00 +02:00
2022-01-18 20:45:21 +01:00
expected_stdout = """
2021-04-26 20:07:00 +02:00
Database "C:\\MIX\\FIREBIRD\\QA\\FBT-REPO\\TMP\\BUGS.CORE_0959.FDB"
Gstat execution time Fri Nov 17 12:37:29 2017
Attributes force write
Primary pointer page: 193, Index root page: 194
Data pages: 7, average fill: 45[percent_sign]
Root page: 197, depth: 1, leaf buckets: 1, nodes: 1000
Gstat completion time Fri Nov 17 12:37:29 2017
2021-12-22 20:23:11 +01:00
"""
2021-04-26 20:07:00 +02:00
@pytest.mark.version('>=3.0')
2022-01-18 20:45:21 +01:00
def test_1(act: Action):
2021-11-10 19:02:05 +01:00
hdr_dbname_ptn = re.compile('Database\\s+"', re.IGNORECASE)
hdr_dbattr_ptn = re.compile('Attributes\\s+\\.*', re.IGNORECASE)
table_ppip_ptn = re.compile('Primary\\s+pointer\\s+page:\\s+\\d+,\\s+Index root page:\\s+\\d+\\s*', re.IGNORECASE)
table_dpaf_ptn = re.compile('Data\\s+pages:\\s+\\d+,\\s+average\\s+fill:\\s+\\d+%\\s*', re.IGNORECASE)
index_root_ptn = re.compile('Root\\s+page:\\s+\\d+,\\s+depth:\\s+\\d+,\\s+leaf\\s+buckets:\\s+\\d+,\\s+nodes:\\s+\\d+\\s*', re.IGNORECASE)
#
gstat_init_ptn = re.compile('Gstat\\s+execution\\s+time\\s+', re.IGNORECASE)
gstat_fini_ptn = re.compile('Gstat\\s+completion\\s+time\\s+', re.IGNORECASE)
#
watched_ptn_list = [hdr_dbname_ptn, hdr_dbattr_ptn, table_ppip_ptn, table_dpaf_ptn,
index_root_ptn, gstat_init_ptn, gstat_fini_ptn]
#
2022-01-18 20:45:21 +01:00
act.expected_stdout = expected_stdout
act.gstat(switches=['-d', '-i', '-r'])
2021-11-10 19:02:05 +01:00
#
matched = []
2022-01-18 20:45:21 +01:00
for line in act.stdout.splitlines():
2021-11-10 19:02:05 +01:00
for p in watched_ptn_list:
if p.search(line):
matched.append(' '.join(line.replace('%','[percent_sign]').split()))
#
actual = '\n'.join(matched)
2022-02-24 19:21:22 +01:00
actual = act.clean_string(actual, act.substitutions)
2022-01-18 20:45:21 +01:00
assert ('localhost' in act.db.dsn and act.clean_expected_stdout == actual)
2021-04-26 20:07:00 +02:00