-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #48 from CSSE6400/47-keep-fix-tests
Completed test.
- Loading branch information
Showing
8 changed files
with
383 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
# macOS | ||
brew install k6 | ||
|
||
# Windows (Using Chocolatey) | ||
choco install k6 | ||
|
||
# Linux | ||
sudo apt install k6 | ||
|
||
|
||
|
||
k6 run sign_up_and_delete_user.js | ||
k6 run get_user_info.js | ||
k6 run create_menu_item.js | ||
k6 run get_menu_item.js | ||
k6 run create_order.js | ||
|
||
1. User Sign-Up and Deletion (sign_up_and_delete_user.js) | ||
Total Requests: 7116 | ||
Successful Requests: 100.00% | ||
Average HTTP Request Duration: 10.42ms | ||
HTTP Request Failure Rate: 0.00% | ||
2. Get User Info (get_user_info.js) | ||
Total Requests: 3605 | ||
Successful Requests: 100.00% | ||
Average HTTP Request Duration: 6.62ms | ||
HTTP Request Failure Rate: 0.00% | ||
3. Create Menu Item (create_menu_item.js) | ||
Total Requests: 3606 | ||
Successful Requests: 100.00% | ||
Average HTTP Request Duration: 7.34ms | ||
HTTP Request Failure Rate: 0.00% | ||
4. Get Menu Items (get_menu_item.js) | ||
Total Requests: 1260 | ||
Successful Requests: 78.05% | ||
Average HTTP Request Duration: 1.89s | ||
HTTP Request Failure Rate: 0.00% | ||
5. Create Order (create_order.js) | ||
Total Requests: 3584 | ||
Successful Requests: 100.00% | ||
Average HTTP Request Duration: 13.4ms | ||
HTTP Request Failure Rate: 0.00% |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
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 itemData = JSON.stringify({ | ||
user_id: 1, | ||
name: `Item_${uuidv4()}`, | ||
description: 'Test item', | ||
price: 10.0, | ||
orderable: true, | ||
}); | ||
|
||
let createItemRes = http.post('http://localhost:8080/api/v1/menu_items', itemData, { | ||
headers: { 'Content-Type': 'application/json' }, | ||
}); | ||
|
||
check(createItemRes, { | ||
'item creation status is 201': (r) => r.status === 201, | ||
}); | ||
|
||
let itemId = createItemRes.json().item_id; | ||
|
||
|
||
sleep(1); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import http from 'k6/http'; | ||
import { check, sleep } from 'k6'; | ||
|
||
export const options = { | ||
stages: [ | ||
{ duration: '1m', target: 20 }, // Ramp-up to 20 users over 1 minute | ||
{ duration: '2m', target: 20 }, // Stay at 20 users for 2 minutes | ||
{ duration: '1m', target: 0 }, // Ramp-down to 0 users over 1 minute | ||
], | ||
}; | ||
|
||
export default function () { | ||
let orderData = JSON.stringify({ | ||
user_id: 1, | ||
order_items: [ | ||
{ item_id: 1, quantity: 2 }, | ||
{ item_id: 2, quantity: 1 }, | ||
], | ||
rewards_added: 5, | ||
}); | ||
|
||
let createOrderRes = http.post('http://localhost:8080/api/v1/users/orders', orderData, { | ||
headers: { 'Content-Type': 'application/json' }, | ||
}); | ||
|
||
check(createOrderRes, { | ||
'order creation status is 201': (r) => r.status === 201, | ||
}); | ||
|
||
sleep(1); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import http from 'k6/http'; | ||
import { check, sleep } from 'k6'; | ||
|
||
export const options = { | ||
stages: [ | ||
{ duration: '1m', target: 20 }, | ||
{ duration: '2m', target: 20 }, | ||
{ duration: '1m', target: 0 }, | ||
], | ||
}; | ||
|
||
export default function () { | ||
let res = http.get('http://localhost:8080/api/v1/menu_items', { | ||
headers: { 'Content-Type': 'application/json' }, | ||
}); | ||
|
||
check(res, { | ||
'status is 200': (r) => r.status === 200, | ||
'response time is < 500ms': (r) => r.timings.duration < 500, | ||
}); | ||
|
||
sleep(1); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import http from 'k6/http'; | ||
import { check, sleep } from 'k6'; | ||
|
||
export const options = { | ||
stages: [ | ||
{ duration: '1m', target: 20 }, | ||
{ duration: '2m', target: 20 }, | ||
{ duration: '1m', target: 0 }, | ||
], | ||
}; | ||
|
||
export default function () { | ||
let res = http.get('http://localhost:8080/api/v1/users/1', { | ||
headers: { 'Content-Type': 'application/json' }, | ||
}); | ||
|
||
check(res, { | ||
'status is 200': (r) => r.status === 200, | ||
'response time is < 500ms': (r) => r.timings.duration < 500, | ||
}); | ||
|
||
sleep(1); | ||
} |
Oops, something went wrong.