-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: Initial k6s individual page speed test cases
- Loading branch information
Showing
2 changed files
with
168 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,134 @@ | ||
import { SharedArray } from 'k6/data'; | ||
import { scenario } from 'k6/execution'; | ||
import http from 'k6/http'; | ||
|
||
import { jUnit } from 'https://jslib.k6.io/k6-summary/0.0.2/index.js'; | ||
import { group } from 'k6'; | ||
|
||
const data = new SharedArray('urls_list', function () { | ||
return JSON.parse(open('parameterizedData.json')).urls_list | ||
}); | ||
|
||
|
||
// const BASE_URL = `http://127.0.0.1:8002/api/v2`; | ||
// const AUTH_TOKEN = 'c3628877f8893f4c43ab23164e9139280ee5161ed532048e99cec671783349b0' | ||
|
||
// const BASE_URL = `https://alfred.nofusscomputing.com/api/v2`; | ||
// const AUTH_TOKEN = 'bf0062e4971ff216db4296d1a29832766c1eb9d37d16e627debcc60fdd5147f3' | ||
|
||
|
||
const BASE_URL = String(__ENV.BASE_URL) + '/api/v2'; | ||
const AUTH_TOKEN = __ENV.AUTH_TOKEN | ||
|
||
/* | ||
clear; \ | ||
K6_PROMETHEUS_RW_TREND_STATS="p(99),p(95),p(90),max,min" \ | ||
K6_PROMETHEUS_RW_SERVER_URL=http://prometheus.metrics.svc.kube.earth.nww:9090/api/v1/write \ | ||
BASE_URL="http://127.0.0.1:8002" \ | ||
AUTH_TOKEN="c3628877f8893f4c43ab23164e9139280ee5161ed532048e99cec671783349b0" \ | ||
k6 run \ | ||
-o experimental-prometheus-rw \ | ||
--tag "commit=$(git rev-parse HEAD)" \ | ||
--tag "testid=local_dev_actual_improved_5" \ | ||
test/page_speed.js | ||
*/ | ||
|
||
const iterations = Number(100) | ||
|
||
|
||
export const options = { | ||
|
||
insecureSkipTLSVerify: true, | ||
|
||
tags: { | ||
testid: 'local_dev_improved_5' | ||
// testid: 'local_dev_un_modified_5' | ||
}, | ||
|
||
scenarios: { | ||
'page_speed': { | ||
executor: 'shared-iterations', | ||
vus: 1, | ||
iterations: Number(data.length * iterations), | ||
maxDuration: '1h', | ||
}, | ||
}, | ||
|
||
thresholds: { | ||
http_req_duration: [ | ||
'p(99)<600', | ||
'p(95)<400', | ||
'p(90)<200' | ||
|
||
], // 95% of requests should be below 200ms | ||
}, | ||
|
||
}; | ||
|
||
|
||
var COMMON_REQUEST_HEADERS = { | ||
dnt: '1', | ||
'user-agent': 'Mozilla/5.0', | ||
'content-type': 'application/json', | ||
accept: 'application/json', | ||
origin: BASE_URL, | ||
referer: BASE_URL, | ||
Authorization: `Token ${AUTH_TOKEN}` | ||
|
||
}; | ||
|
||
|
||
|
||
export default function () { | ||
|
||
|
||
let current_iteration = Number(((scenario.iterationInTest + iterations) - ((scenario.iterationInTest + iterations) % iterations)) / iterations) - 1 | ||
|
||
|
||
const urls = data[Number(current_iteration)]; | ||
|
||
console.log(`arr val is: ${current_iteration} with base: ${BASE_URL} path: ${urls}`) | ||
|
||
|
||
const jar = http.cookieJar(); | ||
|
||
const cookies = jar.cookiesForURL(`${BASE_URL}`); | ||
|
||
|
||
|
||
|
||
group('endpoints', function () { | ||
|
||
let res = http.get(`${BASE_URL}${urls}`, | ||
{ | ||
// tags: {path: data[Number(current_iteration)] }, | ||
// tags: { | ||
// testid: 'local_dev_improved_5' | ||
// // testid: 'local_dev_un_modified_5' | ||
// }, | ||
headers: COMMON_REQUEST_HEADERS, | ||
jar: jar, | ||
} | ||
); | ||
|
||
}) | ||
|
||
// let res_opt = http.options(`${BASE_URL}${urls}`, | ||
// { | ||
// // tags: {path: data[Number(current_iteration)] }, | ||
// headers: COMMON_REQUEST_HEADERS, | ||
// jar: jar, | ||
// } | ||
// ); | ||
|
||
} | ||
|
||
|
||
|
||
export function handleSummary(data) { | ||
console.log('Preparing the end-of-test summary...'); | ||
|
||
return { | ||
'junit.xml': jUnit(data), // Transform summary and save it as a JUnit XML... | ||
}; | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
{ | ||
"urls_list": [ | ||
"/access/organization", | ||
|
||
"/assistance/knowledge_base", | ||
"/assistance/ticket/request", | ||
|
||
"/itam/device", | ||
"/itam/operating_system", | ||
"/itam/software", | ||
|
||
"/itim/ticket/change", | ||
"/itim/cluster", | ||
"/itim/service", | ||
"/itim/ticket/incident", | ||
"/itim/ticket/problem", | ||
|
||
"/project_management/project", | ||
|
||
"/settings/celery_log", | ||
"/settings/cluster_type", | ||
"/settings/device_model", | ||
"/settings/device_type", | ||
"/settings/external_link", | ||
"/settings/knowledge_base_category", | ||
"/settings/manufacturer", | ||
"/settings/port", | ||
"/settings/project_state", | ||
"/settings/project_type", | ||
"/settings/software_category", | ||
"/settings/ticket_category", | ||
"/settings/ticket_comment_category" | ||
] | ||
} |