-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker-compose.qa.yml
More file actions
313 lines (273 loc) · 12.6 KB
/
docker-compose.qa.yml
File metadata and controls
313 lines (273 loc) · 12.6 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
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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
# HelixQA Full Video-Recorded QA Sessions
#
# Provides EVERYTHING required for complete video-recorded QA testing:
# - Containerized catalog-api + catalog-web (from docker-compose.test.yml)
# - Playwright container with video recording for web platform
# - HelixQA runner with step validation + evidence collection
#
# Usage:
# # Step 1: Build and start the test stack
# podman-compose -f docker-compose.test.yml --profile web up -d --build
#
# # Step 2: Run HelixQA web session with video recording
# podman-compose -f docker-compose.test.yml -f docker-compose.qa.yml --profile web run helixqa-web
#
# # Step 3: Run HelixQA API validation
# podman-compose -f docker-compose.test.yml -f docker-compose.qa.yml --profile web run helixqa-api
#
# # Step 4: Collect results from qa-results/ volume
# podman cp catalogizer-helixqa-web:/qa-results ./qa-results-collected
#
# Resource budget: 4 CPU, 8 GB RAM total (30-40% of host).
# Web QA profile: API (2 CPU, 4GB) + Web (0.5 CPU, 1GB) + QA (1 CPU, 2GB) = 3.5 CPU, 7GB
version: "3.8"
volumes:
qa-results:
driver: local
services:
# ---------------------------------------------------------------------------
# helixqa-web: Full Playwright-based web QA with video recording
#
# Uses Playwright's built-in video recording (not ffmpeg screen grab).
# Each page navigation is captured as a video file.
# Screenshots taken at every page transition.
# ---------------------------------------------------------------------------
helixqa-web:
image: docker.io/mcr.microsoft.com/playwright:v1.40.0-jammy
container_name: catalogizer-helixqa-web
network_mode: host
environment:
- PLAYWRIGHT_BROWSERS_PATH=/ms-playwright
- TEST_WEB_URL=http://localhost:3000
- TEST_API_URL=http://localhost:8080
entrypoint: ["bash", "-c"]
command:
- |
set -e
echo "=== HelixQA Web Video-Recorded QA Session ==="
echo "Started: $$(date -Iseconds)"
QA_DIR="/qa-results/web-qa-$$(date +%Y%m%d_%H%M%S)"
mkdir -p "$$QA_DIR"/{videos,screenshots,evidence}
# Wait for services
echo "Waiting for API (localhost:8080)..."
for i in $$(seq 1 60); do
curl -sf http://localhost:8080/health >/dev/null 2>&1 && break
sleep 2
done
curl -sf http://localhost:8080/health >/dev/null || { echo "API not ready"; exit 1; }
echo "API is healthy."
echo "Waiting for Web (localhost:3000)..."
for i in $$(seq 1 60); do
curl -sf http://localhost:3000 >/dev/null 2>&1 && break
sleep 2
done
curl -sf http://localhost:3000 >/dev/null || { echo "Web not ready"; exit 1; }
echo "Web is healthy."
# Authenticate
echo "Authenticating..."
TOKEN=$$(curl -sf -X POST http://localhost:8080/api/v1/auth/login \
-H 'Content-Type: application/json' \
-d '{"username":"admin","password":"admin123"}' | \
node -e "let d='';process.stdin.on('data',c=>d+=c);process.stdin.on('end',()=>{try{console.log(JSON.parse(d).session_token||'')}catch(e){console.log('')}})" 2>/dev/null)
echo "Token obtained: $${TOKEN:+yes}"
# Create Playwright test script for video-recorded navigation
cat > /tmp/qa-test.js << 'JSEOF'
const { chromium } = require('playwright');
(async () => {
const browser = await chromium.launch({ headless: true });
const context = await browser.newContext({
recordVideo: { dir: process.env.VIDEO_DIR, size: { width: 1920, height: 1080 } },
viewport: { width: 1920, height: 1080 }
});
const pages = [
{ path: '/login', name: 'Login Page' },
{ path: '/', name: 'Home' },
{ path: '/dashboard', name: 'Dashboard' },
{ path: '/media', name: 'Media Browser' },
{ path: '/browse', name: 'Entity Browser' },
{ path: '/collections', name: 'Collections' },
{ path: '/favorites', name: 'Favorites' },
{ path: '/playlists', name: 'Playlists' },
{ path: '/analytics', name: 'Analytics' },
{ path: '/subtitles', name: 'Subtitle Manager' },
{ path: '/conversion', name: 'Conversion Tools' },
{ path: '/admin', name: 'Admin Panel' },
{ path: '/ai', name: 'AI Dashboard' },
];
const baseUrl = process.env.TEST_WEB_URL || 'http://localhost:3000';
const screenshotDir = process.env.SCREENSHOT_DIR || '/tmp/screenshots';
const results = [];
for (let i = 0; i < pages.length; i++) {
const { path, name } = pages[i];
const page = await context.newPage();
const url = `${baseUrl}${path}`;
const startTime = Date.now();
try {
console.log(`[${i+1}/${pages.length}] Navigating to ${name} (${url})...`);
await page.goto(url, { waitUntil: 'networkidle', timeout: 30000 });
await page.waitForTimeout(2000); // Allow animations
// Take screenshot
const screenshotPath = `${screenshotDir}/${String(i).padStart(3,'0')}-${path.replace(/\//g,'') || 'home'}.png`;
await page.screenshot({ path: screenshotPath, fullPage: true });
// Check for console errors
const errors = [];
page.on('console', msg => { if (msg.type() === 'error') errors.push(msg.text()); });
const duration = Date.now() - startTime;
console.log(` PASS: ${name} (${duration}ms, screenshot saved)`);
results.push({ page: name, path, status: 'PASS', duration, errors: errors.length });
} catch (err) {
const duration = Date.now() - startTime;
console.log(` FAIL: ${name} - ${err.message} (${duration}ms)`);
results.push({ page: name, path, status: 'FAIL', duration, error: err.message });
}
await page.close();
}
await context.close();
await browser.close();
// Write results JSON
const fs = require('fs');
fs.writeFileSync(process.env.RESULTS_FILE || '/tmp/results.json', JSON.stringify(results, null, 2));
// Summary
const passed = results.filter(r => r.status === 'PASS').length;
const failed = results.filter(r => r.status === 'FAIL').length;
console.log(`\n=== Results: ${passed}/${results.length} passed, ${failed} failed ===`);
process.exit(failed > 0 ? 1 : 0);
})();
JSEOF
# Run the Playwright test with video recording
echo ""
echo "=== Running Playwright Video-Recorded QA ==="
VIDEO_DIR="$$QA_DIR/videos" \
SCREENSHOT_DIR="$$QA_DIR/screenshots" \
RESULTS_FILE="$$QA_DIR/results.json" \
TEST_WEB_URL="http://localhost:3000" \
node /tmp/qa-test.js 2>&1
PLAYWRIGHT_EXIT=$$?
# Generate markdown report
echo ""
echo "Generating report..."
node -e "
const fs = require('fs');
const results = JSON.parse(fs.readFileSync('$$QA_DIR/results.json', 'utf8'));
const videos = fs.readdirSync('$$QA_DIR/videos').filter(f => f.endsWith('.webm'));
const screenshots = fs.readdirSync('$$QA_DIR/screenshots').filter(f => f.endsWith('.png'));
let md = '# HelixQA Web Video-Recorded QA Report\n\n';
md += '**Generated:** ' + new Date().toISOString() + '\n';
md += '**Platform:** Web (Playwright + Chromium)\n\n';
md += '## Video Recordings\n\n';
md += '| # | File | Platform |\n|---|------|----------|\n';
videos.forEach((v, i) => { md += '| ' + (i+1) + ' | ' + v + ' | web |\n'; });
md += '\n**Total videos:** ' + videos.length + '\n\n';
md += '## Page Screenshots (' + screenshots.length + ')\n\n';
md += '| # | Page | Path | Status | Duration |\n';
md += '|---|------|------|--------|----------|\n';
results.forEach((r, i) => {
md += '| ' + (i+1) + ' | ' + r.page + ' | ' + r.path + ' | ' + r.status + ' | ' + r.duration + 'ms |\n';
});
const passed = results.filter(r => r.status === 'PASS').length;
md += '\n## Summary\n\n';
md += '- **Passed:** ' + passed + '/' + results.length + '\n';
md += '- **Failed:** ' + (results.length - passed) + '\n';
md += '- **Videos:** ' + videos.length + '\n';
md += '- **Screenshots:** ' + screenshots.length + '\n';
fs.writeFileSync('$$QA_DIR/qa-report.md', md);
console.log('Report written to $$QA_DIR/qa-report.md');
" 2>&1
echo ""
echo "=== Session Complete ==="
echo "Results: $$QA_DIR/"
ls -lh "$$QA_DIR/videos/" 2>/dev/null
ls -lh "$$QA_DIR/screenshots/" 2>/dev/null | head -5
echo "..."
echo "Videos: $$(ls $$QA_DIR/videos/*.webm 2>/dev/null | wc -l) files"
echo "Screenshots: $$(ls $$QA_DIR/screenshots/*.png 2>/dev/null | wc -l) files"
exit $$PLAYWRIGHT_EXIT
volumes:
- qa-results:/qa-results
- ./challenges/helixqa-banks:/banks:ro
deploy:
resources:
limits:
cpus: "1"
memory: 2g
depends_on:
catalog-web:
condition: service_healthy
profiles:
- web
# ---------------------------------------------------------------------------
# helixqa-api: API endpoint validation against live containerized backend
# ---------------------------------------------------------------------------
helixqa-api:
image: docker.io/library/node:18-bookworm-slim
container_name: catalogizer-helixqa-api
network_mode: host
entrypoint: ["bash", "-c"]
command:
- |
set -e
apt-get update -qq && apt-get install -y -qq curl jq >/dev/null 2>&1
echo "=== HelixQA API Validation Session ==="
QA_DIR="/qa-results/api-qa-$$(date +%Y%m%d_%H%M%S)"
mkdir -p "$$QA_DIR"
# Wait for API
for i in $$(seq 1 60); do
curl -sf http://localhost:8080/health >/dev/null 2>&1 && break
sleep 2
done
# Login
TOKEN=$$(curl -sf -X POST http://localhost:8080/api/v1/auth/login \
-H 'Content-Type: application/json' \
-d '{"username":"admin","password":"admin123"}' | jq -r '.session_token // empty')
echo "Authenticated: $${TOKEN:+yes}"
PASS=0 FAIL=0 TOTAL=0
REPORT="$$QA_DIR/qa-report.md"
echo "# HelixQA API Validation Report" > "$$REPORT"
echo "**Generated:** $$(date -Iseconds)" >> "$$REPORT"
echo "" >> "$$REPORT"
echo "| # | Endpoint | Status | Result |" >> "$$REPORT"
echo "|---|----------|--------|--------|" >> "$$REPORT"
for ep in \
"/health" "/metrics" "/api/v1/auth/status" "/api/v1/discovery" \
"/api/v1/catalog" "/api/v1/media/search" "/api/v1/media/stats" \
"/api/v1/storage-roots" "/api/v1/entities" "/api/v1/entities/types" \
"/api/v1/entities/stats" "/api/v1/collections" "/api/v1/favorites" \
"/api/v1/stats/overall" "/api/v1/stats/filetypes" "/api/v1/stats/scans" \
"/api/v1/challenges" "/api/v1/configuration" "/api/v1/configuration/status" \
"/api/v1/errors/health" "/api/v1/errors/statistics" \
"/api/v1/logs/statistics" "/api/v1/subtitles/languages" \
"/api/v1/conversion/formats" "/api/v1/roles" "/api/v1/users" \
"/api/v1/browse/roots" "/api/v1/sync/statistics" \
"/api/v1/reports/performance" "/api/v1/analytics/system" \
"/api/v1/recommendations/trending" "/api/v1/scans"; do
TOTAL=$$((TOTAL+1))
STATUS=$$(curl -sf -o /dev/null -w '%{http_code}' \
"http://localhost:8080$$ep" \
-H "Authorization: Bearer $$TOKEN" 2>/dev/null)
if [ "$$STATUS" -ge 200 ] && [ "$$STATUS" -lt 400 ]; then
echo " PASS: $$ep ($$STATUS)"
echo "| $$TOTAL | $$ep | $$STATUS | PASS |" >> "$$REPORT"
PASS=$$((PASS+1))
else
echo " FAIL: $$ep ($$STATUS)"
echo "| $$TOTAL | $$ep | $$STATUS | FAIL |" >> "$$REPORT"
FAIL=$$((FAIL+1))
fi
done
echo "" >> "$$REPORT"
echo "## Summary: $$PASS/$$TOTAL passed, $$FAIL failed" >> "$$REPORT"
echo ""
echo "=== API Results: $$PASS/$$TOTAL passed, $$FAIL failed ==="
volumes:
- qa-results:/qa-results
deploy:
resources:
limits:
cpus: "0.5"
memory: 512m
depends_on:
catalog-api:
condition: service_healthy
profiles:
- web
- api