From a224d53923e76e17e10ab31309d11632ebe8b5ba Mon Sep 17 00:00:00 2001 From: Marcello Stanisci Date: Sun, 13 Nov 2016 02:12:18 +0100 Subject: pack extension via xvfb'd chromium before running selenium test --- docker/selenium/crxmake.sh | 43 ------------------------------ docker/selenium/launch_chrome_container.sh | 3 ++- docker/selenium/launch_selenium_test.sh | 31 ++++++++------------- 3 files changed, 13 insertions(+), 64 deletions(-) delete mode 100755 docker/selenium/crxmake.sh diff --git a/docker/selenium/crxmake.sh b/docker/selenium/crxmake.sh deleted file mode 100755 index 539dbfc..0000000 --- a/docker/selenium/crxmake.sh +++ /dev/null @@ -1,43 +0,0 @@ -#!/bin/bash -e -# -# Purpose: Pack a Chromium extension directory into crx format -# Downloaded from https://developer.chrome.com/extensions/crx - -if test $# -ne 2; then - echo "Usage: crxmake.sh " - exit 1 -fi - -dir=$1 -key=$2 -name=$(basename "$dir") -crx="$name.crx" -pub="$name.pub" -sig="$name.sig" -zip="$name.zip" -trap 'rm -f "$pub" "$sig" "$zip"' EXIT - -# zip up the crx dir -cwd=$(pwd -P) -(cd "$dir" && zip -qr -9 -X "$cwd/$zip" .) - -# signature -openssl sha1 -sha1 -binary -sign "$key" < "$zip" > "$sig" - -# public key -openssl rsa -pubout -outform DER < "$key" > "$pub" 2>/dev/null - -byte_swap () { - # Take "abcdefgh" and return it as "ghefcdab" - echo "${1:6:2}${1:4:2}${1:2:2}${1:0:2}" -} - -crmagic_hex="4372 3234" # Cr24 -version_hex="0200 0000" # 2 -pub_len_hex=$(byte_swap $(printf '%08x\n' $(ls -l "$pub" | awk '{print $5}'))) -sig_len_hex=$(byte_swap $(printf '%08x\n' $(ls -l "$sig" | awk '{print $5}'))) -( - echo "$crmagic_hex $version_hex $pub_len_hex $sig_len_hex" | xxd -r -p - cat "$pub" "$sig" "$zip" -) > "$crx" -echo "Wrote $crx" diff --git a/docker/selenium/launch_chrome_container.sh b/docker/selenium/launch_chrome_container.sh index b24612a..d180299 100755 --- a/docker/selenium/launch_chrome_container.sh +++ b/docker/selenium/launch_chrome_container.sh @@ -1,3 +1,4 @@ #!/bin/bash -docker run --name big_heap -e JAVA_OPTS=-Xmx1g -d -p 4444:4444 selenium/standalone-chrome-debug +# If container runs out of heap space, add '-e JAVA_OPTS=-Xmx2g' +docker run -d -p 4444:4444 selenium/standalone-chrome-debug diff --git a/docker/selenium/launch_selenium_test.sh b/docker/selenium/launch_selenium_test.sh index 0ae6709..6bed99a 100755 --- a/docker/selenium/launch_selenium_test.sh +++ b/docker/selenium/launch_selenium_test.sh @@ -1,27 +1,18 @@ #!/bin/bash -# Takes only the docker-machine's IP address, assuming that the -# chrome-docker service runs on port 4444 - -# FIXME use getopt -TEMP=`getopt -o r: --long docker-ip: -n 'launch_selenium_test.sh' -- "$@"` -eval set -- "$TEMP" - -if test "$1" != '--docker-ip'; then - IP=$(docker-machine ip) -else - IP=$2 -fi - - -# update wallet -(cd $HOME/wallet-webex && git pull && ./configure && make) +# update wallet and pack extension +(cd $HOME/wallet-webex \ + && git pull \ + && ./configure \ + && make \ + && xvfb-run chromium --pack-extension $HOME/wallet-webex) eval $(docker-machine env) -# Yes, assume it's already running.. -docker restart big_heap + +# Get fresh image +docker restart container_chrome # call python3 selenium script python3 $HOME/wallet-webex/selenium/test.py \ - --ext-unpacked $HOME/wallet-webex \ - --remote http://$IP:4444/wd/hub + --ext=$HOME/ext.crx \ + --remote=http://$IP:4444/wd/hub -- cgit v1.2.3