mcpField
Q
qe-test-environment-management

qe-test-environment-management

github.com/proffesor-for-testingテスト・品質51983 回インストール今日更新
リポジトリ

qe-test-environment-management について

ローカル、CI、ステージング、本番相当のテスト環境を計画・管理するスキルです。再現性、本番環境との整合、外部サービスのモック、インフラコストの管理を扱います。

主な機能

  1. 01環境タイプの定義
  2. 02Dockerによる再現性確保
  3. 03本番環境との整合確認
  4. 04外部サービスのモック
  5. 05インフラコストの削減

活用シーン

  1. 01テスト基盤のセットアップ
  2. 02環境固有の障害の調査
  3. 03開発環境と本番環境の整合
  4. 04テスト環境コストの削減

インストール

コマンドをコピーしてターミナルで実行します。

$npx skills add https://github.com/proffesor-for-testing/agentic-qe --skill qe-test-environment-management

インストール後、Claude Code で/qe-test-environment-managementを入力して読み込まれたか確認します。

詳細

テスト環境の管理

<default_to_action> テスト環境を管理する際は、次の手順に従います。

  1. 環境の種類(ローカル、CI、ステージング、本番)を定義します
  2. Docker でコンテナ化し、一貫性を確保します
  3. 本番環境との同等性を確保します(同じバージョン、設定)
  4. 外部サービスをモック化します(サービス仮想化)
  5. コストを最適化します(自動シャットダウン、スポットインスタンス)

環境のクイックチェックリスト:

  • 本番環境と同じ OS/バージョン
  • 同じデータベースの種類とバージョン
  • 同じ設定構成
  • 再現性を確保するためのコンテナ
  • 数時間後の自動シャットダウン

成功に欠かせない要素:

  • 「自分のマシンでは動く」=環境の不一致
  • Infrastructure as Code =再現可能な環境
  • サービス仮想化=外部依存なしでのテスト

</default_to_action>

クイックリファレンスカード

使用する場面
  • テストインフラストラクチャのセットアップ
  • 環境固有の障害のデバッグ
  • テストインフラストラクチャのコスト削減
  • 開発環境と本番環境の同等性の確保
環境の種類
種類目的存続期間
ローカル迅速なフィードバック開発者のセッション
CI自動テストビルドごと(一時的)
ステージング本番前の検証継続的
本番カナリア/合成テスト継続的
開発環境/本番環境の同等性チェックリスト
項目一致させる内容
OS同じバージョン
データベース同じ種類+バージョン
依存関係同じバージョン
設定同じ構成
環境変数同じ名前

テスト環境向けの 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

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
}

サービス仮想化

// 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'
});

関連スキル


覚えておくこと

環境の不一致=不安定なテストです。「自分のマシンでは動く」という問題は、OS/バージョンの違い、依存関係の不足、設定の違い、データの違いに起因します。

**Infrastructure as Code は再現性を確保します。**環境設定をバージョン管理します。必要に応じて同一の環境を立ち上げられます。

**エージェントを活用する場合:**エージェントは本番環境に一致するテスト環境を自動的にプロビジョニングし、同等性を確保し、外部サービスをモック化して、自動スケーリングと自動シャットダウンでコストを最適化します。

コメント