Esempio n. 1
0
 def readGrinderOutFile(self, summaryData):
     # reset the test directory
     # TODO this logic does not belong in a method named 'readGrinderOutFile' !
     if path.isdir(CONFIG.reportDir):
         logger.warn("Deleting previous report directory '" + CONFIG.reportDir + "'.")
         shutil.rmtree(CONFIG.reportDir)
     if path.isfile(CONFIG.reportDir):
         logger.warn("Pre-existing file '" + CONFIG.reportDir + "' collides with report dir name.  Deleting.")
         os.remove(CONFIG.reportDir)
     os.mkdir(CONFIG.reportDir)
     shutil.copytree(MDC.get('current.dir') + os.sep + "templates", CONFIG.reportDir + os.sep + "templates")
     analyzerPlugin = ga.constants.VORPAL.getPlugin("analyzer")
     # add the configured response time thresholds to the analyzer columns
     if CONFIG.useThresholds and len(CONFIG.rtimeThresholds) > 0:
         numberFormat = NumberFormat.getNumberInstance()
         list = CONFIG.rtimeThresholds            
         thresholds = list[:len(list) - 1]
         # the first group
         colName = "under %s sec" % numberFormat.format(thresholds[0])
         analyzerPlugin.addColumnName(colName)
         # the middle groups
         if len(thresholds) > 1:
             for i in range(len(thresholds) - 1):
                 colName = "%s to %s sec" % (numberFormat.format(thresholds[i]), numberFormat.format(thresholds[i + 1]))
                 analyzerPlugin.addColumnName(colName)
         # the last group
         name = "over %s sec" % numberFormat.format(thresholds[len(thresholds) - 1])
         analyzerPlugin.addColumnName(name)
     logger.warn("Starting log analysis.")
     for line in summaryData.getTestDataLines():
         if CONFIG.isShowTransactionData():
             if line.startswith("Test") or line.startswith("(Test"):
                 row = self.getRow(line)
                 logger.debug("Adding row name %s" % row.getTxName())
                 analyzerPlugin.addDataRow(row)
         if line.startswith("Totals"):
             analyzerPlugin.setTotalsRow(self.getRow(line, True))
import sys
import os

from org.jtmb.grinderAnalyzer import MDC

# Ensure we're on jython and not cpython
if os.name != "java":
    print "FATAL: cpython is not supported. This program must be invoked with jython 2.2.1 or later."
    sys.exit(1)

# Try to find the grinder analyzer dir.
GA_NAME = "GrinderAnalyzer"

# If the current path has not been provided, use the system property
if MDC.get("current.dir") is None:
    currentDir = os.path.curdir
    MDC.put("current.dir", currentDir)
else:
    currentDir = MDC.get("current.dir")

fullCurrentDir = os.path.realpath(currentDir)
cdir = os.path.split(fullCurrentDir)[1]
if cdir.find(GA_NAME) != 0:
    #    if not fullCurrentDir.endswith("grinderAnalyzer/scripts"):
    print "FATAL: This program can only be run from within the %s directory." % GA_NAME
    print "Current dir: %s, cdir: %s" % (os.getcwd(), cdir)
    sys.exit(1)

# Set the classpath
libDir = "lib"
Esempio n. 3
0
# along with Grinder Analyzer; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA

import os

from org.jtmb.grinderAnalyzer import Configuration
from org.jtmb.grinderAnalyzer import MDC
from org.jtmb.velocityMerger import VelocityMerger
from org.apache.log4j import PropertyConfigurator
from java.util import Properties


def _getProperties_():
    # vPlugin.analyzer=org.jtmb.grinderAnalyzer.HTTPTestPlugin
    props = CONFIG.startupProperties
    props.put("vPlugin.analyzer", "org.jtmb.grinderAnalyzer.GAVelocityPlugin")
    return props

# If the user has provided the path to their own analyzer.properties file, use it.
# Otherwise, use the default provided by this project.
if MDC.get('user.analyzer.config') is not None:
	CONFIG_FILE=MDC.get('user.analyzer.config')
else:
	CONFIG_FILE=MDC.get('current.dir') + os.sep + "conf/analyzer.properties"

# Log4j must be configured before the VelocityMerger classes
# are instantiated.
PropertyConfigurator.configure(CONFIG_FILE)
CONFIG=Configuration(CONFIG_FILE)
VORPAL=VelocityMerger(_getProperties_())