bslatkin / dpxdt

Make continuous deployment safe by comparing before and after webpage screenshots for each release. Depicted shows when any visual, perceptual differences are found. This is the ultimate, automated end-to-end test.
https://dpxdt-test.appspot.com
Apache License 2.0
1.44k stars 124 forks source link

Add a shortcut to waitFor a URL to resolve #98

Closed danvk closed 10 years ago

danvk commented 10 years ago

Waiting for a URL to resolve with some sort of timeout will be a very common pattern for tests (in fact, I'm having trouble thinking what else you would want to wait for).

Here's the incantation I'm currently using:

waitFor: |
    timeout=$(($(date +%s) + 5))  # 5 second timeout
    until \
        curl --silent -I 'http://localhost:5001/' | grep '200 OK' || \
        [[ $(date +%s) -gt $timeout ]]; do
      echo 'Waiting for server to start up...'
      sleep 1
    done

    if [[ $(date +%s) -gt $timeout ]]; then
      echo 'Server failed to start.' 1>&2
      exit 1
    else
      echo 'Server started!'
    fi

It would be better if this could be written as:

waitFor:
    url: http://localhost:5001/
    timeout: 10