2021-04-26 20:07:00 +02:00
|
|
|
#coding:utf-8
|
2022-01-22 21:59:15 +01:00
|
|
|
|
|
|
|
"""
|
|
|
|
ID: issue-4267
|
|
|
|
ISSUE: 4267
|
|
|
|
TITLE: Value of log_sweep parameter in trace configuration is ignored by trace plugin (assumed always true)
|
|
|
|
DESCRIPTION:
|
|
|
|
Test check TWO cases:
|
|
|
|
1) whether log_sweep = true actually lead to logging of sweep events
|
|
|
|
2) whether log_sweep = fales actually prevents from logging of any sweep events (which is ticket issue).
|
|
|
|
JIRA: CORE-3934
|
2022-02-02 15:46:19 +01:00
|
|
|
FBTEST: bugs.core_3934
|
2022-01-22 21:59:15 +01:00
|
|
|
"""
|
2021-04-26 20:07:00 +02:00
|
|
|
|
|
|
|
import pytest
|
2021-11-18 20:15:37 +01:00
|
|
|
import re
|
2022-01-22 21:59:15 +01:00
|
|
|
from firebird.qa import *
|
2021-04-26 20:07:00 +02:00
|
|
|
|
2022-01-22 21:59:15 +01:00
|
|
|
db = db_factory()
|
2021-04-26 20:07:00 +02:00
|
|
|
|
2022-01-22 21:59:15 +01:00
|
|
|
act = python_act('db')
|
2021-11-18 20:15:37 +01:00
|
|
|
|
2021-12-07 20:09:36 +01:00
|
|
|
def sweep_present(trace_log) -> bool:
|
2021-11-18 20:15:37 +01:00
|
|
|
pattern = re.compile('\\s+sweep_(start|progress|finish)(\\s+|$)', re.IGNORECASE)
|
|
|
|
present = False
|
2021-12-07 20:09:36 +01:00
|
|
|
for line in trace_log:
|
2021-11-18 20:15:37 +01:00
|
|
|
if pattern.search(line):
|
|
|
|
present = True
|
|
|
|
break
|
|
|
|
return present
|
2021-04-26 20:07:00 +02:00
|
|
|
|
2022-01-22 21:59:15 +01:00
|
|
|
def check_sweep(act: Action, log_sweep: bool):
|
2021-12-07 20:09:36 +01:00
|
|
|
cfg = ['time_threshold = 0',
|
|
|
|
'log_connections = true',
|
|
|
|
f'log_sweep = {"true" if log_sweep else "false"}',
|
|
|
|
'log_initfini = false',
|
|
|
|
]
|
2022-01-22 21:59:15 +01:00
|
|
|
with act.trace(db_events=cfg), act.connect_server() as srv:
|
|
|
|
srv.database.sweep(database=act.db.db_path)
|
2021-04-26 20:07:00 +02:00
|
|
|
|
2024-05-15 19:26:01 +02:00
|
|
|
@pytest.mark.trace
|
2021-11-18 20:15:37 +01:00
|
|
|
@pytest.mark.version('>=3.0')
|
2022-01-22 21:59:15 +01:00
|
|
|
def test_1(act: Action):
|
2021-11-18 20:15:37 +01:00
|
|
|
# Case 1 - sweep logged
|
2022-01-22 21:59:15 +01:00
|
|
|
check_sweep(act, True)
|
|
|
|
assert sweep_present(act.trace_log)
|
2021-11-18 20:15:37 +01:00
|
|
|
# Case 2 - sweep not logged
|
2022-01-22 21:59:15 +01:00
|
|
|
act.trace_log.clear()
|
|
|
|
check_sweep(act, False)
|
|
|
|
assert not sweep_present(act.trace_log)
|