Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 13 additions & 13 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ jobs:
'add debugOnly and prodOnly packages' \
--retries ${METEOR_SELF_TEST_RETRIES} \
--headless \
--phantom
--browserstack
no_output_timeout: 20m
- run:
name: "Running self-test (Custom Warehouse Tests)"
Expand All @@ -190,7 +190,7 @@ jobs:
--retries ${METEOR_SELF_TEST_RETRIES} \
--exclude "${SELF_TEST_EXCLUDE}" \
--headless \
--phantom \
--browserstack \
--with-tag "custom-warehouse"
no_output_timeout: 20m
- run:
Expand Down Expand Up @@ -227,7 +227,7 @@ jobs:
--retries ${METEOR_SELF_TEST_RETRIES} \
--exclude "${SELF_TEST_EXCLUDE}" \
--headless \
--phantom \
--browserstack \
--junit ./tmp/results/junit/0.xml \
--without-tag "custom-warehouse"
no_output_timeout: 20m
Expand Down Expand Up @@ -268,7 +268,7 @@ jobs:
--retries ${METEOR_SELF_TEST_RETRIES} \
--exclude "${SELF_TEST_EXCLUDE}" \
--headless \
--phantom \
--browserstack \
--junit ./tmp/results/junit/1.xml \
--without-tag "custom-warehouse"
no_output_timeout: 20m
Expand Down Expand Up @@ -309,7 +309,7 @@ jobs:
--retries ${METEOR_SELF_TEST_RETRIES} \
--exclude "${SELF_TEST_EXCLUDE}" \
--headless \
--phantom \
--browserstack \
--junit ./tmp/results/junit/2.xml \
--without-tag "custom-warehouse"
no_output_timeout: 20m
Expand Down Expand Up @@ -350,7 +350,7 @@ jobs:
--retries ${METEOR_SELF_TEST_RETRIES} \
--exclude "${SELF_TEST_EXCLUDE}" \
--headless \
--phantom \
--browserstack \
--junit ./tmp/results/junit/3.xml \
--without-tag "custom-warehouse"
no_output_timeout: 20m
Expand Down Expand Up @@ -391,7 +391,7 @@ jobs:
--retries ${METEOR_SELF_TEST_RETRIES} \
--exclude "${SELF_TEST_EXCLUDE}" \
--headless \
--phantom \
--browserstack \
--junit ./tmp/results/junit/4.xml \
--without-tag "custom-warehouse"
no_output_timeout: 20m
Expand Down Expand Up @@ -432,7 +432,7 @@ jobs:
--retries ${METEOR_SELF_TEST_RETRIES} \
--exclude "${SELF_TEST_EXCLUDE}" \
--headless \
--phantom \
--browserstack \
--junit ./tmp/results/junit/5.xml \
--without-tag "custom-warehouse"
no_output_timeout: 20m
Expand Down Expand Up @@ -473,7 +473,7 @@ jobs:
--retries ${METEOR_SELF_TEST_RETRIES} \
--exclude "${SELF_TEST_EXCLUDE}" \
--headless \
--phantom \
--browserstack \
--junit ./tmp/results/junit/6.xml \
--without-tag "custom-warehouse"
no_output_timeout: 20m
Expand Down Expand Up @@ -514,7 +514,7 @@ jobs:
--retries ${METEOR_SELF_TEST_RETRIES} \
--exclude "${SELF_TEST_EXCLUDE}" \
--headless \
--phantom \
--browserstack \
--junit ./tmp/results/junit/7.xml \
--without-tag "custom-warehouse"
no_output_timeout: 20m
Expand Down Expand Up @@ -555,7 +555,7 @@ jobs:
--retries ${METEOR_SELF_TEST_RETRIES} \
--exclude "${SELF_TEST_EXCLUDE}" \
--headless \
--phantom \
--browserstack \
--junit ./tmp/results/junit/8.xml \
--without-tag "custom-warehouse"
no_output_timeout: 20m
Expand Down Expand Up @@ -596,7 +596,7 @@ jobs:
--retries ${METEOR_SELF_TEST_RETRIES} \
--exclude "${SELF_TEST_EXCLUDE}" \
--headless \
--phantom \
--browserstack \
--junit ./tmp/results/junit/9.xml \
--without-tag "custom-warehouse"
no_output_timeout: 20m
Expand Down Expand Up @@ -637,7 +637,7 @@ jobs:
--retries ${METEOR_SELF_TEST_RETRIES} \
--exclude "${SELF_TEST_EXCLUDE}" \
--headless \
--phantom \
--browserstack \
--junit ./tmp/results/junit/10.xml \
--without-tag "custom-warehouse"
no_output_timeout: 20m
Expand Down
103 changes: 49 additions & 54 deletions tools/tool-testing/clients/browserstack/index.js
Original file line number Diff line number Diff line change
@@ -1,23 +1,15 @@
import { execFile } from 'child_process';
import Client from '../../client.js';
import configuredClients from "./clients.js";
import configuredClients from './clients.js';
import { enterJob } from '../../../utils/buildmessage.js';
import { getUrlWithResuming } from '../../../utils/http-helpers.js';
import { execFileSync } from '../../../utils/processes.js';
import { ensureDependencies } from '../../../cli/dev-bundle-helpers.js';
import {
mkdtemp,
pathJoin,
chmod,
statOrNull,
readFile,
createWriteStream,
getDevBundle,
} from '../../../fs/files.js';
import { mkdtemp, pathJoin, chmod, statOrNull, readFile, createWriteStream, getDevBundle } from '../../../fs/files.js';

const NPM_DEPENDENCIES = {
'browserstack-webdriver': '2.41.1',
'browserstack-local': '1.3.0',
'browserstack-local': '1.3.4'
};

// A memoized key from BrowserStackClient._getBrowserStackKey.
Expand All @@ -27,43 +19,42 @@ export default class BrowserStackClient extends Client {
constructor(options) {
super(options);

enterJob({
title: 'Installing BrowserStack WebDriver in Meteor tool',
}, () => {
ensureDependencies(NPM_DEPENDENCIES);
});
enterJob(
{
title: 'Installing BrowserStack WebDriver in Meteor tool'
},
() => {
ensureDependencies(NPM_DEPENDENCIES);
}
);

this.npmPackageExports = require('browserstack-webdriver');

// Capabilities which are allowed by selenium.
this.config.seleniumOptions =
this.config.seleniumOptions || {};
this.config.seleniumOptions = this.config.seleniumOptions || {};

// Additional capabilities which are unique to BrowserStack.
this.config.browserStackOptions =
this.config.browserStackOptions || {};
this.config.browserStackOptions = this.config.browserStackOptions || {};

this._setName();
}

_setName() {
const name = this.config.seleniumOptions.browserName || "default";
const version = this.config.seleniumOptions.version || "";
const device =
this.config.browserStackOptions.realMobile &&
this.config.browserStackOptions.device || "";

this.name = "BrowserStack: " + name +
(version && ` Version ${version}`) +
(device && ` (Device: ${device})`);
const name = this.config.seleniumOptions.browserName || 'default';
const version = this.config.seleniumOptions.version || '';
const device = (this.config.browserStackOptions.realMobile && this.config.browserStackOptions.device) || '';

this.name = 'BrowserStack: ' + name + (version && ` Version ${version}`) + (device && ` (Device: ${device})`);
}

connect() {
const key = BrowserStackClient._getBrowserStackKey();
if (! key) {
console.log(key);
if (!key) {
throw new Error(
"BrowserStack key not found. Ensure that s3cmd is setup with " +
"S3 credentials, or set BROWSERSTACK_ACCESS_KEY in your environment.");
'BrowserStack key not found. Ensure that s3cmd is setup with ' +
'S3 credentials, or set BROWSERSTACK_ACCESS_KEY in your environment.'
);
}

const capabilities = {
Expand All @@ -81,8 +72,11 @@ export default class BrowserStackClient extends Client {
// On browsers that support it, capture the console
'browserstack.console': 'errors',

// Set local identifier as we test multiple instances in Meteor
'browserstack.localIdentifier': 'meteoropensource',

...this.config.seleniumOptions,
...this.config.browserStackOptions,
...this.config.browserStackOptions
};

const triggerRequest = () => {
Expand All @@ -92,11 +86,11 @@ export default class BrowserStackClient extends Client {
.build();

this.driver.get(this.url);
}
};

this._launchBrowserStackTunnel()
.then(triggerRequest)
.catch((e) => {
.catch(e => {
// In the event of an error, shut down the daemon.
this.stop();

Expand All @@ -114,7 +108,7 @@ export default class BrowserStackClient extends Client {

static _getBrowserStackKey() {
// Use the memoized version, first and foremost.
if (typeof browserStackKey !== "undefined") {
if (typeof browserStackKey !== 'undefined') {
return browserStackKey;
}

Expand All @@ -123,16 +117,17 @@ export default class BrowserStackClient extends Client {
}

// Try to get the credentials from S3 with the s3cmd tool.
const outputDir = pathJoin(mkdtemp(), "key");
const outputDir = pathJoin(mkdtemp(), 'key');
try {
execFileSync("s3cmd", ["get",
"s3://meteor-browserstack-keys/browserstack-key",
outputDir
]);
execFileSync('s3cmd', ['get', 's3://meteor-browserstack-keys/browserstack-key', outputDir]);

return (browserStackKey = readFile(outputDir, "utf8").trim());
return (browserStackKey = readFile(outputDir, 'utf8').trim());
} catch (e) {
// A failure is acceptable here; it was just a try.
// Throw an error so BrowserSTack does not silently fail.
throw new Error(
'BrowserStack key not found. Ensure that s3cmd is setup with ' +
'S3 credentials, or set BROWSERSTACK_ACCESS_KEY in your environment.'
);
}

return (browserStackKey = null);
Expand All @@ -146,11 +141,11 @@ export default class BrowserStackClient extends Client {
onlyAutomate: true,
verbose: true,
// The ",0" means "SSL off". It's localhost, after all.
only: `${this.host},${this.port},0`,
}
only: `${this.host},${this.port},0`
};

return new Promise((resolve, reject) => {
this.tunnelProcess.start(options, (err) => {
this.tunnelProcess.start(options, err => {
if (err) {
reject(err);
} else {
Expand All @@ -161,20 +156,20 @@ export default class BrowserStackClient extends Client {
}

static prerequisitesMet() {
return !! this._getBrowserStackKey();
return !!this._getBrowserStackKey();
}

static pushClients(clients, appConfig) {
configuredClients.forEach((client) => {
clients.push(new BrowserStackClient(
{
configuredClients.forEach(client => {
clients.push(
new BrowserStackClient({
...appConfig,
config: {
seleniumOptions: client.selenium,
browserStackOptions: client.browserstack,
},
},
));
browserStackOptions: client.browserstack
}
})
);
});
}
}