Testing improvements.

Fixes bug 903349 -- sets socket timeout and overrides httplib2 connection
method so that escaping external URI calls don't sit around forever.

Fixes bug 894776 -- run_tests.sh properly respects the -N flag again.

Change-Id: I979f49f065021cb91d8b9d01b6a36f78de1897df
This commit is contained in:
Gabriel Hurley 2011-12-12 11:34:42 -08:00
parent 17b02f9e6e
commit c63d0973fa
3 changed files with 30 additions and 15 deletions

View File

@ -25,6 +25,7 @@ from django import shortcuts
from django import test as django_test
from django import template as django_template
from django.conf import settings
import httplib2
import mox
from horizon import context_processors
@ -114,6 +115,13 @@ class TestCase(django_test.TestCase):
def setUp(self):
self.mox = mox.Mox()
def fake_conn_request(*args, **kwargs):
raise Exception("An external URI request tried to escape through "
"an httplib2 client. Args: %s, kwargs: %s"
% (args, kwargs))
self._real_conn_request = httplib2.Http._conn_request
httplib2.Http._conn_request = fake_conn_request
self._real_horizon_context_processor = context_processors.horizon
context_processors.horizon = lambda request: self.TEST_CONTEXT
@ -127,6 +135,7 @@ class TestCase(django_test.TestCase):
def tearDown(self):
self.mox.UnsetStubs()
httplib2.Http._conn_request = self._real_conn_request
context_processors.horizon = self._real_horizon_context_processor
users.get_user_from_request = self._real_get_user_from_request
self.mox.VerifyAll()

View File

@ -19,6 +19,9 @@
# under the License.
import os
import socket
socket.setdefaulttimeout(1)
ROOT_PATH = os.path.dirname(os.path.abspath(__file__))
DEBUG = True

View File

@ -209,21 +209,24 @@ function environment_check {
function sanity_check {
# Anything that should be determined prior to running the tests, server, etc.
if [ ! -e ${venv} ]; then
echo "Virtualenv not found at openstack-dashboard/.dashboard-venv. Did install_venv.py succeed?"
exit 1
fi
if [ ! -f horizon/bin/test ]; then
echo "Error: Test script not found at horizon/bin/test. Did buildout succeed?"
exit 1
fi
if [ ! -f horizon/bin/coverage ]; then
echo "Error: Coverage script not found at horizon/bin/coverage. Did buildout succeed?"
exit 1
fi
if [ ! -f horizon/bin/seleniumrc ]; then
echo "Error: Selenium script not found at horizon/bin/seleniumrc. Did buildout succeed?"
exit 1
# Don't sanity-check anything environment-related in -N flag is set
if [ $never_venv -eq 0 ]; then
if [ ! -e ${venv} ]; then
echo "Virtualenv not found at openstack-dashboard/.dashboard-venv. Did install_venv.py succeed?"
exit 1
fi
if [ ! -f horizon/bin/test ]; then
echo "Error: Test script not found at horizon/bin/test. Did buildout succeed?"
exit 1
fi
if [ ! -f horizon/bin/coverage ]; then
echo "Error: Coverage script not found at horizon/bin/coverage. Did buildout succeed?"
exit 1
fi
if [ ! -f horizon/bin/seleniumrc ]; then
echo "Error: Selenium script not found at horizon/bin/seleniumrc. Did buildout succeed?"
exit 1
fi
fi
}