Skip to content

Commit

Permalink
test: replace travis-multirunner with @puppeter/browsers
Browse files Browse the repository at this point in the history
following what was done in adapter which is now back to supporting
Firefox stable. Also ignore CHROME_BIN environment variable to download
the actual Chrome version, see
  webrtcHacks/adapter#1157
  • Loading branch information
fippo committed Apr 20, 2024
1 parent 7ac95ca commit d5f7156
Show file tree
Hide file tree
Showing 25 changed files with 87 additions and 66 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/interop-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ jobs:
browserB: [firefox, chrome]
bver: ['unstable']
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
- 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: sudo rm /usr/bin/chromedriver /usr/bin/geckodriver # remove preinstalled github chromedriver/geckodriver from $PATH
- run: Xvfb :99 &
- run: BROWSER=${{matrix.browserA}} BVER=${{matrix.version}} node -e "require('./test/webdriver').buildDriver()" # preinstall
- run: BROWSER=${{matrix.browserB}} BVER=${{matrix.version}} node -e "require('./test/webdriver').buildDriver()" # preinstall
- run: BROWSER_A=${{matrix.browserA}} BROWSER_B=${{matrix.browserB}} BVER=${{matrix.bver}} DISPLAY=:99.0 node_modules/.bin/jest --retries=3 test/interop/
10 changes: 5 additions & 5 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
- run: npm install
- run: npm run eslint
- run: npm run stylelint
Expand All @@ -20,10 +20,10 @@ jobs:
browser: [chrome]
version: [stable]
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v3
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
- run: npm install
- run: BROWSER=${{matrix.browser}} BVER=${{matrix.version}} ./node_modules/travis-multirunner/setup.sh
- run: sudo rm /usr/bin/chromedriver # remove preinstalled github chromedriver from $PATH
- run: Xvfb :99 &
- run: BROWSER=${{matrix.browser}} BVER=${{matrix.version}} node -e "require('./test/webdriver').buildDriver()" # preinstall
- run: BROWSER=${{matrix.browser}} BVER=${{matrix.version}} DISPLAY=:99.0 npm run jest -- --retries=3
14 changes: 6 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
{
"name": "webrtc-samples",
"private": true,
"version": "1.0.0",
"description": "Project checking for WebRTC GitHub samples repo",
"keywords": [
"webrtc",
"demos",
"samples",
"javascript"
"webrtc"
],
"homepage": "https://github.com/webrtc/samples",
"homepage": "https://webrtc.github.io/samples/",
"bugs": {
"url": "https://github.com/webrtc/samples/issues"
},
Expand All @@ -29,14 +27,14 @@
"'**/third_party/*.js'"
],
"devDependencies": {
"@puppeteer/browsers": "^2.2.0",
"eslint": "^8.9.0",
"eslint-config-google": "^0.14.0",
"eslint-plugin-jest": "^27.4.0",
"http-server": "^14.1.0",
"jest": "^29.7.0",
"selenium-webdriver": "^4.12.0",
"selenium-webdriver": "^4.19.0",
"stylelint": "^14.5.3",
"stylelint-config-recommended": "^7.0.0",
"travis-multirunner": "^5.0.1"
"stylelint-config-recommended": "^7.0.0"
}
}
4 changes: 2 additions & 2 deletions src/content/datachannel/basic/js/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ const path = '/src/content/datachannel/basic/index.html';
const url = `${process.env.BASEURL ? process.env.BASEURL : ('file://' + process.cwd())}${path}`;

describe('datachannel basic', () => {
beforeAll(() => {
driver = seleniumHelpers.buildDriver();
beforeAll(async () => {
driver = await seleniumHelpers.buildDriver();
});
afterAll(() => {
return driver.quit();
Expand Down
4 changes: 2 additions & 2 deletions src/content/datachannel/channel/js/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ const path = '/src/content/datachannel/channel/index.html';
const url = `${process.env.BASEURL ? process.env.BASEURL : ('file://' + process.cwd())}${path}`;

describe('datachannel and broadcast channels', () => {
beforeAll(() => {
driver = seleniumHelpers.buildDriver();
beforeAll(async () => {
driver = await seleniumHelpers.buildDriver();
});
afterAll(() => {
return driver.quit();
Expand Down
4 changes: 2 additions & 2 deletions src/content/datachannel/datatransfer/js/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ const path = '/src/content/datachannel/datatransfer/index.html';
const url = `${process.env.BASEURL ? process.env.BASEURL : ('file://' + process.cwd())}${path}`;

describe('datachannel datatransfer', () => {
beforeAll(() => {
driver = seleniumHelpers.buildDriver();
beforeAll(async () => {
driver = await seleniumHelpers.buildDriver();
});
afterAll(() => {
return driver.quit();
Expand Down
4 changes: 2 additions & 2 deletions src/content/datachannel/filetransfer/js/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ const path = '/src/content/datachannel/filetransfer/index.html';
const url = `${process.env.BASEURL ? process.env.BASEURL : ('file://' + process.cwd())}${path}`;

describe('datachannel filetransfer', () => {
beforeAll(() => {
driver = seleniumHelpers.buildDriver();
beforeAll(async () => {
driver = await seleniumHelpers.buildDriver();
});
afterAll(() => {
return driver.quit();
Expand Down
4 changes: 2 additions & 2 deletions src/content/devices/input-output/js/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ const path = '/src/content/devices/input-output/index.html';
const url = `${process.env.BASEURL ? process.env.BASEURL : ('file://' + process.cwd())}${path}`;

describe('input-output', () => {
beforeAll(() => {
driver = seleniumHelpers.buildDriver();
beforeAll(async () => {
driver = await seleniumHelpers.buildDriver();
});
afterAll(() => {
return driver.quit();
Expand Down
4 changes: 2 additions & 2 deletions src/content/getusermedia/gum/js/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ const path = '/src/content/getusermedia/gum/index.html';
const url = `${process.env.BASEURL ? process.env.BASEURL : ('file://' + process.cwd())}${path}`;

describe('getUserMedia', () => {
beforeAll(() => {
driver = seleniumHelpers.buildDriver();
beforeAll(async () => {
driver = await seleniumHelpers.buildDriver();
});
afterAll(() => {
return driver.quit();
Expand Down
4 changes: 2 additions & 2 deletions src/content/getusermedia/resolution/js/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ const path = '/src/content/getusermedia/resolution/index.html';
const url = `${process.env.BASEURL ? process.env.BASEURL : ('file://' + process.cwd())}${path}`;

describe('getUserMedia resolutions', () => {
beforeAll(() => {
driver = seleniumHelpers.buildDriver();
beforeAll(async () => {
driver = await seleniumHelpers.buildDriver();
});
afterAll(() => {
return driver.quit();
Expand Down
4 changes: 2 additions & 2 deletions src/content/insertable-streams/endtoend-encryption/js/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ const path = '/src/content/insertable-streams/endtoend-encryption/index.html';
const url = `${process.env.BASEURL ? process.env.BASEURL : ('file://' + process.cwd())}${path}`;

describe('insertable streams e2ee', () => {
beforeAll(() => {
driver = seleniumHelpers.buildDriver();
beforeAll(async () => {
driver = await seleniumHelpers.buildDriver();
});
afterAll(() => {
return driver.quit();
Expand Down
4 changes: 2 additions & 2 deletions src/content/peerconnection/audio/js/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ const path = '/src/content/peerconnection/audio/index.html';
const url = `${process.env.BASEURL ? process.env.BASEURL : ('file://' + process.cwd())}${path}`;

describe('audio-only peerconnection', () => {
beforeAll(() => {
driver = seleniumHelpers.buildDriver();
beforeAll(async () => {
driver = await seleniumHelpers.buildDriver();
});
afterAll(() => {
return driver.quit();
Expand Down
4 changes: 2 additions & 2 deletions src/content/peerconnection/change-codecs/js/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ const path = '/src/content/peerconnection/change-codecs/index.html';
const url = `${process.env.BASEURL ? process.env.BASEURL : ('file://' + process.cwd())}${path}`;

describe('peerconnection with setCodecPreferences', () => {
beforeAll(() => {
driver = seleniumHelpers.buildDriver();
beforeAll(async () => {
driver = await seleniumHelpers.buildDriver();
});
afterAll(() => {
return driver.quit();
Expand Down
4 changes: 2 additions & 2 deletions src/content/peerconnection/channel/js/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ const path = '/src/content/peerconnection/channel/index.html';
const url = `${process.env.BASEURL ? process.env.BASEURL : ('file://' + process.cwd())}${path}`;

describe('peerconnection and broadcast channels', () => {
beforeAll(() => {
driver = seleniumHelpers.buildDriver();
beforeAll(async () => {
driver = await seleniumHelpers.buildDriver();
});
afterAll(() => {
return driver.quit();
Expand Down
4 changes: 2 additions & 2 deletions src/content/peerconnection/dtmf/js/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ const path = '/src/content/peerconnection/dtmf/index.html';
const url = `${process.env.BASEURL ? process.env.BASEURL : ('file://' + process.cwd())}${path}`;

describe('peerconnection dtmf', () => {
beforeAll(() => {
driver = seleniumHelpers.buildDriver();
beforeAll(async () => {
driver = await seleniumHelpers.buildDriver();
});
afterAll(() => {
return driver.quit();
Expand Down
4 changes: 2 additions & 2 deletions src/content/peerconnection/multiple/js/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ const path = '/src/content/peerconnection/multiple/index.html';
const url = `${process.env.BASEURL ? process.env.BASEURL : ('file://' + process.cwd())}${path}`;

describe('multiple peerconnections', () => {
beforeAll(() => {
driver = seleniumHelpers.buildDriver();
beforeAll(async () => {
driver = await seleniumHelpers.buildDriver();
});
afterAll(() => {
return driver.quit();
Expand Down
4 changes: 2 additions & 2 deletions src/content/peerconnection/munge-sdp/js/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ const path = '/src/content/peerconnection/munge-sdp/index.html';
const url = `${process.env.BASEURL ? process.env.BASEURL : ('file://' + process.cwd())}${path}`;

describe('peerconnection sdp munging', () => {
beforeAll(() => {
driver = seleniumHelpers.buildDriver();
beforeAll(async () => {
driver = await seleniumHelpers.buildDriver();
});
afterAll(() => {
return driver.quit();
Expand Down
4 changes: 2 additions & 2 deletions src/content/peerconnection/negotiate-timing/js/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ const path = '/src/content/peerconnection/negotiate-timing/index.html';
const url = `${process.env.BASEURL ? process.env.BASEURL : ('file://' + process.cwd())}${path}`;

describe('peerconnection with negotiation timing', () => {
beforeAll(() => {
driver = seleniumHelpers.buildDriver();
beforeAll(async () => {
driver = await seleniumHelpers.buildDriver();
});
afterAll(() => {
return driver.quit();
Expand Down
4 changes: 2 additions & 2 deletions src/content/peerconnection/pc1/js/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ const path = '/src/content/peerconnection/pc1/index.html';
const url = `${process.env.BASEURL ? process.env.BASEURL : ('file://' + process.cwd())}${path}`;

describe('simple peerconnection', () => {
beforeAll(() => {
driver = seleniumHelpers.buildDriver();
beforeAll(async () => {
driver = await seleniumHelpers.buildDriver();
});
afterAll(() => {
return driver.quit();
Expand Down
4 changes: 2 additions & 2 deletions src/content/peerconnection/restart-ice/js/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ const path = '/src/content/peerconnection/restart-ice/index.html';
const url = `${process.env.BASEURL ? process.env.BASEURL : ('file://' + process.cwd())}${path}`;

describe('peerconnection ice restart', () => {
beforeAll(() => {
driver = seleniumHelpers.buildDriver();
beforeAll(async () => {
driver = await seleniumHelpers.buildDriver();
});
afterAll(() => {
return driver.quit();
Expand Down
4 changes: 2 additions & 2 deletions src/content/peerconnection/states/js/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ const path = '/src/content/peerconnection/states/index.html';
const url = `${process.env.BASEURL ? process.env.BASEURL : ('file://' + process.cwd())}${path}`;

describe('peerconnection states', () => {
beforeAll(() => {
driver = seleniumHelpers.buildDriver();
beforeAll(async () => {
driver = await seleniumHelpers.buildDriver();
});
afterAll(() => {
return driver.quit();
Expand Down
4 changes: 2 additions & 2 deletions src/content/peerconnection/trickle-ice/js/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ const path = '/src/content/peerconnection/trickle-ice/index.html';
const url = `${process.env.BASEURL ? process.env.BASEURL : ('file://' + process.cwd())}${path}`;

describe('Trickle-Ice', () => {
beforeAll(() => {
driver = seleniumHelpers.buildDriver();
beforeAll(async () => {
driver = await seleniumHelpers.buildDriver();
});
afterAll(() => {
return driver.quit();
Expand Down
4 changes: 2 additions & 2 deletions src/content/peerconnection/upgrade/js/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ const path = '/src/content/peerconnection/upgrade/index.html';
const url = `${process.env.BASEURL ? process.env.BASEURL : ('file://' + process.cwd())}${path}`;

describe('peerconnection upgrade from audio-only to audio-video', () => {
beforeAll(() => {
driver = seleniumHelpers.buildDriver();
beforeAll(async () => {
driver = await seleniumHelpers.buildDriver();
});
afterAll(() => {
return driver.quit();
Expand Down
4 changes: 2 additions & 2 deletions test/interop/connection.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ describe(`basic interop test ${browserA} => ${browserB}`, function() {
browserLogging: true,
}
drivers = [
buildDriver(browserA, options),
buildDriver(browserB, options),
await buildDriver(browserA, options),
await buildDriver(browserB, options),
];
clients = drivers.map(driver => {
return {
Expand Down
37 changes: 30 additions & 7 deletions test/webdriver.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,47 @@
* tree.
*/
const os = require('os');
const path = require('path');

const webdriver = require('selenium-webdriver');
const chrome = require('selenium-webdriver/chrome');
const firefox = require('selenium-webdriver/firefox');
const safari = require('selenium-webdriver/safari');

const puppeteerBrowsers = require('@puppeteer/browsers');

async function download(browser, version, cacheDir, platform) {
const buildId = await puppeteerBrowsers
.resolveBuildId(browser, platform, version);
await puppeteerBrowsers.install({
browser,
buildId,
cacheDir,
platform
});
return buildId;
}
const cacheDir = path.join(process.cwd(), 'browsers');

if (os.platform() === 'win32') {
process.env.PATH += ';' + process.cwd() + '\\node_modules\\chromedriver\\lib\\chromedriver\\';
process.env.PATH += ';' + process.cwd() + '\\node_modules\\geckodriver';
} else {
process.env.PATH += ':node_modules/.bin';
process.env.PATH = path.join(process.env.PATH, 'node_modules', '.bin');
}

function buildDriver(browser = process.env.BROWSER || 'chrome', options = {version: process.env.BVER}) {
async function buildDriver(browser = process.env.BROWSER || 'chrome', options = {version: process.env.BVER}) {
const platform = puppeteerBrowsers.detectBrowserPlatform();

const buildId = await download(browser, options.version || 'stable',
cacheDir, platform);
if (browser === 'chrome') {
process.env.CHROME_BIN = puppeteerBrowsers
.computeExecutablePath({browser, buildId, cacheDir, platform});
} else if (browser === 'firefox') {
process.env.FIREFOX_BIN = puppeteerBrowsers
.computeExecutablePath({browser, buildId, cacheDir, platform});
}
// Chrome options.
const chromeOptions = new chrome.Options()
.addArguments('allow-insecure-localhost')
Expand All @@ -28,11 +55,8 @@ function buildDriver(browser = process.env.BROWSER || 'chrome', options = {versi
if (options.chromeFlags) {
options.chromeFlags.forEach((flag) => chromeOptions.addArguments(flag));
}

if (options.chromepath) {
chromeOptions.setChromeBinaryPath(options.chromepath);
} else if (os.platform() === 'linux' && options.version) {
chromeOptions.setChromeBinaryPath('browsers/bin/chrome-' + options.version);
}

if (!options.devices || options.headless) {
Expand Down Expand Up @@ -65,6 +89,7 @@ function buildDriver(browser = process.env.BROWSER || 'chrome', options = {versi
});
}

// Safari options.
const safariOptions = new safari.Options();
safariOptions.setTechnologyPreview(options.version === 'unstable');

Expand All @@ -73,8 +98,6 @@ function buildDriver(browser = process.env.BROWSER || 'chrome', options = {versi
let firefoxPath = firefox.Channel.RELEASE;
if (options.firefoxpath) {
firefoxPath = options.firefoxpath;
} else if (os.platform() == 'linux' && options.version) {
firefoxPath = 'browsers/bin/firefox-' + options.version;
}
if (options.headless) {
firefoxOptions.addArguments('-headless');
Expand Down

0 comments on commit d5f7156

Please sign in to comment.