Ошибка тестового сценария Grinder JDBC. Результат «TestRunner()» не может быть вызван

Я использую тест производительности запуска сценария JDBC.py. информация журнала измельчителя:

2015-10-14 18:42:40,132 ОШИБКА com-0 thread-24: прерывание потока — {}Результат «TestRunner()» не может быть вызван net.grinder.scriptengine.jython.JythonScriptExecutionException: результат «TestRunner( )' не вызывается в net.grinder.scriptengine.jython.JythonScriptEngine.createWorkerRunnable(JythonScriptEngine.java:183) ~[grinder-core-3.11.jar:na] в net.grinder.engine.process.GrinderProcess$ThreadStarterImplementation$2. create(GrinderProcess.java:784) ~[grinder-core-3.11.jar:na] в net.grinder.engine.process.GrinderThread.run(GrinderThread.java:90) ~[grinder-core-3.11.jar:na ] at java.lang.Thread.run(Thread.java:744) [na:1.7.0_45] 2015-10-14 18:42:40,132 ОШИБКА com-0 thread-3: прерывание потока - {}Результат ' TestRunner()' не вызывается net.grinder.scriptengine.jython.JythonScriptExecutionException: результат TestRunner() не может быть вызван в net.grinder.scriptengine.jython.JythonScriptEngine.createWorkerRunnable(JythonS criptEngine.java:183) ~[grinder-core-3.11.jar:na] в net.grinder.engine.process.GrinderProcess$ThreadStarterImplementation$2.create(GrinderProcess.java:784) ~[grinder-core-3.11.jar: нет данных] в net.grinder.engine.process.GrinderThread.run(GrinderThread.java:90) ~[grinder-core-3.11.jar:нет данных] в java.lang.Thread.run(Thread.java:744) [нет данных :1.7.0_45]

Я изменяю скрипт, но все равно ошибка. Пожалуйста, помогите проверить это.

Тестирую скрипт:

# The sorting tes  supports a configurable array length.
# It runs the JavaTest.sort method of the JavaTest class.

from net.grinder.script.Grinder import grinder
from net.grinder.script import Test
from datetime import datetime
from datetime import timedelta
from java.sql import DriverManager
from oracle.jdbc import OracleDriver

########################################
#
# main body of test script starts here
#
########################################

# Get the propeties to access test configuration information
properties = grinder.getProperties()

# The description is a property (instead of a hardcoded string in this script)
#test = Test(1, properties.get("javatest.description"))
test = Test(2, properties.get("javatest.description"))

# select the method for which to collect information
# test.record(WriteMulitpleLittleFile.write)

# initialize data for compressing
# fileName = properties.get("javatest.fileToCompress")
# grinder.logger.info("data file to compress is " + fileName)
# JavaTest.initializeCompression(fileName)

# If the run mode is runOnce, the TestRunner class will
# run once.  Otherwise, if the run mode is continuous,
# the TestRunner class will run the test for at least
# the specified duration (but possibly longer)
runMode = properties.get("javatest.runMode")
#WriteMulitpleLittleFile.setParameters(dir, fileSize...)
if runMode == "continuous":
  # figure out how long to run the test
  m = int(properties.getProperty("javatest.durationMinutes", "0"))
  h = int(properties.getProperty("javatest.durationHours", "0"))
  d = int(properties.getProperty("javatest.durationDays", "0"))
  duration = timedelta(minutes=m,hours=h,days=d)
  grinder.logger.info("run mode is continuous, duration is " + str(duration))
elif runMode == "runOnce":
  grinder.logger.info("run mode is run once")
  duration = timedelta(minutes=0)
else:
  grinder.logger.info("run mode not set or not recongized, default to run once")
  duration = timedelta(minutes=0)

########################################
#
# The TestRunner class is used by The Grinder to perform the test
#
########################################

#test1 = Test(1, "Database insert")
test2 = Test(2, "Database query")

# Load the Oracle JDBC driver.
DriverManager.registerDriver(OracleDriver())

def getConnection():
    return DriverManager.getConnection(
        "jdbc:oracle:thin:@den00bvr.us.oracle.com:1521:orcl", "PBPUBLIC", "PBPUBLIC")

def ensureClosed(object):
    try: object.close()
    except: pass

# One time initialisation that cleans out old data.
connection = getConnection()
statement = connection.createStatement()

#try: statement.execute("drop table grinder_test1126")
#except: pass

#statement.execute("create table grinder_test1126(thread number, run number)")

ensureClosed(statement)
ensureClosed(connection)

class TestRunner:
   def __init__(self):
#        tid = grinder.threadNumber

#        if (grinder.threadNumber % 2 == 0):
#             Even threadNumber
#             Do insertStatement
#        else:
#             Odd threadNumber
#             Do queryStatement

#   def __call__(self):
#       self.testRunner()

        endTime = datetime.now() + duration
        notDone = True
        while notDone:
         connection = None
         insertStatement = None
         queryStatement = None
         notDone = datetime.now() < endTime

        try:
            connection = getConnection()
#           insertStatement = connection.createStatement()
            queryStatement = connection.createStatement()

#           test1.record(insertStatement)
#           insertStatement.execute("insert into grinder_test1126 values(%d, %d)" %
#                                   (grinder.threadNumber, grinder.runNumber))

            test2.record(queryStatement)
            queryStatement.execute("select * from employee")

        finally:
#           ensureClosed(insertStatement)
            ensureClosed(queryStatement)
            ensureClosed(connection)

person Gang Yan    schedule 14.10.2015    source источник


Ответы (1)


Согласно документации,

Экземпляр TestRunner должен быть вызываемым

Объект Python можно вызывать, если он определяет метод call. Каждый рабочий поток выполняет несколько запусков тестового сценария, как указано в свойствеgrinder.runs. Для каждого запуска рабочий поток вызывает свой TestRunner; таким образом, метод call можно рассматривать как определение запуска.

Ваш сценарий требует функции вызова, чтобы классифицировать его как вызываемый.

person Izy-    schedule 12.09.2016