mcpField
Q
qe-chaos-resilience

qe-chaos-resilience

github.com/proffesor-for-testing测试与质量51987 次安装今天更新
代码仓库

关于 qe-chaos-resilience

qe-chaos-resilience 是指导使用 v3 混沌工程能力的 Agent 技能,面向韧性、负载和灾难恢复测试。它涵盖故障注入、压力测试、韧性验证及安全控制。

主要功能

  1. 01受控故障注入
  2. 02负载与压力测试
  3. 03韧性场景验证
  4. 04灾难恢复测试
  5. 05安全边界与中止条件
  6. 06SLA 验证

适用场景

  1. 01测试网络延迟下的服务表现
  2. 02寻找端点的负载极限
  3. 03验证数据库故障转移与恢复
  4. 04检查服务是否符合 SLA

安装

复制下面的命令,在终端中运行。

$npx skills add https://github.com/proffesor-for-testing/agentic-qe --skill qe-chaos-resilience

安装后在 Claude Code 中输入/qe-chaos-resilience确认已加载。

包含的文件

除 SKILL.md 外,安装时一起下载的参考资料和脚本。

evals/
qe-chaos-resilience.yaml
schemas/
output.json
scripts/
validate-config.json

详细介绍

QE 混沌韧性

目的

指导如何使用 v3 的混沌工程能力,包括受控故障注入、负载/压力测试、韧性验证和灾难恢复测试。

激活条件

  • 测试系统韧性时
  • 执行混沌实验时
  • 进行负载/压力测试时
  • 验证灾难恢复时
  • 测试断路器时

快速入门

# Run chaos experiment
aqe chaos run --experiment network-latency --target api-service

# Load test
aqe chaos load --scenario peak-traffic --duration 30m

# Stress test to breaking point
aqe chaos stress --endpoint /api/users --max-users 10000

# Test circuit breaker
aqe chaos circuit-breaker --service payment-service

Agent 工作流

// Chaos experiment
Task("Run chaos experiment", `
  Execute controlled chaos on api-service:
  - Inject 500ms network latency
  - Monitor service health metrics
  - Verify circuit breaker activation
  - Measure recovery time
  - Document findings
`, "qe-chaos-engineer")

// Load testing
Task("Performance load test", `
  Run load test simulating Black Friday traffic:
  - Ramp up to 10,000 concurrent users
  - Maintain load for 30 minutes
  - Monitor response times and error rates
  - Identify bottlenecks
  - Compare against SLAs
`, "qe-load-tester")

混沌实验

1. 故障注入
await chaosEngineer.injectFault({
  target: 'api-service',
  fault: {
    type: 'latency',
    parameters: {
      delay: '500ms',
      jitter: '100ms',
      percentage: 50
    }
  },
  duration: '5m',
  monitoring: {
    metrics: ['response_time', 'error_rate', 'throughput'],
    alerts: true
  },
  rollback: {
    automatic: true,
    trigger: 'error_rate > 10%'
  }
});
2. 负载测试
await loadTester.execute({
  scenario: 'peak-traffic',
  profile: {
    rampUp: '5m',
    steadyState: '30m',
    rampDown: '5m'
  },
  users: {
    initial: 100,
    target: 5000,
    pattern: 'linear'
  },
  assertions: {
    p95_latency: '<500ms',
    error_rate: '<1%',
    throughput: '>1000rps'
  }
});
3. 压力测试
await loadTester.stressTest({
  endpoint: '/api/checkout',
  strategy: 'step-increase',
  steps: [100, 500, 1000, 2000, 5000],
  stepDuration: '5m',
  findBreakingPoint: true,
  monitoring: {
    resourceUtilization: true,
    databaseConnections: true,
    memoryUsage: true
  }
});
4. 韧性验证
await resilienceTester.validate({
  scenarios: [
    'database-failover',
    'cache-failure',
    'external-service-timeout',
    'pod-termination'
  ],
  expectations: {
    gracefulDegradation: true,
    automaticRecovery: true,
    dataIntegrity: true,
    recoveryTime: '<30s'
  }
});

故障类型

故障描述用例
延迟增加网络延迟测试超时
丢包丢弃网络数据包测试重试逻辑
CPU 压力占用 CPU测试资源限制
内存压力占用内存测试 OOM 处理
磁盘已满填满磁盘空间测试磁盘错误
终止进程终止进程测试恢复

混沌报告

interface ChaosReport {
  experiment: {
    name: string;
    target: string;
    fault: FaultConfig;
    duration: number;
  };
  results: {
    hypothesis: string;
    validated: boolean;
    metrics: {
      before: MetricSnapshot;
      during: MetricSnapshot;
      after: MetricSnapshot;
    };
    events: ChaosEvent[];
    recovery: {
      detected: boolean;
      time: number;
      automatic: boolean;
    };
  };
  findings: {
    severity: 'critical' | 'high' | 'medium' | 'low';
    description: string;
    recommendation: string;
  }[];
  artifacts: {
    logs: string;
    metrics: string;
    traces: string;
  };
}

安全控制

safety:
  blast_radius:
    max_affected_pods: 1
    max_affected_percentage: 10

  abort_conditions:
    - error_rate > 50%
    - p99_latency > 10s
    - service_unavailable

  excluded_environments:
    - production-critical

  required_approvals:
    production: 2
    staging: 0

SLA 验证

await resilienceTester.validateSLA({
  slas: {
    availability: 99.9,
    p95_latency: 500,
    error_rate: 0.1
  },
  period: '30d',
  report: {
    breaches: true,
    trends: true,
    projections: true
  }
});

协作

主要 Agent:qe-chaos-engineer、qe-load-tester、qe-resilience-tester 协调器:qe-chaos-coordinator 相关技能:qe-performance、security-testing

评论

支持 Markdown