Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add test to check if Nginx is serving requests #308

Merged
merged 1 commit into from May 5, 2016
Merged
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

Add test to check if Nginx is serving requests

urllib's error handling is not very helpful for this test, but I'm
using it in an effort to avoid extra dependencies. This only checks
if Nginx is alive and returning requests, not whether the HTTP status
codes indicate success. The reason for this is that the test pillars
we have in the repo are not valid, causing Buildbot and Homu to die
after starting, and thus Nginx returns 502 Bad Gateway errors when it
tries to reverse proxy requests.

Enable the test on Travis as well.
  • Loading branch information
aneeshusa committed Apr 7, 2016
commit 40cd1f7fd2b9628e298bea8ea6ca308e06d7f0e7
@@ -23,6 +23,6 @@ else

# TODO: don't hard-code this
if [ "${SALT_NODE_ID}" = "servo-master1" ]; then
./test.py sls.buildbot.master
./test.py sls.buildbot.master sls.nginx
fi
fi
No changes.
@@ -0,0 +1,23 @@
import urllib.request
import urllib.error

from tests.util import Failure, Success


def run():
try:
urllib.request.urlopen('http://localhost/')
except urllib.error.URLError as e:
# Can call e.read() if there was a response but the HTTP status code
# indicated error; the method is unavailable if a connection could not
# be made. Nginx is reverse proxying Homu and Buildbot, which will be
# dead on Travis because the test pillar credentials are not valid.

# Also, we're 'expecting' a string for e.reason (for the connection
# refused error case), but it may be another exception instance.
if not hasattr(e, 'read'):
return Failure("Nginx is not serving requests:", str(e.reason))

# No need to catch HTTPError or ContentTooShortError specially here

return Success("Nginx is serving requests")
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.