负载测试生成器Skill load-test-generator

负载测试生成器是一个自动化工具,能够根据OpenAPI规范快速生成k6、Locust和Gatling等主流负载测试框架的测试脚本。该技能支持测试场景设计、虚拟用户建模、渐进负载配置、响应时间阈值设置和错误率监控,帮助开发者和测试工程师高效进行性能测试、压力测试和系统稳定性验证。关键词:负载测试、性能测试、OpenAPI、k6脚本、Locust测试、Gatling场景、自动化测试、API测试、压力测试、性能优化。

测试 0 次安装 0 次浏览 更新于 2/26/2026

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
        }
      }
    }
  }
}