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
dec3dfdc
Commit
dec3dfdc
authored
Aug 29, 2012
by
Victor Shnayder
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
some initial load testing bits
parent
22624fee
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
122 additions
and
0 deletions
+122
-0
common/test/load/ab/abtest.py
+109
-0
common/test/load/pages_to_test
+13
-0
No files found.
common/test/load/ab/abtest.py
0 → 100755
View file @
dec3dfdc
#!/usr/bin/env python
"""
A script to run some ab load tests.
"""
import
os
import
sys
import
argparse
"""
function bench {
set -e
set -x
NAME=$1
REQUESTS=$2
CONCURRENT=$3
PAGE=$4
OPTS=$5
OUTDIR="$NAME/page_${PAGE//
\
//-}"
mkdir -p $OUTDIR
ab -Aanant:agarwal -n $REQUESTS -c $CONCURRENT $OPTS http://prod-edx-001.m.edx.org$PAGE | tee -- $OUTDIR/$REQUESTS-$CONCURRENT.results
set +ex
}
For loop to ramp up load:
for conc in 1 2 3 5 8 13 21; do bench anon ${conc}00 $conc /jobs; done
"""
def
test_url
(
url
,
requests
,
concurrency
,
ab_options
,
logpath
):
"""
Run tests for a url
"""
cmd
=
"ab -n {requests} -c {concurrency} {opts} {url} | tee -- {log}"
.
format
(
requests
=
requests
,
concurrency
=
concurrency
,
url
=
url
,
opts
=
ab_options
,
log
=
logpath
,)
print
"running {0}"
.
format
(
cmd
)
os
.
system
(
cmd
)
def
loadtest
(
server
,
pages
,
ab_options
,
args
):
"""Actually do the load test
server: url of server, with or without http[s]://
pages: list of page urls, including leading slash
ab_options: list of options to pass to ab.
args: dictionary of other random arguments
"""
if
not
server
.
startswith
(
'http'
):
# use http by default, but if https is specified, use that
server
=
'http://'
+
server
# want a string
ab_options
=
' '
.
join
(
str
(
s
)
for
s
in
ab_options
)
if
ab_options
is
not
None
else
""
reqs_per_thread
=
10
name
=
args
.
get
(
'name'
,
"noname"
)
for
page
in
pages
:
url
=
"{server}{page}"
.
format
(
server
=
server
,
page
=
page
)
outdir
=
"{name}/page_{page}"
.
format
(
name
=
name
,
page
=
page
.
replace
(
'/'
,
'-'
))
os
.
makedirs
(
outdir
)
for
conc
in
[
1
]:
#[1, 2, 3, 10]:
requests
=
conc
*
reqs_per_thread
logpath
=
outdir
+
'/{requests}-{conc}.results'
.
format
(
requests
=
requests
,
conc
=
conc
)
test_url
(
url
,
requests
,
conc
,
ab_options
,
logpath
)
def
main
():
"""
Run tests
"""
target
=
"prod-edx-001.m.edx.org"
parser
=
argparse
.
ArgumentParser
(
description
=
'Run load tests on an edx server.'
)
parser
.
add_argument
(
'server'
,
help
=
'the server to test'
)
parser
.
add_argument
(
'pages'
,
metavar
=
'PAGE'
,
type
=
str
,
nargs
=
'+'
,
help
=
'a page to test (url will be server/{PAGE})'
)
parser
.
add_argument
(
'--sessionid'
,
help
=
'if testing non-anonymously, specify session id'
)
parser
.
add_argument
(
'--abopt'
,
action
=
'append'
)
args
=
parser
.
parse_args
()
loadtest
(
args
.
server
,
args
.
pages
,
args
.
abopt
,
vars
(
args
))
if
__name__
==
"__main__"
:
main
()
common/test/load/pages_to_test
0 → 100644
View file @
dec3dfdc
# A dumb file specifying pages to test, with abtest options: page\s+(options)?
/
/jobs
/courses/
/wiki/
/courses/BerkeleyX/CS188/fa12/wiki
/courses/BerkeleyX/CS188/fa12/discussion/forum
/courses/BerkeleyX/CS188/fa12/progress
/courses/BerkeleyX/CS188/fa12/info
/courses/BerkeleyX/CS188/fa12/courseware
# Berkeley-specific. Perhaps generate these automatically.
/courses/BerkeleyX/CS188/fa12/courseware/Week_1/Project_0_Tutorial/
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