test-environment-management について
test-environment-managementは、テスト環境の構築と運用に使うスキルです。コンテナ化、本番環境との同等性、外部サービスのモック、定時停止などのコスト管理を扱います。
主な機能
- 01環境種別の定義
- 02Dockerによる再現性の確保
- 03本番環境との同等性の確認
- 04外部サービスのモック化
- 05定時停止によるコスト管理
活用シーン
- 01一貫性のあるテスト基盤の構築
- 02環境固有の障害の調査
- 03外部サービスに依存しないテスト
- 04テスト基盤コストの管理
インストール
コマンドをコピーしてターミナルで実行します。
$
npx skills add https:/ / github.com/ proffesor-for-testing/ agentic-qe --skill test-environment-managementインストール後、Claude Code で/test-environment-managementを入力して読み込まれたか確認します。
同梱ファイルschemas/output.json
詳細
テスト環境の管理
<default_to_action> テスト環境を管理する際は、次の手順に従います。
- 環境の種類(ローカル、CI、ステージング、本番)を定義します
- 一貫性を保つため、Docker でコンテナ化します
- 本番環境と同じバージョン、設定にして同等性を確保します
- 外部サービスをモックします(サービス仮想化)
- 自動シャットダウンやスポットインスタンスを活用してコストを最適化します
環境のクイックチェックリスト:
- 本番環境と同じ OS/バージョン
- 本番環境と同じデータベースの種類とバージョン
- 本番環境と同じ設定構造
- 再現性を確保するためのコンテナ
- 数時間後の自動シャットダウン
成功のための重要な要素:
- 「自分のマシンでは動く」=環境の不一致
- Infrastructure as Code =再現可能な環境
- サービス仮想化=外部依存なしでのテスト </default_to_action>
クイックリファレンスカード
使用する場面
- テストインフラのセットアップ
- 環境固有の障害のデバッグ
- テストインフラのコスト削減
- 開発環境と本番環境の同等性の確保
テスト環境用の Docker
# 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
コンテナ内でテストを実行:
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
サービス仮想化
// 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
コストの最適化
# 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)
スポットインスタンスを使用(70%削減):
resource "aws_instance" "test_runner" {
instance_type = "c5.2xlarge"
instance_market_options {
market_type = "spot"
spot_options {
max_price = "0.10"
}
}
}
エージェント主導の環境管理
// 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");
エージェント連携のヒント
メモリ名前空間
aqe/environment-management/
├── configs/* - Environment configurations
├── parity-checks/* - Dev/prod parity results
├── cost-reports/* - Infrastructure costs
└── service-mocks/* - Service virtualization configs
フリート連携
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'
});
関連スキル
- テストデータ管理 - 環境用のデータ
- 継続的テストのシフトレフト - CI/CD 環境
- カオスエンジニアリングによるレジリエンス - 環境のレジリエンス
覚えておくこと
エージェントを使用する場合: エージェントは、本番環境に一致するテスト環境を自動的にプロビジョニングし、同等性を確保して外部サービスをモックし、自動スケーリングと自動シャットダウンによってコストを最適化します。
コメント
Markdown 対応