Commit 909161dd authored by Ramya Authappan's avatar Ramya Authappan

Merge branch 'qa-artillery-io-script-2' into 'master'

Add artillery.io load testing script and rake tasks

See merge request gitlab-org/gitlab-ce!26210
parents 3c5a81cb f9832a08
tmp/ tmp/
.ruby-version .ruby-version
urls.txt urls.yml
...@@ -16,3 +16,25 @@ desc "Generate Performance Testdata" ...@@ -16,3 +16,25 @@ desc "Generate Performance Testdata"
task :generate_perf_testdata do task :generate_perf_testdata do
QA::Tools::GeneratePerfTestdata.new.run QA::Tools::GeneratePerfTestdata.new.run
end end
desc "Run artillery load tests"
task :run_artillery_load_tests do
unless ENV['HOST_URL'] && ENV['LARGE_ISSUE_URL'] && ENV['LARGE_MR_URL']
urls_file = ENV['URLS_FILE_PATH'] || 'urls.yml'
unless File.exist?(urls_file)
raise "\n#{urls_file} file is missing. Please provide correct URLS_FILE_PATH or all of HOST_URL, LARGE_ISSUE_URL and LARGE_MR_URL\n\n"
end
urls = YAML.safe_load(File.read(urls_file))
ENV['HOST_URL'] = urls[:host]
ENV['LARGE_ISSUE_URL'] = urls[:large_issue]
ENV['LARGE_MR_URL'] = urls[:large_mr]
end
sh('artillery run load/artillery.yml -o report.json')
sh('artillery report report.json -o report.html && rm report.json')
end
desc "Generate data and run load tests"
task generate_data_and_run_load_test: [:generate_perf_testdata, :run_artillery_load_tests]
config:
target: "{{ $processEnvironment.HOST_URL }}"
phases:
- duration: 60
arrivalRate: 1
name: "Warm up"
- duration: 120
arrivalRate: 1
rampTo: 50
name: "Gradual ramp up"
- duration: 60
arrivalRate: 50
name: "Sustained max load"
scenarios:
- name: "Visit large issue url"
flow:
- get:
url: "{{ $processEnvironment.LARGE_ISSUE_URL }}"
- name: "Visit large MR url"
flow:
- get:
url: "{{ $processEnvironment.LARGE_MR_URL }}"
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
require 'securerandom' require 'securerandom'
require 'faker' require 'faker'
require 'yaml'
require_relative '../../qa' require_relative '../../qa'
# This script generates testdata for Performance Testing. # This script generates testdata for Performance Testing.
# Required environment variables: PERSONAL_ACCESS_TOKEN and GITLAB_ADDRESS # Required environment variables: PERSONAL_ACCESS_TOKEN and GITLAB_ADDRESS
...@@ -20,7 +21,8 @@ module QA ...@@ -20,7 +21,8 @@ module QA
@api_client = Runtime::API::Client.new(ENV['GITLAB_ADDRESS'], personal_access_token: ENV['PERSONAL_ACCESS_TOKEN']) @api_client = Runtime::API::Client.new(ENV['GITLAB_ADDRESS'], personal_access_token: ENV['PERSONAL_ACCESS_TOKEN'])
@group_name = "gitlab-qa-perf-sandbox-#{SecureRandom.hex(8)}" @group_name = "gitlab-qa-perf-sandbox-#{SecureRandom.hex(8)}"
@project_name = "my-test-project-#{SecureRandom.hex(8)}" @project_name = "my-test-project-#{SecureRandom.hex(8)}"
@urls = {} @visibility = "public"
@urls = { host: ENV['GITLAB_ADDRESS'] }
end end
def run def run
...@@ -39,26 +41,26 @@ module QA ...@@ -39,26 +41,26 @@ module QA
threads_arr = [] threads_arr = []
methods_arr.each do |m| methods_arr.each do |m|
threads_arr << Thread.new {m.call} threads_arr << Thread.new { m.call }
end end
threads_arr.each(&:join) threads_arr.each(&:join)
STDOUT.puts "\nURLs: #{@urls}" STDOUT.puts "\nURLs: #{@urls}"
File.open("urls.txt", "w") { |file| file.puts @urls.to_s} File.open("urls.yml", "w") { |file| file.puts @urls.to_yaml }
STDOUT.puts "\nDone" STDOUT.puts "\nDone"
end end
private private
def create_group def create_group
group_search_response = post Runtime::API::Request.new(@api_client, "/groups").url, "name=#{@group_name}&path=#{@group_name}" group_search_response = post Runtime::API::Request.new(@api_client, "/groups").url, "name=#{@group_name}&path=#{@group_name}&visibility=#{@visibility}"
group = JSON.parse(group_search_response.body) group = JSON.parse(group_search_response.body)
@urls[:group_page] = group["web_url"] @urls[:group_page] = group["web_url"]
group["id"] group["id"]
end end
def create_project(group_id) def create_project(group_id)
create_project_response = post Runtime::API::Request.new(@api_client, "/projects").url, "name=#{@project_name}&namespace_id=#{group_id}" create_project_response = post Runtime::API::Request.new(@api_client, "/projects").url, "name=#{@project_name}&namespace_id=#{group_id}&visibility=#{@visibility}"
@urls[:project_page] = JSON.parse(create_project_response.body)["web_url"] @urls[:project_page] = JSON.parse(create_project_response.body)["web_url"]
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment