Skip to content

Commit 25b8341

Browse files
committed
update k6 samples
1 parent 7c84177 commit 25b8341

File tree

1 file changed

+77
-3
lines changed

1 file changed

+77
-3
lines changed

samples/client/petstore/k6/script.js

+77-3
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,42 @@ export default function() {
5454
sleep(SLEEP_DURATION);
5555
}
5656

57-
// Request No. 2: testClientModel
57+
// Request No. 2: testEndpointParameters
58+
{
59+
let url = BASE_URL + `/fake`;
60+
// TODO: edit the parameters of the request body.
61+
let body = {"integer": "integer", "int32": "integer", "int64": "long", "number": "bigdecimal", "float": "float", "double": "double", "string": "string", "patternWithoutDelimiter": "string", "byte": "byte[]", "binary": http.file(open("/path/to/file.bin", "b"), "test.bin"), "date": "date", "dateTime": "date", "password": "string", "callback": "string"};
62+
let params = {
63+
headers: {
64+
"Content-Type": "application/x-www-form-urlencoded", "global_api_key_header": `${globalApiKeyHeader}`, "Accept": "application/json"
65+
}, cookies: {
66+
"global_api_key_cookie": `${globalApiKeyCookie}`
67+
}
68+
};
69+
let request = http.post(url, JSON.stringify(body), params);
70+
71+
72+
sleep(SLEEP_DURATION);
73+
}
74+
75+
// Request No. 3: testGroupParameters
76+
{
77+
let url = BASE_URL + `/fake?required_string_group=${required_string_group}&required_int64_group=${required_int64_group}&string_group=${string_group}&int64_group=${int64_group}`;
78+
let params = {
79+
headers: {
80+
"required_boolean_group": `${requiredBooleanGroup}`, "boolean_group": `${booleanGroup}`, "global_api_key_header": `${globalApiKeyHeader}`, "Accept": "application/json"
81+
}, cookies: {
82+
"global_api_key_cookie": `${globalApiKeyCookie}`
83+
}
84+
};
85+
// this is a DELETE method request - if params are also set, empty body must be passed
86+
let request = http.del(url, {} , params);
87+
88+
89+
sleep(SLEEP_DURATION);
90+
}
91+
92+
// Request No. 4: testClientModel
5893
{
5994
let url = BASE_URL + `/fake`;
6095
// TODO: edit the parameters of the request body.
@@ -203,7 +238,25 @@ export default function() {
203238
sleep(SLEEP_DURATION);
204239
}
205240

206-
// Request No. 2: deleteUser
241+
// Request No. 2: updateUser
242+
{
243+
let url = BASE_URL + `/user/${username}`;
244+
// TODO: edit the parameters of the request body.
245+
let body = {"id": "long", "username": "string", "firstName": "string", "lastName": "string", "email": "string", "password": "string", "phone": "string", "userStatus": "integer"};
246+
let params = {
247+
headers: {
248+
"Content-Type": "application/json", "global_api_key_header": `${globalApiKeyHeader}`, "Accept": "application/json"
249+
}, cookies: {
250+
"global_api_key_cookie": `${globalApiKeyCookie}`
251+
}
252+
};
253+
let request = http.put(url, JSON.stringify(body), params);
254+
255+
256+
sleep(SLEEP_DURATION);
257+
}
258+
259+
// Request No. 3: deleteUser
207260
{
208261
let url = BASE_URL + `/user/${username}`;
209262
let params = {
@@ -474,7 +527,28 @@ export default function() {
474527
sleep(SLEEP_DURATION);
475528
}
476529

477-
// Request No. 2: deletePet
530+
// Request No. 2: updatePetWithForm
531+
{
532+
let url = BASE_URL + `/pet/${petId}`;
533+
// TODO: edit the parameters of the request body.
534+
let body = {"name": "string", "status": "string"};
535+
let params = {
536+
headers: {
537+
"Content-Type": "application/x-www-form-urlencoded", "global_api_key_header": `${globalApiKeyHeader}`, "Accept": "application/json"
538+
}, cookies: {
539+
"global_api_key_cookie": `${globalApiKeyCookie}`
540+
}
541+
};
542+
let request = http.post(url, JSON.stringify(body), params);
543+
544+
check(request, {
545+
"Successful operation": (r) => r.status === 200
546+
});
547+
548+
sleep(SLEEP_DURATION);
549+
}
550+
551+
// Request No. 3: deletePet
478552
{
479553
let url = BASE_URL + `/pet/${petId}`;
480554
let params = {

0 commit comments

Comments
 (0)