forked from webrtc/samples
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add Chrome/Firefox interop tests (webrtc#1576)
* add interop tests adds interoperability tests between Chrome unstable and Firefox Nightly. These tests are designed to run nightly as github actions. They do not rely on a signaling server, instead use the mocha-based test that is controlling the individual selenium webdriver instances to act as a signaling channel which exchanges offers and answers with candidates. This pattern is described in the testbed repository https://github.com/fippo/testbed from 2016, this is a "more modern" take on the same subject. To run the tests locally, * npm install --no-save chromedriver geckodriver * npm run mocha test/interop/connection
- Loading branch information
Showing
6 changed files
with
333 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
on: | ||
schedule: | ||
- cron: "30 5 * * *" | ||
push: | ||
jobs: | ||
interop: | ||
runs-on: ubuntu-latest | ||
timeout-minutes: 5 | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
browserA: [chrome, firefox] | ||
browserB: [firefox, chrome] | ||
bver: ['unstable'] | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: actions/setup-node@v3 | ||
- run: npm install | ||
- run: BROWSER=${{matrix.browserA}} BVER=${{matrix.bver}} ./node_modules/travis-multirunner/setup.sh | ||
- run: BROWSER=${{matrix.browserB}} BVER=${{matrix.bver}} ./node_modules/travis-multirunner/setup.sh | ||
- run: Xvfb :99 & | ||
- run: BROWSER_A=${{matrix.browserA}} BROWSER_B=${{matrix.browserB}} BVER=${{matrix.bver}} DISPLAY=:99.0 npm run mocha test/interop/connection.js |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
/* | ||
* Copyright (c) 2022 The WebRTC project authors. All Rights Reserved. | ||
* | ||
* Use of this source code is governed by a BSD-style license | ||
* that can be found in the LICENSE file in the root of the source | ||
* tree. | ||
*/ | ||
const {buildDriver} = require('../webdriver'); | ||
const {PeerConnection, MediaDevices} = require('../webrtcclient'); | ||
const steps = require('../steps'); | ||
|
||
const browserA = process.env.BROWSER_A || 'chrome'; | ||
const browserB = process.env.BROWSER_B || 'chrome'; | ||
|
||
describe(`basic interop test ${browserA} => ${browserB}`, function() { | ||
this.retries(3); // retry up to three times. | ||
let drivers; | ||
let clients; | ||
before(async () => { | ||
const options = { | ||
version: process.env.BVER || 'stable', | ||
browserLogging: true, | ||
} | ||
drivers = [ | ||
buildDriver(browserA, options), | ||
buildDriver(browserB, options), | ||
]; | ||
clients = drivers.map(driver => { | ||
return { | ||
connection: new PeerConnection(driver), | ||
mediaDevices: new MediaDevices(driver), | ||
}; | ||
}); | ||
}); | ||
after(async () => { | ||
await drivers.map(driver => driver.close()); | ||
}); | ||
|
||
it('establishes a connection', async () => { | ||
await Promise.all(drivers); // timeouts in before(Each)? | ||
await steps.step(drivers, (d) => d.get('https://webrtc.github.io/samples/emptypage.html'), 'Empty page loaded'); | ||
await steps.step(clients, (client) => client.connection.create(), 'Created RTCPeerConnection'); | ||
await steps.step(clients, async (client) => { | ||
const stream = await client.mediaDevices.getUserMedia({audio: true, video: true}); | ||
return Promise.all(stream.getTracks().map(async track => { | ||
return client.connection.addTrack(track, stream); | ||
})); | ||
}, 'Acquired and added audio/video stream'); | ||
const offerWithCandidates = await clients[0].connection.setLocalDescription(); | ||
await clients[1].connection.setRemoteDescription(offerWithCandidates); | ||
const answerWithCandidates = await clients[1].connection.setLocalDescription(); | ||
await clients[0].connection.setRemoteDescription(answerWithCandidates); | ||
|
||
await steps.step(drivers, (d) => steps.waitNVideosExist(d, 1), 'Video elements exist'); | ||
await steps.step(drivers, steps.waitAllVideosHaveEnoughData, 'Video elements have enough data'); | ||
}).timeout(30000); | ||
}).timeout(90000);; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/* | ||
* Copyright (c) 2022 The WebRTC project authors. All Rights Reserved. | ||
* | ||
* Use of this source code is governed by a BSD-style license | ||
* that can be found in the LICENSE file in the root of the source | ||
* tree. | ||
*/ | ||
const TIMEOUT = 10000; | ||
|
||
function step(drivers, cb, logMessage) { | ||
return Promise.all(drivers.map(driver => { | ||
return cb(driver); | ||
})).then(() => { | ||
if (logMessage) { | ||
console.log(logMessage); | ||
} | ||
}); | ||
} | ||
function waitNVideosExist(driver, n) { | ||
return driver.wait(() => { | ||
return driver.executeScript(n => document.querySelectorAll('video').length === n, n); | ||
}, TIMEOUT); | ||
} | ||
|
||
function waitAllVideosHaveEnoughData(driver) { | ||
return driver.wait(() => { | ||
return driver.executeScript(() => { | ||
const videos = document.querySelectorAll('video'); | ||
let ready = 0; | ||
for (let i = 0; i < videos.length; i++) { | ||
if (videos[i].readyState >= videos[i].HAVE_ENOUGH_DATA) { | ||
ready++; | ||
} | ||
} | ||
return ready === videos.length; | ||
}); | ||
}, TIMEOUT); | ||
} | ||
|
||
module.exports = { | ||
step, | ||
waitNVideosExist, | ||
waitAllVideosHaveEnoughData, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.