From: <ta...@us...> - 2015-07-28 19:06:40
|
Revision: 62054 http://sourceforge.net/p/firebird/code/62054 Author: tabloid Date: 2015-07-28 19:06:37 +0000 (Tue, 28 Jul 2015) Log Message: ----------- See added / modified .fbt file(s) Added Paths: ----------- qa/fbt-repository/trunk/tests/bugs/core_2940.fbt Added: qa/fbt-repository/trunk/tests/bugs/core_2940.fbt =================================================================== --- qa/fbt-repository/trunk/tests/bugs/core_2940.fbt (rev 0) +++ qa/fbt-repository/trunk/tests/bugs/core_2940.fbt 2015-07-28 19:06:37 UTC (rev 62054) @@ -0,0 +1,216 @@ +{ +'id': 'bugs.core_2940', +'qmid': None, +'tracker_id': 'CORE-2940', +'title': "Trace output could contain garbage data left from filtered out statements", +'description': """### W A R N I N G ### +1) This test uses async. calls of external routine (fbsvcmgr) with opening it in separate command window, + see: subprocess.call('start /min cmd /c ...', shell=True). +2) It was encountered that launching trace session by FBSVCMGR requires 1-2 seconds to be finished, + so this test intentionally uses delay (see calls `time.sleep()`). +3) Format of `database` section differ in 2.5 vs 3.0, so two separate sections have been created here for each FB version. +4) Correct work was checked on: WI-V2.5.5.26916 and WI-V3.0.0.31948. +""", +'min_versions': '2.5.0', +'versions': [ +{ + 'firebird_version': '2.5', + 'platform': 'Windows', + 'test_type': 'Python', + 'init_script': + """ + """, + 'test_script': + """import os +import subprocess +import time + +db_conn.close() +# format in 3.0 differ: database=%[\\\\\\\\/]bugs.core_2940.fdb +txt = '''# Generated auto, do not edit! +<database %[\\\\\\\\/]bugs.core_2940.fdb> + enabled true + #include_filter + exclude_filter %no_trace% + log_connections true + log_transactions true + log_statement_finish true + print_plan true + print_perf true + time_threshold 0 +</database> +''' +trccfg=open( os.path.join(context['temp_directory'],'tmp_trace_2940.cfg'), 'w') +trccfg.write(txt) +trccfg.close() +trclog=open( os.path.join(context['temp_directory'],'tmp_trace_2940.log'), 'w') +trclog.close() +trclst=open( os.path.join(context['temp_directory'],'tmp_trace_2940.lst'), 'w') +trclst.close() + +trc_launch='"fbsvcmgr localhost:service_mgr user SYSDBA password masterkey action_trace_start trc_cfg %s 1>%s 2>&1"' % (trccfg.name, trclog.name ) + +# Launch program in separate (new) window via START command: +subprocess.call('start /min cmd /c %s' % trc_launch, shell=True) + +# Wait! Trace session is initialized not instantly! +time.sleep(2) + +sqltxt='''select 1 from rdb$database; +commit; +select 2 from rdb$database /* no_trace*/; +''' + +runProgram('isql',[dsn,'-user',user_name,'-pas',user_password,'-n'],sqltxt) + +# Save active trace session info into file for further parsing it and obtain session_id back (for stop): +svc_launch='"fbsvcmgr localhost:service_mgr user SYSDBA password masterkey action_trace_list 1>%s 2>&1"' % trclst.name +subprocess.call('cmd /c %s' % svc_launch) + +trcssn=0 +with open( trclst.name,'r') as f: + for line in f: + i=1 + if 'Session ID' in line: + for word in line.split(): + if i==3: + trcssn=word + i=i+1 + break + +# Result: `trcssn` is ID of active trace session. Now we have to terminate it: +runProgram('fbsvcmgr', ['localhost:service_mgr','user','SYSDBA','password','masterkey','action_trace_stop','trc_id',trcssn]) + +time.sleep(1) + +# Repeat: check that this trace session really have been terminated: +runProgram('fbsvcmgr', ['localhost:service_mgr','user','SYSDBA','password','masterkey','action_trace_list']) + +# Output log of trace for comparing it with expected: it must contain only TWO events: TRACE_INIT and TRACE_FINI +# ::: NB ::: Content if trace log is converted to UPPER case in order to reduce change of mismatching with +# updated trace output in some future versions: +with open( trclog.name,'r') as f: + print(f.read().upper()) +f.close() + +if os.path.isfile(trccfg.name): + os.remove(trccfg.name) +if os.path.isfile(trclst.name): + os.remove(trclst.name) +if os.path.isfile(trclog.name): + os.remove(trclog.name) + """, + 'expected_stdout': + """ + 1 RECORDS FETCHED + """, + 'expected_stderr': + """ + """, + 'substitutions':[('^((?!RECORDS FETCHED).)*$','')] + +}, +{ + 'firebird_version': '3.0', + 'platform': 'Windows', + 'test_type': 'Python', + 'init_script': + """ + """, + 'test_script': + """import os +import subprocess +import time + +db_conn.close() + +# ### NOTES ABOUT TRACE CONFIG FOR 3.0 ### +# 1) Header contains `database` clause in different format vs FB 2.5. +# 2) Name and value must be separated by EQUALITY sign ('=') in FB-3 trace.conf, otherwise we get runtime error: +# element "<. . .>" have no attribute value set + +txt = '''# Generated auto, do not edit! +database=%[\\\\\\\\/]bugs.core_2940.fdb +{ + enabled = true + #include_filter + exclude_filter = %no_trace% + log_connections = true + log_transactions = true + log_statement_finish = true + print_plan = true + print_perf = true + time_threshold = 0 +} +''' +trccfg=open( os.path.join(context['temp_directory'],'tmp_trace_2940.cfg'), 'w') +trccfg.write(txt) +trccfg.close() +trclog=open( os.path.join(context['temp_directory'],'tmp_trace_2940.log'), 'w') +trclog.close() +trclst=open( os.path.join(context['temp_directory'],'tmp_trace_2940.lst'), 'w') +trclst.close() + +trc_launch='"fbsvcmgr localhost:service_mgr user SYSDBA password masterkey action_trace_start trc_cfg %s 1>%s 2>&1"' % (trccfg.name, trclog.name ) + +# Launch program in separate (new) window via START command: +subprocess.call('start /min cmd /c %s' % trc_launch, shell=True) + +# Wait! Trace session is initialized not instantly! +time.sleep(2) + +sqltxt='''select 1 from rdb$database; +commit; +select 2 from rdb$database /* no_trace*/; +''' + +runProgram('isql',[dsn,'-user',user_name,'-pas',user_password,'-n'],sqltxt) + +# Save active trace session info into file for further parsing it and obtain session_id back (for stop): +svc_launch='"fbsvcmgr localhost:service_mgr user SYSDBA password masterkey action_trace_list 1>%s 2>&1"' % trclst.name +subprocess.call('cmd /c %s' % svc_launch) + +trcssn=0 +with open( trclst.name,'r') as f: + for line in f: + i=1 + if 'Session ID' in line: + for word in line.split(): + if i==3: + trcssn=word + i=i+1 + break + +# Result: `trcssn` is ID of active trace session. Now we have to terminate it: +runProgram('fbsvcmgr', ['localhost:service_mgr','user','SYSDBA','password','masterkey','action_trace_stop','trc_id',trcssn]) + +time.sleep(1) + +# Repeat: check that this trace session really have been terminated: +runProgram('fbsvcmgr', ['localhost:service_mgr','user','SYSDBA','password','masterkey','action_trace_list']) + +# Output log of trace for comparing it with expected: it must contain only TWO events: TRACE_INIT and TRACE_FINI +# ::: NB ::: Content if trace log is converted to UPPER case in order to reduce change of mismatching with +# updated trace output in some future versions: +with open( trclog.name,'r') as f: + print(f.read().upper()) +f.close() + +if os.path.isfile(trccfg.name): + os.remove(trccfg.name) +if os.path.isfile(trclst.name): + os.remove(trclst.name) +if os.path.isfile(trclog.name): + os.remove(trclog.name) + """, + 'expected_stdout': + """ + 1 RECORDS FETCHED + """, + 'expected_stderr': + """ + """, + 'substitutions':[('^((?!RECORDS FETCHED).)*$','')] +} +] +} Property changes on: qa/fbt-repository/trunk/tests/bugs/core_2940.fbt ___________________________________________________________________ Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |