test-environment-management
关于
This Claude Skill manages test infrastructure using infrastructure as code, Docker/Kubernetes for consistent environments, and service virtualization. It helps developers ensure environment parity with production and optimize testing costs through auto-shutdown and spot instances. Use it when provisioning test environments or managing testing infrastructure.
快速安装
Claude Code
推荐/plugin add https://github.com/proffesor-for-testing/agentic-qegit clone https://github.com/proffesor-for-testing/agentic-qe.git ~/.claude/skills/test-environment-management在 Claude Code 中复制并粘贴此命令以安装该技能
技能文档
Test Environment Management
<default_to_action> When managing test environments:
- DEFINE environment types (local, CI, staging, prod)
- CONTAINERIZE with Docker for consistency
- ENSURE parity with production (same versions, configs)
- MOCK external services (service virtualization)
- OPTIMIZE costs (auto-shutdown, spot instances)
Quick Environment Checklist:
- Same OS/versions as production
- Same database type and version
- Same configuration structure
- Containers for reproducibility
- Auto-shutdown after hours
Critical Success Factors:
- "Works on my machine" = environment inconsistency
- Infrastructure as Code = repeatable environments
- Service virtualization = test without external dependencies </default_to_action>
Quick Reference Card
When to Use
- Setting up test infrastructure
- Debugging environment-specific failures
- Reducing test infrastructure costs
- Ensuring dev/prod parity
Environment Types
| Type | Purpose | Lifetime |
|---|---|---|
| Local | Fast feedback | Developer session |
| CI | Automated tests | Per build (ephemeral) |
| Staging | Pre-prod validation | Persistent |
| Production | Canary/synthetic | Continuous |
Dev/Prod Parity Checklist
| Item | Must Match |
|---|---|
| OS | Same version |
| Database | Same type + version |
| Dependencies | Same versions |
| Config | Same structure |
| Env vars | Same names |
Docker for Test Environments
# docker-compose.test.yml
version: '3.8'
services:
app:
build: .
ports:
- "3000:3000"
environment:
NODE_ENV: test
DATABASE_URL: postgres://postgres:password@db:5432/test
depends_on:
- db
- redis
db:
image: postgres:15
environment:
POSTGRES_DB: test
POSTGRES_PASSWORD: password
redis:
image: redis:7
Run tests in container:
docker-compose -f docker-compose.test.yml up -d
docker-compose -f docker-compose.test.yml exec app npm test
docker-compose -f docker-compose.test.yml down
Infrastructure as Code
# test-environment.tf
resource "aws_instance" "test_server" {
ami = "ami-0c55b159cbfafe1f0"
instance_type = "t3.medium"
tags = {
Name = "test-environment"
Environment = "test"
AutoShutdown = "20:00" # Cost optimization
}
}
resource "aws_rds_instance" "test_db" {
engine = "postgres"
engine_version = "15"
instance_class = "db.t3.micro"
backup_retention_period = 0 # No backups needed for test
skip_final_snapshot = true
}
Service Virtualization
// Mock external services with WireMock
import { WireMock } from 'wiremock-captain';
const wiremock = new WireMock('http://localhost:8080');
// Mock payment gateway
await wiremock.register({
request: {
method: 'POST',
url: '/charge'
},
response: {
status: 200,
jsonBody: { transactionId: '12345', status: 'approved' }
}
});
// Tests use mock instead of real gateway
Cost Optimization
# Auto-shutdown test environments after hours
0 20 * * * aws ec2 stop-instances --instance-ids $(aws ec2 describe-instances \
--filters "Name=tag:Environment,Values=test" \
--query "Reservations[].Instances[].InstanceId" --output text)
# Start before work hours
0 7 * * 1-5 aws ec2 start-instances --instance-ids $(aws ec2 describe-instances \
--filters "Name=tag:Environment,Values=test" \
--query "Reservations[].Instances[].InstanceId" --output text)
Use spot instances (70% savings):
resource "aws_instance" "test_runner" {
instance_type = "c5.2xlarge"
instance_market_options {
market_type = "spot"
spot_options {
max_price = "0.10"
}
}
}
Agent-Driven Environment Management
// Provision test environment
await Task("Environment Provisioning", {
type: 'integration-testing',
services: ['app', 'db', 'redis', 'mocks'],
parity: 'production',
lifetime: '2h'
}, "qe-test-executor");
// Chaos testing in isolated environment
await Task("Chaos Test Environment", {
baseline: 'staging',
isolate: true,
injectFaults: ['network-delay', 'pod-failure']
}, "qe-chaos-engineer");
Agent Coordination Hints
Memory Namespace
aqe/environment-management/
├── configs/* - Environment configurations
├── parity-checks/* - Dev/prod parity results
├── cost-reports/* - Infrastructure costs
└── service-mocks/* - Service virtualization configs
Fleet Coordination
const envFleet = await FleetManager.coordinate({
strategy: 'environment-management',
agents: [
'qe-test-executor', // Provision environments
'qe-performance-tester', // Environment performance
'qe-chaos-engineer' // Resilience testing
],
topology: 'sequential'
});
Related Skills
- test-data-management - Data for environments
- continuous-testing-shift-left - CI/CD environments
- chaos-engineering-resilience - Environment resilience
Remember
Environment inconsistency = flaky tests. "Works on my machine" problems come from: different OS/versions, missing dependencies, configuration differences, data differences.
Infrastructure as Code ensures repeatability. Version control your environment configurations. Spin up identical environments on demand.
With Agents: Agents automatically provision test environments matching production, ensure parity, mock external services, and optimize costs with auto-scaling and auto-shutdown.
GitHub 仓库
相关推荐技能
regression-testing
其他该Skill提供智能化的回归测试策略,帮助开发者在验证代码修复时确保现有功能不被破坏。它通过变更影响分析和风险评估,智能选择测试用例并优化执行顺序,避免全量测试的时间消耗。适用于CI/CD流程中的测试套件规划、变更验证和快速反馈场景,能显著提升回归测试效率。
localization-testing
其他该Skill为全球化产品提供国际化和本地化测试,特别适用于发布新市场或构建多语言产品。它能验证翻译覆盖、测试本地格式(日期/货币)、检查RTL布局和字符编码,并评估文化适应性。开发者可通过它系统检测本地化问题,确保产品符合不同区域的要求。
mutation-testing
其他该Skill通过变异测试评估测试套件的有效性,自动生成代码变异并计算杀灭率来验证测试质量。它适用于识别薄弱测试、证明测试能真正捕获bug,以及提升测试覆盖的可靠性。关键能力包括执行变异分析、定位存活变异,并提供具体的测试强化指导。
mobile-testing
其他该Skill为移动应用提供全面的测试支持,涵盖iOS和Android平台。它专门处理移动端特有场景,如手势操作、传感器、权限及设备碎片化测试,适用于原生应用、混合应用和移动网页。通过定义设备覆盖矩阵和使用真机测试,帮助开发者在1000+设备变体上保障应用质量。
