sqlite-web 0.7.2
gitea.db
action_run_job
Create
Query
access
access_token
action
action_artifact
action_run
action_run_index
action_run_job
action_runner
action_runner_token
action_schedule
action_schedule_spec
action_task
action_task_output
action_task_step
action_tasks_version
action_variable
app_state
attachment
auth_token
badge
branch
collaboration
comment
commit_status
commit_status_index
commit_status_summary
commit_sync_log
commit_sync_status
dbfs_data
dbfs_meta
deploy_key
email_address
email_hash
external_login_user
follow
gpg_key
gpg_key_import
hook_task
issue
issue_assignees
issue_content_history
issue_dependency
issue_index
issue_label
issue_pin
issue_user
issue_watch
label
language_stat
lfs_lock
lfs_meta_object
login_source
milestone
mirror
notice
notification
oauth2_application
oauth2_authorization_code
oauth2_grant
org_user
package
package_blob
package_blob_upload
package_cleanup_rule
package_file
package_property
package_version
project
project_board
project_issue
protected_branch
protected_tag
public_key
pull_auto_merge
pull_request
push_mirror
reaction
release
renamed_branch
repo_archiver
repo_hidden_file
repo_indexer_status
repo_license
repo_redirect
repo_topic
repo_transfer
repo_unit
repository
review
review_state
secret
session
sqlite_sequence
star
stopwatch
system_setting
task
team
team_invite
team_repo
team_unit
team_user
topic
tracked_time
two_factor
upload
user
user_badge
user_blocking
user_open_id
user_redirect
user_setting
version
watch
webauthn_credential
webhook
Toggle helper tables
Structure
Content
Query
Insert
Drop
Import
Export
Delete row 12935 from action_run_job
id
12935
run_id
9521
repo_id
6
owner_id
5
commit_sha
58e5152a38868b8f3832d9573c340a3eb60051c8
is_fork_pull_request
0
name
🔥 负载测试
attempt
1
workflow_payload
name: Performance Tests "on": # 每周一凌晨
name: Performance Tests "on": # 每周一凌晨 2 点运行 schedule: - cron: '0 2 * * 1' # 允许手动触发 workflow_dispatch: inputs: test_type: description: '测试类型' required: true default: 'benchmark' type: choice options: - benchmark - load - stress - all duration: description: '测试持续时间(秒)' required: false default: '60' type: string concurrency: description: '并发数' required: false default: '10' type: string # PR 触发时只运行基准测试 pull_request: branches: [main] paths: - 'backend/src/**' - 'backend/prisma/**' env: NODE_VERSION: "18" PNPM_VERSION: "8" jobs: load-test: name: "\U0001F525 负载测试" runs-on: ubuntu-latest if: needs.setup.outputs.test_type == 'load' || needs.setup.outputs.test_type == 'all' steps: - name: "\U0001F4E5 检出代码" uses: actions/checkout@v4 - name: "\U0001F4E6 安装 pnpm" uses: pnpm/action-setup@v2 with: version: ${{ env.PNPM_VERSION }} - name: "\U0001F7E2 设置 Node.js" uses: actions/setup-node@v4 with: cache: pnpm node-version: ${{ env.NODE_VERSION }} - name: "\U0001F4E6 安装依赖" run: pnpm install --frozen-lockfile - name: "\U0001F527 安装 k6" run: | sudo gpg -k sudo gpg --no-default-keyring --keyring /usr/share/keyrings/k6-archive-keyring.gpg --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys C5AD17C747E3415A3642D57D77C6C491D6AC1D69 echo "deb [signed-by=/usr/share/keyrings/k6-archive-keyring.gpg] https://dl.k6.io/deb stable main" | sudo tee /etc/apt/sources.list.d/k6.list sudo apt-get update sudo apt-get install k6 - name: "\U0001F5C4️ 初始化数据库" run: | cd backend npx prisma migrate deploy npx prisma db seed env: DATABASE_URL: postgresql://test:test@localhost:5432/juhi_load - name: "\U0001F528 构建后端" run: | pnpm --filter shared build pnpm --filter backend build - name: "\U0001F680 启动后端服务" run: | cd backend npm run start & sleep 10 env: NODE_ENV: production PORT: 3000 DATABASE_URL: postgresql://test:test@localhost:5432/juhi_load REDIS_URL: redis://localhost:6379 JWT_SECRET: load-test-jwt-secret REFRESH_TOKEN_SECRET: load-test-refresh-token - name: ⏳ 等待服务就绪 run: | timeout 60 bash -c 'until curl -s http://localhost:3000/health > /dev/null; do sleep 2; done' - name: "\U0001F525 运行负载测试" run: | mkdir -p load-test-results # 创建 k6 负载测试脚本 cat > load-test.js << 'EOF' import http from 'k6/http'; import { check, sleep } from 'k6'; import { Rate, Trend } from 'k6/metrics'; const errorRate = new Rate('errors'); const responseTime = new Trend('response_time'); export const options = { stages: [ { duration: '30s', target: 10 }, // 预热 { duration: '1m', target: 50 }, // 逐步增加 { duration: '2m', target: 50 }, // 稳定负载 { duration: '30s', target: 0 }, // 降低 ], thresholds: { http_req_duration: ['p(95)<500'], // 95% 请求小于 500ms errors: ['rate<0.1'], // 错误率小于 10% }, }; const BASE_URL = 'http://localhost:3000'; export default function () { // 健康检查 let healthRes = http.get(`${BASE_URL}/health`); check(healthRes, { 'health check ok': (r) => r.status === 200 }); // 列表接口 let listRes = http.get(`${BASE_URL}/api/leads?page=1&pageSize=20`, { headers: { 'Authorization': 'Bearer test-token', 'Content-Type': 'application/json', }, }); errorRate.add(listRes.status !== 200 && listRes.status !== 401); responseTime.add(listRes.timings.duration); sleep(0.1); } EOF k6 run --out json=load-test-results/results.json load-test.js - name: "\U0001F4CA 分析负载测试结果" run: "echo \"## \U0001F525 负载测试报告\" >> $GITHUB_STEP_SUMMARY\necho \"\" >> $GITHUB_STEP_SUMMARY\n\nif [ -f \"load-test-results/results.json\" ]; then\n echo \"### 关键指标\" >> $GITHUB_STEP_SUMMARY\n echo \"| 指标 | 值 |\" >> $GITHUB_STEP_SUMMARY\n echo \"|------|------|\" >> $GITHUB_STEP_SUMMARY\n\n # 提取关键指标\n avg_duration=$(cat load-test-results/results.json | jq -s '[.[] | select(.type==\"Point\" and .metric==\"http_req_duration\") | .data.value] | add / length' 2>/dev/null || echo \"N/A\")\n p95_duration=$(cat load-test-results/results.json | jq -s '[.[] | select(.type==\"Point\" and .metric==\"http_req_duration\") | .data.value] | sort | .[length * 0.95 | floor]' 2>/dev/null || echo \"N/A\")\n total_requests=$(cat load-test-results/results.json | jq -s '[.[] | select(.type==\"Point\" and .metric==\"http_reqs\")] | length' 2>/dev/null || echo \"N/A\")\n\n echo \"| 平均响应时间 | ${avg_duration}ms |\" >> $GITHUB_STEP_SUMMARY\n echo \"| P95 响应时间 | ${p95_duration}ms |\" >> $GITHUB_STEP_SUMMARY\n echo \"| 总请求数 | $total_requests |\" >> $GITHUB_STEP_SUMMARY\nfi\n" - name: "\U0001F4E4 上传负载测试结果" uses: actions/upload-artifact@v4 with: name: load-test-results path: load-test-results/ retention-days: "30" timeout-minutes: "45" services: postgres: image: postgres:15 env: POSTGRES_DB: juhi_load POSTGRES_PASSWORD: test POSTGRES_USER: test ports: - 5432:5432 options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5 redis: image: redis:7 ports: - 6379:6379
...
job_id
load-test
needs
["setup"]
runs_on
["ubuntu-latest"]
task_id
10933
status
2
started
1774836434
stopped
1774836525
created
1774836018
updated
1774836525
raw_concurrency
is_concurrency_evaluated
1
concurrency_group
concurrency_cancel
0
Delete
Cancel