From 53a4107c3df2471376088d67c7f7ac7a2af765c3 Mon Sep 17 00:00:00 2001 From: pavel-zotov Date: Sat, 11 Mar 2023 10:39:55 +0300 Subject: [PATCH] Added/Updated tests\bugs\core_6163_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_6163_test.py | 34 ++++++++++++++++++++-------------- 1 file changed, 20 insertions(+), 14 deletions(-) diff --git a/tests/bugs/core_6163_test.py b/tests/bugs/core_6163_test.py index 41cef8fe..78988a68 100644 --- a/tests/bugs/core_6163_test.py +++ b/tests/bugs/core_6163_test.py @@ -33,7 +33,7 @@ NOTES: Checked on 4.0.1.2692, 3.0.8.33535. """ - +import os import binascii import datetime as py_dt from datetime import timedelta @@ -43,6 +43,22 @@ import pytest from firebird.qa import * from firebird.driver import DatabaseError +########################### +### 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 + init_ddl = """ create sequence gen_ba0bab start with 12192683; create sequence gen_badf00d start with 195948557; @@ -112,16 +128,6 @@ expected_stdout = """ @pytest.mark.version('>=3.0.5') 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_holder = enc_settings['encryption_holder'] # fbSampleKeyHolder - encryption_key = enc_settings['encryption_key'] # Red - encryption_started = False encryption_finished = False @@ -167,7 +173,7 @@ def test_1(act: Action, capsys): #--------------------------------------- t1=py_dt.datetime.now() d1 = t1-t1 - sttm = f'alter database encrypt with "{encryption_plugin}" key "{encryption_key}"' + sttm = f'alter database encrypt with "{ENCRYPTION_PLUGIN}" key "{ENCRYPTION_KEY}"' try: con.execute_immediate(sttm) con.commit() @@ -181,8 +187,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: