Skip to content
This repository has been archived by the owner on Feb 13, 2020. It is now read-only.

Commit

Permalink
Add -j option to job load test tool to specify number of jobs created…
Browse files Browse the repository at this point in the history
… per HTTP request.

git-svn-id: https://svn.calendarserver.org/repository/calendarserver/CalendarServer/trunk@14964 e27351fd-9f3e-4f54-a53b-843176b1656c
  • Loading branch information
cyrusdaboo committed Jul 15, 2015
1 parent 6b2e522 commit f5b4693
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 9 deletions.
9 changes: 8 additions & 1 deletion contrib/performance/jobqueue/loadtest.py
Expand Up @@ -52,6 +52,7 @@ def httploop(ctr, config, complete):
"action": "testwork",
"when": config["when"],
"delay": config["delay"],
"jobs": config["jobs"],
"priority": PRIORITY[config["priority"]],
"weight": config["weight"],
})
Expand Down Expand Up @@ -99,6 +100,7 @@ def usage(error_msg=None):
-n NUM Number of child processes [10]
-i MSEC Millisecond delay between each request [1000]
-r RATE Requests/second rate [10]
-j JOBS Number of jobs per HTTP request [1]
-s HOST:PORT Host/port to connect to [localhost:8443]
-b SEC Number of seconds for notBefore [0]
-d MSEC Number of milliseconds for the work [10]
Expand Down Expand Up @@ -136,6 +138,7 @@ def usage(error_msg=None):
config = {
"numProcesses": 10,
"interval": 1000,
"jobs": 1,
"server": "localhost:8443",
"when": 0,
"delay": 10,
Expand All @@ -147,7 +150,7 @@ def usage(error_msg=None):
interval = None
rate = None

options, args = getopt.getopt(sys.argv[1:], "b:d:hi:l:n:p:r:s:w:", [])
options, args = getopt.getopt(sys.argv[1:], "b:d:hi:j:l:n:p:r:s:w:", [])

for option, value in options:
if option == "-h":
Expand All @@ -156,6 +159,8 @@ def usage(error_msg=None):
numProcesses = int(value)
elif option == "-i":
interval = int(value)
elif option == "-j":
config["jobs"] = int(value)
elif option == "-r":
rate = int(value)
if rate <= 100:
Expand Down Expand Up @@ -205,6 +210,8 @@ def usage(error_msg=None):
print(" Number of processes: {}".format(config["numProcesses"]))
print(" Interval between requests: {} ms".format(config["interval"]))
print(" Effective request rate: {} req/sec".format(effective_rate))
print(" Jobs per request: {}".format(config["jobs"]))
print(" Effective job rate: {} jobs/sec".format(effective_rate * config["jobs"]))
print(" Total number of requests: {}").format(config["limit"] if config["limit"] != 0 else "unlimited")
print("")
print("Work details:")
Expand Down
21 changes: 13 additions & 8 deletions twistedcaldav/controlapi.py
Expand Up @@ -377,14 +377,19 @@ def action_testwork(self, j):
delay = j["delay"]
except KeyError:
delay = 0

yield TestWork.schedule(
self._store,
when,
priority,
weight,
delay,
)
try:
jobs = j["jobs"]
except KeyError:
jobs = 1

for _ in range(jobs):
yield TestWork.schedule(
self._store,
when,
priority,
weight,
delay,
)

returnValue(self._ok("ok", "Test work scheduled"))

Expand Down

0 comments on commit f5b4693

Please sign in to comment.