ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/COMP/DBS/Servers/Tests/wsLoadTest.py
Revision: 1.2
Committed: Wed Feb 15 21:34:01 2006 UTC (19 years, 2 months ago) by lueking
Content type: text/x-python
Branch: MAIN
CVS Tags: DBS_0_0_3a, DBS_0_0_3, DBS_0_0_2, DBS_0_0_1, pre_DBS_0_0_1, post_dict_type_checking_merge, post_MiniPythonAPI_merged_to_trunk, pre_MiniPythonAPI_merge_to_trunk, DBS_0_0_0, vs20060320, AfterJan2006SchemaChanges_v01_00_01, HEAD
Branch point for: BranchForCPPWebServiceTesting
Changes since 1.1: +22 -20 lines
Log Message:
load tests for cgi vs. ws

File Contents

# Content
1 #!/usr/bin/env python
2 #
3 # $Id: wsLoadTest.py,v 1.1 2006/02/14 18:51:43 lueking Exp $
4 #
5 # Web service test.
6 #
7 # Base API class provides some common functionality (e.g., logging
8 # configuration). Exception modules are defined in the dbsApi module.
9 #
10 import sys
11 import os.path
12 import string
13 #import SOAPpy
14 import time
15 #
16 # import dbs stuff
17 #
18 try:
19 sys.path.append('../python')
20 sys.path.append('../python/lib')
21 import dbsException
22 import dbsApi
23 import dbsWsClient
24 import dbsWsApi
25 #
26 import dbsMonteCarloDescription
27 import dbsPrimaryDataset
28 import dbsProcessedDataset
29 import dbsProcessingPath
30 import dbsEventCollection
31 import dbsApplication
32 import dbsFile
33 import dbsFileBlock
34 except:
35 msg="ERROR no DBS API available"
36 print msg
37
38 ##############################################################################
39
40
41
42 # Client usage.
43 def usage():
44 clientName = os.path.basename(sys.argv[0])
45 print "Usage:"
46 print " %s --dspath=<datasetPath> --n-calls=<number of calls> [--verbose]" % clientName
47 print "ex: wsLoadTest.py --dspath=/sw04_Anzar/DST/sw_DST813_2_g133_OSC --n-calls=1"
48 ##############################################################################
49 # Web service implementation of the DBS API class. Exceptions are defined
50 # in dbsApi module.
51
52
53 # Main code.
54 if __name__ == "__main__":
55 # Simple argument parser, ignore unrecognized arguments.
56 dimensionsString = None
57 datasetPath = None
58 nCalls = 1
59 debug=0
60 for a in sys.argv[1:]:
61 arg = string.split(a, "=")
62 if arg[0] == "--dspath":
63 datasetPath = arg[1]
64 elif arg[0] == "--wsdl":
65 wsdl = arg[1]
66 elif arg[0] == "--verbose":
67 debug = 1
68 elif arg[0] == "--n-calls":
69 nCalls = int(arg[1])
70 else:
71 print "Ignoring unrecognized argument: %s" % a
72 if not datasetPath:
73 usage()
74 sys.exit(1)
75
76 # Arguments are ok, invoke the service nCalls times, keep statistics.
77 nSuccess = 0
78 nFailure = 0
79 sumDeltaT = 0.0
80 minDeltaT = 1.0e32
81 maxDeltaT = 0
82 api = dbsWsApi.DbsWsApi(wsdlUrl="./DbsDatasetService.wsdl.xml")
83 # Configure logging.
84 if debug: api.setLogLevel(dbsApi.DBS_LOG_LEVEL_ALL_)
85 for i in range(0, nCalls):
86 try:
87 print "\nAttempt #%s" % (i+1)
88 t1 = time.time()
89 # Get dataset contents. It returns list of file blocks, each
90 # file block containing a set of event collections.
91 if debug: print "Getting dataset contents for: %s" % datasetPath
92 fileBlockList = api.getDatasetContents(datasetPath,False)
93 t2 = time.time()
94 deltaT = t2-t1
95 if deltaT < minDeltaT:
96 minDeltaT = deltaT
97 if deltaT > maxDeltaT:
98 maxDeltaT = deltaT
99 sumDeltaT = sumDeltaT + deltaT
100 print "Dataset contents for: %s" % datasetPath
101 for fileBlock in fileBlockList:
102 print ""
103 print "File block name/id: %s/%s" % (fileBlock.getBlockName(),
104 fileBlock.getBlockId())
105 for eventCollection in fileBlock.getEventCollectionList():
106 print " %s" % eventCollection
107 #fileList = datasetInfo.fileList
108 #datasetSizeInBytes = datasetInfo.datasetSizeInBytes
109 #print "Dimension string: %s" % (dimensionsString)
110 #print "Dataset file list:\n%s" % (fileList)
111 #print "Number of files in dataset: %s" % (len(fileList))
112 #print "Dataset size: %s bytes" % (datasetSizeInBytes)
113 print "Call Duration: %.2f seconds" % (deltaT)
114 nSuccess = nSuccess + 1
115 #except SOAPpy.Error, ex:
116 # nFailure = nFailure + 1
117 # print "Caught SOAP exception: %s" % ex.faultstring
118 except dbsException.DbsException, ex:
119 nFailure = nFailure + 1
120 print "Caught exception %s: %s" % (ex.getClassName(), ex.getErrorMessage())
121 except:
122 nFailure = nFailure + 1
123 print "Caught %s exception: %s" % (sys.exc_info()[0], sys.exc_info()[1])
124 sys.stdout.flush()
125 sys.stderr.flush()
126
127 print "\nTest Report"
128 print "================"
129 print "Total Calls: %s" % nCalls
130 print "Successful Calls: %s" % nSuccess
131 print "Success Percentage: %.2f" % (nSuccess/float(nCalls)*100.0)
132 print "Failed Calls: %s" % nFailure
133 print "Failure Percentage: %.2f" % (nFailure/float(nCalls)*100.0)
134 if nSuccess > 0:
135 print "Average Successful Call Duration: %.4f seconds" % (sumDeltaT/nSuccess)
136 print "Maximum Call Duration: %.4f seconds" % (maxDeltaT)
137 print "Minimum Call Duration: %.4f seconds" % (minDeltaT)
138
139