docs: dịch 22 file Markdown còn lại sang tiếng Việt có dấu (TEC-2881)
Some checks failed
CI / Lint → Typecheck → Test → Build (22) (push) Failing after 18s
CI / E2E Tests (push) Has been skipped
CodeQL Analysis / CodeQL (javascript-typescript) (push) Failing after 2m15s
Deploy / Build API Image (push) Failing after 28s
Deploy / Build Web Image (push) Failing after 16s
Deploy / Build AI Services Image (push) Failing after 17s
E2E Tests / Playwright E2E (push) Failing after 31s
Security Scanning / Dependency Audit (pnpm) (push) Failing after 3s
Security Scanning / Trivy Scan — API Image (push) Failing after 1m46s
Security Scanning / Trivy Scan — Web Image (push) Failing after 1m7s
Security Scanning / Trivy Scan — AI Services Image (push) Failing after 53s
Security Scanning / Trivy Filesystem Scan (push) Failing after 35s
Deploy / Deploy to Staging (push) Has been skipped
Deploy / Smoke Test Staging (push) Has been skipped
Deploy / Deploy to Production (push) Has been skipped
Deploy / Smoke Test Production (push) Has been skipped
Security Scanning / Security Gate (push) Failing after 0s
Deploy / Rollback Staging (push) Has been skipped
Deploy / Rollback Production (push) Has been skipped
Some checks failed
CI / Lint → Typecheck → Test → Build (22) (push) Failing after 18s
CI / E2E Tests (push) Has been skipped
CodeQL Analysis / CodeQL (javascript-typescript) (push) Failing after 2m15s
Deploy / Build API Image (push) Failing after 28s
Deploy / Build Web Image (push) Failing after 16s
Deploy / Build AI Services Image (push) Failing after 17s
E2E Tests / Playwright E2E (push) Failing after 31s
Security Scanning / Dependency Audit (pnpm) (push) Failing after 3s
Security Scanning / Trivy Scan — API Image (push) Failing after 1m46s
Security Scanning / Trivy Scan — Web Image (push) Failing after 1m7s
Security Scanning / Trivy Scan — AI Services Image (push) Failing after 53s
Security Scanning / Trivy Filesystem Scan (push) Failing after 35s
Deploy / Deploy to Staging (push) Has been skipped
Deploy / Smoke Test Staging (push) Has been skipped
Deploy / Deploy to Production (push) Has been skipped
Deploy / Smoke Test Production (push) Has been skipped
Security Scanning / Security Gate (push) Failing after 0s
Deploy / Rollback Staging (push) Has been skipped
Deploy / Rollback Production (push) Has been skipped
Hoàn tất đợt cuối của nhiệm vụ chuyển toàn bộ tài liệu sang tiếng Việt. Đã dịch 22 file `.md` còn sót (~9.7k dòng) — gồm RUNBOOK, audits, docs/architecture, docs/load-testing, libs READMEs và các quick references. Giữ nguyên code blocks, đường dẫn, identifier kỹ thuật, URL và biến môi trường. Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
@@ -1,75 +1,75 @@
|
||||
# K6 Load Testing Documentation for GoodGo Platform
|
||||
# Tài Liệu K6 Load Testing cho GoodGo Platform
|
||||
|
||||
Complete guide to understanding and implementing K6 load tests for the GoodGo Platform API.
|
||||
Hướng dẫn đầy đủ để hiểu và triển khai K6 load tests cho GoodGo Platform API.
|
||||
|
||||
---
|
||||
|
||||
## 📚 Documentation Files
|
||||
## 📚 Các File Tài Liệu
|
||||
|
||||
This directory contains three comprehensive guides for K6 load testing:
|
||||
Thư mục này chứa ba hướng dẫn toàn diện về K6 load testing:
|
||||
|
||||
### 1. **K6_LOAD_TESTING_GUIDE.md** (Primary Reference)
|
||||
Comprehensive exploration of the GoodGo Platform API structure for load testing.
|
||||
### 1. **K6_LOAD_TESTING_GUIDE.md** (Tham Khảo Chính)
|
||||
Khám phá toàn diện cấu trúc GoodGo Platform API cho load testing.
|
||||
|
||||
**Contents:**
|
||||
- API module structure (auth, listings, payments, search)
|
||||
- Detailed endpoint documentation with HTTP methods, rate limits, and auth requirements
|
||||
- Complete DTO specifications with request/response body shapes
|
||||
- Database and environment configuration reference
|
||||
- Existing test setup (Playwright, Vitest, CI/CD)
|
||||
- Architecture patterns (CQRS, DDD)
|
||||
- File location quick reference
|
||||
- K6 implementation recommendations
|
||||
**Nội dung:**
|
||||
- Cấu trúc module API (auth, listings, payments, search)
|
||||
- Tài liệu endpoint chi tiết với HTTP method, rate limit và yêu cầu auth
|
||||
- Đặc tả DTO đầy đủ với hình dạng request/response body
|
||||
- Tham khảo cấu hình database và environment
|
||||
- Thiết lập test hiện có (Playwright, Vitest, CI/CD)
|
||||
- Mẫu kiến trúc (CQRS, DDD)
|
||||
- Tham khảo nhanh vị trí file
|
||||
- Khuyến nghị triển khai K6
|
||||
|
||||
**When to use:** Deep dives into specific endpoints, understanding authentication flows, checking environment variables
|
||||
**Khi nào sử dụng:** Khi cần đào sâu vào các endpoint cụ thể, hiểu luồng xác thực, kiểm tra biến môi trường
|
||||
|
||||
### 2. **K6_ENDPOINTS_SUMMARY.md** (Quick Reference)
|
||||
Condensed endpoint reference with data shapes for immediate lookup.
|
||||
### 2. **K6_ENDPOINTS_SUMMARY.md** (Tham Khảo Nhanh)
|
||||
Tham khảo endpoint cô đọng với hình dạng dữ liệu để tra cứu ngay lập tức.
|
||||
|
||||
**Contents:**
|
||||
- All endpoints in table format (method, path, auth, rate limit)
|
||||
- Authentication module (register, login, refresh, profile)
|
||||
- Listings module (CRUD, moderation, media upload)
|
||||
- Payments module (create, list, callbacks, refund)
|
||||
- Search module (full-text, geo)
|
||||
- Request/response body examples (JSON)
|
||||
- K6 test scenarios (search, auth, listings, payments, webhooks)
|
||||
- Rate limits summary
|
||||
- Authentication flow examples (cookies vs tokens)
|
||||
**Nội dung:**
|
||||
- Tất cả endpoint dưới dạng bảng (method, path, auth, rate limit)
|
||||
- Module Authentication (register, login, refresh, profile)
|
||||
- Module Listings (CRUD, kiểm duyệt, upload media)
|
||||
- Module Payments (create, list, callback, refund)
|
||||
- Module Search (full-text, geo)
|
||||
- Ví dụ request/response body (JSON)
|
||||
- Các kịch bản test K6 (search, auth, listings, payments, webhook)
|
||||
- Tóm tắt rate limit
|
||||
- Ví dụ luồng xác thực (cookies vs tokens)
|
||||
|
||||
**When to use:** Quick lookup of endpoint details, copy-paste example payloads, understanding rate limits
|
||||
**Khi nào sử dụng:** Tra cứu nhanh chi tiết endpoint, sao chép payload mẫu, hiểu rate limit
|
||||
|
||||
### 3. **K6_QUICK_START.md** (Executable Examples)
|
||||
Step-by-step guide with ready-to-run K6 scripts and setup instructions.
|
||||
### 3. **K6_QUICK_START.md** (Ví Dụ Chạy Được)
|
||||
Hướng dẫn từng bước với script K6 sẵn sàng chạy và hướng dẫn thiết lập.
|
||||
|
||||
**Contents:**
|
||||
- Installation instructions (macOS, Linux, Docker)
|
||||
- Environment setup (starting API, seeding database)
|
||||
- Five runnable K6 scripts:
|
||||
- Search load test (public, high volume)
|
||||
- Auth load test (rate-limited registration)
|
||||
- Listing creation (authenticated, quota-gated)
|
||||
- Payment processing (authenticated)
|
||||
- All scenarios combined
|
||||
- CI integration with GitHub Actions
|
||||
- Report generation options (JSON, Grafana Cloud, CSV)
|
||||
- Common K6 checks and patterns
|
||||
- Debugging and troubleshooting
|
||||
**Nội dung:**
|
||||
- Hướng dẫn cài đặt (macOS, Linux, Docker)
|
||||
- Thiết lập môi trường (khởi động API, seed database)
|
||||
- Năm script K6 chạy được:
|
||||
- Search load test (công khai, lưu lượng cao)
|
||||
- Auth load test (đăng ký bị giới hạn rate)
|
||||
- Tạo listing (đã xác thực, giới hạn quota)
|
||||
- Xử lý payment (đã xác thực)
|
||||
- Tất cả kịch bản kết hợp
|
||||
- Tích hợp CI với GitHub Actions
|
||||
- Tùy chọn tạo báo cáo (JSON, Grafana Cloud, CSV)
|
||||
- Các check K6 và mẫu phổ biến
|
||||
- Debug và xử lý sự cố
|
||||
|
||||
**When to use:** Getting started quickly, running tests immediately, setting up CI/CD
|
||||
**Khi nào sử dụng:** Bắt đầu nhanh, chạy test ngay, thiết lập CI/CD
|
||||
|
||||
---
|
||||
|
||||
## 🚀 Quick Start (3 Minutes)
|
||||
## 🚀 Bắt Đầu Nhanh (3 Phút)
|
||||
|
||||
### 1. Install K6
|
||||
### 1. Cài Đặt K6
|
||||
```bash
|
||||
brew install k6 # macOS
|
||||
# or
|
||||
apt-get install k6 # Linux
|
||||
```
|
||||
|
||||
### 2. Start API & Database
|
||||
### 2. Khởi Động API & Database
|
||||
```bash
|
||||
pnpm install
|
||||
pnpm db:generate
|
||||
@@ -78,39 +78,39 @@ pnpm db:seed
|
||||
pnpm dev
|
||||
```
|
||||
|
||||
### 3. Run a Load Test
|
||||
### 3. Chạy Load Test
|
||||
```bash
|
||||
# Copy this from K6_QUICK_START.md Step 3
|
||||
k6 run load-tests/search.k6.js
|
||||
```
|
||||
|
||||
### 4. View Results
|
||||
K6 prints a summary to console. For more detailed reports, see K6_QUICK_START.md section on report generation.
|
||||
### 4. Xem Kết Quả
|
||||
K6 in tóm tắt ra console. Để xem báo cáo chi tiết hơn, xem mục tạo báo cáo trong K6_QUICK_START.md.
|
||||
|
||||
---
|
||||
|
||||
## 📊 Test Scenarios Implemented
|
||||
## 📊 Các Kịch Bản Test Đã Triển Khai
|
||||
|
||||
| Scenario | File | Focus | VUs | Duration | Key Endpoints |
|
||||
| Kịch Bản | File | Trọng Tâm | VUs | Thời Lượng | Endpoint Chính |
|
||||
|----------|------|-------|-----|----------|--------------|
|
||||
| Search Load | `load-tests/search.k6.js` | Public search performance | 50 | 4m | `GET /search`, `GET /search/geo` |
|
||||
| Authentication | `load-tests/auth.k6.js` | Auth throughput & rate limits | 10 | 2m | `POST /auth/register`, `POST /auth/login` |
|
||||
| Listing Creation | `load-tests/listings.k6.js` | Authenticated listing CRUD | 5 | 2m | `POST /listings`, `GET /listings/:id` |
|
||||
| Payments | `load-tests/payments.k6.js` | Payment initiation & status | 10 | 2m | `POST /payments`, `GET /payments/:id` |
|
||||
| Combined | `load-tests/all-scenarios.k6.js` | Realistic mixed load | 50 | 5m | Multiple endpoints |
|
||||
| Search Load | `load-tests/search.k6.js` | Hiệu suất tìm kiếm công khai | 50 | 4m | `GET /search`, `GET /search/geo` |
|
||||
| Authentication | `load-tests/auth.k6.js` | Throughput auth & rate limit | 10 | 2m | `POST /auth/register`, `POST /auth/login` |
|
||||
| Tạo Listing | `load-tests/listings.k6.js` | CRUD listing đã xác thực | 5 | 2m | `POST /listings`, `GET /listings/:id` |
|
||||
| Payments | `load-tests/payments.k6.js` | Khởi tạo & trạng thái thanh toán | 10 | 2m | `POST /payments`, `GET /payments/:id` |
|
||||
| Combined | `load-tests/all-scenarios.k6.js` | Tải hỗn hợp thực tế | 50 | 5m | Nhiều endpoint |
|
||||
|
||||
---
|
||||
|
||||
## 🔐 Authentication Methods
|
||||
## 🔐 Phương Thức Xác Thực
|
||||
|
||||
### Option 1: Cookie-Based (Recommended for Browser-Like Tests)
|
||||
### Tùy Chọn 1: Dựa Trên Cookie (Khuyến nghị cho test giống trình duyệt)
|
||||
```javascript
|
||||
const loginRes = http.post(`${BASE_URL}/auth/login`, { phone, password });
|
||||
// Cookies automatically managed by K6
|
||||
const profileRes = http.get(`${BASE_URL}/auth/profile`);
|
||||
```
|
||||
|
||||
### Option 2: Bearer Token (Recommended for API-Only Tests)
|
||||
### Tùy Chọn 2: Bearer Token (Khuyến nghị cho test chỉ API)
|
||||
```javascript
|
||||
const loginRes = http.post(`${BASE_URL}/auth/login`, { phone, password });
|
||||
const { accessToken } = loginRes.json();
|
||||
@@ -118,40 +118,40 @@ const headers = { Authorization: `Bearer ${accessToken}` };
|
||||
const profileRes = http.get(`${BASE_URL}/auth/profile`, { headers });
|
||||
```
|
||||
|
||||
See K6_ENDPOINTS_SUMMARY.md for full examples.
|
||||
Xem K6_ENDPOINTS_SUMMARY.md để xem ví dụ đầy đủ.
|
||||
|
||||
---
|
||||
|
||||
## 🎯 Key Endpoints by Priority
|
||||
## 🎯 Endpoint Chính Theo Mức Ưu Tiên
|
||||
|
||||
### High Priority (Core Functionality)
|
||||
| Endpoint | Priority | Why |
|
||||
### Ưu Tiên Cao (Chức Năng Cốt Lõi)
|
||||
| Endpoint | Ưu Tiên | Tại sao |
|
||||
|----------|----------|-----|
|
||||
| `GET /search` | ⭐⭐⭐ | Public, high-volume query |
|
||||
| `GET /search/geo` | ⭐⭐⭐ | Geospatial, frequently used |
|
||||
| `GET /listings` | ⭐⭐⭐ | Public search/filter |
|
||||
| `GET /listings/:id` | ⭐⭐⭐ | Detail page load |
|
||||
| `POST /auth/login` | ⭐⭐ | User session creation |
|
||||
| `POST /auth/register` | ⭐⭐ | Rate-limited, important |
|
||||
| `GET /search` | ⭐⭐⭐ | Công khai, truy vấn lưu lượng cao |
|
||||
| `GET /search/geo` | ⭐⭐⭐ | Địa không gian, dùng thường xuyên |
|
||||
| `GET /listings` | ⭐⭐⭐ | Tìm/lọc công khai |
|
||||
| `GET /listings/:id` | ⭐⭐⭐ | Tải trang chi tiết |
|
||||
| `POST /auth/login` | ⭐⭐ | Tạo phiên người dùng |
|
||||
| `POST /auth/register` | ⭐⭐ | Bị giới hạn rate, quan trọng |
|
||||
|
||||
### Medium Priority (Feature-Specific)
|
||||
| Endpoint | Priority | Why |
|
||||
### Ưu Tiên Trung Bình (Tính Năng Cụ Thể)
|
||||
| Endpoint | Ưu Tiên | Tại sao |
|
||||
|----------|----------|-----|
|
||||
| `POST /listings` | ⭐⭐ | Quota-gated, authenticated |
|
||||
| `POST /payments` | ⭐⭐ | External integrations |
|
||||
| `GET /payments` | ⭐⭐ | User transaction history |
|
||||
| `POST /payments/callback/:provider` | ⭐⭐ | Webhook handler, critical |
|
||||
| `POST /listings` | ⭐⭐ | Bị giới hạn quota, đã xác thực |
|
||||
| `POST /payments` | ⭐⭐ | Tích hợp bên ngoài |
|
||||
| `GET /payments` | ⭐⭐ | Lịch sử giao dịch người dùng |
|
||||
| `POST /payments/callback/:provider` | ⭐⭐ | Webhook handler, then chốt |
|
||||
|
||||
### Low Priority (Admin/Specialized)
|
||||
| Endpoint | Priority | Why |
|
||||
### Ưu Tiên Thấp (Admin/Chuyên Biệt)
|
||||
| Endpoint | Ưu Tiên | Tại sao |
|
||||
|----------|----------|-----|
|
||||
| `PATCH /listings/:id/moderate` | ⭐ | Admin-only |
|
||||
| `GET /listings/pending` | ⭐ | Admin-only |
|
||||
| `POST /search/reindex` | ⭐ | Admin-only, scheduled |
|
||||
| `PATCH /listings/:id/moderate` | ⭐ | Chỉ admin |
|
||||
| `GET /listings/pending` | ⭐ | Chỉ admin |
|
||||
| `POST /search/reindex` | ⭐ | Chỉ admin, có lịch |
|
||||
|
||||
---
|
||||
|
||||
## 📍 API Structure at a Glance
|
||||
## 📍 Tổng Quan Cấu Trúc API
|
||||
|
||||
```
|
||||
API Base: http://localhost:3001/api/v1
|
||||
@@ -168,9 +168,9 @@ Modules:
|
||||
|
||||
---
|
||||
|
||||
## 🗄️ Database Configuration
|
||||
## 🗄️ Cấu Hình Database
|
||||
|
||||
### Local Development
|
||||
### Phát Triển Cục Bộ
|
||||
```bash
|
||||
DATABASE_URL=postgresql://goodgo:password@localhost:5432/goodgo
|
||||
REDIS_URL=redis://localhost:6379
|
||||
@@ -178,7 +178,7 @@ TYPESENSE_HOST=localhost
|
||||
TYPESENSE_PORT=8108
|
||||
```
|
||||
|
||||
### Test Environment (CI)
|
||||
### Môi Trường Test (CI)
|
||||
```bash
|
||||
DATABASE_URL=postgresql://goodgo:goodgo_test_secret@localhost:5432/goodgo_test
|
||||
REDIS_URL=redis://localhost:6379
|
||||
@@ -186,23 +186,23 @@ TYPESENSE_HOST=localhost
|
||||
TYPESENSE_PORT=8108
|
||||
```
|
||||
|
||||
See K6_LOAD_TESTING_GUIDE.md for full environment variables.
|
||||
Xem K6_LOAD_TESTING_GUIDE.md để biết đầy đủ biến môi trường.
|
||||
|
||||
---
|
||||
|
||||
## ⚡ Rate Limits
|
||||
## ⚡ Rate Limit
|
||||
|
||||
Respect these limits in your load tests:
|
||||
Tôn trọng các giới hạn này trong load test của bạn:
|
||||
|
||||
| Endpoint | Limit | Window | Action on Exceeded |
|
||||
| Endpoint | Limit | Cửa Sổ | Hành Động Khi Vượt |
|
||||
|----------|-------|--------|-------------------|
|
||||
| `/auth/register` | 5 | per hour | Returns 429 |
|
||||
| `/auth/login` | 5 | per hour | Returns 429 |
|
||||
| `/auth/refresh` | 5 | per hour | Returns 429 |
|
||||
| `/payments/callback/*` | 20 | per minute | Returns 429 |
|
||||
| All others | None | N/A | Quota gates apply for writes |
|
||||
| `/auth/register` | 5 | mỗi giờ | Trả về 429 |
|
||||
| `/auth/login` | 5 | mỗi giờ | Trả về 429 |
|
||||
| `/auth/refresh` | 5 | mỗi giờ | Trả về 429 |
|
||||
| `/payments/callback/*` | 20 | mỗi phút | Trả về 429 |
|
||||
| Tất cả khác | Không có | N/A | Quota gate áp dụng cho thao tác ghi |
|
||||
|
||||
**K6 Handling:**
|
||||
**Xử Lý K6:**
|
||||
```javascript
|
||||
check(res, {
|
||||
'status not rate limited': (r) => r.status !== 429,
|
||||
@@ -212,7 +212,7 @@ check(res, {
|
||||
|
||||
---
|
||||
|
||||
## 🏗️ Recommended Test Structure
|
||||
## 🏗️ Cấu Trúc Test Đề Xuất
|
||||
|
||||
```
|
||||
load-tests/
|
||||
@@ -228,24 +228,24 @@ load-tests/
|
||||
└── config.js # Base URL, env, thresholds
|
||||
```
|
||||
|
||||
Example helper structure provided in K6_QUICK_START.md.
|
||||
Cấu trúc helper mẫu được cung cấp trong K6_QUICK_START.md.
|
||||
|
||||
---
|
||||
|
||||
## 🧪 Integration with Existing Tests
|
||||
## 🧪 Tích Hợp Với Các Test Hiện Có
|
||||
|
||||
### Complement, Don't Replace
|
||||
### Bổ Sung, Không Thay Thế
|
||||
|
||||
K6 is for **load testing** (performance under concurrent load).
|
||||
Existing tests serve different purposes:
|
||||
K6 dành cho **load testing** (hiệu suất dưới tải đồng thời).
|
||||
Các test hiện có phục vụ các mục đích khác:
|
||||
|
||||
| Test Type | Tool | Purpose | When |
|
||||
| Loại Test | Công Cụ | Mục Đích | Khi Nào |
|
||||
|-----------|------|---------|------|
|
||||
| Unit Tests | Vitest | Verify function logic | During development |
|
||||
| E2E Tests | Playwright | Verify user flows work | Before deployment |
|
||||
| Load Tests | K6 | Verify performance at scale | Scheduled, on-demand |
|
||||
| Unit Tests | Vitest | Xác minh logic hàm | Trong quá trình phát triển |
|
||||
| E2E Tests | Playwright | Xác minh luồng người dùng hoạt động | Trước khi triển khai |
|
||||
| Load Tests | K6 | Xác minh hiệu suất ở quy mô lớn | Theo lịch, theo yêu cầu |
|
||||
|
||||
### Running All Tests
|
||||
### Chạy Tất Cả Test
|
||||
|
||||
```bash
|
||||
# Unit tests (API only)
|
||||
@@ -263,11 +263,11 @@ pnpm test && pnpm test:e2e && k6 run load-tests/all-scenarios.k6.js
|
||||
|
||||
---
|
||||
|
||||
## 📈 CI/CD Integration
|
||||
## 📈 Tích Hợp CI/CD
|
||||
|
||||
### GitHub Actions Workflow
|
||||
### Workflow GitHub Actions
|
||||
|
||||
Create `.github/workflows/load-test.yml` (template in K6_QUICK_START.md section 🔟):
|
||||
Tạo `.github/workflows/load-test.yml` (mẫu trong K6_QUICK_START.md mục 🔟):
|
||||
|
||||
```bash
|
||||
# Runs on schedule (daily at 2 AM)
|
||||
@@ -275,7 +275,7 @@ Create `.github/workflows/load-test.yml` (template in K6_QUICK_START.md section
|
||||
# Reports results as artifacts
|
||||
```
|
||||
|
||||
### Manual Reporting
|
||||
### Báo Cáo Thủ Công
|
||||
|
||||
```bash
|
||||
# Export JSON
|
||||
@@ -290,74 +290,74 @@ K6_CLOUD_TOKEN=xxx k6 run load-tests/search.k6.js --out cloud
|
||||
|
||||
---
|
||||
|
||||
## 🔗 Cross-Reference Guide
|
||||
## 🔗 Hướng Dẫn Tham Chiếu Chéo
|
||||
|
||||
### Looking for...?
|
||||
### Đang tìm kiếm...?
|
||||
|
||||
| Need | Find in |
|
||||
| Cần | Tìm trong |
|
||||
|------|----------|
|
||||
| All endpoint URLs & methods | K6_ENDPOINTS_SUMMARY.md |
|
||||
| Request/response JSON shapes | K6_ENDPOINTS_SUMMARY.md (📊 Key Data Shapes) |
|
||||
| DTOs & validation rules | K6_LOAD_TESTING_GUIDE.md (Controllers & DTOs) |
|
||||
| Rate limit specifics | K6_ENDPOINTS_SUMMARY.md (📌 Important Rate Limits) |
|
||||
| Authentication flows | K6_ENDPOINTS_SUMMARY.md (🔗 Authentication Flow for K6) |
|
||||
| Database variables | K6_LOAD_TESTING_GUIDE.md (🗄️ Database & Environment) |
|
||||
| Ready-to-run scripts | K6_QUICK_START.md (Steps 3-8️⃣) |
|
||||
| CI/CD setup | K6_QUICK_START.md (Step 🔟) |
|
||||
| Troubleshooting | K6_QUICK_START.md (✅ Troubleshooting) |
|
||||
| Architecture details | K6_LOAD_TESTING_GUIDE.md (📊 Architecture Patterns) |
|
||||
| File locations | K6_LOAD_TESTING_GUIDE.md (📁 File Locations Quick Reference) |
|
||||
| Tất cả URL & method endpoint | K6_ENDPOINTS_SUMMARY.md |
|
||||
| Hình dạng JSON request/response | K6_ENDPOINTS_SUMMARY.md (📊 Key Data Shapes) |
|
||||
| DTO & quy tắc validation | K6_LOAD_TESTING_GUIDE.md (Controllers & DTOs) |
|
||||
| Chi tiết rate limit | K6_ENDPOINTS_SUMMARY.md (📌 Important Rate Limits) |
|
||||
| Luồng xác thực | K6_ENDPOINTS_SUMMARY.md (🔗 Authentication Flow for K6) |
|
||||
| Biến database | K6_LOAD_TESTING_GUIDE.md (🗄️ Database & Environment) |
|
||||
| Script sẵn sàng chạy | K6_QUICK_START.md (Steps 3-8️⃣) |
|
||||
| Thiết lập CI/CD | K6_QUICK_START.md (Step 🔟) |
|
||||
| Xử lý sự cố | K6_QUICK_START.md (✅ Troubleshooting) |
|
||||
| Chi tiết kiến trúc | K6_LOAD_TESTING_GUIDE.md (📊 Architecture Patterns) |
|
||||
| Vị trí file | K6_LOAD_TESTING_GUIDE.md (📁 File Locations Quick Reference) |
|
||||
|
||||
---
|
||||
|
||||
## 🛠️ Common Tasks
|
||||
## 🛠️ Công Việc Phổ Biến
|
||||
|
||||
### Task: Load Test Search Endpoint
|
||||
1. Read: K6_ENDPOINTS_SUMMARY.md (🔍 Search section)
|
||||
2. Use: K6_QUICK_START.md (Step 3️⃣ - Search Load Test)
|
||||
3. Run: `k6 run load-tests/search.k6.js`
|
||||
### Công Việc: Load Test Endpoint Search
|
||||
1. Đọc: K6_ENDPOINTS_SUMMARY.md (mục 🔍 Search)
|
||||
2. Sử dụng: K6_QUICK_START.md (Bước 3️⃣ - Search Load Test)
|
||||
3. Chạy: `k6 run load-tests/search.k6.js`
|
||||
|
||||
### Task: Understand Payment Flow
|
||||
1. Read: K6_LOAD_TESTING_GUIDE.md (💳 PAYMENTS MODULE)
|
||||
2. Check: K6_ENDPOINTS_SUMMARY.md (💳 Payments section)
|
||||
3. Use: K6_QUICK_START.md (Step 7️⃣ - Payment Test)
|
||||
### Công Việc: Hiểu Luồng Payment
|
||||
1. Đọc: K6_LOAD_TESTING_GUIDE.md (💳 PAYMENTS MODULE)
|
||||
2. Kiểm tra: K6_ENDPOINTS_SUMMARY.md (mục 💳 Payments)
|
||||
3. Sử dụng: K6_QUICK_START.md (Bước 7️⃣ - Payment Test)
|
||||
|
||||
### Task: Add New Endpoint to Load Tests
|
||||
1. Find endpoint in: K6_LOAD_TESTING_GUIDE.md or K6_ENDPOINTS_SUMMARY.md
|
||||
2. Get data shape from: K6_ENDPOINTS_SUMMARY.md (📊 Key Data Shapes)
|
||||
3. Check auth from: K6_LOAD_TESTING_GUIDE.md (each module section)
|
||||
4. Implement using examples in: K6_QUICK_START.md
|
||||
### Công Việc: Thêm Endpoint Mới Vào Load Tests
|
||||
1. Tìm endpoint trong: K6_LOAD_TESTING_GUIDE.md hoặc K6_ENDPOINTS_SUMMARY.md
|
||||
2. Lấy hình dạng dữ liệu từ: K6_ENDPOINTS_SUMMARY.md (📊 Key Data Shapes)
|
||||
3. Kiểm tra auth từ: K6_LOAD_TESTING_GUIDE.md (mỗi mục module)
|
||||
4. Triển khai sử dụng ví dụ trong: K6_QUICK_START.md
|
||||
|
||||
---
|
||||
|
||||
## ✅ Verification Checklist
|
||||
## ✅ Danh Sách Kiểm Tra Xác Minh
|
||||
|
||||
Before running load tests, verify:
|
||||
Trước khi chạy load test, hãy xác minh:
|
||||
|
||||
- [ ] API running: `pnpm dev` (port 3001)
|
||||
- [ ] Database seeded: `pnpm db:seed`
|
||||
- [ ] K6 installed: `k6 version`
|
||||
- [ ] Can reach API: `curl http://localhost:3001/api/v1/docs`
|
||||
- [ ] ENV variables set: `JWT_SECRET`, `CORS_ORIGINS`, etc.
|
||||
- [ ] Load test file exists: `load-tests/*.k6.js`
|
||||
- [ ] Test data available: Check seed in `prisma/seed.ts`
|
||||
- [ ] API đang chạy: `pnpm dev` (port 3001)
|
||||
- [ ] Database đã seed: `pnpm db:seed`
|
||||
- [ ] K6 đã cài đặt: `k6 version`
|
||||
- [ ] Có thể truy cập API: `curl http://localhost:3001/api/v1/docs`
|
||||
- [ ] Biến ENV đã set: `JWT_SECRET`, `CORS_ORIGINS`, v.v.
|
||||
- [ ] File load test tồn tại: `load-tests/*.k6.js`
|
||||
- [ ] Có sẵn dữ liệu test: Kiểm tra seed trong `prisma/seed.ts`
|
||||
|
||||
---
|
||||
|
||||
## 📞 Support & References
|
||||
## 📞 Hỗ Trợ & Tham Khảo
|
||||
|
||||
### Internal Documentation
|
||||
- **Full Architecture**: K6_LOAD_TESTING_GUIDE.md
|
||||
- **Endpoint Reference**: K6_ENDPOINTS_SUMMARY.md
|
||||
- **Getting Started**: K6_QUICK_START.md
|
||||
### Tài Liệu Nội Bộ
|
||||
- **Kiến Trúc Đầy Đủ**: K6_LOAD_TESTING_GUIDE.md
|
||||
- **Tham Khảo Endpoint**: K6_ENDPOINTS_SUMMARY.md
|
||||
- **Bắt Đầu**: K6_QUICK_START.md
|
||||
|
||||
### External Resources
|
||||
- **K6 Official Docs**: https://k6.io/docs
|
||||
- **K6 API Reference**: https://k6.io/docs/javascript-api
|
||||
- **K6 Community**: https://community.k6.io
|
||||
- **K6 Examples**: https://github.com/grafana/k6-templates
|
||||
### Tài Nguyên Bên Ngoài
|
||||
- **Tài Liệu Chính Thức K6**: https://k6.io/docs
|
||||
- **Tham Khảo K6 API**: https://k6.io/docs/javascript-api
|
||||
- **Cộng Đồng K6**: https://community.k6.io
|
||||
- **Ví Dụ K6**: https://github.com/grafana/k6-templates
|
||||
|
||||
### Project Files
|
||||
### File Dự Án
|
||||
- **API Controllers**: `apps/api/src/modules/*/presentation/controllers/`
|
||||
- **DTOs**: `apps/api/src/modules/*/presentation/dto/`
|
||||
- **E2E Tests**: `e2e/api/`
|
||||
@@ -365,40 +365,39 @@ Before running load tests, verify:
|
||||
|
||||
---
|
||||
|
||||
## 🎓 Learning Path
|
||||
## 🎓 Lộ Trình Học
|
||||
|
||||
### Beginner (30 minutes)
|
||||
1. Read K6_QUICK_START.md (Steps 1-4)
|
||||
2. Install K6
|
||||
3. Run: `k6 run load-tests/search.k6.js`
|
||||
### Người Mới Bắt Đầu (30 phút)
|
||||
1. Đọc K6_QUICK_START.md (Bước 1-4)
|
||||
2. Cài đặt K6
|
||||
3. Chạy: `k6 run load-tests/search.k6.js`
|
||||
|
||||
### Intermediate (1-2 hours)
|
||||
1. Read K6_ENDPOINTS_SUMMARY.md
|
||||
2. Understand auth flows
|
||||
3. Run auth test: `k6 run load-tests/auth.k6.js`
|
||||
4. Run listing test: `k6 run load-tests/listings.k6.js`
|
||||
### Trung Cấp (1-2 giờ)
|
||||
1. Đọc K6_ENDPOINTS_SUMMARY.md
|
||||
2. Hiểu luồng auth
|
||||
3. Chạy test auth: `k6 run load-tests/auth.k6.js`
|
||||
4. Chạy test listing: `k6 run load-tests/listings.k6.js`
|
||||
|
||||
### Advanced (2-4 hours)
|
||||
1. Read K6_LOAD_TESTING_GUIDE.md completely
|
||||
2. Review controller implementations in source
|
||||
3. Create custom load test script
|
||||
4. Set up CI/CD with GitHub Actions (K6_QUICK_START.md Step 🔟)
|
||||
5. Generate and analyze reports
|
||||
### Nâng Cao (2-4 giờ)
|
||||
1. Đọc K6_LOAD_TESTING_GUIDE.md đầy đủ
|
||||
2. Xem xét triển khai controller trong source
|
||||
3. Tạo script load test tùy chỉnh
|
||||
4. Thiết lập CI/CD với GitHub Actions (K6_QUICK_START.md Bước 🔟)
|
||||
5. Tạo và phân tích báo cáo
|
||||
|
||||
---
|
||||
|
||||
## 📝 Notes
|
||||
## 📝 Ghi Chú
|
||||
|
||||
- **No existing K6 setup** — These docs provide complete guidance
|
||||
- **Three complementary docs** — Explore different docs for different needs
|
||||
- **Executable examples** — K6_QUICK_START.md scripts work as-is
|
||||
- **Rate limits matter** — Consider them in test design
|
||||
- **Quota gates** — Some operations (listings, payments) are gated by subscription
|
||||
- **Test data** — Use seed data or generate unique test users per VU
|
||||
- **Production ready** — Guides follow K6 best practices
|
||||
- **Chưa có thiết lập K6 nào** — Tài liệu này cung cấp hướng dẫn đầy đủ
|
||||
- **Ba tài liệu bổ sung cho nhau** — Khám phá các tài liệu khác nhau cho các nhu cầu khác nhau
|
||||
- **Ví dụ chạy được** — Script K6_QUICK_START.md hoạt động ngay
|
||||
- **Rate limit quan trọng** — Hãy xem xét chúng trong thiết kế test
|
||||
- **Quota gate** — Một số thao tác (listings, payments) bị giới hạn theo subscription
|
||||
- **Dữ liệu test** — Sử dụng dữ liệu seed hoặc tạo người dùng test duy nhất cho mỗi VU
|
||||
- **Sẵn sàng cho production** — Hướng dẫn tuân theo các thực hành tốt nhất của K6
|
||||
|
||||
---
|
||||
|
||||
Generated: 2026-04-09
|
||||
Last Updated: K6_QUICK_START.md latest
|
||||
|
||||
Đã tạo: 2026-04-09
|
||||
Cập nhật lần cuối: K6_QUICK_START.md mới nhất
|
||||
|
||||
Reference in New Issue
Block a user