From 1c74de73214379a1a263cb1b319efa36c7ef1e69 Mon Sep 17 00:00:00 2001 From: Lars Langhans Date: Mon, 13 Sep 2010 09:33:05 +0200 Subject: perftest12:#163613# Performancetest cleanups --- .../runner/graphical/EnhancedComplexTestCase.java | 2 +- qadevOOo/runner/graphical/JPEGCreator.java | 3 +- .../graphical/OpenOfficePostscriptCreator.java | 2 +- qadevOOo/runner/graphical/PostscriptCreator.java | 3 +- qadevOOo/runner/helper/OfficeProvider.java | 6 +- qadevOOo/runner/helper/ProcessHandler.java | 210 +++++++++++++++++++-- qadevOOo/runner/org/openoffice/Runner.java | 2 +- 7 files changed, 208 insertions(+), 20 deletions(-) (limited to 'qadevOOo') diff --git a/qadevOOo/runner/graphical/EnhancedComplexTestCase.java b/qadevOOo/runner/graphical/EnhancedComplexTestCase.java index c3ec2b3e8336..5f624979a64a 100644 --- a/qadevOOo/runner/graphical/EnhancedComplexTestCase.java +++ b/qadevOOo/runner/graphical/EnhancedComplexTestCase.java @@ -45,7 +45,7 @@ abstract public class EnhancedComplexTestCase extends ComplexTestCase implements private void callEntry(String _sEntry, ParameterHelper _aParam) { // log.println("- next file is: ------------------------------"); - log.println("File: " + _sEntry); + log.println(" File: " + _sEntry); // TODO: check if 'sEntry' is a guilty document. File aFile = new File(_aParam.getInputPath()); String sPath = _aParam.getInputPath(); diff --git a/qadevOOo/runner/graphical/JPEGCreator.java b/qadevOOo/runner/graphical/JPEGCreator.java index a4336229e448..7deee0d0d8f6 100644 --- a/qadevOOo/runner/graphical/JPEGCreator.java +++ b/qadevOOo/runner/graphical/JPEGCreator.java @@ -61,7 +61,8 @@ public class JPEGCreator extends EnhancedComplexTestCase public void checkOneFile(String _sDocumentName, String _sResult, ParameterHelper _aParams) throws OfficeException { - GlobalLogWriter.println("Document: " + _sDocumentName + " results: " + _sResult); + GlobalLogWriter.println(" Document: " + _sDocumentName); + GlobalLogWriter.println(" results: " + _sResult); // IOffice aOffice = new Office(_aParams, _sResult); // aOffice.start(); // aOffice.load(_sDocumentName); diff --git a/qadevOOo/runner/graphical/OpenOfficePostscriptCreator.java b/qadevOOo/runner/graphical/OpenOfficePostscriptCreator.java index d918634f8d30..dbe6305ca8c0 100644 --- a/qadevOOo/runner/graphical/OpenOfficePostscriptCreator.java +++ b/qadevOOo/runner/graphical/OpenOfficePostscriptCreator.java @@ -1380,9 +1380,9 @@ public class OpenOfficePostscriptCreator implements IOffice // Watcher Object is need in log object to give a simple way to say if a running office is alive. // As long as a log comes, it pings the Watcher and says the office is alive, if not an // internal counter increase and at a given point (300 seconds) the office is killed. - GlobalLogWriter.println("Set office watcher"); if (GlobalLogWriter.get().getWatcher() == null) { + GlobalLogWriter.println("Set office watcher"); OfficeWatcher aWatcher = (OfficeWatcher)m_aParameterHelper.getTestParameters().get("Watcher"); GlobalLogWriter.get().setWatcher(aWatcher); } diff --git a/qadevOOo/runner/graphical/PostscriptCreator.java b/qadevOOo/runner/graphical/PostscriptCreator.java index ab7ad4536fa6..7109b4851b1b 100644 --- a/qadevOOo/runner/graphical/PostscriptCreator.java +++ b/qadevOOo/runner/graphical/PostscriptCreator.java @@ -59,7 +59,8 @@ public class PostscriptCreator extends EnhancedComplexTestCase public void checkOneFile(String _sDocumentName, String _sResult, ParameterHelper _aParams) throws OfficeException { - GlobalLogWriter.println("Document: " + _sDocumentName + " results: " + _sResult); + GlobalLogWriter.println(" Document: " + _sDocumentName); + GlobalLogWriter.println(" results: " + _sResult); IOffice aOffice = new Office(_aParams, _sResult); PerformanceContainer a = new PerformanceContainer(); diff --git a/qadevOOo/runner/helper/OfficeProvider.java b/qadevOOo/runner/helper/OfficeProvider.java index 8589de47ea82..1d4950ee5404 100644 --- a/qadevOOo/runner/helper/OfficeProvider.java +++ b/qadevOOo/runner/helper/OfficeProvider.java @@ -59,7 +59,7 @@ import util.utils; public class OfficeProvider implements AppProvider { - protected static boolean debug = false; + private static boolean debug = false; /** * copy the user layer to a safe place, usualy to $TMP/user_backup$USER @@ -355,7 +355,7 @@ public class OfficeProvider implements AppProvider if (rInitialObject != null) { - debug = true; + // debug = true; dbg("resolved url"); xMSF = UnoRuntime.queryInterface(XMultiServiceFactory.class, rInitialObject); @@ -434,7 +434,7 @@ public class OfficeProvider implements AppProvider { XMultiServiceFactory msf = null; String exc = ""; - debug = true; + // debug = true; dbg("trying to connect to " + cncstr); diff --git a/qadevOOo/runner/helper/ProcessHandler.java b/qadevOOo/runner/helper/ProcessHandler.java index c414accd44ac..8e37a58a370e 100644 --- a/qadevOOo/runner/helper/ProcessHandler.java +++ b/qadevOOo/runner/helper/ProcessHandler.java @@ -26,6 +26,7 @@ ************************************************************************/ package helper; +import java.io.BufferedReader; import java.io.InputStream; import java.io.File; import java.io.PrintWriter; @@ -33,10 +34,12 @@ import java.io.PrintStream; import java.io.LineNumberReader; import java.io.InputStreamReader; import java.io.OutputStreamWriter; +import java.io.Writer; import java.util.Calendar; import java.util.Date; import java.util.GregorianCalendar; import lib.TestParameters; +import share.LogWriter; import util.PropertyName; import util.utils; @@ -58,6 +61,7 @@ class Pump extends Thread private String pref; private StringBuffer buf = new StringBuffer(256); private PrintWriter log; + private boolean bOutput; /** * Creates Pump for specified InputStream. @@ -70,11 +74,12 @@ class Pump extends Thread * @param outPrefix A prefix which is printed at the * beginning of each output line. */ - public Pump(InputStream is, PrintWriter log, String outPrefix) + public Pump(InputStream is, PrintWriter log, String outPrefix, boolean _bOutput) { this.pref = (outPrefix == null) ? "" : outPrefix; reader = new LineNumberReader(new InputStreamReader(is)); this.log = log; + this.bOutput = _bOutput; start(); } @@ -85,8 +90,11 @@ class Pump extends Thread String line = reader.readLine(); while (line != null) { - log.println(pref + line); - log.flush(); + if (bOutput) + { + log.println(pref + line); + log.flush(); + } buf.append(line).append('\n'); line = reader.readLine(); } @@ -133,6 +141,11 @@ public class ProcessHandler private Process m_aProcess = null; private TestParameters param = null; private boolean debug = false; + private boolean bUseOutput = true; + + private int m_nProcessTimeout = 0; + private String m_sProcessKiller; + private ProcessWatcher m_aWatcher; /** * Creates instance with specified external command. @@ -347,6 +360,24 @@ public class ProcessHandler } + /** + * If not equal 0, the time to maximal wait. + * @param _n + */ + public void setProcessTimeout(int _n) + { + m_nProcessTimeout = _n; + } + + /** + * This command will call after ProcessTimeout is arrived. + * @param _s + */ + public void setProcessKiller(String _s) + { + m_sProcessKiller = _s; + } + /** * This method do an asynchronous execution of the commands. To avoid a interruption on long running processes * caused by OfficeWatcher, the OfficeWatcher get frequently a ping. @@ -395,7 +426,7 @@ public class ProcessHandler if (sOutputText.length() == memText.length()) { changedText = false; - // dbg("runCommand Could not detect changes in output stream!!!"); + // dbg("runCommand Could not detect changes in output stream!!!"); } hangcheck = 10; memText = this.getOutputText(); @@ -515,6 +546,21 @@ public class ProcessHandler return m_nExactStartTimeInMillisec; } + private void showEnvVars() + { + if (envVars != null) + { + for (int i = 0; i < envVars.length; i++) + { + log.println("env: " + envVars[i]); + } + } + else + { + log.println("env: null"); + } + } + protected void execute() { if (isStarted()) @@ -527,27 +573,32 @@ public class ProcessHandler { if (cmdLine == null) { - log.print(utils.getDateTime() + "execute: Starting command from array: "); + log.println(utils.getDateTime() + "execute: Starting command from array: "); for (int i = 0; i < cmdLineArray.length; i++) { - log.print(cmdLineArray[i]); - log.print(" "); + log.println(cmdLineArray[i]); + // log.print(" "); } + showEnvVars(); log.println(""); initialExactStartTime(); + initializeProcessKiller(); m_aProcess = runtime.exec(cmdLineArray, envVars); } else { if (workDir != null) { - log.println(utils.getDateTime() + "execute: Starting command: " + cmdLine + " " + - workDir.getAbsolutePath()); + log.println(utils.getDateTime() + "execute: Starting command: "); + log.println(cmdLine + " path=" + workDir.getAbsolutePath()); + showEnvVars(); m_aProcess = runtime.exec(cmdLine, envVars, workDir); } else { - log.println(utils.getDateTime() + "execute: Starting command: " + cmdLine); + log.println(utils.getDateTime() + "execute: Starting command: "); + log.println(cmdLine); + showEnvVars(); m_aProcess = runtime.exec(cmdLine, envVars); } } @@ -566,8 +617,8 @@ public class ProcessHandler return; } dbg("execute: pump io-streams"); - stdout = new Pump(m_aProcess.getInputStream(), log, "out > "); - stderr = new Pump(m_aProcess.getErrorStream(), log, "err > "); + stdout = new Pump(m_aProcess.getInputStream(), log, "out > ", bUseOutput); + stderr = new Pump(m_aProcess.getErrorStream(), log, "err > ", bUseOutput); stdIn = new PrintStream(m_aProcess.getOutputStream()); // int nExitValue = m_aProcess.exitValue(); @@ -821,4 +872,139 @@ public class ProcessHandler log.println(utils.getDateTime() + "PH." + message); } } + + public void noOutput() + { + bUseOutput = false; + } + // ------------------------------------------------------------------------- + class ProcessWatcher extends Thread + { + + private int m_nTimeoutInSec; + private String m_sProcessToStart; + private boolean m_bInterrupt; + + public ProcessWatcher(int _nTimeOut, String _sProcess) + { + m_nTimeoutInSec = _nTimeOut; + m_sProcessToStart = _sProcess; + m_bInterrupt = false; + } + + /** + * returns true, if the thread should hold on + * @return + */ + public synchronized boolean isInHoldOn() + { + return m_bInterrupt; + } + /** + * Marks the thread to hold on, next time + * STUPID: The thread must poll this flag itself. + * + * Reason: interrupt() seems not to work as expected. + */ + public synchronized void holdOn() + { + m_bInterrupt = true; + interrupt(); + } + + public void run() + { + while (m_nTimeoutInSec > 0) + { + m_nTimeoutInSec--; + try + { + sleep(1000); + } + catch(java.lang.InterruptedException e) + { + // interrupt flag is set back to 'not interrupted' :-( + } + if (isInHoldOn()) + { + break; + } + } + if (m_nTimeoutInSec <= 0 && !isInHoldOn()) // not zero, so we are interrupted. + { + system(m_sProcessToStart); + } + } + + /** + * Start an external Process + * @param _sProcess + */ + private void system(String _sProcess) + { + if (_sProcess == null) + { + return; + } + + try + { + + // run a _sProcess command + // using the Runtime exec method: + Process p = Runtime.getRuntime().exec(_sProcess); + + BufferedReader stdInput = new BufferedReader(new InputStreamReader(p.getInputStream())); + + BufferedReader stdError = new BufferedReader(new InputStreamReader(p.getErrorStream())); + + // read the output from the command + String s; + while ((s = stdInput.readLine()) != null) + { + System.out.println("out:" + s); + } + + // read any errors from the attempted command + while ((s = stdError.readLine()) != null) + { + System.out.println("err:" + s); + } + + } + catch (java.io.IOException e) + { + System.out.println("exception caught: "); + e.printStackTrace(); + } + + } + } + + /** + * If the timeout only given by setProcessTimeout(int seconds) function is != 0, + * a extra thread is created and after time has run out, the ProcessKiller string + * given by function setProcessKiller(string) will execute. + * So it is possible to kill a running office after a given time of seconds. + */ + private void initializeProcessKiller() + { + if (m_nProcessTimeout != 0) + { + m_aWatcher = new ProcessWatcher(m_nProcessTimeout, m_sProcessKiller); + m_aWatcher.start(); + } + } + + /** + * to stop the extra thread, before he will kill a running office. This will stop the thread. + */ + public void stopWatcher() + { + if (m_aWatcher != null) + { + m_aWatcher.holdOn(); + shortWait(5000); + } + } } diff --git a/qadevOOo/runner/org/openoffice/Runner.java b/qadevOOo/runner/org/openoffice/Runner.java index a3741774917e..3023727400b3 100644 --- a/qadevOOo/runner/org/openoffice/Runner.java +++ b/qadevOOo/runner/org/openoffice/Runner.java @@ -184,7 +184,7 @@ public class Runner public static boolean run(String... args) { - System.out.println("OOoRunner Main() version from 20100323 (yyyymmdd)"); + System.out.println("OOoRunner Main() version from 20100913 (yyyymmdd)"); setStartTime(getTime()); -- cgit From a44a97eb905e7edd6dc9abeba73fc8d0ca068a38 Mon Sep 17 00:00:00 2001 From: Lars Langhans Date: Thu, 23 Sep 2010 11:50:47 +0200 Subject: perftest12:#163613# cleanups for O3 usage --- .../runner/graphical/EnhancedComplexTestCase.java | 21 ++++++++++++++++----- qadevOOo/runner/graphical/JPEGEvaluator.java | 2 ++ qadevOOo/runner/graphical/Office.java | 1 + .../graphical/OpenOfficePostscriptCreator.java | 1 + qadevOOo/runner/graphical/ParameterHelper.java | 3 ++- qadevOOo/runner/org/openoffice/Runner.java | 2 +- 6 files changed, 23 insertions(+), 7 deletions(-) (limited to 'qadevOOo') diff --git a/qadevOOo/runner/graphical/EnhancedComplexTestCase.java b/qadevOOo/runner/graphical/EnhancedComplexTestCase.java index 5f624979a64a..3d496826f5f2 100644 --- a/qadevOOo/runner/graphical/EnhancedComplexTestCase.java +++ b/qadevOOo/runner/graphical/EnhancedComplexTestCase.java @@ -254,8 +254,15 @@ private void callEntry(String _sEntry, ParameterHelper _aParam) for (int i=0;i