Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-platform
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
edx-platform
Commits
24e4feca
Commit
24e4feca
authored
Aug 30, 2012
by
Victor Shnayder
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Clean up the load test script a bit
parent
958f1409
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
61 additions
and
8 deletions
+61
-8
common/test/load/ab/abtest.py
+60
-8
common/test/load/pages_to_test
+1
-0
No files found.
common/test/load/ab/abtest.py
View file @
24e4feca
...
@@ -44,6 +44,12 @@ For loop to ramp up load:
...
@@ -44,6 +44,12 @@ For loop to ramp up load:
for conc in 1 2 3 5 8 13 21; do bench anon ${conc}00 $conc /jobs; done
for conc in 1 2 3 5 8 13 21; do bench anon ${conc}00 $conc /jobs; done
Useful curl incantation:
curl stage-edx-001.m.edx.org/courses/BerkeleyX/CS188/fa12/courseware/Week_1/Project_0_Tutorial/ -b "sessionid=de0fe775b2192445dce76a09deeb740a;csrftoken=2987de2837f3d7051a9d92335b448cf1" -u "anant:agarwal" -D headers
pass cookies, user/pass, and dump headers to file "headers"
"""
"""
def
test_url
(
url
,
requests
,
concurrency
,
ab_options
,
logpath
):
def
test_url
(
url
,
requests
,
concurrency
,
ab_options
,
logpath
):
...
@@ -59,15 +65,48 @@ def test_url(url, requests, concurrency, ab_options, logpath):
...
@@ -59,15 +65,48 @@ def test_url(url, requests, concurrency, ab_options, logpath):
print
"running {0}"
.
format
(
cmd
)
print
"running {0}"
.
format
(
cmd
)
os
.
system
(
cmd
)
os
.
system
(
cmd
)
def
read_pagelist
(
filepath
):
def
loadtest
(
server
,
pages
,
ab_options
,
args
):
"""
read list of pages, skipping blank lines and lines that start with '#'
"""
out
=
[]
try
:
with
open
(
filepath
)
as
f
:
for
line
in
f
:
line
=
line
.
strip
()
if
line
.
startswith
(
'#'
)
or
len
(
line
)
==
0
:
continue
out
.
append
(
line
)
except
:
print
"Couldn't load {0}"
.
format
(
filepath
)
raise
return
out
def
loadtest
(
args
):
"""Actually do the load test
"""Actually do the load test
args: argparse result. Should contain:
server: url of server, with or without http[s]://
server: url of server, with or without http[s]://
pages: list of page urls, including leading slash
pages: list of page urls, including leading slash
ab_options: list of options to pass to ab.
abopts: list of options to pass to ab.
args: dictionary of other random arguments
"""
"""
server
=
args
.
server
name
=
args
.
name
ab_options
=
args
.
abopt
if
args
.
abopt
else
[]
ab_options
+=
[
"-Aanant:agarwal"
]
if
args
.
sessionid
:
ab_options
+=
[
"-C 'sessionid={0}'"
.
format
(
args
.
sessionid
)]
if
args
.
csrftoken
:
ab_options
+=
[
"-C 'csrftoken={0}'"
.
format
(
args
.
csrftoken
)]
pages
=
args
.
pages
if
args
.
pages
else
[]
if
args
.
pagelist
:
pages
+=
read_pagelist
(
args
.
pagelist
)
if
not
server
.
startswith
(
'http'
):
if
not
server
.
startswith
(
'http'
):
# use http by default, but if https is specified, use that
# use http by default, but if https is specified, use that
server
=
'http://'
+
server
server
=
'http://'
+
server
...
@@ -75,11 +114,14 @@ def loadtest(server, pages, ab_options, args):
...
@@ -75,11 +114,14 @@ def loadtest(server, pages, ab_options, args):
# want a string
# want a string
ab_options
=
' '
.
join
(
str
(
s
)
for
s
in
ab_options
)
if
ab_options
is
not
None
else
""
ab_options
=
' '
.
join
(
str
(
s
)
for
s
in
ab_options
)
if
ab_options
is
not
None
else
""
reqs_per_thread
=
10
reqs_per_thread
=
2
name
=
args
.
get
(
'name'
,
"noname"
)
# If there are already results for this run, just delete them. (TODO: Desired behavior?)
os
.
system
(
"rm -rf {name}"
.
format
(
name
=
name
))
for
page
in
pages
:
for
page
in
pages
:
url
=
"{server}{page}"
.
format
(
server
=
server
,
page
=
page
)
url
=
"{server}{page}"
.
format
(
server
=
server
,
page
=
page
)
outdir
=
"{name}/page_{page}"
.
format
(
name
=
name
,
page
=
page
.
replace
(
'/'
,
'-'
))
outdir
=
"{name}/page_{page}"
.
format
(
name
=
name
,
page
=
page
.
replace
(
'/'
,
'-'
))
print
"Testing {0}. Output in {1}"
.
format
(
url
,
outdir
)
os
.
makedirs
(
outdir
)
os
.
makedirs
(
outdir
)
for
conc
in
[
1
]:
#[1, 2, 3, 10]:
for
conc
in
[
1
]:
#[1, 2, 3, 10]:
requests
=
conc
*
reqs_per_thread
requests
=
conc
*
reqs_per_thread
...
@@ -97,15 +139,25 @@ def main():
...
@@ -97,15 +139,25 @@ def main():
parser
=
argparse
.
ArgumentParser
(
description
=
'Run load tests on an edx server.'
)
parser
=
argparse
.
ArgumentParser
(
description
=
'Run load tests on an edx server.'
)
parser
.
add_argument
(
'server'
,
parser
.
add_argument
(
'server'
,
help
=
'the server to test'
)
help
=
'the server to test'
)
parser
.
add_argument
(
'
pages'
,
metavar
=
'PAGE'
,
type
=
str
,
nargs
=
'+
'
,
parser
.
add_argument
(
'
--pages'
,
metavar
=
'PAGE'
,
type
=
str
,
nargs
=
'*
'
,
help
=
'a page to test (url will be server/{PAGE})'
)
help
=
'a page to test (url will be server/{PAGE})'
)
parser
.
add_argument
(
'--sessionid'
,
parser
.
add_argument
(
'--sessionid'
,
help
=
'if testing non-anonymously, specify session id'
)
help
=
'if testing non-anonymously, specify session id'
)
parser
.
add_argument
(
'--csrftoken'
,
help
=
'if posting forms, specify csrftoken'
)
parser
.
add_argument
(
'--name'
,
help
=
'test name--results will be in {name}/'
,
default
=
'noname'
)
parser
.
add_argument
(
'--pagelist'
,
help
=
"""a file containing additional pages to test.
Empty lines and lines that start with # are ignored.
Will be added to pages specified on the command line"""
)
parser
.
add_argument
(
'--abopt'
,
action
=
'append'
)
parser
.
add_argument
(
'--abopt'
,
action
=
'append'
)
args
=
parser
.
parse_args
()
args
=
parser
.
parse_args
()
loadtest
(
args
.
server
,
args
.
pages
,
args
.
abopt
,
vars
(
args
)
)
loadtest
(
args
)
if
__name__
==
"__main__"
:
if
__name__
==
"__main__"
:
main
()
main
()
common/test/load/pages_to_test
View file @
24e4feca
# A dumb file specifying pages to test, with abtest options: page\s+(options)?
# A dumb file specifying pages to test, with abtest options: page\s+(options)?
# lines that start with '\s*#' ignored
/
/
/jobs
/jobs
/courses/
/courses/
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment