-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest-resources.ps1
More file actions
37 lines (31 loc) · 1.88 KB
/
test-resources.ps1
File metadata and controls
37 lines (31 loc) · 1.88 KB
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
# Test script to verify resources data and API
Write-Host "=== Checking Database ===" -ForegroundColor Cyan
Write-Host "Resources count:" -ForegroundColor Yellow
docker exec library-postgres psql -U postgres -d catalog_db -t -A -c "SELECT COUNT(*) FROM resources;"
Write-Host "`nSample resources:" -ForegroundColor Yellow
docker exec library-postgres psql -U postgres -d catalog_db -c "SELECT id, name, type, status FROM resources LIMIT 5;"
Write-Host "`n=== Testing API ===" -ForegroundColor Cyan
Write-Host "Testing API Gateway health:" -ForegroundColor Yellow
$health = Invoke-RestMethod -Uri "http://localhost:8080/health" -Method Get -ErrorAction SilentlyContinue
if ($health) { Write-Host "API Gateway: OK" -ForegroundColor Green } else { Write-Host "API Gateway: FAILED" -ForegroundColor Red }
Write-Host "`nTesting Catalog Service health:" -ForegroundColor Yellow
try {
$catalogHealth = Invoke-RestMethod -Uri "http://localhost:8080/api/resources/health" -Method Get -ErrorAction Stop
Write-Host "Catalog Service: OK" -ForegroundColor Green
} catch {
Write-Host "Catalog Service: FAILED - $_" -ForegroundColor Red
}
Write-Host "`nTesting Resources API (no auth):" -ForegroundColor Yellow
try {
$resources = Invoke-RestMethod -Uri "http://localhost:8080/api/resources" -Method Get -ErrorAction Stop
Write-Host "Resources API: OK - Found $($resources.Count) resources" -ForegroundColor Green
if ($resources.Count -gt 0) {
Write-Host "First resource: $($resources[0].name)" -ForegroundColor Cyan
}
} catch {
Write-Host "Resources API: FAILED - $_" -ForegroundColor Red
Write-Host "Status Code: $($_.Exception.Response.StatusCode.value__)" -ForegroundColor Yellow
}
Write-Host "`n=== Checking Service Logs ===" -ForegroundColor Cyan
Write-Host "Recent catalog service logs:" -ForegroundColor Yellow
docker logs library-catalog-service --tail 10 2>&1 | Select-Object -Last 5