Skip to content

Commit

Permalink
feat(config): allow SE traffic to be sent via Sauce Connect's Relay
Browse files Browse the repository at this point in the history
Tests with Sauce Connect have two connections to Sauce Labs, a
tunnel from Sauce Connect client to host, and Selenium commands themselves which are sent independently.

Sauce Connect is able to relay Selenium commands through the established tunnel, which helps obviate proxy and other issues with Selenium traffic.

This change adds config values `connectLocationForSERelay` and
`connectPortForSERelay` which allow users to make Karma send Selenium
commands through a Sauce Connect instance at that host and port.
  • Loading branch information
DylanLacey authored and dignifiedquire committed Aug 22, 2017
1 parent 0219065 commit 0ac67d4
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 3 deletions.
13 changes: 13 additions & 0 deletions README.md
Expand Up @@ -128,6 +128,19 @@ Default:

Options to send to Sauce Connect. Check [here](https://github.com/bermi/sauce-connect-launcher#advanced-usage) for all available options.

### connectLocationForSERelay
Type: `String`
default: `ondemand.saucelabs.com`

If set, will attempt to connect to the specified host as a Selenium relay. This is intended to send Selenium commands through a Sauce Connect tunnel.

### connectPortForSERelay
Type: `Integer`
Default: 80

If set, will change the host used to connect to the Selenium server. This is intended to send Selenium commands through a Sauce Connect tunnel.


### build
Type: `String`
Default: *One of the following environment variables*:
Expand Down
13 changes: 10 additions & 3 deletions lib/sauce_launcher.js
Expand Up @@ -28,6 +28,9 @@ function processConfig (helper, config, args) {
tunnelIdentifier: tunnelIdentifier
})

var seleniumHostLocation = config.connectLocationForSERelay || 'ondemand.saucelabs.com'
var seleniumHostPort = config.connectPortForSERelay || connectOptions.port || 80

var build = process.env.BUILD_NUMBER ||
process.env.BUILD_TAG ||
process.env.CI_BUILD_NUMBER ||
Expand Down Expand Up @@ -78,8 +81,10 @@ function processConfig (helper, config, args) {
browserName: browserName,
username: username,
accessKey: accessKey,
proxy: proxy,
startConnect: startConnect
startConnect: startConnect,
seleniumHost: seleniumHostLocation,
seleniumPort: seleniumHostPort,
proxy: proxy
}
}

Expand All @@ -104,6 +109,8 @@ var SauceLauncher = function (
var accessKey = pConfig.accessKey
var proxy = pConfig.proxy
var startConnect = pConfig.startConnect
var seleniumHost = pConfig.seleniumHost
var seleniumPort = pConfig.seleniumPort

var pendingCancellations = 0
var sessionIsReady = false
Expand All @@ -115,7 +122,7 @@ var SauceLauncher = function (
var log = logger.create('launcher.sauce')
var driverLog = logger.create('wd')

var driver = wd.promiseChainRemote('ondemand.saucelabs.com', 80, username, accessKey)
var driver = wd.promiseChainRemote(seleniumHost, seleniumPort, username, accessKey)

driver.on('status', function (info) {
driverLog.debug(info.cyan)
Expand Down

0 comments on commit 0ac67d4

Please sign in to comment.