-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
00fa913
commit db64c83
Showing
6 changed files
with
131 additions
and
11 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,50 @@ | ||
// import http from 'k6/http'; | ||
// import { check } from 'k6'; | ||
|
||
// export default function () { | ||
// const google_uri = 'https://accounts.google.com/o/oauth2/v2/auth' | ||
// const google_body = { | ||
// 'client_secrect': 'NuGDq8U4euU-vQB-j2VtaiqS', | ||
// 'client_id': '498160978863-vsfnulg0j0g2v4lolbtkjth0l8dk38mh.apps.googleusercontent.com' | ||
// } | ||
// const response_google = http.post(google_uri, google_body); | ||
// // check(response_google, { | ||
// // "is status 200": (r) => r.status === 200, | ||
// // }) | ||
// const url = 'http://localhost:8080/accounts/google-login'; | ||
// const payload = JSON.stringify({ | ||
// token: 'ya29.a0ARrdaM-dgc_xV_mUQ6akxEzTaTisO-Nh5z2pMT4kUOuImFt-RLf9C0SaKJ1ZT3WPSTd3cplvoTY67AbifHM3UKYnXxsoZyfM6NMpAbzDiKdIQQ1wb0koz5drpzKYuZjbLl4_zsXsWJjJYN9yUBdvvC-DtZ6h' | ||
// }); | ||
|
||
// const params = { | ||
// headers: { | ||
// 'Content-Type': 'application/json', | ||
// }, | ||
// }; | ||
|
||
// const response = http.post(url, payload, params); | ||
|
||
// check(response, { | ||
// "is status 200": (r) => r.status === 200, | ||
// "is generated token": r.json('token') !== '' | ||
// }) | ||
// } | ||
|
||
|
||
// export let options = { | ||
// vus: 20, | ||
// duration: '5s', | ||
// }; | ||
|
||
|
||
// // export let options = { | ||
// // stages: [ | ||
// // { duration: '5m', target: 100 }, // simulate ramp-up of traffic from 1 to 100 users over 5 minutes. | ||
// // { duration: '10m', target: 100 }, // stay at 100 users for 10 minutes | ||
// // { duration: '5m', target: 0 }, // ramp-down to 0 users | ||
// // ], | ||
// // thresholds: { | ||
// // http_req_duration: ['p(99)<1500'], // 99% of requests must complete below 1.5s | ||
// // 'logged in successfully': ['p(99)<1500'], // 99% of requests must complete below 1.5s | ||
// // }, | ||
// // } |
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
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,53 @@ | ||
import http from 'k6/http'; | ||
import { check, group, sleep } from 'k6'; | ||
|
||
// export let options = { | ||
// stages: [ | ||
// { duration: '5m', target: 100 }, // simulate ramp-up of traffic from 1 to 100 users over 5 minutes. | ||
// { duration: '10m', target: 100 }, // stay at 100 users for 10 minutes | ||
// { duration: '5m', target: 0 }, // ramp-down to 0 users | ||
// ], | ||
// thresholds: { | ||
// http_req_duration: ['p(99)<1500'], // 99% of requests must complete below 1.5s | ||
// 'logged in successfully': ['p(99)<1500'], // 99% of requests must complete below 1.5s | ||
// }, | ||
// }; | ||
|
||
export default () => { | ||
const url = 'http://localhost:8080/accounts/login'; | ||
const payload = JSON.stringify({ | ||
email: "testLoad@gmail.com", | ||
password: "123456" | ||
}); | ||
|
||
const params = { | ||
headers: { | ||
'Content-Type': 'application/json', | ||
}, | ||
}; | ||
|
||
const loginRes = http.post(url, payload, params); | ||
|
||
check(loginRes, { | ||
'is logged in successfully': (r) => r.json('token') !== '', | ||
}); | ||
|
||
// console.log(loginRes) | ||
|
||
let authHeaders = { | ||
headers: { | ||
token: `${loginRes.json('token')}`, | ||
}, | ||
}; | ||
|
||
let getProducts = http.get(`http://localhost:8080/products/get-product`, authHeaders).json(); | ||
|
||
check(getProducts, { 'get user Products successful': (r) => r.status === true }); | ||
|
||
sleep(1); | ||
}; | ||
|
||
export let options = { | ||
vus: 1, | ||
duration: '5s', | ||
}; |