From 2c88c553ae619f41e2989bd045a049a0889f55bf Mon Sep 17 00:00:00 2001 From: Adam Harwell Date: Thu, 4 Oct 2018 16:08:00 -0700 Subject: [PATCH] HTTPS HMs need the same validation path as HTTP++ Second take on this patch, didn't realize the Create and the Update paths were different. Same exact change as the other patch, but in the update validation method. For reference: https://review.openstack.org/#/c/604924/ Change-Id: I916ccb7658d4849b3c208405ec40fc1a0eab4ba7 --- octavia/api/v2/controllers/health_monitor.py | 3 ++- .../functional/api/v2/test_health_monitor.py | 23 +++++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/octavia/api/v2/controllers/health_monitor.py b/octavia/api/v2/controllers/health_monitor.py index baa57ef90d..2f50b59a32 100644 --- a/octavia/api/v2/controllers/health_monitor.py +++ b/octavia/api/v2/controllers/health_monitor.py @@ -257,7 +257,8 @@ class HealthMonitorController(base.BaseController): return db_hm def _validate_update_hm(self, db_hm, health_monitor): - if db_hm.type != consts.HEALTH_MONITOR_HTTP: + if db_hm.type not in (consts.HEALTH_MONITOR_HTTP, + consts.HEALTH_MONITOR_HTTPS): if health_monitor.http_method != wtypes.Unset: raise exceptions.InvalidOption( value=consts.HTTP_METHOD, option='health monitors of ' diff --git a/octavia/tests/functional/api/v2/test_health_monitor.py b/octavia/tests/functional/api/v2/test_health_monitor.py index 27375edd94..fdbf538a61 100644 --- a/octavia/tests/functional/api/v2/test_health_monitor.py +++ b/octavia/tests/functional/api/v2/test_health_monitor.py @@ -1129,6 +1129,29 @@ class TestHealthMonitor(base.BaseAPITest): healthmonitor_id=api_hm.get('id'))).json.get(self.root_tag) self.assertEqual(2, response[constants.MAX_RETRIES]) + def test_update_HTTPS(self): + api_hm = self.create_health_monitor( + self.pool_with_listener_id, + constants.HEALTH_MONITOR_HTTPS, 1, 1, 1, 1, + admin_state_up=False, expected_codes='200', + http_method='GET', name='Test HM', url_path='/').get(self.root_tag) + self.set_lb_status(self.lb_id) + self.assertEqual('/', api_hm[constants.URL_PATH]) + new_hm = {constants.URL_PATH: '/health'} + self.put( + self.HM_PATH.format(healthmonitor_id=api_hm.get('id')), + self._build_body(new_hm)) + self.assert_correct_status( + lb_id=self.lb_id, listener_id=self.listener_id, + pool_id=self.pool_with_listener_id, hm_id=api_hm.get('id'), + lb_prov_status=constants.PENDING_UPDATE, + listener_prov_status=constants.PENDING_UPDATE, + pool_prov_status=constants.PENDING_UPDATE, + hm_prov_status=constants.PENDING_UPDATE) + response = self.get(self.HM_PATH.format( + healthmonitor_id=api_hm.get('id'))).json.get(self.root_tag) + self.assertEqual('/health', response[constants.URL_PATH]) + def test_update_TCP(self): api_hm = self.create_health_monitor( self.pool_with_listener_id,