本文整理汇总了Python中net.grinder.script.Test类的典型用法代码示例。如果您正苦于以下问题:Python Test类的具体用法?Python Test怎么用?Python Test使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Test类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __call__
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))
示例2: __call__
def __call__(self):
try:
test = Test(TestID.PTG_ASYNC, "StoRM ptg-async without release or file transfer")
test.record(do_prepare_to_get)
do_prepare_to_get(self.SRMclient)
except Exception:
error("Error executing ptg-async: %s" % traceback.format_exc())
示例3: __init__
def __init__(self, partition):
grinder.logger.output('Selected dataset %s' % dataset_url)
self.test = Test(Instrumented.next_test,
'Partition into %d slices' % partition)
self.test_tot = Test(100 + Instrumented.next_test,
'Total for %d slices' % partition)
Instrumented.next_test += 1
self.requests = generate_subset_requests(variable, {'time': partition})
# Create a fresh callable to instrument
def f(req):
return req()
self.test.record(f)
self.f = f
def f2():
for req in self.requests:
grinder.logger.output('Requesting %s' % req)
data = self.f(req)
grinder.logger.output('Data returned of shape %s' % data.shape)
self.test_tot.record(f2)
self.f2 = f2
示例4: __call__
def __call__(self):
test = Test(1, "StoRM srmLs")
client = SRMClientFactory.newSRMClient(SRM_ENDPOINT, PROXY_FILE)
surl_range = range(1, random.randrange(NUM_FILES))
surls = []
for i in surl_range:
surls.append(SURL_PREFIX + "/f" + str(i))
test.record(client)
log("Listing %d surls..." % surl_range[-1])
res = client.srmLs(surls,
MAX_WAITING_TIME_IN_MSEC)
log("List result: %s: %s" % (res.returnStatus.statusCode,
res.returnStatus.explanation))
statuses = res.getDetails().getPathDetailArray()
for s in statuses:
log("%s -> %s" %(s.getPath(),
s.getStatus().getStatusCode()))
示例5: __call__
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
# Creates a Test Suite.
suite = TestSuite(VoCardRequestServiceTest().getClass());
suite.addTestSuite(ElectoralRollRegistrationRequestServiceTest().getClass());
suite.addTestSuite(RequestServiceTest().getClass());
suite.addTestSuite(DocumentServiceTest().getClass());
suite.addTestSuite(FakeExternalServiceTest().getClass());
suite.addTestSuite(LocalReferentialServiceTest().getClass());
suite.addTestSuite(CategoryServiceTest().getClass());
#suite.addTestSuite(HomeFolderModificationRequestServiceTest().getClass());
# Returns the tests as an enumeration.
tests = suite.tests();
# Iterate over the tests.
testNumber = 0
for test in tests:
testNumber += 1
testCase = Test(testNumber, test.getName()).wrap(suite)
testResult = TestResult()
testCase.runTest(test, testResult)
if testResult.errorCount() > 0:
grinder.statistics.success = 0
elif testResult.failureCount() > 0:
grinder.statistics.success = 0
示例6: __call__
def __call__(self):
test = Test(TestID.ATLAS_RENAMING, "Atlas renaming")
test.record(atlas_renaming)
debug("WEBDAV_ENDPOINT: %s" % WEBDAV_ENDPOINT)
atlas_renaming(HTTP_CLIENT)
示例7: __call__
def __call__(self):
try:
test = Test(TestID.MIX_DAV, "StoRM Mix WebDAV test")
test.record(mix_dav)
mix_dav(self.HTTP_Client, self.local_file_path)
except Exception, e:
error("Error executing mix-dav: %s" % traceback.format_exc())
示例8: __call__
def __call__(self):
try:
test = Test(TestID.TXFER_OUT, "StoRM file-transfer OUT")
test.record(file_transfer_out)
file_transfer_out(self.SRMclient, self.HTTPclient, self.local_file_path, self.target_file_surl, self.transfer_protocol)
cleanup(self.SRMclient, self.target_file_surl)
except Exception, e:
error("Error executing file-transfer-out: %s" % traceback.format_exc())
示例9: __call__
def __call__(self):
if (self.isFirstRun()):
self.initBarrier.await()
try:
test = Test(TestID.PUT_DAV, "StoRM PUT WebDAV test")
test.record(put_dav)
put_dav(self.remote_URL)
except Exception, e:
error("Error executing put-dav: %s" % traceback.format_exc())
示例10: __call__
def __call__(self):
if (grinder.runNumber == 0):
self.initBarrier.await()
try:
test = Test(TestID.GET_DAV, "StoRM GET WebDAV test")
test.record(get_dav)
get_dav(random.choice(FILE_URLS))
except Exception, e:
error("Error executing get-dav: %s" % traceback.format_exc())
示例11: __init__
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()
示例12: __init__
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()
示例13: __call__
def __call__(self, url, client):
test = Test(TestID.DELETE, "DELETE")
test.record(delete)
try:
return delete(url, client)
except Exception:
error("Error executing DELETE: %s" % traceback.format_exc())
raise
示例14: __call__
def __call__(self, src_url, dest_url, client):
test = Test(TestID.MOVE, "MOVE")
test.record(move)
try:
return move(src_url, dest_url, client)
except Exception:
error("Error executing MOVE: %s" % traceback.format_exc())
raise
示例15: __call__
def __call__(self):
try:
test = Test(TestID.RM_MULTI, "StoRM srmRm multiple calls")
test.record(rm_files)
surls = setup(SRM_CLIENT, TEST_NUMFILES)
rm_files(SRM_CLIENT, surls)
except Exception, e:
error("Error executing rm-multi: %s" % traceback.format_exc())