Created
December 2, 2016 14:02
-
-
Save elthariel/eb030021ed9488bf40c96e40a2734942 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/env ruby | |
# frozen_string_literal: true | |
require 'ruby-jmeter' | |
def api(path) | |
'http://api.dev.foodle.fr/api/v1' + path | |
end | |
CAT = %w(express vegetables exotics classics basic_meals).freeze | |
DEV = %w(companion actifry cookeo).freeze | |
TYP = %w(entree dessert main_course).freeze | |
INGREDIENTS = [ | |
'poulet', 'brocolis', 'epinard', 'boeuf', 'pomme de terre', 'creme', | |
'oeuf', 'ail', 'oignons', 'thon', 'lentille', 'coco', 'crevette', | |
'saumon', 'tomate', 'huile', 'mais', 'poivre', 'cumin', 'haricot' | |
].freeze | |
loop do | |
test time: 1200 do | |
auth_data = { email: '[email protected]', password: '83f00dl3' } | |
threads count: 100, rampup: 0 do | |
think_time 500, 2000 | |
header name: 'Content-Type', value: 'application/json' | |
post name: 'Login', url: api('/login'), raw_body: auth_data.to_json do | |
extract name: 'access_token', regex: '.*"access_token": ?"([^"]+)".*' | |
end | |
header name: 'authorization', value: '${access_token}' | |
2.times do | |
visit name: 'profile', url: api('/users/1') | |
3.times do | |
visit name: 'Search', | |
url: api("/recipes?by_ingredients[]=#{INGREDIENTS.sample}") | |
end | |
2.times do | |
visit name: 'Category', | |
url: api("/recipes?by_category[]=#{CAT.sample}") | |
visit name: 'Device', | |
url: api("/recipes?by_device_type[]=#{DEV.sample}") | |
visit name: 'Dish Type', | |
url: api("/recipes?by_recipe_type[]=#{TYP.sample}") | |
end | |
8.times do | |
visit name: 'Recipe', url: api("/recipes/#{(rand * 70).to_i}") | |
end | |
2.times do | |
visit name: 'Show Preparation', | |
url: api("/preparations/#{(rand * 500).to_i}") | |
end | |
end | |
end | |
generate_summary_results | |
summary_report | |
end.run | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment