Commit d67bafe3 authored by Grant Young's avatar Grant Young

Merge branch 'gy-version-support-fixes' into 'master'

Fix Test Support for older GitLab Versions

See merge request !137
parents b6335224 70c02329
......@@ -127,8 +127,7 @@ As an example, the following is one of our Options Config Files, [`20s_2rps.json
{ "duration": "5s", "target": 0 }
],
"rps": 20,
"batchPerHost": 0,
"maxRedirects": 0
"batchPerHost": 0
}
```
......@@ -136,7 +135,6 @@ As an example, the following is one of our Options Config Files, [`20s_2rps.json
* It should be noted that each stage will ramp up from the previous, so in this example the scenario is to ramp up from 0 to 2 users over 5 seconds and then maintain 2 users for another 15s.
* `rps` - Sets the maximum Requests per Second that k6 can make in total.
* `batchPerHost` - Sets k6 to allow unlimited requests to the same host in [batch](https://docs.k6.io/docs/batch-requests) calls.
* `maxRedirects` - Sets the max number of redirects k6 will follow to none.
Note that it's best practice to set the number of users (VUs) to the same amount as RPS to ensure the target RPS can be reached.
......
......@@ -5,6 +5,5 @@
{ "duration": "5s", "target": 0 }
],
"rps": 10,
"batchPerHost": 0,
"maxRedirects": 0
"batchPerHost": 0
}
......@@ -5,6 +5,5 @@
{ "duration": "5s", "target": 0 }
],
"rps": 20,
"batchPerHost": 0,
"maxRedirects": 0
"batchPerHost": 0
}
......@@ -5,6 +5,5 @@
{ "duration": "5s", "target": 0 }
],
"rps": 2,
"batchPerHost": 0,
"maxRedirects": 0
"batchPerHost": 0
}
......@@ -5,6 +5,5 @@
{ "duration": "5s", "target": 0 }
],
"rps": 200,
"batchPerHost": 0,
"maxRedirects": 0
"batchPerHost": 0
}
......@@ -5,6 +5,5 @@
{ "duration": "5s", "target": 0 }
],
"rps": 2,
"batchPerHost": 0,
"maxRedirects": 0
"batchPerHost": 0
}
......@@ -5,6 +5,5 @@
{ "duration": "5s", "target": 0 }
],
"rps": 2,
"batchPerHost": 0,
"maxRedirects": 0
"batchPerHost": 0
}
......@@ -5,6 +5,5 @@
{ "duration": "1s", "target": 0 }
],
"rps": 2,
"batchPerHost": 0,
"maxRedirects": 0
"batchPerHost": 0
}
......@@ -5,6 +5,5 @@
{ "duration": "5s", "target": 0 }
],
"rps": 1000,
"batchPerHost": 0,
"maxRedirects": 0
"batchPerHost": 0
}
......@@ -5,6 +5,5 @@
{ "duration": "5s", "target": 0 }
],
"rps": 100,
"batchPerHost": 0,
"maxRedirects": 0
"batchPerHost": 0
}
......@@ -5,6 +5,5 @@
{ "duration": "5s", "target": 0 }
],
"rps": 10,
"batchPerHost": 0,
"maxRedirects": 0
"batchPerHost": 0
}
......@@ -5,6 +5,5 @@
{ "duration": "5s", "target": 0 }
],
"rps": 2000,
"batchPerHost": 0,
"maxRedirects": 0
"batchPerHost": 0
}
......@@ -5,6 +5,5 @@
{ "duration": "5s", "target": 0 }
],
"rps": 200,
"batchPerHost": 0,
"maxRedirects": 0
"batchPerHost": 0
}
......@@ -5,6 +5,5 @@
{ "duration": "5s", "target": 0 }
],
"rps": 2,
"batchPerHost": 0,
"maxRedirects": 0
"batchPerHost": 0
}
......@@ -5,6 +5,5 @@
{ "duration": "5s", "target": 0 }
],
"rps": 40,
"batchPerHost": 0,
"maxRedirects": 0
"batchPerHost": 0
}
......@@ -5,6 +5,5 @@
{ "duration": "5s", "target": 0 }
],
"rps": 500,
"batchPerHost": 0,
"maxRedirects": 0
"batchPerHost": 0
}
/*global __ENV : true */
/*
@endpoint: `GET /:group/:project/-/branches`
@endpoint: `GET /:group/:project/branches`
@description: Web - Project Branches Page. <br>Controllers: `BranchesController#show`, `Projects::BranchesController#diverging_commit_counts`</br>
@issue: https://gitlab.com/gitlab-org/gitlab/-/issues/211710
*/
......@@ -45,8 +45,8 @@ export default function() {
let project = selectProject(projects);
let responses = http.batch([
["GET", `${__ENV.ENVIRONMENT_URL}/${project['group']}/${project['name']}/-/branches`, null, {tags: {endpoint: 'branches', controller: 'Projects::BranchesController', action: 'show'}}],
["GET", `${__ENV.ENVIRONMENT_URL}/${project['group']}/${project['name']}/-/branches/all`, null, {tags: {endpoint: 'branches/all', controller: 'Projects::MergeRequestsController', action: 'show'}}]
["GET", `${__ENV.ENVIRONMENT_URL}/${project['group']}/${project['name']}/branches`, null, {tags: {endpoint: 'branches', controller: 'Projects::BranchesController', action: 'show'}}],
["GET", `${__ENV.ENVIRONMENT_URL}/${project['group']}/${project['name']}/branches/all`, null, {tags: {endpoint: 'branches/all', controller: 'Projects::MergeRequestsController', action: 'show'}}]
]);
responses.forEach(function(res) {
/20(0|1)/.test(res.status) ? successRate.add(true) : (successRate.add(false), logError(res));
......
/*global __ENV : true */
/*
@endpoint: `GET /:group/:project/-/issues/:issue_iid`
@endpoint: `GET /:group/:project/issues/:issue_iid`
@description: Web - Project Issue Page. <br>Controllers: `Projects::IssuesController#show`, `Projects::IssuesController#discussions`, `Projects::IssuesController#related_branches`, `Projects::IssuesController#can_create_branch` </br>
@issue: https://gitlab.com/gitlab-org/gitlab/-/issues/211377
*/
......@@ -51,8 +51,8 @@ export default function() {
let project = selectProject(projects);
let responses = http.batch([
["GET", `${__ENV.ENVIRONMENT_URL}/${project['group']}/${project['name']}/-/issues/${project['issue_iid']}`, null, {tags: {endpoint: 'issue', controller: 'Projects::IssuesController', action: 'show'}}],
["GET", `${__ENV.ENVIRONMENT_URL}/${project['group']}/${project['name']}/-/issues/${project['issue_iid']}/realtime_changes`, null, {tags: {endpoint: 'realtime_changes', controller: 'Projects::IssuesController', action: 'realtime_changes'}}],
["GET", `${__ENV.ENVIRONMENT_URL}/${project['group']}/${project['name']}/issues/${project['issue_iid']}`, null, {tags: {endpoint: 'issue', controller: 'Projects::IssuesController', action: 'show'}}],
["GET", `${__ENV.ENVIRONMENT_URL}/${project['group']}/${project['name']}/issues/${project['issue_iid']}/realtime_changes`, null, {tags: {endpoint: 'realtime_changes', controller: 'Projects::IssuesController', action: 'realtime_changes'}}],
["GET", `${__ENV.ENVIRONMENT_URL}/${project['group']}/${project['name']}/issues/${project['issue_iid']}/discussions.json`, null, {tags: {endpoint: 'discussions.json', controller: 'Projects::IssuesController', action: 'discussions.json'}}],
["GET", `${__ENV.ENVIRONMENT_URL}/${project['group']}/${project['name']}/issues/${project['issue_iid']}/related_branches`, null, {tags: {endpoint: 'related_branches', controller: 'Projects::IssuesController', action: 'related_branches'}, headers: { 'Accept': 'application/json' }}],
["GET", `${__ENV.ENVIRONMENT_URL}/${project['group']}/${project['name']}/issues/${project['issue_iid']}/can_create_branch`, null, {tags: {endpoint: 'can_create_branch', controller: 'Projects::IssuesController', action: 'can_create_branch'}, headers: { 'Accept': 'application/json' }}]
......
......@@ -37,7 +37,7 @@ export default function() {
group("Web - Project Issues Page", function() {
let project = selectProject(projects);
let res = http.get(`${__ENV.ENVIRONMENT_URL}/${project['group']}/${project['name']}/-/issues`);
let res = http.get(`${__ENV.ENVIRONMENT_URL}/${project['group']}/${project['name']}/issues`);
/20(0|1)/.test(res.status) ? successRate.add(true) : (successRate.add(false), logError(res));
});
}
/*global __ENV : true */
/*
@endpoint: `GET /:group/:project/-/merge_requests/:merge_request_iid/diffs`
@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#diffs_metadata.json`, `Projects::MergeRequests::DiffsController#diffs_batch.json`</br>
@issue: https://gitlab.com/gitlab-org/gitlab/-/issues/209784
@gitlab_version: 12.7.0
*/
import http from "k6/http";
......@@ -47,18 +48,18 @@ export default function() {
let project = selectProject(projects);
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_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'}}],
["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_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
let seqDiffRes = 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));
seqDiffRes = 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(seqDiffRes.status) ? successRate.add(true) : (successRate.add(false), logError(seqDiffRes));
}
});
}
/*global __ENV : true */
/*
@endpoint: `GET /:group/:project/-/merge_requests/:merge_request_iid/commits`
@endpoint: `GET /:group/:project/merge_requests/:merge_request_iid/commits`
@description: Web - Project Merge Request Commits Page. <br>Controllers: `Projects::MergeRequestsController#show`, `Projects::MergeRequestsController#commits.json`</br>
@issue: https://gitlab.com/gitlab-org/gitlab/-/issues/209912
@flags: repo_storage
......@@ -46,8 +46,8 @@ export default function() {
let project = selectProject(projects);
let responses = http.batch([
["GET", `${__ENV.ENVIRONMENT_URL}/${project['group']}/${project['name']}/-/merge_requests/${project['mr_commits_iid']}/commits`, null, {tags: {endpoint: 'commits', controller: 'Projects::MergeRequestsController', action: 'show'}}],
["GET", `${__ENV.ENVIRONMENT_URL}/${project['group']}/${project['name']}/-/merge_requests/${project['mr_commits_iid']}/commits.json`, null, {tags: {endpoint: 'commits.json', controller: 'Projects::MergeRequestsController', action: 'commits.json'}}]
["GET", `${__ENV.ENVIRONMENT_URL}/${project['group']}/${project['name']}/merge_requests/${project['mr_commits_iid']}/commits`, null, {tags: {endpoint: 'commits', controller: 'Projects::MergeRequestsController', action: 'show'}}],
["GET", `${__ENV.ENVIRONMENT_URL}/${project['group']}/${project['name']}/merge_requests/${project['mr_commits_iid']}/commits.json`, null, {tags: {endpoint: 'commits.json', controller: 'Projects::MergeRequestsController', action: 'commits.json'}}]
]);
responses.forEach(function(res) {
/20(0|1)/.test(res.status) ? successRate.add(true) : (successRate.add(false), logError(res));
......
/*global __ENV : true */
/*
@endpoint: `GET /:group/:project/-/merge_requests/:merge_request_iid`
@endpoint: `GET /:group/:project/merge_requests/:merge_request_iid`
@description: Web - Project Merge Request Discussions Page. <br>Controllers: `Projects::MergeRequestsController#show`, `Projects::MergeRequests::ContentController#widget.json`, `Projects::MergeRequestsController#discussions.json`</br>
@issue: https://gitlab.com/gitlab-org/gitlab/-/issues/209786
*/
......@@ -47,9 +47,9 @@ export default function() {
let project = selectProject(projects);
let responses = http.batch([
["GET", `${__ENV.ENVIRONMENT_URL}/${project['group']}/${project['name']}/-/merge_requests/${project['mr_discussions_iid']}`, null, {tags: {endpoint: 'merge_request', controller: 'Projects::MergeRequestsController', action: 'show'}}],
["GET", `${__ENV.ENVIRONMENT_URL}/${project['group']}/${project['name']}/-/merge_requests/${project['mr_discussions_iid']}/discussions.json`, null, {tags: {endpoint: 'discussions.json', controller: 'Projects::MergeRequestsController', action: 'discussions.json'}}],
["GET", `${__ENV.ENVIRONMENT_URL}/${project['group']}/${project['name']}/-/merge_requests/${project['mr_discussions_iid']}/widget.json`, null, {tags: {endpoint: 'widget.json', controller: 'Projects::MergeRequests::ContentController', action: 'widget.json'}}]
["GET", `${__ENV.ENVIRONMENT_URL}/${project['group']}/${project['name']}/merge_requests/${project['mr_discussions_iid']}`, null, {tags: {endpoint: 'merge_request', controller: 'Projects::MergeRequestsController', action: 'show'}}],
["GET", `${__ENV.ENVIRONMENT_URL}/${project['group']}/${project['name']}/merge_requests/${project['mr_discussions_iid']}/discussions.json`, null, {tags: {endpoint: 'discussions.json', controller: 'Projects::MergeRequestsController', action: 'discussions.json'}}],
["GET", `${__ENV.ENVIRONMENT_URL}/${project['group']}/${project['name']}/merge_requests/${project['mr_discussions_iid']}/widget.json`, null, {tags: {endpoint: 'widget.json', controller: 'Projects::MergeRequests::ContentController', action: 'widget.json'}}]
]);
responses.forEach(function(res) {
/20(0|1)/.test(res.status) ? successRate.add(true) : (successRate.add(false), logError(res));
......
......@@ -37,7 +37,7 @@ export default function() {
group("Web - Project Merge Requests Page", function() {
let project = selectProject(projects);
let res = http.get(`${__ENV.ENVIRONMENT_URL}/${project['group']}/${project['name']}/-/merge_requests`);
let res = http.get(`${__ENV.ENVIRONMENT_URL}/${project['group']}/${project['name']}/merge_requests`);
/20(0|1)/.test(res.status) ? successRate.add(true) : (successRate.add(false), logError(res));
});
}
......@@ -108,7 +108,7 @@ module RunK6
end
tests.reject! { |test| TestInfo.test_has_unsafe_requests?(test) } unless unsafe
tests.select! { |test| TestInfo.test_supported_by_version?(test, env_version) } unless env_version == '-'
tests.select! { |test| TestInfo.test_supported_by_version?(test, env_version) }
tests
end
......
......@@ -59,18 +59,21 @@ module TestInfo
false
end
def test_supported_by_version?(test_file, gitlab_version_string)
test_version = nil
gitlab_version = Semantic::Version.new(gitlab_version_string.match(/\d+\.\d+\.\d+/)[0])
def test_supported_by_version?(test_file, gitlab_version)
test_supported_version = get_test_tag_value(test_file, 'gitlab_version')
return true if test_supported_version.nil?
File.open(test_file, "r") do |test_file_content|
test_file_content.each_line do |line|
test_version = Semantic::Version.new(line.match(/@gitlab_version: (\d+\.\d+\.\d+)/)[1]) if line.match?(/@gitlab_version: (\d+\.\d+\.\d+)/)
end
if test_supported_version && gitlab_version == '-'
warn Rainbow("GitLab version wasn't able to be determined. Test '#{File.basename(test_file)}' requires GitLab version '#{test_supported_version}' and up. Check that the environment is accessible and the ACCESS_TOKEN provided is correct then try again. Skipping out of caution...").yellow
return false
end
gitlab_version = Semantic::Version.new(gitlab_version.match(/\d+\.\d+\.\d+/)[0])
if test_supported_version && gitlab_version < Semantic::Version.new(test_supported_version)
warn Rainbow("Test '#{File.basename(test_file)}' isn't supported by GitLab version '#{gitlab_version}'. Requires '#{test_supported_version}' and up. Skipping...").yellow
return false
end
test_supported_by_version = true unless test_version && gitlab_version < test_version
warn Rainbow("Test '#{File.basename(test_file)}' isn't supported by GitLab version '#{gitlab_version}'. Requires '#{test_version}' and up. Skipping...").yellow unless test_supported_by_version
test_supported_by_version
true
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