From ac96aaad008681726cd021699504a61163a03df0 Mon Sep 17 00:00:00 2001 From: Carson McManus Date: Sat, 24 Feb 2024 13:00:12 -0500 Subject: [PATCH] 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 --- tests/load/utils.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/tests/load/utils.js b/tests/load/utils.js index 7a3628f92..e4d94ab1d 100644 --- a/tests/load/utils.js +++ b/tests/load/utils.js @@ -53,9 +53,10 @@ export function createRoom(name, token, roomOptions = {}, options = { doCheck: t roomOptions ); const url = `http://${HOSTNAME}/api/room/create`; - let resp = http.post(url, body, { + let resp = http.post(url, JSON.stringify(body), { headers: { - Authorization: `Bearer ${token}`, + "Content-Type": "application/json", + "Authorization": `Bearer ${token}`, }, }); if (options.doCheck) { @@ -98,9 +99,10 @@ export function reqVideo(room, token, videoId, options = { action: "add", target } else { throw new Error(`Invalid action: ${options.action}`); } - const resp = fn(url, body, { + const resp = fn(url, JSON.stringify(body), { headers: { - Authorization: `Bearer ${token}`, + "Content-Type": "application/json", + "Authorization": `Bearer ${token}`, }, }); return resp;