- 
                Notifications
    
You must be signed in to change notification settings  - Fork 18
 
Improve v2 SDK test robustness and failure diagnostics #1321
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
          
 | 
    
        
          
                internal/e2e-js/utils.ts
              
                Outdated
          
        
      | /* This is a workaround what we think is a bug in Playwright/Chromium | ||
| * There are cases where totalAudioEnergy is not present in the report | ||
| * even though we see audio and it's not silence. | ||
| * This is particularly common with G.711 codecs (PCMU/PCMA). | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What made you add this comment (and the related following one,
// Fallback to packetsReceived (common with G.711 codecs)
)?
| 
           Thanks @RafaelPChequer - I've left a few suggestions/comments.  | 
    
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The v2 SDK tests were moved to the rtc-testing repo. If you’re improving these tests, please check with Giacomo on whether to make them here or in the rtc-testing repo.
Co-authored-by: Giacomo Vacca <[email protected]>
Co-authored-by: Giacomo Vacca <[email protected]>
…to rpc/apex-16463-e2e-tests-fix-and-improve
…thub.com/signalwire/signalwire-js into rpc/apex-16463-e2e-tests-fix-and-improve
| 
           Claude finished @RafaelPChequer's task —— View job Code Review Complete ✅I've thoroughly analyzed this PR and provide the following comprehensive review: 📋 SummaryThis PR significantly enhances the robustness and diagnostic capabilities of v2 WebRTC e2e tests. The improvements focus on early failure detection, better error messaging, and fallback validation mechanisms for different codec scenarios. ✅ Strengths1. Excellent Error Diagnostics// v2WebrtcFromRest.spec.ts:334-348
const expectCallNotHungUp = async (page: Page, callName: string) => {
  if (statusText?.includes('MEDIA_TIMEOUT')) {
    throw new Error(
      `${callName} failed with MEDIA_TIMEOUT (Code 804). ` +
      `This usually indicates:\n` +
      `- TURN server not available or misconfigured\n` +
      `- Firewall blocking UDP/TURN traffic (port 3478)\n` +
      `- Network instability or high latency\n` +
      `- ICE gathering failed\n`
    )
  }
}✅ Excellent: Provides actionable debugging information for common WebRTC issues. 2. Proactive Monitoring// v2WebrtcFromRest.spec.ts:427-443
const callDurationMs = 40000
const checkInterval = 5000
for (let i = 0; i < numChecks; i++) {
  await pageCallee1.waitForTimeout(checkInterval)
  await Promise.all([
    expectCallNotHungUp(pageCallee1, 'Callee1'),
    expectCallNotHungUp(pageCallee2, 'Callee2')
  ])
}✅ Smart: Catches failures early instead of waiting until the end. 3. Robust Audio Validation// utils.ts:1216-1250
if (totalAudioEnergy !== undefined && totalAudioEnergy !== null) {
  expect(totalAudioEnergy).toBeGreaterThan(minTotalAudioEnergy)
} else {
  console.log('⚠️ totalAudioEnergy not available (common with G.711/PCMU/PCMA codecs)')
  if (packetsReceived !== undefined && packetsReceived !== null) {
    expect(packetsReceived).toBeGreaterThan(minPacketsReceived)
  }
}✅ Practical: Handles codec-specific metric variations gracefully. 
 | 
    
Description
Improved end-to-end tests for v2 WebRTC in the SDK by adding a helper function to detect MEDIA_TIMEOUT and unexpected hangups, implementing periodic checks during call duration to ensure calls remain active and catch failures early, and enhancing audio reception validation with fallbacks for missing metrics (e.g., using packetsReceived or totalSamplesReceived when totalAudioEnergy is unavailable, common with G.711 codecs). These changes increase test reliability, provide better error diagnostics for network/ICE issues, and help prevent regressions in SPR-related scenarios.
Type of change
Code snippets
In case of new feature or breaking changes, please include code snippets.