File size: 4,683 Bytes
0021b08
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
# FastAPI Processing Simulator - PowerShell Client Runner
# This script provides easy ways to run the WebSocket client

Write-Host ""
Write-Host "================================================" -ForegroundColor Cyan
Write-Host " FastAPI Processing Simulator - Client Runner" -ForegroundColor Cyan
Write-Host "================================================" -ForegroundColor Cyan
Write-Host ""

# Check if Python is available
try {
    $pythonVersion = python --version 2>$null
    Write-Host "βœ… Found Python: $pythonVersion" -ForegroundColor Green
} catch {
    Write-Host "❌ Error: Python is not installed or not in PATH" -ForegroundColor Red
    Write-Host "Please install Python and try again."
    Read-Host "Press Enter to exit"
    exit 1
}

# Check if websockets module is available
try {
    python -c "import websockets" 2>$null
    if ($LASTEXITCODE -ne 0) {
        throw "websockets not found"
    }
    Write-Host "βœ… WebSockets module is available" -ForegroundColor Green
} catch {
    Write-Host "πŸ“¦ Installing required websockets module..." -ForegroundColor Yellow
    pip install websockets
    if ($LASTEXITCODE -ne 0) {
        Write-Host "❌ Error: Failed to install websockets module" -ForegroundColor Red
        Read-Host "Press Enter to exit"
        exit 1
    }
    Write-Host "βœ… WebSockets module installed successfully" -ForegroundColor Green
}

function Show-Menu {
    Write-Host ""
    Write-Host "Select an option:" -ForegroundColor Yellow
    Write-Host "1. Interactive mode (default)" -ForegroundColor White
    Write-Host "2. Quick test (sample data)" -ForegroundColor White
    Write-Host "3. Stress test (5 concurrent requests)" -ForegroundColor White
    Write-Host "4. Custom automated test" -ForegroundColor White
    Write-Host "5. Show help" -ForegroundColor White
    Write-Host "6. Exit" -ForegroundColor White
    Write-Host ""
}

function Start-InteractiveMode {
    Write-Host ""
    Write-Host "πŸš€ Starting interactive mode..." -ForegroundColor Green
    python client.py --interactive
}

function Start-QuickTest {
    Write-Host ""
    Write-Host "⚑ Running quick test with sample data..." -ForegroundColor Green
    python client.py --folder "sample-folder" --env "production"
    Read-Host "Press Enter to continue"
}

function Start-StressTest {
    Write-Host ""
    Write-Host "πŸ’ͺ Running stress test with 5 concurrent requests..." -ForegroundColor Green
    python client.py --stress 5
    Read-Host "Press Enter to continue"
}

function Start-CustomTest {
    Write-Host ""
    $folder = Read-Host "Enter folder name"
    $env = Read-Host "Enter environment"
    $url = Read-Host "Enter WebSocket URL (or press Enter for default)"
    
    Write-Host ""
    Write-Host "πŸ”§ Running custom test..." -ForegroundColor Green
    
    if ([string]::IsNullOrWhiteSpace($url)) {
        python client.py --folder $folder --env $env
    } else {
        python client.py --url $url --folder $folder --env $env
    }
    Read-Host "Press Enter to continue"
}

function Show-Help {
    Write-Host ""
    Write-Host "πŸ“– Help - Available Commands:" -ForegroundColor Cyan
    Write-Host ""
    Write-Host "Manual Usage:" -ForegroundColor Yellow
    Write-Host "  python client.py --interactive" -ForegroundColor White
    Write-Host "  python client.py --folder 'test' --env 'dev'" -ForegroundColor White
    Write-Host "  python client.py --stress 10" -ForegroundColor White
    Write-Host "  python client.py --url 'ws://other-server:8000/ws' --folder 'data' --env 'prod'" -ForegroundColor White
    Write-Host ""
    Write-Host "Features:" -ForegroundColor Yellow
    Write-Host "  β€’ Interactive mode with menu-driven interface" -ForegroundColor White
    Write-Host "  β€’ Automated testing with custom parameters" -ForegroundColor White
    Write-Host "  β€’ Stress testing with concurrent requests" -ForegroundColor White
    Write-Host "  β€’ Real-time progress monitoring" -ForegroundColor White
    Write-Host "  β€’ Comprehensive error handling" -ForegroundColor White
    Write-Host ""
    Read-Host "Press Enter to continue"
}

# Main loop
do {
    Show-Menu
    $choice = Read-Host "Enter your choice (1-6)"
    
    switch ($choice) {
        "1" { Start-InteractiveMode }
        "2" { Start-QuickTest }
        "3" { Start-StressTest }
        "4" { Start-CustomTest }
        "5" { Show-Help }
        "6" { 
            Write-Host ""
            Write-Host "πŸ‘‹ Goodbye!" -ForegroundColor Green
            exit 0
        }
        "" { Start-InteractiveMode }
        default { 
            Write-Host "❌ Invalid choice. Please try again." -ForegroundColor Red
        }
    }
} while ($true)