|
| 1 | +apiVersion: v1 |
| 2 | +kind: ConfigMap |
| 3 | +metadata: |
| 4 | + name: test |
| 5 | + namespace: k6-tests |
| 6 | +data: |
| 7 | + test.js: | |
| 8 | + import http from "k6/http"; |
| 9 | + import { check, sleep } from "k6"; |
| 10 | + import { Trend, Counter } from "k6/metrics"; |
| 11 | +
|
| 12 | + const BASE_URL = __ENV.BASE_URL || 'http://localhost:3333'; |
| 13 | +
|
| 14 | + export const options = { |
| 15 | + stages: [ |
| 16 | + { duration: '5s', target: 5 }, |
| 17 | + { duration: '10s', target: 5 }, |
| 18 | + { duration: '5s', target: 0 }, |
| 19 | + ], |
| 20 | + cloud: { |
| 21 | + projectID: $PROJECT_ID, |
| 22 | + name: 'k6-operator-e2e-cloud-stream' |
| 23 | + } |
| 24 | + }; |
| 25 | +
|
| 26 | + const pizzas = new Counter('quickpizza_number_of_pizzas'); |
| 27 | + const ingredients = new Trend('quickpizza_ingredients'); |
| 28 | +
|
| 29 | + export function setup() { |
| 30 | + console.log("Starting folks!") |
| 31 | + } |
| 32 | +
|
| 33 | + export default function () { |
| 34 | + let restrictions = { |
| 35 | + maxCaloriesPerSlice: 500, |
| 36 | + mustBeVegetarian: false, |
| 37 | + excludedIngredients: ["pepperoni"], |
| 38 | + excludedTools: ["knife"], |
| 39 | + maxNumberOfToppings: 6, |
| 40 | + minNumberOfToppings: 2 |
| 41 | + } |
| 42 | + let res = http.post(`/api/pizza`, JSON.stringify(restrictions), { |
| 43 | + headers: { |
| 44 | + 'Content-Type': 'application/json', |
| 45 | + 'X-User-ID': 23423, |
| 46 | + }, |
| 47 | + }); |
| 48 | + check(res, { "status is 200": (res) => res.status === 200 }); |
| 49 | + console.log(`${res.json().pizza.name} (${res.json().pizza.ingredients.length} ingredients)`); |
| 50 | + pizzas.add(1); |
| 51 | + ingredients.add(res.json().pizza.ingredients.length); |
| 52 | + sleep(1); |
| 53 | + } |
| 54 | +
|
| 55 | + export function teardown(){ |
| 56 | + console.log("That's all folks!") |
| 57 | + } |
0 commit comments