ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/COMP/DBS/Servers/Tests/cgiLoadTest.py
Revision: 1.1
Committed: Tue Feb 14 18:52:22 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
Log Message:
ws load test script

File Contents

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