Home > Development > Testing > ---
Phase 2 Cache Testing Guide
Quick Start: Log Tags
Copy-paste for logcat filtering:
tag:CacheService tag:CacheMetrics tag:HybridTournamentRepo tag:FirebaseTournamentRepo tag:RoundDetailsScreen tag:ArcheryApp
Verbose version (includes more detail):
tag:CacheService tag:CacheMetrics tag:HybridTournamentRepo tag:FirebaseTournamentRepo tag:RoundDetailsScreen tag:ArcheryApp tag:TournamentSync tag:TournamentRoundState
Feature Flag Activation (Gradual Rollout)
Step 1: Basic Caching (Start Here)
// In CacheFeatureFlags.kt
var enableTournamentScoreCache = true
var enableSmartListeners = trueWhat to test:
- Open completed tournament round → Should cache data
- Reopen same round → Should use cache (faster load)
Expected logs:
- First load:
❌ Cache miss: Fetching from Firestore - Second load:
✅ Cache hit: Returning X cached ends
Step 2: Batch Fetching (After Step 1 works)
var enableBatchParticipantFetch = trueWhat to test:
- Open participant selector modal (roster button)
- Should load all participants faster
Expected logs:
🎯 Batch fetching tournament participant scores for modal✅ Batch cache hit: [participantId] = [score](for cached)❌ Batch cache miss: X participants need Firestore fetch
Step 3: Indefinite Caching (After Step 2 works)
var cacheCompletedTournamentsIndefinitely = trueWhat to test:
- Completed tournaments should stay cached forever
- Cache should survive app restarts
Expected logs:
💾 Cached X ends for [participant] (status: COMPLETED)
Step 4: Automatic Cleanup (Last)
var enableAutomaticCacheCleanup = trueWhat to test:
- Wait 30 seconds after app startup
- Check for cleanup log
Expected logs:
🧹 Initial cache cleanup: X entries removed- After 24 hours:
🧹 Periodic cache cleanup: X entries removed
Manual Test Scenarios
Test 1: Completed Tournament Cache Hit
Steps:
- Complete a tournament round (or find an already completed round)
- Open the round details from tournament screen
- Observe logs - Should see cache miss + Firestore fetch
- Close the round details
- Reopen the same round
- Observe logs - Should see cache hit, no Firestore
Success Criteria:
- ✅ Second load shows
✅ Cache hit - ✅ Second load is noticeably faster
- ✅ No Firestore logs on cache hit
Test 2: Active Tournament TTL
Steps:
- Start scoring a tournament round (IN_PROGRESS)
- Score a few ends
- Exit and reopen within 30 seconds
- Observe logs - Should see cache hit
- Wait 31+ seconds
- Reopen round
- Observe logs - Should see cache miss (TTL expired)
Success Criteria:
- ✅ Cache hit within 30 seconds
- ✅ Cache miss after 30 seconds
- ✅ Real-time updates still work
Test 3: Modal Batch Fetch
Steps:
- Open a round with 3+ participants
- Click the roster/filter button (top-right list icon)
- Observe logs - Check batch fetch behavior
- Close and reopen modal
- Observe logs - Should use cache
Success Criteria:
- ✅ First load:
📊 Modal: Batch fetched X participant scores - ✅ Second load: Cache hits for all participants
- ✅ Modal opens faster on second load
Test 4: Cache Invalidation (Status Change)
Steps:
- Have a cached active tournament
- Complete the tournament
- Observe logs - Should see invalidation
- Reopen tournament
- Observe logs - Should fetch fresh from Firestore
Success Criteria:
- ✅
🔄 Invalidated cache for completed tournament: [id] - ✅ Fresh cache created with indefinite TTL
Test 5: Multi-Participant Modal Performance
Steps:
- Create tournament with 5+ participants
- Each scores a few ends
- Open round details
- Click roster button to open modal
- Time the modal load
- Close and reopen modal
- Time again - Should be 3-5x faster
Success Criteria:
- ✅ Cached load < 200ms
- ✅ All participant scores visible
- ✅ Logs show batch cache hits
Performance Metrics to Report
Cache Effectiveness
Run these after testing for a while:
// Add to any screen temporarily to see stats
CacheMetrics.logSummary()
CacheMetrics.logDetailedMetrics()Look for:
- Hit Rate: Should be > 70% for completed tournaments
- Firestore Reads Saved: Should increase over time
- Cache Efficiency: Should be > 80%
Load Time Comparison
Measure these scenarios:
- First load (cache miss): Typical = 1-2 seconds
- Cached load (hit): Target = < 500ms
- Modal with 5 participants: Target < 300ms (cached)
Bug Fix Verification
COMPLETED Round Navigation
Previously: Clicking “View Results” on completed round showed error snackbar Now: Should navigate smoothly to round details
Test:
- Complete a tournament round
- Return to tournament details screen
- Click “View Results” button
- Expected: Navigate directly to RoundDetailsScreen
- Not expected: No error snackbar about “Cannot score a COMPLETED round”
Troubleshooting
Cache Not Working
Check:
- Feature flags are
truein CacheFeatureFlags.kt - Database migrated to version 31: Check in Android Studio Database Inspector
- Logs show
enableTournamentScoreCacheis true
Logs Not Showing
Check:
- Using correct log tags (see top of document)
- LogConfig.d() is not filtered in your build
CacheFeatureFlags.logCacheMetrics = true
Cache Always Missing
Check:
- TTL settings (30s for active, indefinite for completed)
- Tournament status is correct
- Participant ID matches exactly
What to Report Back
For each test scenario, please share:
1. Log Output
# Use this logcat command:
adb logcat -s CacheService:D CacheMetrics:D HybridTournamentRepo:D
2. Observations
- Modal load time (before/after caching)
- Any errors or unexpected behavior
- Cache hit rates from
CacheMetrics.logSummary()
3. Performance Notes
- Perceived speed improvement
- Any UI lag or freezing
- Memory usage (if noticeable)
Expected Log Examples
Cache Hit (Good)
D/HybridTournamentRepo: 🔍 Smart cache check: KYD3J4/1/participant123 (status: COMPLETED)
D/CacheService: 💾 Cache check: KYD3J4/1/participant123 = HIT (status: COMPLETED, ttl: 9223372036854775807s)
D/HybridTournamentRepo: ✅ Cache hit: Returning 10 cached ends for participant123
Cache Miss (Expected on First Load)
D/HybridTournamentRepo: 🔍 Smart cache check: KYD3J4/1/participant123 (status: COMPLETED)
D/CacheService: 💾 Cache check: KYD3J4/1/participant123 = MISS (status: COMPLETED, ttl: 9223372036854775807s)
D/HybridTournamentRepo: ❌ Cache miss: Fetching from Firestore
D/FirebaseTournamentRepo: 📦 Fetching scores for participant123
D/CacheService: 💾 Cached 10 ends for participant123 (status: COMPLETED)
Batch Fetch (Modal)
D/RoundDetailsScreen: 🎯 Batch fetching tournament participant scores for modal
D/HybridTournamentRepo: ✅ Batch cache hit: participant1 = 280
D/HybridTournamentRepo: ✅ Batch cache hit: participant2 = 295
D/HybridTournamentRepo: ❌ Batch cache miss: 1 participants need Firestore fetch
D/RoundDetailsScreen: 📊 Modal: Batch fetched 3 participant scores
Success Criteria Summary
Phase 2 is successful when:
✅ Performance:
- Completed rounds load in < 500ms (cached)
- Modal loads 3-5x faster with cache
- Cache hit rate > 70%
✅ Functionality:
- No breaking changes
- Real-time updates work for active rounds
- All participant types work correctly
✅ Reliability:
- No crashes or errors
- Graceful degradation if cache fails
- Proper TTL expiration
Related Documentation:
- See Data-Sync-Flow for smart caching architecture details
- See Tournament-Flow for tournament lifecycle integration
Last Updated: 2025-10-03
Database Version: 31
Feature Flags: Located in CacheFeatureFlags.kt