You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

57 lines
1.5 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

import http from "k6/http";
import { check, sleep } from "k6";
const BASE_URL = __ENV.BASE_URL || "http://localhost:3000";
const CUSTOMER_ID = __ENV.CUSTOMER_ID || "CUST_001";
export const options = {
vus: 1,
duration: "70s",
thresholds: {
http_req_failed: ["rate<0.02"],
},
};
const headers = {
"Content-Type": "application/json",
"x-auth-type": "service",
"x-customer-id": CUSTOMER_ID,
"x-permissions": "pricing:markup:write",
};
const body = JSON.stringify({
request_id: "00000000-0000-4000-8000-000000000001",
customer_id: CUSTOMER_ID,
pickup_address: {
street: "1234 Warehouse Blvd",
city: "Los Angeles",
state: "CA",
zip: "90001",
place_id: "ChIJ_pickup",
formatted_address: "1234 Warehouse Blvd, Los Angeles, CA 90001, USA",
selected_from_suggestions: true,
},
delivery_address: {
street: "5678 Distribution Dr",
city: "Dallas",
state: "TX",
zip: "75201",
place_id: "ChIJ_delivery",
formatted_address: "5678 Distribution Dr, Dallas, TX 75201, USA",
selected_from_suggestions: true,
},
weight: { value: 500, unit: "lb" },
dimensions: { length: 48, width: 40, height: 48, unit: "in" },
pallet_count: 2,
cargo_type: "general_freight",
});
/** TC-303customer 60 次/分钟限流 */
export default function rateLimitTest() {
const res = http.post(`${BASE_URL}/api/quotes`, body, { headers });
check(res, {
"status is 200 or 429": (r) => r.status === 200 || r.status === 429,
});
sleep(0.5);
}