Skip to content

Commit

Permalink
linting
Browse files Browse the repository at this point in the history
  • Loading branch information
kclark-scottlogic committed Feb 29, 2024
1 parent aa6e1f0 commit 9549bcb
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 29 deletions.
2 changes: 1 addition & 1 deletion k6/load.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ export const options = {

export default async function () {
requestFunction();
};
}
50 changes: 25 additions & 25 deletions k6/requestFunctionExtract.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,30 +12,30 @@ const vuCookieJar = (() => {
};
})();

export function requestFunction () {
// Use same jar for every iteration of same VU! k6 doesn't do this for us :(
const vuID = exec.vu.idInTest;
let jar = vuCookieJar.get(vuID);
if (!jar) {
jar = http.cookieJar();
vuCookieJar.set(vuID, jar);
}
let originalCookie = (jar.cookiesForURL(baseUrl)[cookieName] || [])[0];
export function requestFunction() {
// Use same jar for every iteration of same VU! k6 doesn't do this for us :(
const vuID = exec.vu.idInTest;
let jar = vuCookieJar.get(vuID);
if (!jar) {
jar = http.cookieJar();
vuCookieJar.set(vuID, jar);
}
let originalCookie = (jar.cookiesForURL(baseUrl)[cookieName] || [])[0];

const data = { infoMessage: 'Hi', chatMessageType: 'LEVEL_INFO', level: 3 };
const response = http.post(`${baseUrl}/test/load`, JSON.stringify(data), {
headers: { 'Content-Type': 'application/json' },
jar,
});
// Expecting cookie to match original, OR first-time be added to the jar
const expectedCookie =
originalCookie || jar.cookiesForURL(baseUrl)[cookieName][0];
check(response, {
'response code was 200': (response) => response.status === 200,
'cookie was preserved': (response) =>
response.cookies[cookieName].length === 1 &&
response.cookies[cookieName][0].value === expectedCookie,
});
const data = { infoMessage: 'Hi', chatMessageType: 'LEVEL_INFO', level: 3 };
const response = http.post(`${baseUrl}/test/load`, JSON.stringify(data), {
headers: { 'Content-Type': 'application/json' },
jar,
});
// Expecting cookie to match original, OR first-time be added to the jar
const expectedCookie =
originalCookie || jar.cookiesForURL(baseUrl)[cookieName][0];
check(response, {
'response code was 200': (response) => response.status === 200,
'cookie was preserved': (response) =>
response.cookies[cookieName].length === 1 &&
response.cookies[cookieName][0].value === expectedCookie,
});

sleep(1);
};
sleep(1);
}
6 changes: 3 additions & 3 deletions k6/spike.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ export const options = {
// Key configurations for spike in this section
stages: [
{ duration: '2ms', target: 2000 }, // fast ramp-up to a high point
{ duration: '1m', target: 0 } // quick ramp-down to 0 users
]
{ duration: '1m', target: 0 }, // quick ramp-down to 0 users
],
};

export default async function () {
requestFunction();
};
}

0 comments on commit 9549bcb

Please sign in to comment.