Skip to content

Instantly share code, notes, and snippets.

@ashleygwilliams
Last active August 29, 2015 14:25
Show Gist options
  • Save ashleygwilliams/353b60c2c65453cf5d6e to your computer and use it in GitHub Desktop.
Save ashleygwilliams/353b60c2c65453cf5d6e to your computer and use it in GitHub Desktop.
{
"x": 1,
"y": 0,
"styles" : {
"background-color": "#ffffff"
}
}
-- webmaker-android user story (MAKE-PAGES)
-- summary: discover -> make new project -> make a blank page x10
-- user agent: android version >= 41
http.set_user_agent_string("Mozilla/5.0 (Android 4.4; Mobile; rv:41.0) Gecko/41.0 Firefox/41.0")
local request_headers = {
["Authorization"]="token 593d8827deee01eeb7131b29a6fcf767dfe77598711c3e0ed3ecc9489b797ce2",
["Content-Type"]="application/json"
}
local base_url = "https://webmaker-api-loadtesting.herokuapp.com"
local user_path = "/users/13207"
math.randomseed(os.time())
-- visit discover page
http.request_batch({
{
"GET",
base_url .. "/discover",
response_body_bytes=10240
}
}
)
client.sleep(math.random(0,20))
-- make a new project
local response = http.request_batch({
{
"POST",
base_url .. user_path .. "/projects",
headers=request_headers,
data=json.stringify({
title="test project name"
}),
response_body_bytes=10240
}
})
client.sleep(math.random(0,20))
-- parse response to get page URL
response = json.parse(response[1]["body"])
for key,value in pairs(response) do log.debug(key,value) end
local project_id = response.project.id
local project_path = "/projects/" .. project_id
local page_url = base_url .. user_path .. project_path .. "/pages"
-- request project pages
http.request_batch({
{
"GET",
page_url,
response_body_bytes=10240
}
})
client.sleep(math.random(0,20))
-- utility to make a blank page for a single user's project
function make_page(n)
local response = http.request_batch({
{
"POST",
page_url,
headers = request_headers,
data = json.stringify({
x = n+1,
y = 0,
styles = json.stringify({
backgroundColor="#f2f6fc"
})
}),
response_body_bytes = 10240
}
})
client.sleep(math.random(0,20))
return response
end
-- make 10 pages
for i=0,10 do make_page(i) end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment