summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xmagnum/drivers/heat/template_def.py6
-rw-r--r--magnum/tests/unit/conductor/handlers/test_k8s_cluster_conductor.py8
-rw-r--r--magnum/tests/unit/drivers/test_template_definition.py4
3 files changed, 15 insertions, 3 deletions
diff --git a/magnum/drivers/heat/template_def.py b/magnum/drivers/heat/template_def.py
index 0849c32..d69bed6 100755
--- a/magnum/drivers/heat/template_def.py
+++ b/magnum/drivers/heat/template_def.py
@@ -313,7 +313,11 @@ class BaseTemplateDefinition(TemplateDefinition):
313 CONF.cluster.etcd_discovery_service_endpoint_format % 313 CONF.cluster.etcd_discovery_service_endpoint_format %
314 {'size': cluster.master_count}) 314 {'size': cluster.master_count})
315 try: 315 try:
316 discovery_url = requests.get(discovery_endpoint).text 316 discovery_request = requests.get(discovery_endpoint)
317 if discovery_request.status_code != requests.codes.ok:
318 raise exception.GetDiscoveryUrlFailed(
319 discovery_endpoint=discovery_endpoint)
320 discovery_url = discovery_request.text
317 except req_exceptions.RequestException as err: 321 except req_exceptions.RequestException as err:
318 LOG.error(six.text_type(err)) 322 LOG.error(six.text_type(err))
319 raise exception.GetDiscoveryUrlFailed( 323 raise exception.GetDiscoveryUrlFailed(
diff --git a/magnum/tests/unit/conductor/handlers/test_k8s_cluster_conductor.py b/magnum/tests/unit/conductor/handlers/test_k8s_cluster_conductor.py
index 01c0240..a793c09 100644
--- a/magnum/tests/unit/conductor/handlers/test_k8s_cluster_conductor.py
+++ b/magnum/tests/unit/conductor/handlers/test_k8s_cluster_conductor.py
@@ -161,6 +161,7 @@ class TestClusterConductorWithK8s(base.TestCase):
161 '"1","modifiedIndex":10,"createdIndex":10}}') 161 '"1","modifiedIndex":10,"createdIndex":10}}')
162 mock_resp = mock.MagicMock() 162 mock_resp = mock.MagicMock()
163 mock_resp.text = expected_result 163 mock_resp.text = expected_result
164 mock_resp.status_code = 200
164 mock_get.return_value = mock_resp 165 mock_get.return_value = mock_resp
165 cluster = objects.Cluster(self.context, **self.cluster_dict) 166 cluster = objects.Cluster(self.context, **self.cluster_dict)
166 mock_driver.return_value = k8s_dr.Driver() 167 mock_driver.return_value = k8s_dr.Driver()
@@ -502,6 +503,7 @@ class TestClusterConductorWithK8s(base.TestCase):
502 '"1","modifiedIndex":10,"createdIndex":10}}') 503 '"1","modifiedIndex":10,"createdIndex":10}}')
503 mock_resp = mock.MagicMock() 504 mock_resp = mock.MagicMock()
504 mock_resp.text = expected_result 505 mock_resp.text = expected_result
506 mock_resp.status_code = 200
505 mock_get.return_value = mock_resp 507 mock_get.return_value = mock_resp
506 cluster = objects.Cluster(self.context, **self.cluster_dict) 508 cluster = objects.Cluster(self.context, **self.cluster_dict)
507 mock_driver.return_value = k8s_coreos_dr.Driver() 509 mock_driver.return_value = k8s_coreos_dr.Driver()
@@ -580,7 +582,8 @@ class TestClusterConductorWithK8s(base.TestCase):
580 reqget): 582 reqget):
581 self.cluster_template_dict['cluster_distro'] = 'coreos' 583 self.cluster_template_dict['cluster_distro'] = 'coreos'
582 self.cluster_dict['discovery_url'] = None 584 self.cluster_dict['discovery_url'] = None
583 mock_req = mock.MagicMock(text='http://tokentest/h1/h2/h3') 585 mock_req = mock.MagicMock(text='http://tokentest/h1/h2/h3',
586 status_code=200)
584 reqget.return_value = mock_req 587 reqget.return_value = mock_req
585 cluster_template = objects.ClusterTemplate( 588 cluster_template = objects.ClusterTemplate(
586 self.context, **self.cluster_template_dict) 589 self.context, **self.cluster_template_dict)
@@ -763,7 +766,8 @@ class TestClusterConductorWithK8s(base.TestCase):
763 CONF.set_override('etcd_discovery_service_endpoint_format', 766 CONF.set_override('etcd_discovery_service_endpoint_format',
764 'http://etcd/test?size=%(size)d', 767 'http://etcd/test?size=%(size)d',
765 group='cluster') 768 group='cluster')
766 mock_req = mock.MagicMock(text='https://address/token') 769 mock_req = mock.MagicMock(text='https://address/token',
770 status_code=200)
767 reqget.return_value = mock_req 771 reqget.return_value = mock_req
768 772
769 (template_path, 773 (template_path,
diff --git a/magnum/tests/unit/drivers/test_template_definition.py b/magnum/tests/unit/drivers/test_template_definition.py
index 27a75ca..de6ace8 100644
--- a/magnum/tests/unit/drivers/test_template_definition.py
+++ b/magnum/tests/unit/drivers/test_template_definition.py
@@ -555,6 +555,7 @@ class AtomicK8sTemplateDefinitionTestCase(BaseTemplateDefinitionTestCase):
555 expected_discovery_url = 'http://etcd/token' 555 expected_discovery_url = 'http://etcd/token'
556 mock_resp = mock.MagicMock() 556 mock_resp = mock.MagicMock()
557 mock_resp.text = expected_discovery_url 557 mock_resp.text = expected_discovery_url
558 mock_resp.status_code = 200
558 mock_get.return_value = mock_resp 559 mock_get.return_value = mock_resp
559 mock_cluster = mock.MagicMock() 560 mock_cluster = mock.MagicMock()
560 mock_cluster.master_count = 10 561 mock_cluster.master_count = 10
@@ -592,6 +593,7 @@ class AtomicK8sTemplateDefinitionTestCase(BaseTemplateDefinitionTestCase):
592 def test_k8s_get_discovery_url_not_found(self, mock_get): 593 def test_k8s_get_discovery_url_not_found(self, mock_get):
593 mock_resp = mock.MagicMock() 594 mock_resp = mock.MagicMock()
594 mock_resp.text = '' 595 mock_resp.text = ''
596 mock_resp.status_code = 200
595 mock_get.return_value = mock_resp 597 mock_get.return_value = mock_resp
596 598
597 fake_cluster = mock.MagicMock() 599 fake_cluster = mock.MagicMock()
@@ -964,6 +966,7 @@ class AtomicSwarmTemplateDefinitionTestCase(base.TestCase):
964 expected_discovery_url = 'http://etcd/token' 966 expected_discovery_url = 'http://etcd/token'
965 mock_resp = mock.MagicMock() 967 mock_resp = mock.MagicMock()
966 mock_resp.text = expected_discovery_url 968 mock_resp.text = expected_discovery_url
969 mock_resp.status_code = 200
967 mock_get.return_value = mock_resp 970 mock_get.return_value = mock_resp
968 mock_cluster = mock.MagicMock() 971 mock_cluster = mock.MagicMock()
969 mock_cluster.discovery_url = None 972 mock_cluster.discovery_url = None
@@ -979,6 +982,7 @@ class AtomicSwarmTemplateDefinitionTestCase(base.TestCase):
979 def test_swarm_get_discovery_url_not_found(self, mock_get): 982 def test_swarm_get_discovery_url_not_found(self, mock_get):
980 mock_resp = mock.MagicMock() 983 mock_resp = mock.MagicMock()
981 mock_resp.text = '' 984 mock_resp.text = ''
985 mock_resp.status_code = 200
982 mock_get.return_value = mock_resp 986 mock_get.return_value = mock_resp
983 987
984 fake_cluster = mock.MagicMock() 988 fake_cluster = mock.MagicMock()