From: Daniel Henrique Barboza <danielhb(a)linux.vnet.ibm.com>
Changed mockmodel and model/config.py to point to the proxy
port instead of the kimchid port, which is not exposed
anymore.
tests/utils was changed to launch a proxy instance
for each run_server call.
tests/test_rest.py changed to reflect the changes in model
and mockmodel.
Signed-off-by: Daniel Henrique Barboza <danielhb(a)linux.vnet.ibm.com>
---
src/kimchi/mockmodel.py | 2 +-
src/kimchi/model/config.py | 2 +-
tests/test_rest.py | 8 +++++---
tests/utils.py | 10 ++++++++--
4 files changed, 15 insertions(+), 7 deletions(-)
diff --git a/src/kimchi/mockmodel.py b/src/kimchi/mockmodel.py
index 8c7d7bb..82f75e3 100644
--- a/src/kimchi/mockmodel.py
+++ b/src/kimchi/mockmodel.py
@@ -832,7 +832,7 @@ class MockModel(object):
return disks.get_partition_details(name)
def config_lookup(self, name):
- return {'http_port': cherrypy.server.socket_port,
+ return {'http_port': cherrypy.config.nginx_port,
'display_proxy_port':
kconfig.get('display', 'display_proxy_port'),
'version': config.get_version()}
diff --git a/src/kimchi/model/config.py b/src/kimchi/model/config.py
index 7081373..c9e3e9d 100644
--- a/src/kimchi/model/config.py
+++ b/src/kimchi/model/config.py
@@ -40,7 +40,7 @@ class ConfigModel(object):
def lookup(self, name):
proxy_port = kconfig.get('display', 'display_proxy_port')
- return {'http_port': cherrypy.server.socket_port,
+ return {'http_port': cherrypy.config.nginx_port,
'display_proxy_port': proxy_port,
'version': get_version()}
diff --git a/tests/test_rest.py b/tests/test_rest.py
index a40ba93..ddb0aa9 100644
--- a/tests/test_rest.py
+++ b/tests/test_rest.py
@@ -49,14 +49,16 @@ ssl_port = None
def setUpModule():
- global test_server, model, host, port, ssl_port
+ global test_server, model, host, port, proxy_port, ssl_port
patch_auth()
model = kimchi.mockmodel.MockModel('/tmp/obj-store-test')
host = '127.0.0.1'
port = get_free_port('http')
+ proxy_port = get_free_port('proxy_port')
ssl_port = get_free_port('https')
- test_server = run_server(host, port, ssl_port, test_mode=True, model=model)
+ test_server = run_server(host, port, ssl_port, test_mode=True,
+ proxy_port=proxy_port, model=model)
def tearDownModule():
@@ -1356,7 +1358,7 @@ class RestTests(unittest.TestCase):
def test_config(self):
resp = self.request('/config').read()
conf = json.loads(resp)
- self.assertEquals(port, conf['http_port'])
+ self.assertEquals(proxy_port, conf['http_port'])
def test_capabilities(self):
resp = self.request('/config/capabilities').read()
diff --git a/tests/utils.py b/tests/utils.py
index fe03a1a..77e5d1d 100644
--- a/tests/utils.py
+++ b/tests/utils.py
@@ -93,16 +93,22 @@ def get_free_port(name='http'):
return _ports[name]
-def run_server(host, port, ssl_port, test_mode,
+def run_server(host, port, ssl_port, test_mode, proxy_port=None,
model=None, environment='development'):
+ if proxy_port is None:
+ proxy_port = get_free_port('proxy_port')
+ if ssl_port is None:
+ ssl_port = get_free_port('ssl_port')
args = type('_', (object,),
- {'host': host, 'port': port, 'ssl_port':
ssl_port,
+ {'host': host, 'port': port, 'proxy_ssl_port':
ssl_port,
+ 'proxy_port': proxy_port,
'ssl_cert': '', 'ssl_key': '',
'test': test_mode, 'access_log': '/dev/null',
'error_log': '/dev/null', 'environment':
environment,
'log_level': 'debug'})()
if model is not None:
setattr(args, 'model', model)
+
s = kimchi.server.Server(args)
t = threading.Thread(target=s.start)
t.setDaemon(True)
--
1.8.3.1