Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions k6/foundations/09.data.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ export const options = {
const pizzas = new Counter('quickpizza_number_of_pizzas');
const ingredients = new Trend('quickpizza_ingredients');

const customers = new SharedArray('all my customers', function () {
return JSON.parse(open('./data/customers.json')).customers;
const tokens = new SharedArray('all tokens', function () {
return JSON.parse(open('./data/tokens.json')).tokens;
});

export function setup() {
Expand All @@ -59,7 +59,7 @@ export function getPizza() {
let res = http.post(`${BASE_URL}/api/pizza`, JSON.stringify(restrictions), {
headers: {
'Content-Type': 'application/json',
'Authorization': 'token abcdef0123456789',
'Authorization': 'Token ' + tokens[Math.floor(Math.random() * tokens.length)],
},
});
check(res, { "status is 200": (res) => res.status === 200 });
Expand Down
6 changes: 3 additions & 3 deletions k6/foundations/11.composability.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ export const options = {
const pizzas = new Counter("quickpizza_number_of_pizzas");
const ingredients = new Trend("quickpizza_ingredients");

const customers = new SharedArray("all my customers", function () {
return JSON.parse(open("./data/customers.json")).customers;
const tokens = new SharedArray("all tokens", function () {
return JSON.parse(open("./data/tokens.json")).tokens;
});

export function setup() {
Expand All @@ -73,7 +73,7 @@ export function getPizza() {
let res = http.post(`${BASE_URL}/api/pizza`, JSON.stringify(restrictions), {
headers: {
"Content-Type": "application/json",
'Authorization': 'token abcdef0123456789',
"Authorization": "Token " + tokens[Math.floor(Math.random() * tokens.length)],
},
});
check(res, { "status is 200": (res) => res.status === 200 });
Expand Down
6 changes: 3 additions & 3 deletions k6/foundations/12.modularization.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ export const options = {
const pizzas = new Counter('quickpizza_number_of_pizzas');
const ingredients = new Trend('quickpizza_ingredients');

const customers = new SharedArray('all my customers', function () {
return JSON.parse(open('./data/customers.json')).customers;
const tokens = new SharedArray('all tokens', function () {
return JSON.parse(open('./data/tokens.json')).tokens;
});

export function setup() {
Expand All @@ -68,7 +68,7 @@ export function getPizza() {
let res = http.post(`${BASE_URL}/api/pizza`, JSON.stringify(restrictions), {
headers: {
'Content-Type': 'application/json',
'Authorization': 'token abcdef0123456789',
'Authorization': 'Token ' + tokens[Math.floor(Math.random() * tokens.length)],
},
});
check(res, { "status is 200": (res) => res.status === 200 });
Expand Down
10 changes: 0 additions & 10 deletions k6/foundations/data/customers.json

This file was deleted.

10 changes: 10 additions & 0 deletions k6/foundations/data/tokens.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"tokens": [
"QivfLrMEt7thtJLQ",
"LJwhcDFp0TgvpOtg",
"WA1UafNBZrfQMpTf",
"NS9RTUgm42fgxe1E",
"O62N74Bbt3lNwY6l",
"pW6DNdnWppqMl1c6"
]
}
Loading