Last active
November 22, 2024 11:05
-
-
Save cataphract/e360e2d02111ba2f27adc130347e9483 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
import { check } from "k6"; | |
import http from "k6/http"; | |
const SCENARIO = __ENV.SCENARIO; | |
const EXTENDED_SCENARIO_NAME = __ENV.EXTENDED_SCENARIO_NAME; | |
const scenarios = { | |
normal_operation: { | |
executor: "constant-arrival-rate", | |
rate: parseInt(__ENV.K6_OPTIONS_NORMAL_OPERATION_RATE), | |
timeUnit: "1s", | |
duration: __ENV.K6_OPTIONS_NORMAL_OPERATION_DURATION, | |
gracefulStop: __ENV.K6_OPTIONS_NORMAL_OPERATION_GRACEFUL_STOP, | |
preAllocatedVUs: parseInt( | |
__ENV.K6_OPTIONS_NORMAL_OPERATION_PRE_ALLOCATED_VUS, | |
), | |
maxVUs: parseInt(__ENV.K6_OPTIONS_NORMAL_OPERATION_MAX_VUS), | |
}, | |
high_load: { | |
executor: "constant-arrival-rate", | |
rate: parseInt(__ENV.K6_OPTIONS_HIGH_LOAD_RATE), | |
timeUnit: "1s", | |
duration: __ENV.K6_OPTIONS_HIGH_LOAD_DURATION, | |
gracefulStop: __ENV.K6_OPTIONS_HIGH_LOAD_GRACEFUL_STOP, | |
preAllocatedVUs: parseInt(__ENV.K6_OPTIONS_HIGH_LOAD_PRE_ALLOCATED_VUS), | |
maxVUs: parseInt(__ENV.K6_OPTIONS_HIGH_LOAD_MAX_VUS), | |
}, | |
}; | |
export const options = { | |
scenarios: { | |
[EXTENDED_SCENARIO_NAME]: scenarios[SCENARIO], | |
}, | |
noConnectionReuse: false, | |
}; | |
export default function () { | |
const baseUrl = "http://localhost:8081/"; | |
const queryParams = [ | |
'param1=' + encodeURIComponent('value space'), | |
'param2=' + encodeURIComponent('value+plus'), | |
'param3=' + encodeURIComponent('value%20encoded'), | |
'param4=' + encodeURIComponent('100%'), | |
'param5=' + encodeURIComponent('test+value'), | |
'param6=' + encodeURIComponent('hello%world'), | |
'param7=' + encodeURIComponent('safe&sound'), | |
'param8=' + encodeURIComponent('yes?no'), | |
'param9=' + encodeURIComponent('smile😊'), | |
'param10=' + encodeURIComponent('path/to/resource'), | |
'param1=' + encodeURIComponent('another+value'), | |
'param3=' + encodeURIComponent('100%25complete') | |
].join('&'); | |
const url = `${baseUrl}?${queryParams}`; | |
const params = { | |
headers: { | |
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36', | |
'Accept-Language': 'en-US,en;q=0.5', | |
'Accept-Encoding': 'gzip, deflate, br', | |
'Authorization': 'Bearer your_bearer_token_here', | |
'Cookie': 'sessionId=abc123; userId=123+45; token=xyz6789', | |
'Content-Type': 'application/json', | |
}, | |
}; | |
const res = http.get(url, params); | |
check(res, { | |
"is status 200": (r) => r.status === 200, | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment