كتابة سيناريوهات k6
في هذا الدرس 4 موضوعات
هذا الدرس مخطط له. يعرض المخطط أدناه الموضوعات التي سيغطيها، ولم يُنشر الدرس الكامل بعد.
نص الدروس والتمارين باللغة الإنجليزية، بينما تبقى واجهة الموقع وعناوين الدروس بالعربية.
في هذا الدرس
script a realistic user journey in k6.
الموضوعات المخطط لها
- k6 scripts are JavaScript:
options(load shape, thresholds) and a default function (one user iteration). - Use checks for correctness and thresholds for pass or fail.
- Add think time (
sleep) between steps; real users pause. - Parametrize data (users, SKUs) so caches are not unrealistically warm.
- Run the load generator on a separate machine from the system under test. Verify tool version before recording; Gatling is an alternative.
تفاصيل المخطط المبدئي
عرض عملي
export const options = { thresholds: { http_req_duration: ['p(95)<300'], http_req_failed: ['rate<0.001'] } };
export default function () {
http.get(`${BASE}/products?q=${pick(terms)}`); sleep(2);
http.post(`${BASE}/cart`, JSON.stringify({sku: pick(skus), qty: 1}), params); sleep(3);
}اختبر فهمك
What does a threshold do?
أظهر الإجابة
Fails the run when a metric violates the limit.
التطبيق
طبّق هذا الدرس بمختبر الوحدة وتمارينها واختبارها.
تعليم الدرس كمكتمل اختياري ويمكنك التراجع عنه في أي وقت. يبقى تقدمك محفوظًا في هذا المتصفح.