Skip to content

Commit

Permalink
Add evaluation and revise tests
Browse files Browse the repository at this point in the history
  • Loading branch information
dannymaate committed Jun 3, 2024
1 parent 1cf95d2 commit 20f3192
Show file tree
Hide file tree
Showing 5 changed files with 247 additions and 139 deletions.
5 changes: 2 additions & 3 deletions k6_test/create_menu_item.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ export function uuidv4() {

export const options = {
stages: [
{ duration: '1m', target: 20 },
{ duration: '2m', target: 20 },
{ duration: '1m', target: 500 },
{ duration: '2m', target: 1000 },
{ duration: '1m', target: 0 },
],
};
Expand All @@ -37,6 +37,5 @@ export default function () {

let itemId = createItemRes.json().item_id;


sleep(1);
}
50 changes: 50 additions & 0 deletions k6_test/delete_menu_item.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import http from 'k6/http';
import { check, sleep } from 'k6';

export function uuidv4() {
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
var r = (Math.random() * 16) | 0,
v = c == 'x' ? r : (r & 0x3) | 0x8;
return v.toString(16);
});
}


export const options = {
stages: [
{ duration: '1m', target: 20 },
{ duration: '2m', target: 20 },
{ duration: '1m', target: 0 },
],
};

export default function () {
let res = http.get('http://brewbucks-485861802.us-east-1.elb.amazonaws.com/api/v1/menu_items', {
headers: { 'Content-Type': 'application/json' },
});

latte_item = next(item for item in menu_items)
delete_data = {
"user_id": 1,
"item_id": latte_item["item_id"]
}

let itemData = JSON.stringify({
user_id: 1,
item_id: 9
});



let delItemRes = http.del('http://brewbucks-485861802.us-east-1.elb.amazonaws.com/api/v1/menu_items', itemData, {
headers: { 'Content-Type': 'application/json' },
});

check(delItemRes, {
'item deletion status is 201': (r) => r.status === 201,
});

let itemId = delItemRes.json().item_id;

sleep(1);
}
2 changes: 1 addition & 1 deletion k6_test/get_user_info.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export default function () {

check(res, {
'status is 200': (r) => r.status === 200,
'response time is < 500ms': (r) => r.timings.duration < 500,
'response time is < 1000ms': (r) => r.timings.duration < 1000,
});

sleep(1);
Expand Down
Loading

0 comments on commit 20f3192

Please sign in to comment.