This repository has been archived by the owner on Sep 10, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
TEMPLATE.js
33 lines (27 loc) · 1.45 KB
/
TEMPLATE.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import http from 'k6/http';
import { group } from "k6";
import { loadOptions, parseResponse, loadServiceConfig, withHeaders } from "./lib/k6_extensions.js";
// TODO :: call loadOptions() with the name of the json options that you want to load, eg: loadOptions('default-soak-test')
// This parameter must be supplied with a value. The directory './options/' will be searched and '.json' appended
export let options = loadOptions('default-load-test');
// TODO :: call loadServiceConfig with the name of the service that you want to load, eg: loadServiceConfig('myservice')
// This parameter must be supplied with a value. The directory './services/' will be searched and '.json' appended
export let serviceConfig = Object.assign({}, loadServiceConfig('myservice'), {
getParams: withHeaders(),
postParams: withHeaders({ "Content-Type": "application/json"})
});
export function setup() { return serviceConfig; }
export default function (data) {
// TODO :: Update `data.baseUrl` with the extension to your endpoint, eg: data.baseUrl + "public/crocodiles"
group("GET /YOUR-ENDPOINT", function() {
parseResponse(http.get(data.baseUrl, data.getParams));
});
group("POST /YOUR-ENDPOINT", function() {
parseResponse(http.post(data.baseUrl, JSON.stringify(getRequestBody()), data.postParams));
});
};
function getRequestBody()
{
// TODO :: Update the response to include the details that you wish to send on the POST endpoint above
return {};
}