| 1 | // A posting storm: posts arrive at a steady rate, whether the API keeps up or not. |
| 2 | import http from 'k6/http'; |
| 3 | |
| 4 | export { handleSummary } from './summary.js'; |
| 5 | |
| 6 | export const options = { |
| 7 | scenarios: { |
| 8 | storm: { |
| 9 | executor: 'constant-arrival-rate', |
| 10 | rate: Number(__ENV.RATE || 400), // new posts per second |
| 11 | timeUnit: '1s', |
| 12 | duration: '20s', |
| 13 | preAllocatedVUs: 100, |
| 14 | maxVUs: 400, |
| 15 | }, |
| 16 | }, |
| 17 | summaryTrendStats: ['med', 'p(99)'], |
| 18 | }; |
| 19 | |
| 20 | export default function () { |
| 21 | const id = 1 + Math.floor(Math.random() * 100000); |
| 22 | http.post(`${__ENV.BASE_URL}/posts`, JSON.stringify({ body: 'a post from the storm' }), { |
| 23 | headers: { Authorization: `Bearer seed-token-${id}`, 'Content-Type': 'application/json' }, |
| 24 | }); |
| 25 | } |