Commit 1dc3c962 authored by Grant Young's avatar Grant Young

Update Web MR Changes test to new endpoints

Endpoints have changed in the product to load diffs in batches
parent 7c7fd01b
# 1st Stage
FROM ruby:2.6-alpine AS build
ARG K6_VERSION="0.26.0"
ARG K6_VERSION="0.26.1"
ENV K6_VERSION="${K6_VERSION}"
ENV GEM_HOME="/usr/local/bundle"
ENV PATH $GEM_HOME/bin:$GEM_HOME/gems/bin:$PATH
......
/*global __ENV : true */
/*
@endpoint: `GET /:group/:project/-/merge_requests/:merge_request_iid/diffs`
@description: Web - Project Merge Request Changes Page. <br>Controllers: `Projects::MergeRequestsController#show`, `Projects::MergeRequests::DiffsController#show.json`</br>
@description: Web - Project Merge Request Changes Page. <br>Controllers: `Projects::MergeRequestsController#show`, `Projects::MergeRequests::DiffsController#diffs_metadata.json`, `Projects::MergeRequests::DiffsController#diffs_batch.json`</br>
@issue: https://gitlab.com/gitlab-org/gitlab/issues/30507
*/
......@@ -10,20 +10,22 @@ import { group } from "k6";
import { Rate } from "k6/metrics";
import { logError, getRpsThresholds, getTtfbThreshold, adjustRps, adjustStageVUs, getProjects, selectProject } from "../../lib/gpt_k6_modules.js";
export let endpointCount = 2
export let endpointCount = 7
export let webProtoRps = adjustRps(__ENV.WEB_ENDPOINT_THROUGHPUT)
export let webProtoStages = adjustStageVUs(__ENV.WEB_ENDPOINT_THROUGHPUT)
export let rpsThresholds = getRpsThresholds(__ENV.WEB_ENDPOINT_THROUGHPUT * 0.1, endpointCount)
export let ttfbThreshold = getTtfbThreshold(15000)
export let rpsThresholds = getRpsThresholds(__ENV.WEB_ENDPOINT_THROUGHPUT * 0.5, endpointCount)
export let ttfbThreshold = getTtfbThreshold(3000)
export let successRate = new Rate("successful_requests")
export let options = {
thresholds: {
"successful_requests": [`rate>${__ENV.SUCCESS_RATE_THRESHOLD}`],
"http_req_waiting{endpoint:diffs}": [`p(90)<${ttfbThreshold}`],
"http_req_waiting{endpoint:diffs.json}": [`p(90)<${ttfbThreshold}`],
"http_req_waiting{endpoint:diffs_metadata.json}": [`p(90)<${ttfbThreshold}`],
"http_req_waiting{endpoint:diffs_batch.json}": [`p(90)<${ttfbThreshold}`],
"http_reqs": [`count>=${rpsThresholds['count']}`],
"http_reqs{endpoint:diffs}": [`count>=${rpsThresholds['count_per_endpoint']}`],
"http_reqs{endpoint:diffs.json}": [`count>=${rpsThresholds['count_per_endpoint']}`]
"http_reqs{endpoint:diffs_metadata.json}": [`count>=${rpsThresholds['count_per_endpoint']}`],
"http_reqs{endpoint:diffs_batch.json}": [`count>=${rpsThresholds['count_per_endpoint']}`]
},
rps: webProtoRps,
stages: webProtoStages
......@@ -46,10 +48,17 @@ export default function() {
let responses = http.batch([
["GET", `${__ENV.ENVIRONMENT_URL}/${project['group']}/${project['name']}/-/merge_requests/${project['mr_commits_iid']}/diffs`, null, {tags: {endpoint: 'diffs', controller: 'Projects::MergeRequestsController', action: 'show'}}],
["GET", `${__ENV.ENVIRONMENT_URL}/${project['group']}/${project['name']}/-/merge_requests/${project['mr_commits_iid']}/diffs.json?w=0`, null, {tags: {endpoint: 'diffs.json', controller: 'Projects::MergeRequests::DiffsController', action: 'show.json'}}]
["GET", `${__ENV.ENVIRONMENT_URL}/${project['group']}/${project['name']}/-/merge_requests/${project['mr_commits_iid']}/diffs_metadata.json?`, null, {tags: {endpoint: 'diffs_metadata.json', controller: 'Projects::MergeRequests::DiffsController', action: 'diffs_metadata.json'}}],
["GET", `${__ENV.ENVIRONMENT_URL}/${project['group']}/${project['name']}/-/merge_requests/${project['mr_commits_iid']}/diffs_batch.json?w=0&per_page=20&page=1`, null, {tags: {endpoint: 'diffs_batch.json', controller: 'Projects::MergeRequests::DiffsController', action: 'diffs_batch.json'}}],
]);
responses.forEach(function(res) {
/20(0|1)/.test(res.status) ? successRate.add(true) : (successRate.add(false), logError(res));
});
let pageRes = null
for (let i = 2; i <= 5; i++) {
pageRes = http.get(`${__ENV.ENVIRONMENT_URL}/${project['group']}/${project['name']}/-/merge_requests/${project['mr_commits_iid']}/diffs_batch.json?w=0&per_page=20&page=${i}`, {tags: {endpoint: 'diffs_batch.json', controller: 'Projects::MergeRequests::DiffsController', action: 'diffs_batch.json'}});
/20(0|1)/.test(pageRes.status) ? successRate.add(true) : (successRate.add(false), logError(pageRes));
}
});
}
......@@ -17,7 +17,7 @@ module RunK6
extend self
def setup_k6
k6_version = ENV['K6_VERSION'] || '0.26.0'
k6_version = ENV['K6_VERSION'] || '0.26.1'
['k6', File.join(Dir.tmpdir, 'k6')].each do |k6|
return k6 if Open3.capture2e("#{k6} version" + ';')[0].strip.match?(/^k6 v#{k6_version}/)
......@@ -176,16 +176,16 @@ module RunK6
end
def generate_results_summary(results_json:)
<<~DOC
results_summary = <<~DOC
* Environment: #{results_json['name'].capitalize}
* Environment Version: #{results_json['version']} `#{results_json['revision']}`
* Option: #{results_json['option']}
* Date: #{results_json['date']}
* Run Time: #{ChronicDuration.output(results_json['time']['run'], format: :short)} (Start: #{results_json['time']['start']}, End: #{results_json['time']['end']})
* GPT Version: v#{results_json['gpt_version']}
█ Overall Results Score: #{results_json['overall_result_score']}%
DOC
results_summary += "\n█ Overall Results Score: #{results_json['overall_result_score']}%\n" unless results_json['overall_result_score'].nil?
results_summary
end
def generate_results_table(results_json:)
......
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