# Integration Test Configuration
# Defines test environment settings for OrbStack machine "provisioning"

version: "1.0.0"

# OrbStack connection details
orbstack:
  machine_name: "provisioning"
  connection:
    type: "docker"  # OrbStack uses Docker API
    socket: "/var/run/docker.sock"

  resources:
    cpu_cores: 4
    memory_mb: 8192
    disk_gb: 100

  network:
    subnet: "172.20.0.0/16"
    gateway: "172.20.0.1"
    dns: ["172.20.0.2"]  # CoreDNS

# Test workspace configuration
test_workspace:
  name: "test-workspace"
  path: "/tmp/provisioning-test-workspace"
  auto_cleanup: true

  config:
    provider: "local"
    region: "local"
    environment: "test"

# Platform service endpoints (deployed on OrbStack)
services:
  orchestrator:
    host: "172.20.0.10"
    port: 8080
    health_endpoint: "/health"

  coredns:
    host: "172.20.0.2"
    port: 53
    protocol: "udp"

  oci_registry:
    # Zot for solo/multi-user modes
    zot:
      host: "172.20.0.20"
      port: 5000
      ui_port: 5001

    # Harbor for enterprise mode
    harbor:
      host: "172.20.0.21"
      port: 443
      ui_port: 80

  gitea:
    host: "172.20.0.30"
    port: 3000
    ssh_port: 2222

  postgres:
    host: "172.20.0.40"
    port: 5432
    database: "provisioning"
    username: "provisioning"

  prometheus:
    host: "172.20.0.50"
    port: 9090

  grafana:
    host: "172.20.0.51"
    port: 3001

# Test data definitions
test_data:
  users:
    - username: "admin"
      email: "admin@test.local"
      role: "admin"
      password_hash: "test123"

    - username: "developer"
      email: "dev@test.local"
      role: "developer"
      password_hash: "test123"

    - username: "viewer"
      email: "viewer@test.local"
      role: "viewer"
      password_hash: "test123"

    - username: "operator"
      email: "ops@test.local"
      role: "operator"
      password_hash: "test123"

  workspaces:
    - name: "dev-workspace"
      owner: "developer"
      environment: "dev"

    - name: "prod-workspace"
      owner: "operator"
      environment: "prod"

  extensions:
    taskservs:
      - name: "kubernetes"
        version: "1.28.0"
        source: "oci"

      - name: "containerd"
        version: "1.7.0"
        source: "oci"

      - name: "postgres"
        version: "15.0"
        source: "gitea"

    providers:
      - name: "aws"
        version: "1.0.0"
        source: "local"

      - name: "upcloud"
        version: "1.0.0"
        source: "local"

    clusters:
      - name: "buildkit"
        version: "1.0.0"
        source: "gitea"

# Test execution settings
test_execution:
  parallel:
    enabled: true
    max_workers: 4

  timeouts:
    test_timeout_seconds: 300
    setup_timeout_seconds: 600
    teardown_timeout_seconds: 300

  retries:
    max_retries: 3
    retry_delay_seconds: 5
    retry_backoff_multiplier: 2.0

  cleanup:
    auto_cleanup_on_success: true
    auto_cleanup_on_failure: false  # Keep for debugging
    cleanup_timeout_seconds: 120

# Test reporting
reporting:
  output_dir: "/tmp/provisioning-test-reports"
  formats:
    - "junit"
    - "html"
    - "json"

  junit:
    filename: "junit-results.xml"

  html:
    filename: "test-report.html"
    template: "default"

  json:
    filename: "test-results.json"
    pretty: true

# Mode-specific configurations
modes:
  solo:
    services:
      - "orchestrator"
      - "coredns"
      - "oci_registry"  # Zot

    features:
      multi_user: false
      rbac: false
      audit_logging: false
      kms: false
      monitoring: false

  multiuser:
    services:
      - "orchestrator"
      - "coredns"
      - "oci_registry"  # Zot
      - "gitea"
      - "postgres"

    features:
      multi_user: true
      rbac: true
      audit_logging: false
      kms: false
      monitoring: false

  cicd:
    services:
      - "orchestrator"
      - "coredns"
      - "oci_registry"  # Zot
      - "gitea"
      - "postgres"

    features:
      multi_user: true
      rbac: true
      audit_logging: true
      kms: false
      monitoring: true
      api_server: true

  enterprise:
    services:
      - "orchestrator"
      - "coredns"
      - "oci_registry"  # Harbor
      - "gitea"
      - "postgres"
      - "prometheus"
      - "grafana"
      - "kms"
      - "elasticsearch"

    features:
      multi_user: true
      rbac: true
      audit_logging: true
      kms: true
      monitoring: true
      api_server: true
      harbor_registry: true

# Performance test settings
performance:
  concurrency_tests:
    concurrent_server_creations: 10
    concurrent_dns_registrations: 20
    concurrent_workflow_submissions: 5

  scalability_tests:
    max_servers: 100
    max_dns_records: 100
    max_oci_artifacts: 1000

  benchmarks:
    server_creation_target_seconds: 30
    taskserv_installation_target_seconds: 60
    dns_registration_target_seconds: 5

# Security test settings
security:
  rbac_tests:
    test_unauthorized_access: true
    test_role_permissions: true
    test_workspace_isolation: true

  kms_tests:
    test_ssh_key_storage: true
    test_key_rotation: true
    test_audit_logging: true

# Logging configuration
logging:
  level: "info"  # debug, info, warn, error
  output: "file"  # file, stdout, both
  file_path: "/tmp/provisioning-test.log"
  rotation:
    enabled: true
    max_size_mb: 100
    max_files: 5
