name: load-test-generator description: 从OpenAPI规范生成k6、Locust和Gatling的负载测试脚本 allowed-tools:
- Bash
- Read
- Write
- Glob
负载测试生成器技能
概述
根据OpenAPI规范生成k6、Locust和Gatling的负载测试脚本,包括测试场景和性能验证模式。
能力
- 生成k6负载测试脚本
- 生成Locust测试
- 创建Gatling场景
- 从OpenAPI规范生成测试场景
- 配置渐进/渐退模式
- 配置思考时间
- 虚拟用户建模
- 阈值配置
目标流程
- 性能优化
- 弹性模式
- 迁移策略
输入模式
{
"type": "object",
"required": ["scenarios"],
"properties": {
"scenarios": {
"type": "array",
"items": {
"type": "object",
"properties": {
"name": { "type": "string" },
"endpoints": { "type": "array" },
"load": {
"type": "object",
"properties": {
"vus": { "type": "number" },
"duration": { "type": "string" },
"rampUp": { "type": "string" }
}
}
}
}
},
"framework": {
"type": "string",
"enum": ["k6", "locust", "gatling", "artillery"],
"default": "k6"
},
"openapiSpec": {
"type": "string",
"description": "用于自动生成的OpenAPI规范路径"
},
"options": {
"type": "object",
"properties": {
"thresholds": {
"type": "object",
"properties": {
"p95ResponseTime": { "type": "number" },
"errorRate": { "type": "number" }
}
},
"thinkTime": {
"type": "object",
"properties": {
"min": { "type": "number" },
"max": { "type": "number" }
}
},
"dataFile": {
"type": "string",
"description": "测试数据CSV文件路径"
}
}
}
}
}
输出模式
{
"type": "object",
"properties": {
"scripts": {
"type": "array",
"items": {
"type": "object",
"properties": {
"name": { "type": "string" },
"path": { "type": "string" },
"framework": { "type": "string" }
}
}
},
"configFile": {
"type": "string"
},
"runCommand": {
"type": "string"
},
"thresholds": {
"type": "object"
}
}
}
使用示例
{
kind: 'skill',
skill: {
name: 'load-test-generator',
context: {
scenarios: [
{
name: 'smoke-test',
endpoints: ['/api/health', '/api/users'],
load: { vus: 10, duration: '1m', rampUp: '10s' }
}
],
framework: 'k6',
options: {
thresholds: {
p95ResponseTime: 500,
errorRate: 0.01
}
}
}
}
}