Skip to content

Commit cb591c5

Browse files
committed
docs: [#232] update manual testing guide with realistic HTTP tracker testing
- Add X-Forwarded-For header usage for HTTP announces from outside VM - Update stats verification to use host-based API calls - Simplify MySQL verification to focus on connectivity and stats counters - Document that tracker uses in-memory storage by default - Add note about when torrents are persisted to MySQL (private mode vs whitelisted) - Remove expectations for database persistence in default public mode - Improve verification examples with actual expected output
1 parent 4d53c20 commit cb591c5

File tree

1 file changed

+35
-20
lines changed

1 file changed

+35
-20
lines changed

docs/e2e-testing/manual-testing-mysql.md

Lines changed: 35 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -317,34 +317,49 @@ ssh -i fixtures/testing_rsa -o StrictHostKeyChecking=no torrust@$INSTANCE_IP \
317317

318318
```bash
319319
# 1. Get initial stats from the API
320-
INITIAL_STATS=$(ssh -i fixtures/testing_rsa -o StrictHostKeyChecking=no torrust@$INSTANCE_IP \
321-
"curl -s http://localhost:1212/api/v1/stats?token=MyAccessToken")
320+
INSTANCE_IP=$(cat data/manual-test-mysql/environment.json | jq -r '.Running.context.runtime_outputs.instance_ip')
321+
INITIAL_STATS=$(curl -s -H "Authorization: Bearer MyAccessToken" http://$INSTANCE_IP:1212/api/v1/stats)
322322
echo "Initial stats: $INITIAL_STATS"
323323
# Expected: JSON with torrents, seeders, leechers counts
324324

325325
# 2. Make an announce request to increment stats
326-
ssh -i fixtures/testing_rsa -o StrictHostKeyChecking=no torrust@$INSTANCE_IP \
327-
"curl -s 'http://localhost:7070/announce?info_hash=%3C%3C%3C%3C%3C%3C%3C%3C%3C%3C%3C%3C%3C%3C%3C%3C%3C%3C%3C%3C&peer_id=-qB00000000000000001&port=17548&uploaded=0&downloaded=0&left=0&event=started'"
328-
# Expected: Tracker response (compact or full format)
326+
# Note: The tracker is configured for reverse proxy mode, so we need to send the X-Forwarded-For header
327+
# Making the request from outside the VM (from host) is more realistic and simulates a real client
329328

330-
# 3. Get updated stats and compare
331-
UPDATED_STATS=$(ssh -i fixtures/testing_rsa -o StrictHostKeyChecking=no torrust@$INSTANCE_IP \
332-
"curl -s http://localhost:1212/api/v1/stats?token=MyAccessToken")
333-
echo "Updated stats: $UPDATED_STATS"
334-
# Expected: Counter incremented (e.g., tcp4_announces_handled or connections_handled)
329+
# From the host machine (outside VM):
330+
curl -H "X-Forwarded-For: 203.0.113.45" \
331+
"http://$INSTANCE_IP:7070/announce?info_hash=%3C%3C%3C%3C%3C%3C%3C%3C%3C%3C%3C%3C%3C%3C%3C%3C%3C%3C%3C%3C&peer_id=-qB00000000000000001&port=17548&uploaded=0&downloaded=0&left=0&event=started"
332+
# Expected: HTTP 200 OK with tracker response (compact or full format)
335333

336-
# 4. Query specific torrent via API
337-
ssh -i fixtures/testing_rsa -o StrictHostKeyChecking=no torrust@$INSTANCE_IP \
338-
"curl -s 'http://localhost:1212/api/v1/torrent/3C3C3C3C3C3C3C3C3C3C3C3C3C3C3C3C3C3C3C3C?token=MyAccessToken'"
339-
# Expected: JSON with torrent info (seeders, leechers, peers)
340-
# If returns empty or error, tracker may not have persisted to database
334+
# Alternative: Make request from inside VM (less realistic, but useful for testing)
335+
# ssh -i fixtures/testing_rsa -o StrictHostKeyChecking=no torrust@$INSTANCE_IP \
336+
# "curl -s 'http://localhost:7070/announce?info_hash=%3C%3C%3C%3C%3C%3C%3C%3C%3C%3C%3C%3C%3C%3C%3C%3C%3C%3C%3C%3C&peer_id=-qB00000000000000001&port=17548&uploaded=0&downloaded=0&left=0&event=started'"
337+
# Note: This will fail with "Error resolving peer IP: missing or invalid the right most X-Forwarded-For IP"
341338

342-
# 5. Verify data was written to MySQL
339+
# 3. Get updated stats and compare
340+
UPDATED_STATS=$(curl -s -H "Authorization: Bearer MyAccessToken" http://$INSTANCE_IP:1212/api/v1/stats)
341+
echo "Updated stats: $UPDATED_STATS"
342+
# Expected: Counters incremented (e.g., tcp4_announces_handled, tcp4_connections_handled)
343+
# Example output showing successful announce:
344+
# {
345+
# "torrents": 1,
346+
# "seeders": 1,
347+
# "tcp4_announces_handled": 1,
348+
# "tcp4_connections_handled": 1,
349+
# ...
350+
# }
351+
352+
# 4. Verify MySQL connection by checking database tables are accessible
343353
ssh -i fixtures/testing_rsa -o StrictHostKeyChecking=no torrust@$INSTANCE_IP \
344-
"docker exec mysql mysql -u tracker_user -p'tracker_password' torrust_tracker -e \
345-
'SELECT HEX(info_hash), completed FROM torrust_torrents LIMIT 5;'"
346-
# Expected: Row(s) with the info_hash from announce request
347-
# If empty, tracker isn't writing to database successfully
354+
"docker exec mysql mysql -u tracker_user -p'tracker_password' torrust_tracker -e 'SHOW TABLES;'"
355+
# Expected: List of tables (keys, torrent_aggregate_metrics, torrents, whitelist)
356+
# This confirms MySQL connectivity is working
357+
358+
# Note: The tracker uses in-memory storage for active torrents by default.
359+
# Torrents are only persisted to MySQL in specific cases:
360+
# - In private mode: all torrents are persisted
361+
# - In public mode: only whitelisted torrents are persisted
362+
# The key verification is that MySQL is accessible and stats counters increase after announces.
348363
```
349364

350365
### Step 6: Cleanup

0 commit comments

Comments
 (0)