-
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.
#16: A more solid take at starting a browsermob proxy on an unused port.
- Loading branch information
1 parent
9b94701
commit 0232440
Showing
2 changed files
with
18 additions
and
25 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 |
---|---|---|
@@ -1,36 +1,46 @@ | ||
#!/bin/bash | ||
|
||
# Starting the proxy as early as possible to minimize the risk of having the port taken by another proxy process | ||
/usr/bin/curl -s -X POST -d "port=$2" http://localhost:9090/proxy | ||
/usr/bin/curl -s -X PUT -d "captureHeaders=1" http://localhost:9090/proxy/$2/har | ||
|
||
/usr/bin/Xvfb :$1 -nolisten tcp -ac > /dev/null 2> /dev/null & | ||
XVFB_PID=$! | ||
|
||
export DISPLAY=:$1 | ||
mkdir /var/tmp/journeymonitor-firefox-profile-$XVFB_PID | ||
|
||
# Launching a browsermob proxy, ensuring that we don't work with a port that is already taken | ||
PROXY_STARTED=0 | ||
while [ $PROXY_STARTED -eq 0 ] | ||
do | ||
PROXY_PORT=$(( ( RANDOM % 32767 ) + 9091 )) | ||
PROXY_START_OUTPUT=`/usr/bin/curl -s -X POST -d "port=$PROXY_PORT" http://localhost:9090/proxy` | ||
if [ "$PROXY_START_OUTPUT" == "{\"port\":$PROXY_PORT}" ] | ||
then | ||
PROXY_STARTED=1 | ||
fi | ||
done | ||
|
||
/usr/bin/curl -s -X PUT -d "captureHeaders=1" http://localhost:9090/proxy/$PROXY_PORT/har | ||
|
||
# Firefoxes should not be started in parallel it seems | ||
sleep $[ ( $RANDOM % 10 ) + 1 ]s | ||
|
||
/usr/bin/java \ | ||
-jar /opt/selenese-runner-java/selenese-runner.jar \ | ||
--driver firefox \ | ||
--proxy localhost:$2 \ | ||
--proxy localhost:$PROXY_PORT \ | ||
--cli-args "--new-instance" \ | ||
--cli-args "--profile /var/tmp/journeymonitor-firefox-profile-$XVFB_PID" \ | ||
--width 1920 \ | ||
--height 1200 \ | ||
--screenshot-on-fail /var/tmp/journeymonitor-screenshots \ | ||
--strict-exit-code \ | ||
--timeout 120000 \ | ||
$3 | ||
$2 | ||
STATUS=$? | ||
|
||
echo $STATUS > /var/tmp/journeymonitor-testcase-run-$1-exit-status | ||
|
||
/usr/bin/curl -s http://localhost:9090/proxy/$2/har > /var/tmp/journeymonitor-testcase-run-$1-har | ||
/usr/bin/curl -s -X DELETE http://localhost:9090/proxy/$2 | ||
/usr/bin/curl -s http://localhost:9090/proxy/$PROXY_PORT/har > /var/tmp/journeymonitor-testcase-run-$1-har | ||
/usr/bin/curl -s -X DELETE http://localhost:9090/proxy/$PROXY_PORT | ||
|
||
rm -rf /var/tmp/journeymonitor-firefox-profile-$XVFB_PID | ||
kill $XVFB_PID |
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