Skip to content

Commit ac96aaa

Browse files
committed
fix k6 load tests so post bodies will be json
By default, k6/http will encode post requests as `x-www-form-urlencoded`. This can result in boolean values getting interpreted by the monolith as strings. Related: #1339
1 parent 3f7dee2 commit ac96aaa

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

tests/load/utils.js

+6-4
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,10 @@ export function createRoom(name, token, roomOptions = {}, options = { doCheck: t
5353
roomOptions
5454
);
5555
const url = `http://${HOSTNAME}/api/room/create`;
56-
let resp = http.post(url, body, {
56+
let resp = http.post(url, JSON.stringify(body), {
5757
headers: {
58-
Authorization: `Bearer ${token}`,
58+
"Content-Type": "application/json",
59+
"Authorization": `Bearer ${token}`,
5960
},
6061
});
6162
if (options.doCheck) {
@@ -98,9 +99,10 @@ export function reqVideo(room, token, videoId, options = { action: "add", target
9899
} else {
99100
throw new Error(`Invalid action: ${options.action}`);
100101
}
101-
const resp = fn(url, body, {
102+
const resp = fn(url, JSON.stringify(body), {
102103
headers: {
103-
Authorization: `Bearer ${token}`,
104+
"Content-Type": "application/json",
105+
"Authorization": `Bearer ${token}`,
104106
},
105107
});
106108
return resp;

0 commit comments

Comments
 (0)