Skip to content

Instantly share code, notes, and snippets.

@jone
Last active December 12, 2015 07:58

Revisions

  1. jone revised this gist Feb 10, 2013. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion job-config.sh
    Original file line number Diff line number Diff line change
    @@ -26,4 +26,4 @@ export DESIRED_CAPABILITIES
    BROWSER=$(echo $SELENIUM_DRIVER | perl -pe 's|.*browser=(.*?)&.*|\1|')
    export BROWSER
    bin/test
    bin/test
  2. jone revised this gist Feb 9, 2013. 1 changed file with 6 additions and 28 deletions.
    34 changes: 6 additions & 28 deletions job-config.sh
    Original file line number Diff line number Diff line change
    @@ -1,15 +1,20 @@
    export REMOTE_URL="http://XXXX:[email protected]:80/wd/hub"
    export ZSERVER_HOST="0.0.0.0"
    export ZSERVER_PORT="2000"

    $PYTHON27 bootstrap.py
    bin/buildout

    DESIRED_CAPABILITIES=$(cat <<EOF | python -
    import os
    SELENIUM_DRIVER = os.environ.get('SELENIUM_DRIVER')
    DESIRED_CAPABILITIES = ''
    for item in SELENIUM_DRIVER.split('?', 1)[1].split('&')
    for item in SELENIUM_DRIVER.split('?', 1)[1].split('&'):
    DESIRED_CAPABILITIES += ','
    item = item.replace('=', ':')
    item = item.replace('os:', 'platform:')
    item = item.replace('browser-version:', 'version:')
    DESIRED_CAPABILITIES += item
    DESIRED_CAPABILITIES = DESIRED_CAPABILITIES[1:]
    JOB_NAME = os.environ.get('JOB_NAME').replace('jenkins-', '').replace('/SELENIUM_DRIVER=', ' | ')
    BULD_NUMBER = os.environ.get('BUILD_NUMBER')
    @@ -21,31 +26,4 @@ export DESIRED_CAPABILITIES
    BROWSER=$(echo $SELENIUM_DRIVER | perl -pe 's|.*browser=(.*?)&.*|\1|')
    export BROWSER
    ZSERVER_PORT=$(cat <<EOF | python -
    import socket
    # Sauce only tunnels certain ports, so we need to pick one of those ports and it should be
    # not used.
    # See port list at: https://saucelabs.com/docs/connect#localhost
    PORTS = [2000, 2001, 2020, 2222, 3000, 3001, 3030, 3333, 4000, 4001, 4040, 5000, 5001, 5050, 5555, 6000, 6001, 6060, 6666, 7000, 7070, 7777, 8000, 8001, 8080, 8888, 9000, 9001, 9080, 9090, 9999, 4502, 4503, 8003, 8031]
    def get_free_port():
    for port in PORTS:
    sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    sock.settimeout(60)
    try:
    sock.connect(('localhost', port))
    except socket.error:
    return port
    else:
    sock.close()
    print get_free_port()
    EOF
    )
    export ZSERVER_PORT
    $PYTHON27 bootstrap.py
    bin/buildout
    bin/test
  3. jone revised this gist Feb 9, 2013. 1 changed file with 15 additions and 2 deletions.
    17 changes: 15 additions & 2 deletions job-config.sh
    Original file line number Diff line number Diff line change
    @@ -1,8 +1,21 @@
    export REMOTE_URL="http://XXXX:[email protected]:80/wd/hub"
    export ZSERVER_HOST="0.0.0.0"


    DESIRED_CAPABILITIES=$(python -c "import os; print (','.join(map(lambda item: item.replace('=', ':').replace('os:', 'platform:').replace('browser-version:', 'version:'), os.environ.get('SELENIUM_DRIVER').split('?', 1)[1].split('&')))) + ',name:' + os.environ.get('JOB_NAME').replace('jenkins-', '').replace('/SELENIUM_DRIVER=', '|') + '|#' + os.environ.get('BUILD_NUMBER')")
    DESIRED_CAPABILITIES=$(cat <<EOF | python -
    import os
    SELENIUM_DRIVER = os.environ.get('SELENIUM_DRIVER')
    DESIRED_CAPABILITIES = ''
    for item in SELENIUM_DRIVER.split('?', 1)[1].split('&')
    DESIRED_CAPABILITIES += ','
    item = item.replace('=', ':')
    item = item.replace('os:', 'platform:')
    item = item.replace('browser-version:', 'version:')
    DESIRED_CAPABILITIES = DESIRED_CAPABILITIES[1:]
    JOB_NAME = os.environ.get('JOB_NAME').replace('jenkins-', '').replace('/SELENIUM_DRIVER=', ' | ')
    BULD_NUMBER = os.environ.get('BUILD_NUMBER')
    DESIRED_CAPABILITIES += ',name:' + JOB_NAME + ' | #' + BULD_NUMBER
    print DESIRED_CAPABILITIES
    EOF)
    export DESIRED_CAPABILITIES
    BROWSER=$(echo $SELENIUM_DRIVER | perl -pe 's|.*browser=(.*?)&.*|\1|')
  4. @garbas garbas revised this gist Feb 9, 2013. 1 changed file with 16 additions and 1 deletion.
    17 changes: 16 additions & 1 deletion gistfile1.sh
    Original file line number Diff line number Diff line change
    @@ -2,8 +2,23 @@ export REMOTE_URL="http://XXXX:[email protected]:80/wd/hub"
    export ZSERVER_HOST="0.0.0.0"


    DESIRED_CAPABILITIES=$(python -c "import os; print (','.join(map(lambda item: item.replace('=', ':').replace('os:', 'platform:').replace('browser-version:', 'version:'), os.environ.get('SELENIUM_DRIVER').split('?', 1)[1].split('&')))) + ',name:' + os.environ.get('JOB_NAME').replace('jenkins-', '').replace('/SELENIUM_DRIVER=', '|') + '|#' + os.environ.get('BUILD_NUMBER')")
    DESIRED_CAPABILITIES=$(cat <<EOF | python -
    import os
    SELENIUM_DRIVER = os.environ.get('SELENIUM_DRIVER')
    DESIRED_CAPABILITIES = ''
    for item in SELENIUM_DRIVER.split('?', 1)[1].split('&')
    DESIRED_CAPABILITIES += ','
    item = item.replace('=', ':')
    item = item.replace('os:', 'platform:')
    item = item.replace('browser-version:', 'version:')
    DESIRED_CAPABILITIES = DESIRED_CAPABILITIES[1:]
    JOB_NAME = os.environ.get('JOB_NAME').replace('jenkins-', '').replace('/SELENIUM_DRIVER=', ' | ')
    BULD_NUMBER = os.environ.get('BUILD_NUMBER')
    DESIRED_CAPABILITIES += ',name:' + JOB_NAME + ' | #' + BULD_NUMBER
    print DESIRED_CAPABILITIES
    EOF)
    export DESIRED_CAPABILITIES
    BROWSER=$(echo $SELENIUM_DRIVER | perl -pe 's|.*browser=(.*?)&.*|\1|')
    export BROWSER
  5. jone revised this gist Feb 9, 2013. 1 changed file with 26 additions and 0 deletions.
    26 changes: 26 additions & 0 deletions job-config.sh
    Original file line number Diff line number Diff line change
    @@ -4,9 +4,35 @@ export ZSERVER_HOST="0.0.0.0"

    DESIRED_CAPABILITIES=$(python -c "import os; print (','.join(map(lambda item: item.replace('=', ':').replace('os:', 'platform:').replace('browser-version:', 'version:'), os.environ.get('SELENIUM_DRIVER').split('?', 1)[1].split('&')))) + ',name:' + os.environ.get('JOB_NAME').replace('jenkins-', '').replace('/SELENIUM_DRIVER=', '|') + '|#' + os.environ.get('BUILD_NUMBER')")
    export DESIRED_CAPABILITIES

    BROWSER=$(echo $SELENIUM_DRIVER | perl -pe 's|.*browser=(.*?)&.*|\1|')
    export BROWSER

    ZSERVER_PORT=$(cat <<EOF | python -
    import socket
    # Sauce only tunnels certain ports, so we need to pick one of those ports and it should be
    # not used.
    # See port list at: https://saucelabs.com/docs/connect#localhost
    PORTS = [2000, 2001, 2020, 2222, 3000, 3001, 3030, 3333, 4000, 4001, 4040, 5000, 5001, 5050, 5555, 6000, 6001, 6060, 6666, 7000, 7070, 7777, 8000, 8001, 8080, 8888, 9000, 9001, 9080, 9090, 9999, 4502, 4503, 8003, 8031]
    def get_free_port():
    for port in PORTS:
    sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    sock.settimeout(60)
    try:
    sock.connect(('localhost', port))
    except socket.error:
    return port
    else:
    sock.close()
    print get_free_port()
    EOF
    )
    export ZSERVER_PORT

    $PYTHON27 bootstrap.py
    bin/buildout
    bin/test
  6. jone revised this gist Feb 9, 2013. 1 changed file with 2 additions and 1 deletion.
    3 changes: 2 additions & 1 deletion job-config.sh
    Original file line number Diff line number Diff line change
    @@ -1,7 +1,8 @@
    export REMOTE_URL="http://XXXX:[email protected]:80/wd/hub"
    export ZSERVER_HOST="0.0.0.0"

    DESIRED_CAPABILITIES=$(python -c "import os; print ','.join(map(lambda item: item.replace('=', ':').replace('os:', 'platform:').replace('browser-version:', 'version:'), os.environ.get('SELENIUM_DRIVER').split('?', 1)[1].split('&')))")

    DESIRED_CAPABILITIES=$(python -c "import os; print (','.join(map(lambda item: item.replace('=', ':').replace('os:', 'platform:').replace('browser-version:', 'version:'), os.environ.get('SELENIUM_DRIVER').split('?', 1)[1].split('&')))) + ',name:' + os.environ.get('JOB_NAME').replace('jenkins-', '').replace('/SELENIUM_DRIVER=', '|') + '|#' + os.environ.get('BUILD_NUMBER')")
    export DESIRED_CAPABILITIES
    BROWSER=$(echo $SELENIUM_DRIVER | perl -pe 's|.*browser=(.*?)&.*|\1|')
    export BROWSER
  7. jone renamed this gist Feb 9, 2013. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  8. jone revised this gist Feb 9, 2013. 2 changed files with 20 additions and 0 deletions.
    20 changes: 20 additions & 0 deletions get_free_port.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,20 @@
    import socket

    # Sauce only tunnels certain ports, so we need to pick one of those ports and it should be
    # not used.
    # See port list at: https://saucelabs.com/docs/connect#localhost
    PORTS = [2000, 2001, 2020, 2222, 3000, 3001, 3030, 3333, 4000, 4001, 4040, 5000, 5001, 5050, 5555, 6000, 6001, 6060, 6666, 7000, 7070, 7777, 8000, 8001, 8080, 8888, 9000, 9001, 9080, 9090, 9999, 4502, 4503, 8003, 8031]

    def get_free_port():
    for port in PORTS:
    sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    sock.settimeout(60)

    try:
    sock.connect(('localhost', port))
    except socket.error:
    return port
    else:
    sock.close()

    print get_free_port()
    File renamed without changes.
  9. @garbas garbas revised this gist Feb 8, 2013. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion gistfile1.sh
    Original file line number Diff line number Diff line change
    @@ -2,7 +2,7 @@ export REMOTE_URL="http://XXXX:[email protected]:80/wd/hub"
    export ZSERVER_HOST="0.0.0.0"


    DESIRED_CAPABILITIES=$(python -c "import os; print (','.join(map(lambda item: item.replace('=', ':').replace('os:', 'platform:').replace('browser-version:', 'version:'), os.environ.get('SELENIUM_DRIVER').split('?', 1)[1].split('&')))) + ',name:' + os.environ.get('JOB_NAME').replace('jenkins-', '').replace('-SELENIUM_DRIVER=', '|') + '|#' + os.environ.get('BUILD_NUMBER')")
    DESIRED_CAPABILITIES=$(python -c "import os; print (','.join(map(lambda item: item.replace('=', ':').replace('os:', 'platform:').replace('browser-version:', 'version:'), os.environ.get('SELENIUM_DRIVER').split('?', 1)[1].split('&')))) + ',name:' + os.environ.get('JOB_NAME').replace('jenkins-', '').replace('/SELENIUM_DRIVER=', '|') + '|#' + os.environ.get('BUILD_NUMBER')")
    export DESIRED_CAPABILITIES
    BROWSER=$(echo $SELENIUM_DRIVER | perl -pe 's|.*browser=(.*?)&.*|\1|')
    export BROWSER
  10. @garbas garbas revised this gist Feb 8, 2013. 1 changed file with 2 additions and 1 deletion.
    3 changes: 2 additions & 1 deletion gistfile1.sh
    Original file line number Diff line number Diff line change
    @@ -1,7 +1,8 @@
    export REMOTE_URL="http://XXXX:[email protected]:80/wd/hub"
    export ZSERVER_HOST="0.0.0.0"

    DESIRED_CAPABILITIES=$(python -c "import os; print ','.join(map(lambda item: item.replace('=', ':').replace('os:', 'platform:').replace('browser-version:', 'version:'), os.environ.get('SELENIUM_DRIVER').split('?', 1)[1].split('&')))")

    DESIRED_CAPABILITIES=$(python -c "import os; print (','.join(map(lambda item: item.replace('=', ':').replace('os:', 'platform:').replace('browser-version:', 'version:'), os.environ.get('SELENIUM_DRIVER').split('?', 1)[1].split('&')))) + ',name:' + os.environ.get('JOB_NAME').replace('jenkins-', '').replace('-SELENIUM_DRIVER=', '|') + '|#' + os.environ.get('BUILD_NUMBER')")
    export DESIRED_CAPABILITIES
    BROWSER=$(echo $SELENIUM_DRIVER | perl -pe 's|.*browser=(.*?)&.*|\1|')
    export BROWSER
  11. jone revised this gist Feb 8, 2013. 1 changed file with 4 additions and 3 deletions.
    7 changes: 4 additions & 3 deletions gistfile1.sh
    Original file line number Diff line number Diff line change
    @@ -1,10 +1,11 @@
    export REMOTE_URL="http://XXXX:[email protected]:80/wd/hub"
    export ZOPE_HOST="localhost"
    export ZSERVER_HOST="0.0.0.0"
    DESIRED_CAPABILITIES=$(python -c "import os; print dict(map(lambda item: item.split('='), os.environ.get('SELENIUM_DRIVER').split('?', 1)[1].split('&')))")

    DESIRED_CAPABILITIES=$(python -c "import os; print ','.join(map(lambda item: item.replace('=', ':').replace('os:', 'platform:').replace('browser-version:', 'version:'), os.environ.get('SELENIUM_DRIVER').split('?', 1)[1].split('&')))")
    export DESIRED_CAPABILITIES
    BROWSER=$(echo $SELENIUM_DRIVER | perl -pe 's|.*browser=(.*?)&.*|\1|')
    export BROWSER

    $PYTHON27 bootstrap.py
    bin/buildout
    bin/test
    bin/test
  12. jone revised this gist Feb 8, 2013. 1 changed file with 4 additions and 2 deletions.
    6 changes: 4 additions & 2 deletions gistfile1.sh
    Original file line number Diff line number Diff line change
    @@ -1,8 +1,10 @@
    export REMOTE_URL="http://XXXX:[email protected]:80/wd/hub"
    export ZOPE_HOST="localhost"
    export ZSERVER_HOST="0.0.0.0"
    export DESIRED_CAPABILITIES=$(echo \$SELENIUM_DRIVER | sed -e 's/sauce-ondemand:?//' -e 's/&/", "/g' -e 's/=/": "/g' -e 's/^\(.*\)\$/{"\1"}/')
    export BROWSER=$(echo \$SELENIUM_DRIVER | perl -pe 's|.*browser=(.*?)&.*|\1|')
    DESIRED_CAPABILITIES=$(python -c "import os; print dict(map(lambda item: item.split('='), os.environ.get('SELENIUM_DRIVER').split('?', 1)[1].split('&')))")
    export DESIRED_CAPABILITIES
    BROWSER=$(echo $SELENIUM_DRIVER | perl -pe 's|.*browser=(.*?)&.*|\1|')
    export BROWSER
    $PYTHON27 bootstrap.py
    bin/buildout
    bin/test
  13. jone revised this gist Feb 8, 2013. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion gistfile1.sh
    Original file line number Diff line number Diff line change
    @@ -2,7 +2,7 @@ export REMOTE_URL="http://XXXX:[email protected]:80/wd/hub"
    export ZOPE_HOST="localhost"
    export ZSERVER_HOST="0.0.0.0"
    export DESIRED_CAPABILITIES=$(echo \$SELENIUM_DRIVER | sed -e 's/sauce-ondemand:?//' -e 's/&/", "/g' -e 's/=/": "/g' -e 's/^\(.*\)\$/{"\1"}/')
    export BROWSER=$(echo $SELENIUM_DRIVER | perl -pe 's|.*browser=(.*?)&.*|\1|')
    export BROWSER=$(echo \$SELENIUM_DRIVER | perl -pe 's|.*browser=(.*?)&.*|\1|')
    $PYTHON27 bootstrap.py
    bin/buildout
    bin/test
  14. jone revised this gist Feb 8, 2013. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion gistfile1.sh
    Original file line number Diff line number Diff line change
    @@ -1,7 +1,7 @@
    export REMOTE_URL="http://XXXX:[email protected]:80/wd/hub"
    export ZOPE_HOST="localhost"
    export ZSERVER_HOST="0.0.0.0"
    export DESIRED_CAPABILITIES=$(echo $SELENIUM_DRIVER | sed -e 's/sauce-ondemand:?//' -e 's/&/", "/g' -e 's/=/": "/g' -e 's/^\(.*\)$/{"\1"}/')
    export DESIRED_CAPABILITIES=$(echo \$SELENIUM_DRIVER | sed -e 's/sauce-ondemand:?//' -e 's/&/", "/g' -e 's/=/": "/g' -e 's/^\(.*\)\$/{"\1"}/')
    export BROWSER=$(echo $SELENIUM_DRIVER | perl -pe 's|.*browser=(.*?)&.*|\1|')
    $PYTHON27 bootstrap.py
    bin/buildout
  15. jone revised this gist Feb 8, 2013. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions gistfile1.sh
    Original file line number Diff line number Diff line change
    @@ -1,8 +1,8 @@
    export REMOTE_URL="http://XXXX:[email protected]:80/wd/hub"
    export ZOPE_HOST="localhost"
    export ZSERVER_HOST="0.0.0.0"
    export DESIRED_CAPABILITIES=`echo $SELENIUM_DRIVER | sed -e 's/sauce-ondemand:?//' -e 's/&/", "/g' -e 's/=/": "/g' -e 's/^\(.*\)$/{"\1"}/'`
    export BROWSER=`echo $SELENIUM_DRIVER | perl -pe 's|.*browser=(.*?)&.*|\1|'`
    export DESIRED_CAPABILITIES=$(echo $SELENIUM_DRIVER | sed -e 's/sauce-ondemand:?//' -e 's/&/", "/g' -e 's/=/": "/g' -e 's/^\(.*\)$/{"\1"}/')
    export BROWSER=$(echo $SELENIUM_DRIVER | perl -pe 's|.*browser=(.*?)&.*|\1|')
    $PYTHON27 bootstrap.py
    bin/buildout
    bin/test
  16. jone created this gist Feb 8, 2013.
    8 changes: 8 additions & 0 deletions gistfile1.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,8 @@
    export REMOTE_URL="http://XXXX:[email protected]:80/wd/hub"
    export ZOPE_HOST="localhost"
    export ZSERVER_HOST="0.0.0.0"
    export DESIRED_CAPABILITIES=`echo $SELENIUM_DRIVER | sed -e 's/sauce-ondemand:?//' -e 's/&/", "/g' -e 's/=/": "/g' -e 's/^\(.*\)$/{"\1"}/'`
    export BROWSER=`echo $SELENIUM_DRIVER | perl -pe 's|.*browser=(.*?)&.*|\1|'`
    $PYTHON27 bootstrap.py
    bin/buildout
    bin/test