From 60fb787fa3fc3e4764310c9bbfd6f6927b665f3f Mon Sep 17 00:00:00 2001 From: Sukrit Khera Date: Tue, 1 Mar 2016 22:41:58 -0700 Subject: [PATCH 1/2] Use upstream configuration in addition to hosts, listeners to discover proxy ports --- deployer/__init__.py | 2 +- deployer/services/deployment.py | 4 +++- tests/unit/services/test_deployment.py | 11 ++++++++--- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/deployer/__init__.py b/deployer/__init__.py index 38d49d5..04e8f24 100644 --- a/deployer/__init__.py +++ b/deployer/__init__.py @@ -3,7 +3,7 @@ from celery.signals import setup_logging -__version__ = '0.4.4' +__version__ = '0.4.5' __author__ = 'sukrit' deployer.logger.init_logging() diff --git a/deployer/services/deployment.py b/deployer/services/deployment.py index f36ee9b..e892c7f 100644 --- a/deployer/services/deployment.py +++ b/deployer/services/deployment.py @@ -40,7 +40,9 @@ def get_exposed_ports(deployment): {listener.get('upstream-port') for listener in deployment.get('proxy', {}).get('listeners', {}) .values() - } + } | + {int(port) for port in deployment.get('proxy', {}).get( + 'upstreams', {})} ) diff --git a/tests/unit/services/test_deployment.py b/tests/unit/services/test_deployment.py index 9b0033f..cdf9b20 100644 --- a/tests/unit/services/test_deployment.py +++ b/tests/unit/services/test_deployment.py @@ -45,7 +45,7 @@ def test_get_exposed_ports_with_no_proxy(): eq_(ports, []) -def test_get_exposed_ports_with_hosts_and_listeners(): +def test_get_exposed_ports_with_hosts_listeners_and_upstreams(): # Given: Deployment parameters deployment = _create_test_deployment() @@ -77,6 +77,11 @@ def test_get_exposed_ports_with_hosts_and_listeners(): 'ssh': { 'upstream-port': 22 } + }, + 'upstreams': { + '8080': {}, + '8022': {}, + '8122': {} } } @@ -85,8 +90,8 @@ def test_get_exposed_ports_with_hosts_and_listeners(): # When: I get exposed ports for deployment ports = get_exposed_ports(deployment) - # Then: Empty set is returned - eq_(ports, [22, 8080, 8081, 8082]) + # Then: Exposed ports are returned + eq_(ports, [22, 8022, 8080, 8081, 8082, 8122]) @patch('deployer.services.deployment.get_discovered_nodes') From c6932b10606f2022470894f2829b6eeb2ab8c9a9 Mon Sep 17 00:00:00 2001 From: Sukrit Khera Date: Tue, 1 Mar 2016 23:20:32 -0700 Subject: [PATCH 2/2] Add instructions to upgrade pip --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 1f69ac4..51d68a2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,6 +9,7 @@ services: # command to install dependencies install: + - "pip install -U pip" - "pip install -r requirements.txt" - "pip install -r dev-requirements.txt"