Beispiel #1
0
 def __call__(self):
   """This method is called for every run performed by the worker thread."""
   
   self.initSession()
   self.auth()
   self.bind()
   self.requestSession()
   self.getRoster()
   
   message = "Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Duis rutrum porttitor ante. Nunc arcu leo."
   show = "chat"
   
   #for i in range(2):
   while(True):
     if show == "dnd":
       show = "chat"
     else:
       show = "dnd"
     self.changePresence(show)
     if grinder.statistics.forLastTest.time < 5000:
       grinder.sleep(5000 - grinder.statistics.forLastTest.time)
     for j in range(5):
       self.sendMessage(message, self.targetUser)
       if grinder.statistics.forLastTest.time < 5000:
         grinder.sleep(5000 - grinder.statistics.forLastTest.time)
   
   self.terminate()
Beispiel #2
0
    def page2(self):
        """GET / (requests 201-209)."""
        result = request201.GET('/')

        grinder.sleep(17)
        request202.GET('/resources/css/petclinic.css', None, (
            NVPair('Accept', 'text/css,*/*;q=0.1'),
            NVPair('Referer', 'http://localhost:8080/'),
        ))

        request203.GET('/resources/images/favicon.png')

        request204.GET('/webjars/jquery-ui/1.11.4/jquery-ui.min.js')

        request205.GET('/webjars/jquery/2.2.4/jquery.min.js')

        request206.GET('/resources/images/pets.png')

        request207.GET('/resources/images/spring-logo-dataflow.png', None, (
            NVPair('Accept', 'image/png,image/*;q=0.8,*/*;q=0.5'),
            NVPair('Referer',
                   'http://localhost:8080/resources/css/petclinic.css'),
        ))

        request208.GET('/webjars/bootstrap/3.3.6/js/bootstrap.min.js')

        request209.GET('/resources/images/spring-pivotal-logo.png')

        return result
Beispiel #3
0
  def page1(self):
    """GET supercars.do (requests 101-111)."""
    result = request101.GET('/Cars_Sample_App/supercars.do', None,
      ( NVPair('Accept', 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8'), ))
    self.token_query = \
      httpUtilities.valueFromBodyURI('query') # 'manu'
    # 15 different values for token_mid found in response, using the first one.
    self.token_mid = \
      httpUtilities.valueFromBodyURI('mid') # '3'

    grinder.sleep(124)
    request102.GET('/Cars_Sample_App/images/enquire_but.gif')

    request103.GET('/Cars_Sample_App/images/line.gif')

    request104.GET('/Cars_Sample_App/images/manufacturers/Bmw.gif')

    request105.GET('/Cars_Sample_App/images/manufacturers/AstonMartin.gif')

    request106.GET('/Cars_Sample_App/images/manufacturers/Ferrari.gif')

    request107.GET('/Cars_Sample_App/images/insurance_but.gif')

    grinder.sleep(90)
    request108.GET('/Cars_Sample_App/images/manufacturers/Porsche.gif')

    request109.GET('/Cars_Sample_App/images/manufacturers/Jaguar.gif')

    request110.GET('/Cars_Sample_App/images/pipe.gif')

    request111.GET('/Cars_Sample_App/images/manufacturers/Lotus.gif')

    return result
Beispiel #4
0
  def __call__(self):
    """Called for every run performed by the worker thread."""
    self.page1()      # GET customerSearchForm.xhtml (request 101)
    self.page2()      # GET theme.css.xhtml (request 201)

    grinder.sleep(54)
    self.page3()      # GET scripts.js.xhtml (request 301)
    self.page4()      # GET primefaces.css.xhtml (request 401)
    self.page5()      # GET layout.css.xhtml (request 501)
    self.page6()      # GET primefaces-extensions.css.xhtml (request 601)
    self.page7()      # GET primefaces.js.xhtml (request 701)
    self.page8()      # GET jquery.js.xhtml (request 801)
    self.page9()      # GET jsf.js.xhtml (request 901)
    self.page10()     # GET primefaces-extensions.js.xhtml (request 1001)
    self.page11()     # GET layout.js.xhtml (requests 1101-1102)

    grinder.sleep(198)
    self.page12()     # GET dot_clear.gif.xhtml (request 1201)
    self.page13()     # GET ui-icons_333333_256x240.png.xhtml (request 1301)

    grinder.sleep(4709)
    self.page14()     # GET ui-icons_ffffff_256x240.png.xhtml (request 1401)

    grinder.sleep(9272)
    self.page15()     # POST customerSearchForm.xhtml (request 1501)

    grinder.sleep(1483)
    self.page16()     # POST customerSearchForm.xhtml (request 1601)
Beispiel #5
0
    def __call__(self):

        grinder.logger.info(
            'Checking grinder.agents to see if test needs to run')

        locationCount = len(helper.getLocationIds())
        if locationCount > 0:
            grinder.logger.info(
                "Found %d locations for key %s" %
                (locationCount, helper.getLocationPropertyKey()))
            maxAgents = grinder.properties.getInt('grinder.agents', 100)
            if maxAgents <= grinder.agentNumber:
                grinder.logger.info(
                    'Not running agent %d because the max number of agents was %d'
                    % (grinder.agentNumber, maxAgents))
                return

            grinder.logger.info('Running agent')

            pullTest()
            pushTest()

            grinder.sleep(
                Long.parseLong(grinder.properties.get('time.between.sync.ms')))

        else:
            grinder.logger.info('No location assigned to this agent: %s' %
                                helper.getLocationPropertyKey())
Beispiel #6
0
  def page17(self):
    """GET analysis (requests 1701-1704)."""
    self.token__ = \
      '1296067539166'
    self.token_scorable_component_id = \
      '295'
    result = request1701.GET('/outcomes/item/analysis' +
      '?_=' +
      self.token__ +
      '&assessment_id=' +
      self.token_assessment_id +
      '&scorable_component_id=' +
      self.token_scorable_component_id +
      '&classe_id=' +
      self.token_classe_id)

    grinder.sleep(15)
    request1702.GET('/outcomes/static/images/matrix/item_overlay/overlay_B_gr.png')

    grinder.sleep(46)
    request1703.GET('/outcomes/static/images/matrix/item_overlay/click_to_close.png')

    request1704.GET('/outcomes/static/images/matrix/item_overlay/overlay_A_red.png')

    return result
Beispiel #7
0
  def page1(self):
    """GET / (requests 101-107)."""
    
    # Expecting 302 'Found'
    result = request101.GET('/')

    grinder.sleep(16)
    
    # Expecting 302 'Moved Temporarily'
    request102.GET('/wgen/index.jsp')

    grinder.sleep(31)
    request103.GET('/wgen/Login.do')

    grinder.sleep(125)
    request104.GET('/wgen/amp/js/googleAnalytics.js')

    request105.GET('/wgen/amp/css/main.css')

    grinder.sleep(31)
    request106.GET('/wgen/amp/js/scripts.js')

    grinder.sleep(15)
    request107.GET('/wgen/amp/flash_detect/Dispatch.js')

    return result
Beispiel #8
0
  def page19(self):
    """GET standard (requests 1901-1902)."""
    self.token_standardSortField = \
      'id'
    self.token__ = \
      '1295903176536'
    result = request1901.GET('/outcomes/assessment/results/group/standard' +
      '?assessmentId=' +
      self.token_assessmentId +
      '&classeId=' +
      self.token_classeId +
      '&studentSortField=' +
      self.token_studentSortField +
      '&standardSortField=' +
      self.token_standardSortField +
      '&_=' +
      self.token__)

    grinder.sleep(111)
    self.token__ = \
      '1295903177043'
    request1902.GET('/outcomes/static/common/js/widgets/tooltip.js' +
      '?_=' +
      self.token__)

    return result
Beispiel #9
0
  def page18(self):
    """GET hex (requests 1801-1811)."""
    self.token_hex_id = \
      '1'
    result = request1801.GET('/outcomes/map/hex' +
      '?hex_id=' +
      self.token_hex_id)

    request1802.GET('/outcomes/static/images/learningMap/standard_overlay/frame_insufficient_data.png')

    request1803.GET('/outcomes/static/images/learningMap/standard_overlay/frame_insideTOP.png')

    request1804.GET('/outcomes/static/images/learningMap/standard_overlay/frame_insideLEFT.png')

    request1805.GET('/outcomes/static/images/learningMap/standard_overlay/frame_inside.png')

    request1806.GET('/outcomes/static/images/learningMap/standard_overlay/frame_insideRIGHT.png')

    request1807.GET('/outcomes/static/images/learningMap/standard_overlay/frame_insideBOTTOM.png')

    request1808.GET('/outcomes/static/images/learningMap/standard_overlay/expand_list.png')

    request1809.GET('/outcomes/static/images/learningMap/standard_overlay/pts_row_headers_clear_bg_box_ends.png')

    request1810.GET('/outcomes/static/images/learningMap/standard_overlay/icon_student_clear_for_filling.png')

    grinder.sleep(16)
    request1811.GET('/outcomes/static/images/learningMap/standard_overlay/item_number_row_bg.png')

    return result
Beispiel #10
0
  def page9(self):
    """GET standard (requests 901-902)."""
    self.token_studentSortField = \
      'last_name'
    self.token__ = \
      '1295903049193'
    result = request901.GET('/outcomes/assessment/results/group/standard' +
      '?assessmentId=' +
      self.token_assessmentId +
      '&classeId=' +
      self.token_classeId +
      '&studentSortField=' +
      self.token_studentSortField +
      '&standardSortField=' +
      self.token_standardSortField +
      '&_=' +
      self.token__)

    grinder.sleep(107)
    self.token__ = \
      '1295903049729'
    request902.GET('/outcomes/static/common/js/widgets/tooltip.js' +
      '?_=' +
      self.token__)

    return result
Beispiel #11
0
  def page22(self):
    """GET standard (requests 2201-2202)."""
    self.token_assessmentId = \
      '25'
    self.token__ = \
      '1295903198668'
    result = request2201.GET('/outcomes/assessment/results/group/standard' +
      '?assessmentId=' +
      self.token_assessmentId +
      '&classeId=' +
      self.token_classeId +
      '&studentSortField=' +
      self.token_studentSortField +
      '&standardSortField=' +
      self.token_standardSortField +
      '&_=' +
      self.token__)

    grinder.sleep(177)
    self.token__ = \
      '1295903199063'
    request2202.GET('/outcomes/static/common/js/widgets/tooltip.js' +
      '?_=' +
      self.token__)

    return result
Beispiel #12
0
  def page21(self):
    """GET alignedToNode (requests 2101-2103)."""
    self.token__ = \
      '1295890935857'
    self.token_nodeId = \
      '51848'
    result = request2101.GET('/oib/passage/manage/alignedToNode' +
      '?_=' +
      self.token__ +
      '&sort=' +
      self.token_sort +
      '&sortDir=' +
      self.token_sortDir +
      '&nodeId=' +
      self.token_nodeId +
      '&page=' +
      self.token_page +
      '&forSelect=' +
      self.token_forSelect +
      '&searchString=' +
      self.token_searchString +
      '&filterString=' +
      self.token_filterString)

    grinder.sleep(14132)
    request2102.GET('/oib/static/images/view_overlay/border.png')

    request2103.GET('/oib/static/images/view_overlay/close_X.png')

    return result
Beispiel #13
0
  def page22(self):
    """POST viewPassage (requests 2201-2207)."""
    result = request2201.POST('/oib/viewPassage',
      ( NVPair('id', '1342'),
        NVPair('version', '1'), ),
      ( NVPair('Content-Type', 'application/x-www-form-urlencoded; charset=UTF-8'), ))

    grinder.sleep(17)
    request2202.GET('/oib/static/images/tooltips/tooltip_win_arrow_top.png')

    request2203.GET('/oib/static/css/standards_create.css')

    request2204.GET('/oib/static/css/widgets/shopping_cart.css')

    self.token__ = \
      '1295890950579'
    request2205.GET('/oib/static/js/widgets/sharing.js' +
      '?_=' +
      self.token__)

    grinder.sleep(24)
    self.token__ = \
      '1295890950607'
    request2206.GET('/oib/static/js/widgets/SharingDropdown.js' +
      '?_=' +
      self.token__)

    self.token__ = \
      '1295890950624'
    request2207.GET('/oib/static/common/js/3p/jqueryMultiSelect.js' +
      '?_=' +
      self.token__)

    return result
Beispiel #14
0
  def page10(self):
    """GET results (requests 1001-1004)."""
    self.token_itemSortField = \
      'performance'
    self.token__ = \
      '1295903065533'
    result = request1001.GET('/outcomes/assessment/results' +
      '?assessmentId=' +
      self.token_assessmentId +
      '&classeId=' +
      self.token_classeId +
      '&studentSortField=' +
      self.token_studentSortField +
      '&itemSortField=' +
      self.token_itemSortField +
      '&_=' +
      self.token__)

    grinder.sleep(122)
    request1002.GET('/outcomes/static/images/matrix/exclamation_point_cell_darks.png')

    grinder.sleep(14)
    request1003.GET('/outcomes/static/images/matrix/dash_cell.png')

    self.token__ = \
      '1295903065986'
    request1004.GET('/outcomes/static/common/js/widgets/tooltip.js' +
      '?_=' +
      self.token__)

    return result
Beispiel #15
0
  def page20(self):
    """GET alignedToSubtree (requests 2001-2003)."""
    self.token__ = \
      '1295891998691'
    result = request2001.GET('/oib/rubric/manage/alignedToSubtree' +
      '?_=' +
      self.token__ +
      '&sort=' +
      self.token_sort +
      '&sortDir=' +
      self.token_sortDir +
      '&nodeId=' +
      self.token_nodeId +
      '&forSelect=' +
      self.token_forSelect +
      '&searchString=' +
      self.token_searchString +
      '&filterString=' +
      self.token_filterString)

    grinder.sleep(15312)
    request2002.GET('/oib/static/images/view_overlay/border.png')

    request2003.GET('/oib/static/images/view_overlay/close_X.png')

    return result
Beispiel #16
0
    def __call__(self):
        # Declare the global variables that we update.
        global checkpointReachedForRun, waiting

        # Locking ensures only a single thread can be active (not
        # waiting) in the section between the acquire() and the
        # release().
        c.acquire()
        waiting += 1

        if waiting == numberOfThreads:
            # We're the last thread, wake everyone up.
            checkpointReachedForRun = grinder.runNumber
            waiting = 0
            c.notifyAll()
        else:
            while grinder.runNumber > checkpointReachedForRun:
                c.wait()

        c.release()

        grinder.logger.output("Hello World")

        # Sleep for a random amount of time around 10 seconds.
        grinder.sleep(10000)
Beispiel #17
0
    def run_test_set(self, test_set):
        """Overridden from WebtestRunner base class, to record the
        response for each request.
        """
        for filename in test_set.filenames:
            log("========== Executing: %s ==========" % filename)
            # Add an empty list to the responses dict, if it doesn't exist
            if filename not in self.webtest_responses:
                self.webtest_responses[filename] = []

            # Execute all requests in this test set, in order
            for test, wrapper, request in WebtestRunner.webtest_requests[filename]:
                # Try to correlate this request with previous responses
                # in the current webtest file
                self.correlate(filename, request)

                # Execute this request
                try:
                    response = self.execute(test, wrapper, request)
                # If problems occurred, report an error and re-raise
                except RuntimeError:
                    grinder.statistics.forLastTest.success = False
                    raise
                # Otherwise, store the test number and response body
                else:
                    body = response.getText()
                    self.webtest_responses[filename].append((test.getNumber(), body))

                # If response was not valid, report an error
                if response.getStatusCode() >= 400:
                    grinder.statistics.forLastTest.success = False

                # Sleep
                grinder.sleep(WebtestRunner.think_time)
    def __call__(self):
        log = grinder.logger.info

        trader = homeTest.create()

        tradeTest = tests["trade"].wrap(trader)

        stocksToSell = {"BEAS": 100, "MSFT": 999}
        for stock, amount in stocksToSell.items():
            tradeResult = tradeTest.sell("John", stock, amount)
            log("Result of tradeTest.sell(): %s" % tradeResult)

        grinder.sleep(100)  # Idle a while

        stocksToBuy = {"BEAS": abs(random.nextInt()) % 1000}
        for stock, amount in stocksToBuy.items():
            tradeResult = tradeTest.buy("Phil", stock, amount)
            log("Result of tradeTest.buy(): %s" % tradeResult)

        queryTest = tests["query"].wrap(trader)
        balance = queryTest.getBalance()
        log("Balance is $%.2f" % balance)

        trader.remove()  # We don't record the remove() as a test

        # Can obtain information about the thread context...
        if grinder.threadNumber == 0 and grinder.runNumber == 0:
            # ...and navigate from the proxy back to the test
            d = queryTest.__test__
            log("Query test is test %d, (%s)" % (d.number, d.description))
Beispiel #19
0
    def sendData(self, **args):
        response = ''
        delay = 0
        # case : we have a template
        if isinstance(args['data'], str):
            response = args['data']
            config = self.setProperties(args['data'])
            delay = config.get('response0.delay_ms') or None
        # case : we don't have a template, so we have a dictionary
        else:
            response = str(args['data'])

        liResp = {
            'httpStatCode': '200',
            'responseText': response,
            'message': response,
            'errorCode': 200
        }

        # Ok, we add also the context for testing
        liResp.update(args['context'])

        logger.debug('response: %s' % (liResp))

        if self.sleep:
            grinder.sleep(random.randint(self.min_random, self.max_random))

        return liResp
Beispiel #20
0
    def __call__(self):
        log = grinder.logger.info

        trader = homeTest.create()

        tradeTest = tests["trade"].wrap(trader)

        stocksToSell = {"BEAS": 100, "MSFT": 999}
        for stock, amount in stocksToSell.items():
            tradeResult = tradeTest.sell("John", stock, amount)
            log("Result of tradeTest.sell(): %s" % tradeResult)

        grinder.sleep(100)  # Idle a while

        stocksToBuy = {"BEAS": abs(random.nextInt()) % 1000}
        for stock, amount in stocksToBuy.items():
            tradeResult = tradeTest.buy("Phil", stock, amount)
            log("Result of tradeTest.buy(): %s" % tradeResult)

        queryTest = tests["query"].wrap(trader)
        balance = queryTest.getBalance()
        log("Balance is $%.2f" % balance)

        trader.remove()  # We don't record the remove() as a test

        # Can obtain information about the thread context...
        if grinder.threadNumber == 0 and grinder.runNumber == 0:
            # ...and navigate from the proxy back to the test
            d = queryTest.__test__
            log("Query test is test %d, (%s)" % (d.number, d.description))
    def page3(self):
        """POST QuoteWindow (requests 301-304)."""
        self.token_action = \
          '1'

        # Expecting 302 'Moved Temporarily'
        result = request301.POST(
            '/portal/portal/default/MotorPlus/QuoteWindow' + '?action=' +
            self.token_action, (
                NVPair('title', 'Mr.'),
                NVPair('firstname', 'Richard'),
                NVPair('surname', 'Anderson'),
                NVPair('address1', 'Little Owls'),
                NVPair('address2', 'Huntington Road'),
                NVPair('town', 'Crowborough'),
                NVPair('county', 'East Sussex'),
                NVPair('postcode', 'TN6 2LJ'),
                NVPair('phone', '07711 611522'),
                NVPair('email', '*****@*****.**'),
                NVPair('op=Next:immediate=false', 'Next'),
            ), (NVPair('Content-Type', 'application/x-www-form-urlencoded'), ))
        self.token_action = \
          httpUtilities.valueFromLocationURI('action') # '2'

        grinder.sleep(17)
        request302.GET('/portal/portal/default/MotorPlus/QuoteWindow' +
                       '?action=' + self.token_action)

        return result
Beispiel #22
0
    def __call__(self):
        """This method is called for every run performed by the worker thread."""

        self.initSession()
        self.auth()
        self.bind()
        self.requestSession()
        self.getRoster()

        message = "Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Duis rutrum porttitor ante. Nunc arcu leo."
        show = "chat"

        #for i in range(2):
        while (True):
            if show == "dnd":
                show = "chat"
            else:
                show = "dnd"
            self.changePresence(show)
            if grinder.statistics.forLastTest.time < 5000:
                grinder.sleep(5000 - grinder.statistics.forLastTest.time)
            for j in range(5):
                self.sendMessage(message, self.targetUser)
                if grinder.statistics.forLastTest.time < 5000:
                    grinder.sleep(5000 - grinder.statistics.forLastTest.time)

        self.terminate()
Beispiel #23
0
  def page8(self):
    """GET getFiltered (requests 801-803)."""
    self.token__ = \
      '1295893897288'
    self.token_filterId = \
      'pool5'
    self.token_forSelect = \
      'true'
    result = request801.GET('/oib/assessment/manage/getFiltered' +
      '?_=' +
      self.token__ +
      '&subject=' +
      self.token_subject +
      '&sort=' +
      self.token_sort +
      '&sortDir=' +
      self.token_sortDir +
      '&filterId=' +
      self.token_filterId +
      '&page=' +
      self.token_page +
      '&forSelect=' +
      self.token_forSelect)

    grinder.sleep(6478)
    request802.GET('/oib/static/images/view_overlay/border.png')

    request803.GET('/oib/static/images/view_overlay/close_X.png')

    return result
Beispiel #24
0
  def page17(self):
    """POST viewItem (requests 1701-1704)."""
    result = request1701.POST('/oib/viewItem',
      ( NVPair('id', '1346'),
        NVPair('version', '1'), ),
      ( NVPair('Content-Type', 'application/x-www-form-urlencoded; charset=UTF-8'), ))

    grinder.sleep(27)
    self.token__ = \
      '1295903684110'
    request1702.GET('/oib/static/js/widgets/sharing.js' +
      '?_=' +
      self.token__)

    grinder.sleep(53)
    self.token__ = \
      '1295903684165'
    request1703.GET('/oib/static/js/widgets/SharingDropdown.js' +
      '?_=' +
      self.token__)

    self.token__ = \
      '1295903684173'
    request1704.GET('/oib/static/common/js/3p/jqueryMultiSelect.js' +
      '?_=' +
      self.token__)

    return result
Beispiel #25
0
  def page1(self):
    """GET index.php (requests 101-102)."""
    result = request101.GET('/~spark2007/dday/index.php')

    grinder.sleep(5114)
    request102.GET('/~spark2007/dday/ajax1.js')

    return result
Beispiel #26
0
  def page14(self):
    """GET ui-bg_gloss-wave_35_f6a828_500x100.png (requests 1401-1402)."""
    result = request1401.GET('/~spark2007/css/ui-lightness/images/ui-bg_gloss-wave_35_f6a828_500x100.png')

    grinder.sleep(5026)
    request1402.GET('/~spark2007/css/ui-lightness/images/ui-bg_highlight-soft_75_ffe45c_1x100.png')

    return result
Beispiel #27
0
  def page6(self):
    """GET clock.js (requests 601-602)."""
    result = request601.GET('/~spark2007/js/clock.js')

    grinder.sleep(84)
    request602.GET('/~spark2007/images/header.jpg')

    return result
Beispiel #28
0
  def page1(self):
    """GET login (requests 101-102)."""
    result = request101.GET('/oib/login')

    grinder.sleep(22)
    request102.GET('/oib/static/images/three2twelve.png')

    return result
Beispiel #29
0
  def page7(self):
    """GET cutScores (requests 701-702)."""
    result = request701.GET('/outcomes/trusted/cutScores')

    grinder.sleep(203)
    request702.GET('/outcomes/static/js/matrix/ManageCutScores.js')

    return result
Beispiel #30
0
  def page5(self):
    """GET ellipsis.xml (requests 501-502)."""
    result = request501.GET('/oib/static/common/css/ellipsis.xml')

    grinder.sleep(32)
    request502.GET('/oib/static/images/manage/locate_rounded_corner_objects.png')

    return result
Beispiel #31
0
    def __call__(self):
        # Per thread scripting goes here.
        log("push events")
        grinder.sleep(1000)
        for i in range(0, 1000):
            instrumentedConsumer.push_structured_event(createEvent(1))
            grinder.sleep(250)

        log("done")
Beispiel #32
0
    def __call__(self):
        """Called for every run performed by the worker thread."""
        self.page1()  # GET / (requests 101-102)

        grinder.sleep(1530)
        self.page2()  # POST / (request 201)

        grinder.sleep(3534)
        self.page3()  # POST / (requests 301-302)
Beispiel #33
0
    def __call__(self):
        # Per thread scripting goes here.
        log("push events")
        grinder.sleep(1000)
        for i in range (0, 1000):
            instrumentedConsumer.push_structured_event(createEvent(1))
	    grinder.sleep(250)

        log("done")
Beispiel #34
0
  def page5(self):
    """GET ellipsis.xml (requests 501-503)."""
    result = request501.GET('/oib/static/common/css/ellipsis.xml')

    grinder.sleep(172)
    request502.GET('/oib/static/images/view_overlay/sprites.png')

    request503.GET('/oib/static/images/manage/assessment_item_count_box.png')

    return result
    def __call__(self):
        t1Ms = time.time() * 1000 

        doTest = Test(1, "Send  message").wrap(self._doTest)
        doTest()

        if sleepTime > 0:
            # Adjust sleep time based on test time
            adjustedSleeptime = sleepTime - ((time.time() * 1000) - t1Ms)
            grinder.sleep(long(adjustedSleeptime))
Beispiel #36
0
  def page53(self):
    """GET logout (requests 5301-5302)."""
    result = request5301.GET('/oa/logout' +
      '?status=' +
      self.token_status)

    grinder.sleep(68)
    request5302.GET('/oa/static/css/account_logout.css')

    return result
Beispiel #37
0
  def page5(self):
    """GET ellipsis.xml (requests 501-503)."""
    result = request501.GET('/oib/static/common/css/ellipsis.xml')

    grinder.sleep(43)
    request502.GET('/oib/static/images/manage/locate_rounded_corner_objects.png')

    grinder.sleep(19)
    request503.GET('/oib/static/images/manage/assessment_item_count_box.png')

    return result
Beispiel #38
0
    def run_test_set(self, test_set):
        """Run all ``.webtest`` files in the given `TestSet`.
        """
        for filename in test_set.filenames:
            if WebtestRunner.verbosity != 'error':
                log("==== Executing: %s ==========" % filename)

            self._run_webtest_file(filename)

        # Sleep between scenarios
        grinder.sleep(WebtestRunner.scenario_think_time)
Beispiel #39
0
  def page1(self):
    """GET index.new.php (requests 101-103)."""
    result = request101.GET('/~spark2007/index.new.php')

    grinder.sleep(5205)
    request102.GET('/~spark2007/css/css.css')

    grinder.sleep(10116)
    request103.GET('/~spark2007/css/ui-lightness/jquery-ui-1.7.2.custom.css')

    return result
Beispiel #40
0
    def run_test_set(self, test_set):
        """Run all ``.webtest`` files in the given `TestSet`.
        """
        for filename in test_set.filenames:
            if WebtestRunner.verbosity != 'error':
                log("==== Executing: %s ==========" % filename)

            self._run_webtest_file(filename)

        # Sleep between scenarios
        grinder.sleep(WebtestRunner.scenario_think_time)
Beispiel #41
0
  def page16(self):
    """GET about.do (requests 1601-1602)."""
    result = request1601.GET('/Cars_Sample_App/about.do', None,
      ( NVPair('Accept', 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8'),
        NVPair('Referer', 'http://supercars-tomcat:8080/Cars_Sample_App/insurance.do'), ))

    grinder.sleep(118)
    request1602.GET('/Cars_Sample_App/images/about_car.gif', None,
      ( NVPair('Accept', '*/*'),
        NVPair('Referer', 'http://supercars-tomcat:8080/Cars_Sample_App/about.do'), ))

    return result
Beispiel #42
0
    def __call__(self):
        grinder.sleep(5000*self.thread, 0)
        grinder.logger.output('Thread %d starting requests' % self.thread)

        # Each thread randomly selects a sample requests
        reqs = list(self.requests)
        grinder.logger.output('Sampling %d requests from %d' % (req_sample_size, len(reqs)))
        requests = random.sample(reqs, req_sample_size)
        
        for req in requests:
            grinder.logger.output('Requesting %s' % req)
            data = call_request(req)
            grinder.logger.output('Data returned of shape %s' % data.shape)
Beispiel #43
0
def evalss():
    wait = 250
    input = 'from+sage.all+import+*;factor(ZZ.random_element(10**40))'
    result = request.GET('/execute?input=%s' % input)
    id = result.text
    count = 0
    while True:
        grinder.sleep(wait)
        result = request.GET('/get?id=%s' % id)
        count += 1
        if result.text.find('wait') == -1:
            break
    ans = eval(result.text)
    print('test waited%s ans = %s' % (count, ans['output']))
Beispiel #44
0
  def page18(self):
    """GET cars.do (requests 1801-1802)."""
    result = request1801.GET('/Cars_Sample_App/cars.do' +
      '?query=' +
      self.token_query +
      '&mid=' +
      self.token_mid)
    self.token_query = \
      httpUtilities.valueFromBodyURI('query') # 'car'
    # 4 different values for token_cid found in response; the first matched
    # the last known value of token_cid - don't update the variable.

    grinder.sleep(98)
    request1802.GET('/Cars_Sample_App/images/cars/1.jpg')

    return result
Beispiel #45
0
 def get_delivery_time(self):
     # Wait until we have received a message.
     timeOut = System.currentTimeMillis() + 5000
     self.lock.acquire()
     while not self.messageQueue and System.currentTimeMillis() < timeOut:
         self.lock.release()
         grinder.sleep(100)
         self.lock.acquire()
     try:
         if self.messageQueue:
             # Pop delivery time from first message in message queue
             return self.messageQueue.pop(0)
         else:
             raise Exception, 'Timeout'
     finally:
         self.lock.release()
    def page4(self):
        """POST QuoteWindow (requests 401-404)."""
        self.token_action = \
          '1'

        # Expecting 302 'Moved Temporarily'
        result = request401.POST(
            '/portal/portal/default/MotorPlus/QuoteWindow' + '?action=' +
            self.token_action, (
                NVPair(
                    '/asset[assetTypeId=#VehicleAsset#][0]attribute[id=#make#]',
                    'AC'),
                NVPair(
                    '/asset[assetTypeId=#VehicleAsset#][0]attribute[id=#model#]',
                    'ACE'),
                NVPair(
                    '/asset[assetTypeId=#VehicleAsset#][0]attribute[id=#cc#]',
                    '2000'),
                NVPair(
                    '/asset[assetTypeId=#VehicleAsset#][0]attribute[id=#bodytype#]',
                    'Salon'),
                NVPair(
                    '/asset[assetTypeId=#VehicleAsset#][0]attribute[id=#year#]',
                    '2001'),
                NVPair(
                    '/asset[assetTypeId=#VehicleAsset#][0]attribute[id=#registration#]',
                    'LGO 920Y'),
                NVPair(
                    '/asset[assetTypeId=#VehicleAsset#][0]attribute[id=#datebought#]',
                    '01/12/2002'),
                NVPair(
                    '/asset[assetTypeId=#VehicleAsset#][0]attribute[id=#cost#]',
                    '5000'),
                NVPair(
                    '/asset[assetTypeId=#VehicleAsset#][0]attribute[id=#value#]',
                    '5000'),
                NVPair('op=Next:immediate=false', 'Next'),
            ), (NVPair('Content-Type', 'application/x-www-form-urlencoded'), ))
        self.token_action = \
          httpUtilities.valueFromLocationURI('action') # '2'

        grinder.sleep(21)
        request402.GET('/portal/portal/default/MotorPlus/QuoteWindow' +
                       '?action=' + self.token_action)

        return result
    def page5(self):
        """POST QuoteWindow (requests 501-504)."""
        self.token_action = \
          '1'

        # Expecting 302 'Moved Temporarily'
        result = request501.POST(
            '/portal/portal/default/MotorPlus/QuoteWindow' + '?action=' +
            self.token_action, (
                NVPair(
                    '/asset[assetTypeId=#VehicleAsset#][0]attribute[id=#lefthanddrive#]',
                    'No'),
                NVPair(
                    '/asset[assetTypeId=#VehicleAsset#][0]attribute[id=#registeredinproposersname#]',
                    'Yes'),
                NVPair(
                    '/asset[assetTypeId=#VehicleAsset#][0]attribute[id=#ownedbyproposer#]',
                    'Yes'),
                NVPair(
                    '/asset[assetTypeId=#VehicleAsset#][0]attribute[id=#driventoandfromwork#]',
                    'Yes'),
                NVPair(
                    '/asset[assetTypeId=#VehicleAsset#][0]attribute[id=#modified#]',
                    'No'),
                NVPair(
                    '/asset[assetTypeId=#VehicleAsset#][0]attribute[id=#securitydevice#]',
                    'Yes'),
                NVPair(
                    '/asset[assetTypeId=#VehicleAsset#][0]attribute[id=#keptatproposersaddress#]',
                    'Yes'),
                NVPair(
                    '/asset[assetTypeId=#VehicleAsset#][0]attribute[id=#storedingarage#]',
                    'Yes'),
                NVPair(
                    '/asset[assetTypeId=#VehicleAsset#][0]attribute[id=#garageofsolidconstruction#]',
                    'Yes'),
                NVPair('op=Next:immediate=false', 'Next'),
            ), (NVPair('Content-Type', 'application/x-www-form-urlencoded'), ))
        self.token_action = \
          httpUtilities.valueFromLocationURI('action') # '2'

        grinder.sleep(19)
        request502.GET('/portal/portal/default/MotorPlus/QuoteWindow' +
                       '?action=' + self.token_action)

        return result
Beispiel #48
0
    def page1(self):
        """GET contacts (requests 101-103)."""

        # Expecting 302 'Moved Temporarily'
        result = request101.GET('/contacts')

        request102.GET('/contacts/')
        self.token_operation = \
          httpUtilities.valueFromBodyURI('operation') # 'browse'

        grinder.sleep(19)
        request103.GET('/contacts/css/styles.css', None, (
            NVPair('Accept', 'text/css,*/*;q=0.1'),
            NVPair('Referer', 'http://host01.example.com:7011/contacts/'),
        ))

        return result
Beispiel #49
0
    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))
Beispiel #50
0
  def page2(self):
    """GET cars.do (requests 201-202)."""
    result = request201.GET('/Cars_Sample_App/cars.do' +
      '?query=' +
      self.token_query +
      '&mid=' +
      self.token_mid)
    self.token_query = \
      httpUtilities.valueFromBodyURI('query') # 'car'
    # 4 different values for token_cid found in response, using the first one.
    self.token_cid = \
      httpUtilities.valueFromBodyURI('cid') # '2'

    grinder.sleep(103)
    request202.GET('/Cars_Sample_App/images/cars/1.jpg')

    return result
Beispiel #51
0
    def page1(self):
        """GET / (requests 101-103)."""
        result = request101.GET('/pub/')
        # 3 different values for token_sort found in response, using the first one.
        self.token_sort = \
          httpUtilities.valueFromBodyURI('sort') # 'rating'
        # 2 different values for token_typ found in response, using the first one.
        self.token_typ = \
          httpUtilities.valueFromBodyURI('typ') # 'active'
        self.token_reverse = \
          httpUtilities.valueFromBodyURI('reverse') # 'True'

        grinder.sleep(218)
        request102.GET('/css/main.css')

        request103.GET('/javascript/dynamic/localization.js')

        return result
Beispiel #52
0
  def page4(self):
    """GET enquire.do (requests 401-402)."""
    self.token_carName = \
      'SDB9'
    result = request401.GET('/Cars_Sample_App/enquire.do' +
      '?car=' +
      self.token_car +
      '&carName=' +
      self.token_carName)
    self.token_carId = \
      httpUtilities.valueFromHiddenInput('carId') # '2'

    grinder.sleep(107)
    request402.GET('/Cars_Sample_App/images/submit_button.gif', None,
      ( NVPair('Accept', '*/*'),
        NVPair('Referer', 'http://supercars-tomcat:8080/Cars_Sample_App/enquire.do?car=2&carName=S%A0DB9'), ))

    return result
    def page2(self):
        """POST QuoteWindow (requests 201-204)."""
        self.token_action = \
          '1'

        # Expecting 302 'Moved Temporarily'
        result = request201.POST(
            '/portal/portal/default/MotorPlus/QuoteWindow' + '?action=' +
            self.token_action,
            (NVPair('op=Get A Quote:immediate=false', 'Get A Quote'), ),
            (NVPair('Content-Type', 'application/x-www-form-urlencoded'), ))
        self.token_action = \
          httpUtilities.valueFromLocationURI('action') # '2'

        grinder.sleep(88)
        request202.GET('/portal/portal/default/MotorPlus/QuoteWindow' +
                       '?action=' + self.token_action)

        return result
Beispiel #54
0
    def __call__(self):
        log = grinder.logger.info

        log("Creating queue session")
        session = connection.createQueueSession(0, Session.AUTO_ACKNOWLEDGE)

        sender = session.createSender(queue)
        instrumentedSender = Test(1, "Send a message").wrap(sender)

        message = createBytesMessage(session, 100)

        log("Sending ten messages")

        for i in range(0, 10):
            instrumentedSender.send(message)
            grinder.sleep(100)

        log("Closing queue session")
        session.close()
    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))
Beispiel #56
0
    def _run_webtest_file(self, filename):
        """Execute all requests in the given .webtest filename.
        May raise a `CaptureFailed` or `BadRequestMethod` if errors occur.
        """
        # Execute all requests in this test set, in order
        for test, wrapper, request in WebtestRunner.webtest_requests[filename]:
            # Execute this request
            try:
                response = self.execute(test, wrapper, request)

            # If problems occurred, report an error
            except (CaptureFailed, BadRequestMethod):
                grinder.statistics.forLastTest.success = False
                raise

            # If response was not valid, report an error
            if response.getStatusCode() >= 400:
                grinder.statistics.forLastTest.success = False

            # Sleep between requests
            grinder.sleep(WebtestRunner.think_time)
Beispiel #57
0
 def __call__(self):
     request.GET('/', [], [])
     grinder.sleep(1000)
     request.POST('/reserve.php', [], [])
     grinder.sleep(5000)
     request.POST('/payment.php', [], [NVPair('Content-Type', 'application/json')])
     grinder.sleep(1000)
Beispiel #58
0
    def __call__(self):
        log = grinder.logger.info

        trader = home.create()
        tests["trade"].record(trader.sell)
        tests["trade"].record(trader.buy)
        tests["query"].record(trader.getBalance)

        stocksToSell = {"BEAS": 100, "MSFT": 999}
        for stock, amount in stocksToSell.items():
            tradeResult = trader.sell("John", stock, amount)
            log("Result of trader.sell(): %s" % tradeResult)

        grinder.sleep(100)  # Idle a while

        stocksToBuy = {"BEAS": abs(random.nextInt()) % 1000}
        for stock, amount in stocksToBuy.items():
            tradeResult = trader.buy("Phil", stock, amount)
            log("Result of trader.buy(): %s" % tradeResult)

        balance = trader.getBalance()
        log("Balance is $%.2f" % balance)

        trader.remove()  # We don't record the remove() as a test
Beispiel #59
0
  def page11(self):
    """POST search.do (requests 1101-1102)."""
    self.token_query = \
      'search'
    result = request1101.POST('/Cars_Sample_App/search.do' +
      '?query=' +
      self.token_query,
      ( NVPair('criteria', 'Aston'),
        NVPair('x', '46'),
        NVPair('y', '19'), ),
      ( NVPair('Accept', 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8'),
        NVPair('Content-Type', 'application/x-www-form-urlencoded'),
        NVPair('Referer', 'http://supercars-tomcat:8080/Cars_Sample_App/search.do'), ))
    self.token_query = \
      httpUtilities.valueFromBodyURI('query') # 'car'
    # 3 different values for token_cid found in response; the first matched
    # the last known value of token_cid - don't update the variable.

    grinder.sleep(95)
    request1102.GET('/Cars_Sample_App/images/cars/1.jpg', None,
      ( NVPair('Accept', '*/*'),
        NVPair('Referer', 'http://supercars-tomcat:8080/Cars_Sample_App/search.do?query=search'), ))

    return result