Skip to content

Instantly share code, notes, and snippets.

@larsvegas
Last active April 2, 2019 15:43
Show Gist options
  • Save larsvegas/af64ddee9ec53560d163be01e8f5a504 to your computer and use it in GitHub Desktop.
Save larsvegas/af64ddee9ec53560d163be01e8f5a504 to your computer and use it in GitHub Desktop.
flower-shop.js from Performance Testing for DevOps in the Cloud from Codemotion 2019 Amsterdam
// System under Test – the target system you'll generate traffic against
definition.setTarget("testapp.loadtest.party");
// your Load Generator Cluster
definition.setTestOptions({
cluster: { sizing: "preflight", },
});
// user base of 10.000 unique users
// doing a user journey
// in highest hour in a week
var $userBase = 10000;
var $newUserPerSecond = $userBase / 60 / 60;
definition.setArrivalPhases([
// for 5 minutes
// start RATE new clients/users per second
{ duration: 5 * 60, rate: $newUserPerSecond }, // 100%
{ duration: 5 * 60, rate: $newUserPerSecond * 2 }, // 200%
{ duration: 5 * 60, rate: $newUserPerSecond * 3 }, // 300%
{ duration: 5 * 60, rate: $newUserPerSecond * 4 }, // 200%
]);
// the user Journey
definition.session("flower-shop-user-journey", function(session) {
session.get("/flowers", {
tag: "flower-list"
});
session.wait(30); // wait for 30 seconds
var flower = session.ds.generate("random_number", { range: [1000, 9999]});
session.get("/flowers/:flowerId", {
tag: "flower-detail",
params: {
flowerId: flower
}
});
session.wait(30); // wait for 30 seconds
session.post("/flower-cart/add", {
tag: "add-flower-to-cart",
payload: JSON.stringify({
"item": {
"qty": session.ds.generate("random_number", { range: [1, 9]}),
"flower_id": flower
}
})
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment