# Locust Configuration
# mockupAWS v1.0.0 Performance Testing

# Host Configuration
host = "http://localhost:8000"

# User Distribution
users = [
    {"class": "RegularUser", "weight": 3, "description": "Regular browsing user"},
    {"class": "IngestUser", "weight": 5, "description": "High-volume log ingestion"},
    {"class": "AuthUser", "weight": 1, "description": "Authentication operations"},
    {"class": "AdminUser", "weight": 1, "description": "Admin operations"},
]


# Load Shapes for different test scenarios
class LoadShapes:
    """Predefined load shapes for different test scenarios"""

    @staticmethod
    def steady_100():
        """Steady 100 concurrent users"""
        return {"spawn_rate": 10, "user_count": 100, "duration": "10m"}

    @staticmethod
    def steady_500():
        """Steady 500 concurrent users"""
        return {"spawn_rate": 50, "user_count": 500, "duration": "15m"}

    @staticmethod
    def steady_1000():
        """Steady 1000 concurrent users"""
        return {"spawn_rate": 100, "user_count": 1000, "duration": "20m"}

    @staticmethod
    def spike_test():
        """Spike test: sudden increase to 2000 users"""
        return {
            "stages": [
                {"duration": "2m", "users": 100},
                {"duration": "1m", "users": 2000},
                {"duration": "5m", "users": 2000},
                {"duration": "2m", "users": 0},
            ]
        }

    @staticmethod
    def ramp_up():
        """Gradual ramp up to find breaking point"""
        return {
            "stages": [
                {"duration": "2m", "users": 100},
                {"duration": "2m", "users": 250},
                {"duration": "2m", "users": 500},
                {"duration": "2m", "users": 750},
                {"duration": "2m", "users": 1000},
                {"duration": "2m", "users": 1500},
                {"duration": "2m", "users": 2000},
            ]
        }


# Performance Thresholds
thresholds = {
    "response_time": {
        "p50": 100,  # 50th percentile < 100ms
        "p95": 200,  # 95th percentile < 200ms
        "p99": 500,  # 99th percentile < 500ms
        "max": 2000,  # Max response time < 2s
    },
    "error_rate": {
        "max": 0.01,  # Error rate < 1%
    },
    "throughput": {
        "min_rps": 100,  # Minimum 100 requests per second
    },
}

# CSV Export Configuration
csv_export = {
    "enabled": True,
    "directory": "./reports",
    "filename_prefix": "locust",
    "include_stats": True,
    "include_failures": True,
    "include_exceptions": True,
}

# Web UI Configuration
web_ui = {
    "enabled": True,
    "host": "0.0.0.0",
    "port": 8089,
    "auth": {"enabled": False, "username": "admin", "password": "admin"},
}
