This repository has been archived by the owner on Jul 29, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(blockingproxy): Add synchronization with BlockingProxy. (#3813)
This adds support for BlockingProxy behind the flag --useBlockingProxy. If set, the driver providers will start a proxy during their setup phase, passing the selenium address to the proxy and starting a webdriver client that talks to the proxy. Starting a proxy for each driver provider isn't strictly necessary. However, when we run with multiple capabilities it's easier to handle the logging if each Protractor instance has it's own proxy. Known issues: - Doesn't work with directConnect. You can get the address of chromedriver by mucking around in Selenium internals, but this probably changed for Selenium 3.0 and I doubt it's worth figuring out until we upgrade. - Doesn't yet work with webDriverProxy (but it's an easy fix)
- Loading branch information
Showing
18 changed files
with
209 additions
and
31 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,62 @@ | ||
import {ChildProcess, fork} from 'child_process'; | ||
import * as q from 'q'; | ||
|
||
import {Config} from './config'; | ||
import {Logger} from './logger'; | ||
|
||
const BP_PATH = require.resolve('blocking-proxy/built/lib/bin.js'); | ||
|
||
let logger = new Logger('BlockingProxy'); | ||
|
||
export class BlockingProxyRunner { | ||
bpProcess: ChildProcess; | ||
public port: number; | ||
|
||
constructor(private config: Config) {} | ||
|
||
start() { | ||
return q.Promise((resolve, reject) => { | ||
this.checkSupportedConfig(); | ||
|
||
let args = [ | ||
'--fork', '--seleniumAddress', this.config.seleniumAddress, '--rootElement', | ||
this.config.rootElement | ||
]; | ||
this.bpProcess = fork(BP_PATH, args, {silent: true}); | ||
logger.info('Starting BlockingProxy with args: ' + args.toString()); | ||
this.bpProcess | ||
.on('message', | ||
(data) => { | ||
this.port = data['port']; | ||
resolve(data['port']); | ||
}) | ||
.on('error', | ||
(err) => { | ||
reject(new Error('Unable to start BlockingProxy ' + err)); | ||
}) | ||
.on('exit', (code: number, signal: number) => { | ||
reject(new Error('BP exited with ' + code)); | ||
logger.error('Exited with ' + code); | ||
logger.error('signal ' + signal); | ||
}); | ||
|
||
this.bpProcess.stdout.on('data', (msg: Buffer) => { | ||
logger.debug(msg.toString().trim()); | ||
}); | ||
|
||
this.bpProcess.stderr.on('data', (msg: Buffer) => { | ||
logger.error(msg.toString().trim()); | ||
}); | ||
|
||
process.on('exit', () => { | ||
this.bpProcess.kill(); | ||
}) | ||
}) | ||
} | ||
|
||
checkSupportedConfig() { | ||
if (this.config.directConnect) { | ||
throw new Error('BlockingProxy not yet supported with directConnect!'); | ||
} | ||
} | ||
} |
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
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
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
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
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
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
Oops, something went wrong.