6
0
mirror of https://github.com/FirebirdSQL/firebird-qa.git synced 2025-01-22 13:33:07 +01:00
firebird-qa/tests/bugs/core_5418_test.py

136 lines
4.2 KiB
Python
Raw Permalink Normal View History

2021-04-26 20:07:00 +02:00
#coding:utf-8
2022-01-25 22:55:48 +01:00
"""
ID: issue-5691
ISSUE: 5691
TITLE: Inconsistent output when retrieving the server log via Services API
DESCRIPTION:
Test gets FB home directory and copies firebird.log to *.tmp.
Then it makes firebird.log empty and retrieves it via services API. Output should be empty.
Finally, it opens firebird.log and adds to it several empty newlines.
Repeat retrieveing content - it also should not contain any characters except newline.
NOTES:
[7.12.2021] pcisar
Test requires direct changes to firebird.log which could require elevated privileges!
JIRA: CORE-5418
FBTEST: bugs.core_5418
2022-01-25 22:55:48 +01:00
"""
2021-04-26 20:07:00 +02:00
2022-01-25 22:55:48 +01:00
import pytest
from firebird.qa import *
2021-04-26 20:07:00 +02:00
2022-01-25 22:55:48 +01:00
db = db_factory()
2021-04-26 20:07:00 +02:00
2022-01-25 22:55:48 +01:00
act = python_act('db')
2021-04-26 20:07:00 +02:00
2022-01-25 22:55:48 +01:00
@pytest.mark.skip('FIXME: direct write to firebird.log')
@pytest.mark.version('>=3')
def test_1(act: Action):
pytest.fail("Not IMPLEMENTED")
2021-04-26 20:07:00 +02:00
# test_script_1
#---
#
2021-04-26 20:07:00 +02:00
# import os
# from fdb import services
# import subprocess
# import time
# import shutil
# import difflib
# import re
#
2021-04-26 20:07:00 +02:00
# os.environ["ISC_USER"] = user_name
# os.environ["ISC_PASSWORD"] = user_password
#
2021-04-26 20:07:00 +02:00
# engine = str(db_conn.engine_version) # convert to text because 'float' object has no attribute 'startswith'
# db_conn.close()
#
2021-04-26 20:07:00 +02:00
# svc = services.connect(host='localhost')
# fb_home=svc.get_home_directory()
# svc.close()
#
2021-04-26 20:07:00 +02:00
# #--------------------------------------------
#
2021-04-26 20:07:00 +02:00
# def flush_and_close( file_handle ):
# # https://docs.python.org/2/library/os.html#os.fsync
# # If you're starting with a Python file object f,
# # first do f.flush(), and
2021-04-26 20:07:00 +02:00
# # then do os.fsync(f.fileno()), to ensure that all internal buffers associated with f are written to disk.
# global os
#
2021-04-26 20:07:00 +02:00
# file_handle.flush()
# if file_handle.mode not in ('r', 'rb') and file_handle.name != os.devnull:
# # otherwise: "OSError: [Errno 9] Bad file descriptor"!
# os.fsync(file_handle.fileno())
# file_handle.close()
#
2021-04-26 20:07:00 +02:00
# #--------------------------------------------
#
2021-04-26 20:07:00 +02:00
# def cleanup( f_names_list ):
# global os
# for i in range(len( f_names_list )):
# if type(f_names_list[i]) == file:
# del_name = f_names_list[i].name
# elif type(f_names_list[i]) == str:
# del_name = f_names_list[i]
# else:
# print('Unrecognized type of element:', f_names_list[i], ' - can not be treated as file.')
# del_name = None
#
2021-04-26 20:07:00 +02:00
# if del_name and os.path.isfile( del_name ):
# os.remove( del_name )
#
2021-04-26 20:07:00 +02:00
# #--------------------------------------------
#
2021-04-26 20:07:00 +02:00
# if engine.startswith('2.5'):
# get_firebird_log_key='action_get_ib_log'
# else:
# get_firebird_log_key='action_get_fb_log'
#
2021-04-26 20:07:00 +02:00
# fb_log = os.path.join( fb_home, 'firebird.log' )
# fb_bak = os.path.join( fb_home, 'firebird.tmp' )
# shutil.copy2( fb_log, fb_bak )
# open(fb_log, 'w').close()
#
2021-04-26 20:07:00 +02:00
# f_init_log = open( os.path.join(context['temp_directory'],'tmp_5418_old.log'), 'w')
# subprocess.call( [ context['fbsvcmgr_path'],"localhost:service_mgr", get_firebird_log_key ], stdout = f_init_log, stderr = subprocess.STDOUT)
# flush_and_close( f_init_log )
#
2021-04-26 20:07:00 +02:00
# f = open(fb_log, 'w')
# for i in range(0,10):
# f.write(os.linesep)
# flush_and_close( f )
#
2021-04-26 20:07:00 +02:00
# f_curr_log = open( os.path.join(context['temp_directory'],'tmp_5418_new.log'), 'w')
# subprocess.call( [ context['fbsvcmgr_path'],"localhost:service_mgr", get_firebird_log_key ], stdout = f_curr_log, stderr = subprocess.STDOUT )
# flush_and_close( f_curr_log )
#
2021-04-26 20:07:00 +02:00
# shutil.move( fb_bak, fb_log )
#
2021-04-26 20:07:00 +02:00
# f_init_log=open(f_init_log.name, 'r')
# f_curr_log=open(f_curr_log.name, 'r')
# difftext = ''.join(difflib.unified_diff(
# f_init_log.readlines(),
2021-04-26 20:07:00 +02:00
# f_curr_log.readlines()
# ))
# f_init_log.close()
# f_curr_log.close()
#
2021-04-26 20:07:00 +02:00
# f_diff_txt=open( os.path.join(context['temp_directory'],'tmp_5418_diff.txt'), 'w')
# f_diff_txt.write(difftext)
# flush_and_close( f_diff_txt )
#
2021-04-26 20:07:00 +02:00
# p = re.compile('\\+\\s?\\S+')
# with open( f_diff_txt.name,'r') as f:
# for line in f:
# if line.startswith('+') and line.strip() != '+++' and p.search(line):
# print( 'UNEXPECTED content in firebird.log: %(line)s' % locals() )
#
2021-04-26 20:07:00 +02:00
# # Cleanup.
# ##########
# time.sleep(1)
# cleanup( (f_init_log,f_curr_log,f_diff_txt) )
#
#
2021-04-26 20:07:00 +02:00
#---