- Added comprehensive CT109 E2E test documentation - All tests passing: LittleShop (✅), SilverPay (✅), Payment creation (✅) - Performance fix verified: 65ms bot activity tracking - BTC payment successfully created: 0.00214084 BTC - Triggering CI/CD to deploy TeleBot with configured bot token Test Results: 100% pass rate (12/12 tests) Trading Status: Ready for operations Bot Token: 8254383681:AAE_j4cUIP9ABVE4Pqrmtgjfmqq1yc4Ow5A 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
320 lines
13 KiB
PowerShell
320 lines
13 KiB
PowerShell
# E2E Integration Test for CT109 Pre-Production
|
||
# Tests LittleShop + TeleBot + SilverPay on CT109 deployment
|
||
|
||
$ErrorActionPreference = "Stop"
|
||
$ct109BaseUrl = "http://10.0.0.51:5100"
|
||
$teleBotUrl = "http://10.0.0.51:5010"
|
||
$silverPayUrl = "http://10.0.0.51:5500"
|
||
|
||
Write-Host "============================================" -ForegroundColor Cyan
|
||
Write-Host "CT109 PRE-PRODUCTION E2E TEST" -ForegroundColor Cyan
|
||
Write-Host "============================================" -ForegroundColor Cyan
|
||
Write-Host "Target: $ct109BaseUrl" -ForegroundColor Gray
|
||
Write-Host ""
|
||
|
||
# Test results tracking
|
||
$testResults = @{
|
||
Passed = 0
|
||
Failed = 0
|
||
Total = 0
|
||
Tests = @()
|
||
}
|
||
|
||
function Test-Endpoint {
|
||
param(
|
||
[string]$Name,
|
||
[string]$Url,
|
||
[string]$Method = "GET",
|
||
[object]$Body = $null,
|
||
[hashtable]$Headers = @{}
|
||
)
|
||
|
||
$testResults.Total++
|
||
$startTime = Get-Date
|
||
|
||
try {
|
||
Write-Host "[$($testResults.Total)] Testing: $Name" -ForegroundColor Yellow
|
||
|
||
$params = @{
|
||
Uri = $Url
|
||
Method = $Method
|
||
Headers = $Headers
|
||
TimeoutSec = 10
|
||
}
|
||
|
||
if ($Body) {
|
||
$params.Body = ($Body | ConvertTo-Json -Depth 10)
|
||
$params.ContentType = "application/json"
|
||
}
|
||
|
||
$response = Invoke-WebRequest @params
|
||
$elapsed = (Get-Date) - $startTime
|
||
|
||
if ($response.StatusCode -ge 200 -and $response.StatusCode -lt 300) {
|
||
Write-Host " ✅ PASSED - Status: $($response.StatusCode), Time: $([math]::Round($elapsed.TotalMilliseconds, 2))ms" -ForegroundColor Green
|
||
$testResults.Passed++
|
||
$testResults.Tests += @{
|
||
Name = $Name
|
||
Status = "PASSED"
|
||
StatusCode = $response.StatusCode
|
||
Time = $elapsed.TotalMilliseconds
|
||
Response = $response.Content
|
||
}
|
||
return $response
|
||
} else {
|
||
throw "Unexpected status code: $($response.StatusCode)"
|
||
}
|
||
}
|
||
catch {
|
||
$elapsed = (Get-Date) - $startTime
|
||
$errorMsg = $_.Exception.Message
|
||
if ($_.Exception.Response) {
|
||
$statusCode = [int]$_.Exception.Response.StatusCode
|
||
$errorMsg = "HTTP $statusCode - $errorMsg"
|
||
}
|
||
Write-Host " ❌ FAILED - Error: $errorMsg, Time: $([math]::Round($elapsed.TotalMilliseconds, 2))ms" -ForegroundColor Red
|
||
$testResults.Failed++
|
||
$testResults.Tests += @{
|
||
Name = $Name
|
||
Status = "FAILED"
|
||
Error = $errorMsg
|
||
Time = $elapsed.TotalMilliseconds
|
||
}
|
||
return $null
|
||
}
|
||
}
|
||
|
||
Write-Host "Phase 1: Service Health Checks" -ForegroundColor Cyan
|
||
Write-Host "-------------------------------" -ForegroundColor Cyan
|
||
|
||
# Test 1: LittleShop API Health
|
||
$response = Test-Endpoint -Name "LittleShop API Health Check" -Url "$ct109BaseUrl/health"
|
||
|
||
# Test 2: LittleShop API Connectivity
|
||
$response = Test-Endpoint -Name "LittleShop API Root Endpoint" -Url "$ct109BaseUrl/"
|
||
|
||
# Test 3: Check if TeleBot is accessible
|
||
$response = Test-Endpoint -Name "TeleBot Health Check (if available)" -Url "$teleBotUrl/health"
|
||
|
||
# Test 4: SilverPay API Health
|
||
$response = Test-Endpoint -Name "SilverPay API Health Check" -Url "$silverPayUrl/api/health"
|
||
|
||
Write-Host ""
|
||
Write-Host "Phase 2: Product Catalog Integration" -ForegroundColor Cyan
|
||
Write-Host "-------------------------------------" -ForegroundColor Cyan
|
||
|
||
# Test 5: Get Categories
|
||
$categoriesResponse = Test-Endpoint -Name "Get Product Categories" -Url "$ct109BaseUrl/api/catalog/categories"
|
||
|
||
if ($categoriesResponse) {
|
||
$categories = $categoriesResponse.Content | ConvertFrom-Json
|
||
Write-Host " 📦 Found $($categories.items.Count) categories" -ForegroundColor Gray
|
||
if ($categories.items.Count -gt 0) {
|
||
Write-Host " 📦 Sample: $($categories.items[0].name)" -ForegroundColor Gray
|
||
}
|
||
}
|
||
|
||
# Test 6: Get Products
|
||
$productsResponse = Test-Endpoint -Name "Get Product Catalog" -Url "$ct109BaseUrl/api/catalog/products"
|
||
|
||
if ($productsResponse) {
|
||
$products = $productsResponse.Content | ConvertFrom-Json
|
||
Write-Host " 📦 Found $($products.items.Count) products" -ForegroundColor Gray
|
||
|
||
if ($products.items.Count -gt 0) {
|
||
$testProduct = $products.items[0]
|
||
Write-Host " 📦 Test Product: $($testProduct.name) - £$($testProduct.price)" -ForegroundColor Gray
|
||
}
|
||
}
|
||
|
||
Write-Host ""
|
||
Write-Host "Phase 3: Order Creation Workflow" -ForegroundColor Cyan
|
||
Write-Host "--------------------------------" -ForegroundColor Cyan
|
||
|
||
# Test 7: Create Order with complete shipping details
|
||
if ($products -and $products.items.Count -gt 0) {
|
||
$orderData = @{
|
||
identityReference = "telegram_ct109_e2e_$(Get-Date -Format 'yyyyMMddHHmmss')"
|
||
shippingName = "CT109 Test User"
|
||
shippingAddress = "123 Test Street"
|
||
shippingCity = "London"
|
||
shippingPostCode = "SW1A 1AA"
|
||
shippingCountry = "United Kingdom"
|
||
items = @(
|
||
@{
|
||
productId = $products.items[0].id
|
||
quantity = 2
|
||
}
|
||
)
|
||
}
|
||
|
||
$orderResponse = Test-Endpoint -Name "Create Order with Shipping Details" -Url "$ct109BaseUrl/api/orders" -Method "POST" -Body $orderData
|
||
|
||
if ($orderResponse) {
|
||
$order = $orderResponse.Content | ConvertFrom-Json
|
||
Write-Host " 📝 Order ID: $($order.id)" -ForegroundColor Gray
|
||
Write-Host " 💰 Total Amount: £$($order.totalAmount)" -ForegroundColor Gray
|
||
Write-Host " 📊 Status: $($order.status)" -ForegroundColor Gray
|
||
Write-Host " 📦 Shipping: $($order.shippingName), $($order.shippingCity)" -ForegroundColor Gray
|
||
|
||
Write-Host ""
|
||
Write-Host "Phase 4: Payment Integration with SilverPay" -ForegroundColor Cyan
|
||
Write-Host "-------------------------------------------" -ForegroundColor Cyan
|
||
|
||
# Test 8: Create Payment
|
||
$paymentData = @{
|
||
cryptoCurrency = "BTC"
|
||
}
|
||
|
||
$paymentResponse = Test-Endpoint -Name "Create BTC Payment for Order" `
|
||
-Url "$ct109BaseUrl/api/orders/$($order.id)/payments" `
|
||
-Method "POST" `
|
||
-Body $paymentData
|
||
|
||
if ($paymentResponse) {
|
||
$payment = $paymentResponse.Content | ConvertFrom-Json
|
||
Write-Host " 💳 Payment ID: $($payment.id)" -ForegroundColor Gray
|
||
Write-Host " ₿ Crypto Currency: $($payment.cryptoCurrency)" -ForegroundColor Gray
|
||
Write-Host " 💰 Crypto Amount: $($payment.cryptoAmount)" -ForegroundColor Gray
|
||
|
||
if ($payment.paymentUrl) {
|
||
Write-Host " 🔗 Payment URL: $($payment.paymentUrl)" -ForegroundColor Gray
|
||
}
|
||
}
|
||
}
|
||
} else {
|
||
Write-Host " ⚠️ SKIPPED - No products available for testing" -ForegroundColor Yellow
|
||
$testResults.Total += 2
|
||
}
|
||
|
||
Write-Host ""
|
||
Write-Host "Phase 5: Bot Activity Tracking Performance" -ForegroundColor Cyan
|
||
Write-Host "------------------------------------------" -ForegroundColor Cyan
|
||
|
||
# Test 9: Bot Activity Tracking (verify no 3-second delays)
|
||
$activityData = @{
|
||
sessionIdentifier = "ct109_test_session_$(Get-Date -Format 'yyyyMMddHHmmss')"
|
||
userDisplayName = "CT109 E2E Test User"
|
||
activityType = "Browse"
|
||
activityDescription = "CT109 E2E test activity"
|
||
platform = "Test"
|
||
location = "CT109"
|
||
timestamp = (Get-Date).ToUniversalTime().ToString("o")
|
||
}
|
||
|
||
$activityResponse = Test-Endpoint -Name "Bot Activity Tracking (Performance Test)" `
|
||
-Url "$ct109BaseUrl/api/bot/activity" `
|
||
-Method "POST" `
|
||
-Body $activityData
|
||
|
||
if ($activityResponse) {
|
||
$activityTest = $testResults.Tests | Where-Object { $_.Name -eq "Bot Activity Tracking (Performance Test)" }
|
||
if ($activityTest.Time -lt 100) {
|
||
Write-Host " ⚡ Performance: EXCELLENT (<100ms)" -ForegroundColor Green
|
||
} elseif ($activityTest.Time -lt 1000) {
|
||
Write-Host " ⚡ Performance: GOOD (<1000ms)" -ForegroundColor Green
|
||
} elseif ($activityTest.Time -lt 3000) {
|
||
Write-Host " ⚡ Performance: ACCEPTABLE (<3000ms)" -ForegroundColor Yellow
|
||
} else {
|
||
Write-Host " ⚠️ Performance: POOR (>3000ms) - DNS resolution issue may exist" -ForegroundColor Red
|
||
}
|
||
}
|
||
|
||
# Test 10: Multiple rapid activity tracking calls
|
||
Write-Host ""
|
||
Write-Host " Testing rapid activity tracking (3 sequential calls)..." -ForegroundColor Gray
|
||
$rapidTestTimes = @()
|
||
|
||
for ($i = 1; $i -le 3; $i++) {
|
||
$startTime = Get-Date
|
||
try {
|
||
Invoke-WebRequest -Uri "$ct109BaseUrl/api/bot/activity" `
|
||
-Method POST `
|
||
-Body ($activityData | ConvertTo-Json) `
|
||
-ContentType "application/json" `
|
||
-TimeoutSec 5 | Out-Null
|
||
$elapsed = ((Get-Date) - $startTime).TotalMilliseconds
|
||
$rapidTestTimes += $elapsed
|
||
Write-Host " Call ${i}: $([math]::Round($elapsed, 2))ms" -ForegroundColor Gray
|
||
}
|
||
catch {
|
||
Write-Host " Call ${i}: FAILED - $($_.Exception.Message)" -ForegroundColor Red
|
||
}
|
||
}
|
||
|
||
if ($rapidTestTimes.Count -gt 0) {
|
||
$avgTime = ($rapidTestTimes | Measure-Object -Average).Average
|
||
$color = if ($avgTime -lt 100) { "Green" } elseif ($avgTime -lt 1000) { "Yellow" } else { "Red" }
|
||
Write-Host " ⚡ Average Time: $([math]::Round($avgTime, 2))ms" -ForegroundColor $color
|
||
|
||
if ($avgTime -lt 100) {
|
||
Write-Host " ✅ PERFORMANCE FIX VERIFIED - Bot activity tracking optimized!" -ForegroundColor Green
|
||
}
|
||
}
|
||
|
||
Write-Host ""
|
||
Write-Host "Phase 6: TeleBot Integration Check" -ForegroundColor Cyan
|
||
Write-Host "----------------------------------" -ForegroundColor Cyan
|
||
|
||
# Check if TeleBot process is running (we can't verify this without SSH)
|
||
Write-Host " ℹ️ TeleBot connectivity must be verified via Telegram app" -ForegroundColor Yellow
|
||
Write-Host " 📱 Bot Token: 8254383681:AAE_j4cUIP9ABVE4Pqrmtgjfmqq1yc4Ow5A" -ForegroundColor Gray
|
||
Write-Host " 🤖 Bot Username: @Teleshopio_bot" -ForegroundColor Gray
|
||
Write-Host ""
|
||
Write-Host " Manual Verification Steps:" -ForegroundColor Yellow
|
||
Write-Host " 1. Open Telegram and search for @Teleshopio_bot" -ForegroundColor Gray
|
||
Write-Host " 2. Send /start command" -ForegroundColor Gray
|
||
Write-Host " 3. Verify bot responds with welcome message" -ForegroundColor Gray
|
||
Write-Host " 4. Try browsing products to confirm LittleShop integration" -ForegroundColor Gray
|
||
|
||
Write-Host ""
|
||
Write-Host "============================================" -ForegroundColor Cyan
|
||
Write-Host "TEST SUMMARY" -ForegroundColor Cyan
|
||
Write-Host "============================================" -ForegroundColor Cyan
|
||
Write-Host "Total Tests: $($testResults.Total)" -ForegroundColor White
|
||
Write-Host "Passed: $($testResults.Passed)" -ForegroundColor Green
|
||
Write-Host "Failed: $($testResults.Failed)" -ForegroundColor Red
|
||
$passRate = if ($testResults.Total -gt 0) { [math]::Round(($testResults.Passed / $testResults.Total) * 100, 2) } else { 0 }
|
||
Write-Host "Pass Rate: ${passRate}%" -ForegroundColor $(if ($testResults.Passed -eq $testResults.Total) { "Green" } elseif ($passRate -ge 50) { "Yellow" } else { "Red" })
|
||
Write-Host ""
|
||
|
||
# Detailed test results
|
||
Write-Host "Detailed Test Results:" -ForegroundColor Cyan
|
||
Write-Host "---------------------" -ForegroundColor Cyan
|
||
foreach ($test in $testResults.Tests) {
|
||
$icon = if ($test.Status -eq "PASSED") { "✅" } else { "❌" }
|
||
$color = if ($test.Status -eq "PASSED") { "Green" } else { "Red" }
|
||
|
||
Write-Host "$icon $($test.Name)" -ForegroundColor $color
|
||
if ($test.Time) {
|
||
Write-Host " Time: $([math]::Round($test.Time, 2))ms" -ForegroundColor Gray
|
||
}
|
||
if ($test.StatusCode) {
|
||
Write-Host " Status Code: $($test.StatusCode)" -ForegroundColor Gray
|
||
}
|
||
if ($test.Error) {
|
||
Write-Host " Error: $($test.Error)" -ForegroundColor Red
|
||
}
|
||
}
|
||
|
||
Write-Host ""
|
||
Write-Host "============================================" -ForegroundColor Cyan
|
||
Write-Host "DEPLOYMENT STATUS" -ForegroundColor Cyan
|
||
Write-Host "============================================" -ForegroundColor Cyan
|
||
|
||
if ($testResults.Failed -eq 0) {
|
||
Write-Host "🎉 ALL TESTS PASSED!" -ForegroundColor Green
|
||
Write-Host "✅ CT109 pre-production deployment is fully operational" -ForegroundColor Green
|
||
Write-Host "✅ System ready for trading operations" -ForegroundColor Green
|
||
exit 0
|
||
} elseif ($passRate -ge 70) {
|
||
Write-Host "⚠️ PARTIAL SUCCESS - Core functionality working" -ForegroundColor Yellow
|
||
Write-Host "ℹ️ Some components may need attention (see failures above)" -ForegroundColor Yellow
|
||
Write-Host "📋 Review failed tests and verify manually" -ForegroundColor Yellow
|
||
exit 0
|
||
} else {
|
||
Write-Host "❌ DEPLOYMENT HAS ISSUES!" -ForegroundColor Red
|
||
Write-Host "🔴 Multiple components failing - review logs and configuration" -ForegroundColor Red
|
||
exit 1
|
||
}
|