当前位置: 首页>>代码示例>>Python>>正文


Python Test.wrap方法代码示例

本文整理汇总了Python中net.grinder.script.Test.wrap方法的典型用法代码示例。如果您正苦于以下问题:Python Test.wrap方法的具体用法?Python Test.wrap怎么用?Python Test.wrap使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在net.grinder.script.Test的用法示例。


在下文中一共展示了Test.wrap方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __call__

# 需要导入模块: from net.grinder.script import Test [as 别名]
# 或者: from net.grinder.script.Test import wrap [as 别名]
 def __call__(self):
     grinder.statistics.delayReports = 1
     error = grinder.logger.error
     log = grinder.logger.output
         
     twitterTest = Test(201, "REST twittersoek")
     twitterRequest = twitterTest.wrap(HTTPRequest(url=baseUrl))
     
     profilbildeTest = Test(202, "REST profilbilder")
     profilbildeRequest = profilbildeTest.wrap(HTTPRequest())
     
     try:
         log("Soek etter 'Grinder' paa twitter og henter JSON-resultater")
         twitterJson = twitterRequest.GET("search.json?q=" + sokeord).text
         twitterObjekt = JSONObject(twitterJson)
         twitterResultater = twitterObjekt.getJSONArray("results")
         for i in range(0,twitterResultater.length()):
             enkeltTweet = twitterResultater.getJSONObject(i)
             brukerID = enkeltTweet.getString("from_user_id_str")
             log("Henter profilbilde for bruker:" + brukerID)
             profilbildeUrl = enkeltTweet.getString("profile_image_url")
             profilbildeRequest.GET(profilbildeUrl)
     except JSONException, ex:
         grinder.statistics.forLastTest.setSuccess(0)
         error("EXCEPTION HENDTE:")
         error(str(ex))
开发者ID:Espenhh,项目名称:Grinder-eksempel,代码行数:28,代码来源:t002json.py

示例2: __init__

# 需要导入模块: from net.grinder.script import Test [as 别名]
# 或者: from net.grinder.script.Test import wrap [as 别名]
 def __init__(self):
     url_file = open(url_file_path)
     self.tests = []
     for num, url in enumerate(url_file):
         url = url.strip()
         test = Test(num, url)
         request = test.wrap(HTTPRequest())
         self.tests.append((request, url))
     url_file.close()
开发者ID:Espenhh,项目名称:jz13,代码行数:11,代码来源:test1.py

示例3: __init__

# 需要导入模块: from net.grinder.script import Test [as 别名]
# 或者: from net.grinder.script.Test import wrap [as 别名]
 def __init__(self):
     url_file = open(url_file_path)
     self.tests = []
     for num, url in enumerate(url_file):
         url = url.strip()
         test = Test(num, url)
         request = test.wrap(HTTPRequest())
         self.tests.append((request, url))
     url_file.close()
     grinder.statistics.setDelayReports(True)
开发者ID:kvalle,项目名称:grinder-workshop,代码行数:12,代码来源:task3.py

示例4: __init__

# 需要导入模块: from net.grinder.script import Test [as 别名]
# 或者: from net.grinder.script.Test import wrap [as 别名]
 def __init__(self):
     url_file = open(url_file_path)
     self.requests = []
     for num, line in enumerate(url_file):
         url, description = line.split(' ', 1)
         test = Test(num, description.strip())
         request_fn = request_factory(url)
         wrapped_request_fn = test.wrap(request_fn)
         self.requests.append(wrapped_request_fn)
     url_file.close()
开发者ID:kvalle,项目名称:grinder-workshop,代码行数:12,代码来源:task2-extras.py

示例5: __init__

# 需要导入模块: from net.grinder.script import Test [as 别名]
# 或者: from net.grinder.script.Test import wrap [as 别名]
 def __init__(self):
     url_file = open(url_file_path, "rb")
     self.tests = []
     for num, line in enumerate(url_file):
         line = [val.strip() for val in line.split("|")]
         url, description, checks = line[0], line[1], line[2:]
         test = Test(num, description)
         request = test.wrap(HTTPRequest())
         self.tests.append((request, url, checks))
     url_file.close()
     grinder.statistics.setDelayReports(True)
开发者ID:stevexu01,项目名称:grinder-workshop,代码行数:13,代码来源:task3-extras.py

示例6: _add_webtest_file

# 需要导入模块: from net.grinder.script import Test [as 别名]
# 或者: from net.grinder.script.Test import wrap [as 别名]
 def _add_webtest_file(cls, filename):
     """Add all requests in the given ``.webtest`` filename to the class.
     """
     # Parse the Webtest file
     webtest = parser.Webtest(filename)
     # Create an HTTPRequest and Test wrapper for each request,
     # numbered sequentially
     test_requests = []
     for index, request in enumerate(webtest.requests):
         # First request is test_number+1, then test_number+2 etc.
         test = Test(cls.test_number + index + 1, str(request))
         wrapper = test.wrap(HTTPRequest())
         test_requests.append((test, wrapper, request))
     # Add the (test, request) list to class for this filename
     cls.webtest_requests[filename] = test_requests
     # Skip ahead to the next test_number
     cls.test_number += cls.test_number_skip
开发者ID:a-e,项目名称:grinder-webtest,代码行数:19,代码来源:runner.py

示例7: __call__

# 需要导入模块: from net.grinder.script import Test [as 别名]
# 或者: from net.grinder.script.Test import wrap [as 别名]
    def __call__(self):
        t1 = System.currentTimeMillis()

        test = Test(1, "HTTP post")
        request = test.wrap(HTTPRequest())

        timestamp = "<foo>|timestamp=" + str(System.currentTimeMillis()) + "|"
        padding = 'X' * (MSG_SIZE - len(timestamp) - len("</foo>"))
        data = timestamp + padding + "</foo>"

        result = request.POST(URL, data)

        if not result.statusCode == 204:
            raise Exception("Unexpected HTTP response; " + result.getText())

        if sleepTime > 0:
            # Adjust sleep time based on test time
            adjustedSleeptime = sleepTime - (System.currentTimeMillis() - t1)
            grinder.sleep(long(adjustedSleeptime))
开发者ID:chinnurtb,项目名称:rabbitmq-streams,代码行数:21,代码来源:send_http_post.py

示例8: Test

# 需要导入模块: from net.grinder.script import Test [as 别名]
# 或者: from net.grinder.script.Test import wrap [as 别名]
testCycle = Test(0,"Full Cycle")

test1 = Test(1, "RetrieveDC")
test2 = Test(2, "Ingest")
test3 = Test(3, "modifyRELSEXT")
test4 = Test(4, "RetrieveRELSEXT")



utilities = HTTPPluginControl.getHTTPUtilities()
auth = utilities.basicAuthorizationHeader(grinder.getProperties().getProperty('fcrepo.userName'),grinder.getProperties().getProperty('fcrepo.password'))
contenttype = NVPair('Content-Type','text/xml')
dedupobject = FileInputStream('fcagent-file-store/current/DataWellDeDup.xml')


requestDCHTTP = test1.wrap(HTTPRequest())
ingestHTTP = test2.wrap(HTTPRequest())

requestRELSEXT = test4.wrap(HTTPRequest())


            
def establishFirstFromFedora():
    global auth
    log("establish First")
    contenttype = NVPair('Content-Type','text/xml')
    target =  SERVER + '/objects/nextPID?format=xml'

    
    result = HTTPRequest().POST(target,None,[contenttype,auth])
    text =  str(result.getText())
开发者ID:statsbiblioteket,项目名称:doms-grinding,代码行数:33,代码来源:DataWellTest1.py

示例9: Test

# 需要导入模块: from net.grinder.script import Test [as 别名]
# 或者: from net.grinder.script.Test import wrap [as 别名]
import time
import random
import urllib2
import logging, logging.config
import config
from core.user import User 
from core.session import Session
from core.admin import Admin
from core.exceptions import RequestFailedError
from core.exceptions import ConnectionError
from core.exceptions import InvalidArgumentError
import java
 
log = grinder.logger.info
test2 = Test(2, 'Game step test')
logWrapper = test2.wrap(log)


 #   Тест: Игра случайного игрока. Игрок пытается сделать ход в каждой сессии из его списка сессий
   
class TestRunner:
       
    def __init__(self):
        """
            TestRunner constructor
            do nothing 
        """
        pass
      #  grinder.logger.info('Thread #%d started' % grinder.threadNumber )
    
    def __call__(self):
开发者ID:synesis-ru,项目名称:QA-Tools,代码行数:33,代码来源:TestScript2.py

示例10: __init__

# 需要导入模块: from net.grinder.script import Test [as 别名]
# 或者: from net.grinder.script.Test import wrap [as 别名]
class TestRunner:
	 
    # There's a runsForThread variable for each worker thread. This
    # statement specifies a class-wide initial value.
    runsForThread = 0
 
    # The __init__ method is called once for each thread.
    def __init__(self):
        self.barrier = grinder.barrier("initialization")
    
        global rayolock
        rayolock.lock()
        try:
            global testNumber        
            testNumber += 1
    
            # There's an initialisationTime variable for each worker thread.
            self.initialisationTime = System.currentTimeMillis()
            self.loadTest = LoadTest()
            self.loadTest.loadTest(testNumber)
        
            self.test = Test(testNumber, "Load Test")
            self.wrapper = self.test.wrap(self.loadTest) 
        
            grinder.logger.output("New thread started at time %s" %
                              self.initialisationTime)
        finally:
            rayolock.unlock()
        grinder.logger.output("Waiting for other threads to initialize")                  
        self.barrier.await()
 
    # The __call__ method is called once for each test run performed by
    # a worker thread.
    def __call__(self):
 
        # Turn off automatic reporting for the current worker thread.
        # Having done this, the script can modify or set the statistics
        # before they are sent to the log and the console.
        grinder.statistics.delayReports = 1    
        
        # We really should synchronise this access to the shared
        # totalNumberOfRuns variable. See JMS receiver example for how
        # to use the Python Condition class.
        global totalNumberOfRuns
        totalNumberOfRuns += 1
 
        self.runsForThread += 1
 
        grinder.logger.output(
            "runsForThread=%d, totalNumberOfRuns=%d, initialisationTime=%d" %
            (self.runsForThread, totalNumberOfRuns, self.initialisationTime))
 		
        try:
            self.wrapper.testLoadScenario2()
        except:
            grinder.statistics.forLastTest.success = 0
 		
        # You can also vary behaviour based on thread ID.
        if grinder.threadNumber % 2 == 0:
            grinder.logger.output("I have an even thread ID.")
 
    # Scripts can optionally define a __del__ method. The Grinder
    # guarantees this will be called at shutdown once for each thread
    # It is useful for closing resources (e.g. database connections)
    # that were created in __init__.
    def __del__(self):
        grinder.logger.output("Thread shutting down") 
开发者ID:adhearsion,项目名称:rayo-load-tests,代码行数:69,代码来源:rayo-load-tests.py

示例11: Test

# 需要导入模块: from net.grinder.script import Test [as 别名]
# 或者: from net.grinder.script.Test import wrap [as 别名]
import time
import random
import urllib2
import logging, logging.config
import config
from core.user import User 
from core.session import Session
from core.admin import Admin
from core.exceptions import RequestFailedError
from core.exceptions import ConnectionError
from core.exceptions import InvalidArgumentError
import java
 
log = grinder.logger.info
test3 = Test(3, 'all users are playing ')
logWrapper = test3.wrap(log)

 #   Тест: Создание по 10 сессий для каждого игрока
   
class TestRunner:
       
    def __init__(self):
        pass
      #  grinder.logger.info('Thread #%d started' % grinder.threadNumber )
    
    def __call__(self):
       # logging.basicConfig(level=logging.DEBUG)
       # log = logging.getLogger('main')
        curThreadInfo = java.lang.Thread.currentThread().toString()
        try:
            logging.debug("******* Staring task %s" % curThreadInfo)
开发者ID:synesis-ru,项目名称:QA-Tools,代码行数:33,代码来源:TestScript3.py

示例12: Test

# 需要导入模块: from net.grinder.script import Test [as 别名]
# 或者: from net.grinder.script.Test import wrap [as 别名]
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Grinder Analyzer; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA



"""
Based on the simple HTTP script in the Grinder script gallery.

Classes:

    TestRunner:     main entry point for the grinder

"""

from net.grinder.script import Test
from net.grinder.script.Grinder import grinder
 
test1 = Test(1, "Log method")
 
# Wrap the info() method with our Test and call the result logWrapper.
logWrapper = test1.wrap(grinder.logger.info)
 
class TestRunner:
    def __call__(self):
        logWrapper("Hello World")
        grinder.sleep(250)

开发者ID:DealerDotCom,项目名称:grinder-analyzer,代码行数:31,代码来源:nonHTTPTest.py

示例13: __init__

# 需要导入模块: from net.grinder.script import Test [as 别名]
# 或者: from net.grinder.script.Test import wrap [as 别名]
class G2HTTPTest:
    """Parses parameters for an individual test and wraps the test
    invocation in a G3 Test."""

    def __init__(self, testNumber, properties):
        self.sleepTime = properties["sleepTime"]

        headers = []
        seenContentType = 0

        for e in properties.getPropertySubset("parameter.header.").entrySet():
            headers.append(NVPair(e.key, e.value))
            if not seenContentType and e.key.lower() == "content-type":
                seenContentType = 1

        postDataFilename = properties["parameter.post"]

        if postDataFilename:
            file = open(postDataFilename)
            self.postData = file.read()
            file.close()

            if not seenContentType:
                headers.append(NVPair("Content-type",
                                      "application/x-www-form-urlencoded"))

        else: self.postData = None

        self.okString = properties["parameter.ok"]
        self.url = properties["parameter.url"]

        realm = properties["basicAuthenticationRealm"]
        user = properties["basicAuthenticationUser"]
        password = properties["basicAuthenticationPassword"]

        if realm and user and password:
            self.basicAuthentication = (realm, user, password)

        elif not realm and not user and not password:
            self.basicAuthentication = None

        else:
            raise "If you specify one of { basicAuthenticationUser, basicAuthenticationRealm, basicAuthenticationPassword } you must specify all three."

        request = HTTPRequest(headers=headers)
        self.test = Test(testNumber, properties["description"])
        self.request = self.test.wrap(request)

    def doTest(self, iteration):

        if self.basicAuthentication:
            connection = HTTPPluginControl.getThreadConnection(self.url)

            connection.addBasicAuthorization(self.basicAuthentication[0],
                                             self.basicAuthentication[1],
                                             self.basicAuthentication[2])

        grinder.statistics.delayReports = 1

        if self.postData:
            page = self.request.POST(self.url, self.postData).text
        else:
            page = self.request.GET(self.url).text

        if not page:
            error = self.okString
        else:
            error = self.okString and page.find(self.okString) == -1

            if error or logHTML:
                if self.test.description:
                    description = "_%s" % self.test.description
                else:
                    description = ""

                filename = grinder.filenameFactory.createFilename(
                    "page",
                    "_%d_%.3d%s" % (iteration, self.test.number, description))

                file = open(filename, "w")
                print >> file, page
                file.close()

                if error:
                    grinder.logger.error(
                        "The 'ok' string ('%s') was not found in the page "
                        "received. The output has been written to '%s'." %
                        (self.okString, filename))

        if error:
            grinder.statistics.forLastTest.success = 0

        if self.sleepTime:
            grinder.sleep(long(self.sleepTime))
开发者ID:DealerDotCom,项目名称:grinder,代码行数:96,代码来源:httpg2.py

示例14: __call__

# 需要导入模块: from net.grinder.script import Test [as 别名]
# 或者: from net.grinder.script.Test import wrap [as 别名]
 def __call__(self):
     kontoTest = Test(101, "Laste vg.no")
     kontoRequest = kontoTest.wrap(HTTPRequest())   
     kontoRequest.GET("http://www.vg.no")
开发者ID:Espenhh,项目名称:Grinder-eksempel,代码行数:6,代码来源:t001vg.py

示例15: Test

# 需要导入模块: from net.grinder.script import Test [as 别名]
# 或者: from net.grinder.script.Test import wrap [as 别名]
"""



from net.grinder.plugin.http import HTTPRequest
from net.grinder.script import Test
from net.grinder.script.Grinder import grinder

# constants
TOMCAT_HOST = "qa-perftest001"
TOMCAT_PORT = 8080
THINK_TIME = 400

test1 = Test(1, "Tomcat home")
request1 = test1.wrap(HTTPRequest())
# http://localhost:8080
url1 = "http://%s:%d" % (TOMCAT_HOST, TOMCAT_PORT)

test2 = Test(2, "Tomcat relnotes")
request2 = test2.wrap(HTTPRequest())
# http://localhost:8080/RELEASE-NOTES.txt
url2 = "http://%s:%d/RELEASE-NOTES.txt" % (TOMCAT_HOST, TOMCAT_PORT)

test3 = Test(3, "Tomcat documentation")
request3 = test3.wrap(HTTPRequest())
# http://localhost:8080/docs/
url3 = "http://%s:%d/docs/" % (TOMCAT_HOST, TOMCAT_PORT)

test4 = Test(4, "Tomcat servlets")
request4 = test4.wrap(HTTPRequest())
开发者ID:DealerDotCom,项目名称:grinder-analyzer,代码行数:32,代码来源:HTTPTest.py


注:本文中的net.grinder.script.Test.wrap方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。