コード例 #1
0
#connection options
domain = 	 	 	 	'http://test.constellation.tv'
screening = 	 	 'Wx5rFpEf4S5KLks'
time_to_run = 	 60
films =  	 	[ 87 ]
film = 	 	 	str(random.choice( films ))

# Set up a cookie handler to log all cookies that are sent and received.
class MyCookiePolicyHandler(CookiePolicyHandler):
	def acceptCookie(self, cookie, request, response):
		return 1
 
	def sendCookie(self, cookie, request):
		return 1
 
CookieModule.setCookiePolicyHandler(MyCookiePolicyHandler())


class TestRunner:

	#decide whether this is a reader or writing thread
	def __init__(self):
		
		tid = grinder.threadNumber
		
		#self.testRunnter = self.writer
			 	
		if tid % 4 == 2:
			self.testRunnter = self.reader
		else:
			self.testRunnter = self.writer
コード例 #2
0
# The URL of the server we want to hit.
url0 = 'http://127.0.0.1:5000'

# *sob* - failed to get json packages working.  Using 're' is an option,
# although it requires you install jython2.5 (which still doesn't have
# json builtin) - so to avoid all that complication, hack 'eval' into
# working for us...
_json_ns = {'null': None}


def json_loads(val):
    return eval(val, _json_ns)


CookieModule.setCookiePolicyHandler(None)
from net.grinder.plugin.http import HTTPPluginControl
HTTPPluginControl.getConnectionDefaults().followRedirects = 1

# To use a proxy server, uncomment the next line and set the host and port.
# connectionDefaults.setProxyServer("localhost", 8001)

# These definitions at the top level of the file are evaluated once,
# when the worker process is started.
connectionDefaults.defaultHeaders = \
  [ NVPair('Accept-Language', 'en-us,en;q=0.5'),
    NVPair('Accept-Charset', 'ISO-8859-1,utf-8;q=0.7,*;q=0.7'),
    NVPair('Accept-Encoding', 'gzip, deflate'),
    NVPair('User-Agent', 'Mozilla/5.0 (Windows NT 6.0; WOW64; rv:2.0b6) Gecko/20100101 Firefox/4.0b6'), ]

request1 = HTTPRequest()
コード例 #3
0
ファイル: authentication_util.py プロジェクト: yzhu1/wgspring
def enableCookieLogging():
    CookieModule.setCookiePolicyHandler(MyCookiePolicyHandler())
コード例 #4
0
ファイル: send.py プロジェクト: SriramBms/f1
# Static URL we want to hit
linkdrop_static_url = grinder.getProperties().getProperty("linkdrop.static_url", '/share/')

# How often we want to hit the static page per send
linkdrop_static_per_send = grinder.getProperties().getInt("linkdrop.static_per_send", 0)

# *sob* - failed to get json packages working.  Using 're' is an option,
# although it requires you install jython2.5 (which still doesn't have
# json builtin) - so to avoid all that complication, hack 'eval' into
# working for us...
_json_ns = {'null': None}
def json_loads(val):
    return eval(val, _json_ns)

CookieModule.setCookiePolicyHandler(None)
from net.grinder.plugin.http import HTTPPluginControl
HTTPPluginControl.getConnectionDefaults().followRedirects = 1

# To use a proxy server, uncomment the next line and set the host and port.
# connectionDefaults.setProxyServer("localhost", 8001)

# These definitions at the top level of the file are evaluated once,
# when the worker process is started.
connectionDefaults.defaultHeaders = \
  [ NVPair('Accept-Language', 'en-us,en;q=0.5'),
    NVPair('Accept-Charset', 'ISO-8859-1,utf-8;q=0.7,*;q=0.7'),
    NVPair('Accept-Encoding', 'gzip, deflate'),
    NVPair('User-Agent', 'Mozilla/5.0 (Windows NT 6.0; WOW64; rv:2.0b6) Gecko/20100101 Firefox/4.0b6'), ]

request1 = HTTPRequest()
コード例 #5
0
ファイル: login.py プロジェクト: 0cara0/ngrinder3.4.3_mysql
# _*_ coding: utf8 _*_
from HTTPClient import NVPair, Cookie, CookieModule, CookiePolicyHandler
from net.grinder.plugin.http import HTTPPluginControl, HTTPRequest
from net.grinder.script import Test
from net.grinder.script.Grinder import grinder
from java.util import Date
# Set up a cookie handler to log all cookies that are sent and received. 
class MyCookiePolicyHandler(CookiePolicyHandler): 
    def acceptCookie(self, cookie, request, response): 
        return 1

    def sendCookie(self, cookie, request): 
        return 1

CookieModule.setCookiePolicyHandler(MyCookiePolicyHandler()) 

test1 = Test(1, "checkout home")
request1 = test1.wrap(HTTPRequest(url="http://my.site.com"))
class TestRunner:
    def __init__(self):
        # Login URL
        request = HTTPRequest(url="https://login.site.com")
        ##### reset to the all cookies #####
        threadContext = HTTPPluginControl.getThreadHTTPClientContext() 
        self.cookies = CookieModule.listAllCookies(threadContext) 
        for c in self.cookies: CookieModule.removeCookie(c, threadContext)

        # do login
        request.POST("/login/do", ( NVPair("id", "my_id"),NVPair("pw", "my_passwd")));
        ##### save to the login info in cookies #####
        self.cookies = CookieModule.listAllCookies(threadContext)