From 61f2241e2fc9021b77b65d42db15cb4e62195a13 Mon Sep 17 00:00:00 2001 From: pavel-zotov Date: Sat, 11 Mar 2023 10:56:44 +0300 Subject: [PATCH] Added/Updated tests\bugs\core_5808_test.py: Max waiting time for encryption/decryption to complete must be separated for different OS. MAX_WAIT_FOR_ENCR_FINISH_WIN and MAX_WAIT_FOR_ENCR_FINISH_NIX settings are used now from QA_GLOBALS['encryption'] instead of old MAX_ENCRYPT_DECRYPT_MS. --- tests/bugs/core_5808_test.py | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/tests/bugs/core_5808_test.py b/tests/bugs/core_5808_test.py index 20487a3e..a99d4cd0 100644 --- a/tests/bugs/core_5808_test.py +++ b/tests/bugs/core_5808_test.py @@ -25,7 +25,7 @@ NOTES: Checked on 4.0.1.2692 - both on Linux and Windows. NB: duration on Linux ~40 s; on Windows ~22 s. """ - +import os import re import time import datetime as py_dt @@ -38,6 +38,23 @@ from firebird.qa import * from firebird.driver import DatabaseError from firebird.driver import SrvRestoreFlag, SrvRepairFlag +########################### +### S E T T I N G S ### +########################### + +# QA_GLOBALS -- dict, is defined in qa/plugin.py, obtain settings +# from act.files_dir/'test_config.ini': +enc_settings = QA_GLOBALS['encryption'] + +# ACHTUNG: this must be carefully tuned on every new host: +# +MAX_WAITING_ENCR_FINISH = int(enc_settings['MAX_WAIT_FOR_ENCR_FINISH_WIN' if os.name == 'nt' else 'MAX_WAIT_FOR_ENCR_FINISH_NIX']) +assert MAX_WAITING_ENCR_FINISH > 0 + +ENCRYPTION_PLUGIN = enc_settings['encryption_plugin'] # fbSampleDbCrypt +ENCRYPTION_KEY = enc_settings['encryption_key'] # Red + + N_ROWS = 15 init_script = f""" create table test1(s varchar(784) unique, b blob); @@ -75,14 +92,6 @@ act = python_act('db') @pytest.mark.version('>=4.0') def test_1(act: Action, capsys): - # QA_GLOBALS -- dict, is defined in qa/plugin.py, obtain settings - # from act.files_dir/'test_config.ini': - enc_settings = QA_GLOBALS['encryption'] - - MAX_ENCRYPT_DECRYPT_MS = int(enc_settings['max_encrypt_decrypt_ms']) # 5000 - ENCRYPTION_PLUGIN = enc_settings['encryption_plugin'] # fbSampleDbCrypt - ENCRYPTION_KEY = enc_settings['encryption_key'] # Red - encryption_started = False encryption_finished = False with act.db.connect() as con: @@ -103,8 +112,8 @@ def test_1(act: Action, capsys): while encryption_started: t2=py_dt.datetime.now() d1=t2-t1 - if d1.seconds*1000 + d1.microseconds//1000 > MAX_ENCRYPT_DECRYPT_MS: - print(f'TIMEOUT EXPIRATION: encryption took {d1.seconds*1000 + d1.microseconds//1000} ms which exceeds limit = {MAX_ENCRYPT_DECRYPT_MS} ms.') + if d1.seconds*1000 + d1.microseconds//1000 > MAX_WAITING_ENCR_FINISH: + print(f'TIMEOUT EXPIRATION: encryption took {d1.seconds*1000 + d1.microseconds//1000} ms which exceeds limit = {MAX_WAITING_ENCR_FINISH} ms.') break # Possible output: