From c6f0563c44f518e216d7c2b25ba385248b2be27c Mon Sep 17 00:00:00 2001 From: zotov Date: Sun, 25 Sep 2022 19:10:57 +0300 Subject: [PATCH] Added/Updated functional\syspriv\test_access_shutdown_database.py. Added substituion pair for suppressing '-Some database(s) were shutdown when trying to read mapping data' message that appears on Classic when we try to bring DB online using fbsvcmgr call. It seems to be a kind of bug. Sent report to Alex et al. --- .../syspriv/test_access_shutdown_database.py | 32 ++++++++++++++++--- 1 file changed, 28 insertions(+), 4 deletions(-) diff --git a/tests/functional/syspriv/test_access_shutdown_database.py b/tests/functional/syspriv/test_access_shutdown_database.py index 3d688131..c2eb1e31 100644 --- a/tests/functional/syspriv/test_access_shutdown_database.py +++ b/tests/functional/syspriv/test_access_shutdown_database.py @@ -24,6 +24,7 @@ from firebird.driver import ShutdownMode,ShutdownMethod from firebird.driver.types import DatabaseError substitutions = [ ('no permission for (shutdown|(bring online)) access to database .*', 'no permission for shutdown/online access to database') + ,('-Some database.* shutdown when trying to read mapping data', '') # <<< perhaps this is due to bug in Classic. May need to be deleted later // 25.09.2022 ,('335544528 : database.* shutdown', '335544528 : database shutdown') ,('Data source : Firebird::localhost:.*', 'Data source : Firebird::localhost:') ,('-At block line: [\\d]+, col: [\\d]+', '-At block line') @@ -126,6 +127,9 @@ def test_1(act: Action, tmp_user: User, tmp_role:Role, capsys): # --------------------------------------------------------------- + # Must FAIL: user has right only to *access* to DB in shutdown-single mode and make some DMLs there. + # But he has NO right to change DB state to shutdown (any kind of mode). + # Expected error: "no permission for shutdown/online access to database ..." with act.connect_server(user = tmp_user.name, password = tmp_user.password, role = tmp_role.name) as srv_nondba: try: srv_nondba.database.shutdown(database=act.db.db_path @@ -136,7 +140,15 @@ def test_1(act: Action, tmp_user: User, tmp_role:Role, capsys): except DatabaseError as e: print(e.__str__()) + act.expected_stdout = expected_stdout_fbsvc + act.stdout = capsys.readouterr().out + assert act.clean_stdout == act.clean_expected_stdout # <<<<<<<<<<<<<<<<<<<<<<<< check #0 + act.reset() + #----------------------------------------------------------------- + + # Must PASS: we change DB state to shut-single using SYSDBA account. + # No message must be issued now: with act.connect_server() as srv_sysdba: try: srv_sysdba.database.shutdown(database=act.db.db_path @@ -147,12 +159,14 @@ def test_1(act: Action, tmp_user: User, tmp_role:Role, capsys): except DatabaseError as e: print(e.__str__()) - act.expected_stdout = expected_stdout_fbsvc + act.expected_stdout = '' act.stdout = capsys.readouterr().out assert act.clean_stdout == act.clean_expected_stdout # <<<<<<<<<<<<<<<<<<<<<<<< check #1 act.reset() # --------------------------------------------------------------- + # Result: DB now is in shutdown-single mode. + # We have to check that only single attachment can be established to this DB: sql_chk=''' set list on; @@ -181,6 +195,11 @@ def test_1(act: Action, tmp_user: User, tmp_role:Role, capsys): # --------------------------------------------------------------- # must FAIL: we attempt to bring DB online using NON-dba account: + # Expected error: "no permission for bring online access to database ..." + # !!!NB!!! As of 25.09.2022, for FB 4.x and 5.x in Classic mode additional message will raise here: + # "-Some database(s) were shutdown when trying to read mapping data" + # Sent report to Alex et al, 25.09.2022 18:55. Waiting for resolution. + # with act.connect_server(user = tmp_user.name, password = tmp_user.password, role = tmp_role.name) as srv_nondba: try: srv_nondba.database.bring_online(database=act.db.db_path) @@ -188,6 +207,11 @@ def test_1(act: Action, tmp_user: User, tmp_role:Role, capsys): except DatabaseError as e: print(e.__str__()) + act.expected_stdout = expected_stdout_fbsvc + act.stdout = capsys.readouterr().out + assert act.clean_stdout == act.clean_expected_stdout # <<<<<<<<<<<<<<<<<<<<<<<< check #3 + act.reset() + # must PASS because here we return DB online using SYSDBA account: with act.connect_server() as srv_sysdba: try: @@ -196,7 +220,7 @@ def test_1(act: Action, tmp_user: User, tmp_role:Role, capsys): except DatabaseError as e: print(e.__str__()) - act.expected_stdout = expected_stdout_fbsvc - act.stdout = capsys.readouterr().out - assert act.clean_stdout == act.clean_expected_stdout # <<<<<<<<<<<<<<<<<<<<<<<< check #3 + assert '' == capsys.readouterr().out + assert act.clean_stdout == act.clean_expected_stdout # <<<<<<<<<<<<<<<<<<<<<<<< check #4 act.reset() +