[Kimchi-devel] [PATCH] [Wok] Do not use proxy when running tests
Aline Manera
alinefm at linux.vnet.ibm.com
Mon Feb 27 13:42:24 UTC 2017
Hi Lucio,
After applying this patch, I got the following errors while running the
tests:
======================================================================
ERROR: test_production_env (test_server_root.ServerRootTests)
----------------------------------------------------------------------
Traceback (most recent call last):
File "test_server_root.py", line 47, in test_production_env
setup_server('production', server_root)
File "test_server_root.py", line 35, in setup_server
server_root=server_root)
File "utils.py", line 102, in run_server
s = wok.server.Server(args)
File "/home/alinefm/wok/src/wok/server.py", line 148, in __init__
self.reqLogger = RequestLogger()
File "/home/alinefm/wok/src/wok/reqlogger.py", line 123, in __init__
h = logging.handlers.WatchedFileHandler(log, 'a')
File "/usr/lib64/python2.7/logging/handlers.py", line 391, in __init__
logging.FileHandler.__init__(self, filename, mode, encoding, delay)
File "/usr/lib64/python2.7/logging/__init__.py", line 913, in __init__
StreamHandler.__init__(self, self._open())
File "/usr/lib64/python2.7/logging/__init__.py", line 943, in _open
stream = open(self.baseFilename, self.mode)
IOError: [Errno 13] Permission denied:
'/home/alinefm/wok/data/user-requests.data'
======================================================================
ERROR: test_production_env (test_server_root.ServerRootTests)
----------------------------------------------------------------------
Traceback (most recent call last):
File "test_server_root.py", line 40, in tearDown
test_server.stop()
AttributeError: 'NoneType' object has no attribute 'stop'
----------------------------------------------------------------------
Ran 21 tests in 30.105s
FAILED (errors=12)
I have already deleted the former user-requests.data file but the error
keeps the same.
Do I need to do something before tetsing this patch?
Regards,
Aline Manera
On 02/24/2017 05:54 PM, Lucio Correia wrote:
> Currently administration permissions are required to
> run tests in order to change nginx configuration.
>
> With this patch, tests requests are handled directly by
> cherrypy, without being proxied by nginx. This allows
> tests to be run without administration permissions.
>
> Signed-off-by: Lucio Correia <luciojhc at linux.vnet.ibm.com>
> ---
> src/wok/server.py | 3 ++-
> tests/utils.py | 17 ++++++++++++-----
> 2 files changed, 14 insertions(+), 6 deletions(-)
>
> diff --git a/src/wok/server.py b/src/wok/server.py
> index fc2e167..cdffe6d 100644
> --- a/src/wok/server.py
> +++ b/src/wok/server.py
> @@ -69,7 +69,8 @@ class Server(object):
> config.config.set(sec, item, str(getattr(options, item)))
>
> # Check proxy configuration
> - check_proxy_config()
> + if not hasattr(options, 'no_proxy') or not options.no_proxy:
> + check_proxy_config()
>
> make_dirs = [
> os.path.abspath(config.get_log_download_path()),
> diff --git a/tests/utils.py b/tests/utils.py
> index 3c7e9da..2e4c63a 100644
> --- a/tests/utils.py
> +++ b/tests/utils.py
> @@ -40,6 +40,7 @@ from wok.exception import NotFoundError, OperationFailed
> from wok.utils import wok_log
>
> HOST = '0.0.0.0'
> +PORT = 8010
> PROXY_PORT = 8001
>
> fake_user = {'admin': 'letmein!', 'user': 'letmein!'}
> @@ -88,14 +89,15 @@ if sys.version_info[:2] == (2, 6):
> unittest.TestCase.assertNotIn = assertNotIn
>
>
> -def run_server(test_mode, environment='dev', server_root=''):
> +def run_server(test_mode, environment='dev', server_root='', no_proxy=True):
>
> + port = PORT if no_proxy else PROXY_PORT
> args = type('_', (object,),
> - {'cherrypy_port': 8010, 'max_body_size': '4*1024',
> + {'cherrypy_port': port, 'max_body_size': '4*1024',
> 'test': test_mode, 'access_log': '/dev/null',
> 'error_log': '/dev/null', 'environment': environment,
> 'log_level': 'debug', 'session_timeout': 10,
> - 'server_root': server_root})()
> + 'server_root': server_root, 'no_proxy': no_proxy})()
>
> s = wok.server.Server(args)
> t = threading.Thread(target=s.start)
> @@ -121,8 +123,8 @@ def _request(conn, path, data, method, headers, user):
> return conn.getresponse()
>
>
> -def request(path, data=None, method='GET', headers=None, user='admin'):
> - # verify if HTTPSConnection has context parameter
> +def requestHttps(path, data=None, method='GET', headers=None, user='admin'):
> + # To work, this requires run_server() to be called with no_proxy=False.
> if "context" in inspect.getargspec(httplib.HTTPSConnection.__init__).args:
> context = ssl._create_unverified_context()
> conn = httplib.HTTPSConnection(HOST, PROXY_PORT, context=context)
> @@ -132,6 +134,11 @@ def request(path, data=None, method='GET', headers=None, user='admin'):
> return _request(conn, path, data, method, headers, user)
>
>
> +def request(path, data=None, method='GET', headers=None, user='admin'):
> + conn = httplib.HTTPConnection(HOST, PORT)
> + return _request(conn, path, data, method, headers, user)
> +
> +
> class FakeUser(User):
> auth_type = "fake"
>
More information about the Kimchi-devel
mailing list