From c6db3e4f17847edd122a74fa09c7a985d6085933 Mon Sep 17 00:00:00 2001 From: Brian Haley Date: Mon, 16 Dec 2019 16:45:25 -0500 Subject: [PATCH] Support hacking 2.0.0 Eventually hacking will move to 2.0.0 (diskimage-builder is holding it back), and when it does there will be a few errors to fix. We can get ahead of it so it doesn't break us with some small changes for these items: F601 dictionary key $item repeated with different values F632 use ==/!= to compare str, bytes, and int literals E501 line too long While doing this noticed the lower-constraints.txt for hacking was set at 0.12.0, when test-requirements.txt had it at 1.1.0, so fixed that as well. Change-Id: I80d2a5f97e7a4896a8fa765c1971c8bb7e72d211 --- lower-constraints.txt | 2 +- octavia/api/common/pagination.py | 6 +++-- .../controller/worker/v2/controller_worker.py | 1 + .../functional/api/v2/test_load_balancer.py | 8 +++--- .../health_daemon/test_health_daemon.py | 26 ++++++++++++------- .../sample_configs/sample_configs_combined.py | 6 ++--- .../sample_configs/sample_configs_split.py | 6 ++--- .../health_drivers/test_update_db.py | 2 +- test-requirements.txt | 2 +- 9 files changed, 34 insertions(+), 25 deletions(-) diff --git a/lower-constraints.txt b/lower-constraints.txt index e14a245640..8d8a20348a 100644 --- a/lower-constraints.txt +++ b/lower-constraints.txt @@ -45,7 +45,7 @@ gitdb2==2.0.3 GitPython==2.1.8 greenlet==0.4.13 gunicorn==19.9.0 -hacking==0.12.0 +hacking==1.1.0 idna==2.6 imagesize==1.0.0 ipaddress==1.0.17 diff --git a/octavia/api/common/pagination.py b/octavia/api/common/pagination.py index 3ee8424f7b..11869a82d9 100644 --- a/octavia/api/common/pagination.py +++ b/octavia/api/common/pagination.py @@ -345,7 +345,8 @@ class PaginationHelper(object): default = PaginationHelper._get_default_column_value( model_attr.property.columns[0].type) attr = sa_sql.expression.case( - [(model_attr != None, # noqa: E711 # pylint: disable=singleton-comparison + # pylint: disable=singleton-comparison + [(model_attr != None, # noqa E711 model_attr), ], else_=default) crit_attrs.append((attr == marker_values[j])) @@ -353,7 +354,8 @@ class PaginationHelper(object): default = PaginationHelper._get_default_column_value( model_attr.property.columns[0].type) attr = sa_sql.expression.case( - [(model_attr != None, # noqa: E711 # pylint: disable=singleton-comparison + # pylint: disable=singleton-comparison + [(model_attr != None, # noqa E711 model_attr), ], else_=default) this_sort_dir = self.sort_keys[i][1] if this_sort_dir == constants.DESC: diff --git a/octavia/controller/worker/v2/controller_worker.py b/octavia/controller/worker/v2/controller_worker.py index 77417c96e7..ddc73b3a7f 100644 --- a/octavia/controller/worker/v2/controller_worker.py +++ b/octavia/controller/worker/v2/controller_worker.py @@ -53,6 +53,7 @@ def retryMaskFilter(record): return False return True + LOG.logger.addFilter(retryMaskFilter) diff --git a/octavia/tests/functional/api/v2/test_load_balancer.py b/octavia/tests/functional/api/v2/test_load_balancer.py index 47a97716a5..6ed1cbb992 100644 --- a/octavia/tests/functional/api/v2/test_load_balancer.py +++ b/octavia/tests/functional/api/v2/test_load_balancer.py @@ -1552,8 +1552,8 @@ class TestLoadBalancer(base.BaseAPITest): lbs = self.get( self.LBS_PATH, - params={'name': 'lb1', 'tags': 'test_tag2', - 'vip_address': '10.0.0.1', 'tags': 'test_tag1'} + params={'name': 'lb1', 'tags': 'test_tag1', + 'vip_address': '10.0.0.1'} ).json.get(self.root_tag_list) self.assertIsInstance(lbs, list) self.assertEqual(1, len(lbs)) @@ -1561,8 +1561,8 @@ class TestLoadBalancer(base.BaseAPITest): lbs = self.get( self.LBS_PATH, - params={'name': 'lb1', 'tags': 'test_tag2', - 'vip_address': '10.0.0.1', 'tags': 'test_tag3'} + params={'name': 'lb1', 'tags': 'test_tag3', + 'vip_address': '10.0.0.1'} ).json.get(self.root_tag_list) self.assertIsInstance(lbs, list) self.assertEqual(0, len(lbs)) diff --git a/octavia/tests/unit/amphorae/backends/health_daemon/test_health_daemon.py b/octavia/tests/unit/amphorae/backends/health_daemon/test_health_daemon.py index 558dda2310..381a0b67c8 100644 --- a/octavia/tests/unit/amphorae/backends/health_daemon/test_health_daemon.py +++ b/octavia/tests/unit/amphorae/backends/health_daemon/test_health_daemon.py @@ -33,11 +33,15 @@ LISTENER_ID1 = uuidutils.generate_uuid() LISTENER_ID2 = uuidutils.generate_uuid() LISTENER_IDS = [LISTENER_ID1, LISTENER_ID2] BASE_PATH = '/tmp/test' -SAMPLE_POOL_STATUS = {'432fc8b3-d446-48d4-bb64-13beb90e22bc': { - 'status': 'UP', - 'uuid': '432fc8b3-d446-48d4-bb64-13beb90e22bc', - 'members': { - '302e33d9-dee1-4de9-98d5-36329a06fb58': 'DOWN'}}} +SAMPLE_POOL_STATUS = { + '432fc8b3-d446-48d4-bb64-13beb90e22bc': { + 'status': 'UP', + 'uuid': '432fc8b3-d446-48d4-bb64-13beb90e22bc', + 'members': {'302e33d9-dee1-4de9-98d5-36329a06fb58': 'DOWN'}}, + '3661ed10-99db-4d2c-bffb-99b60eb876ff': { + 'status': 'UP', + 'uuid': '3661ed10-99db-4d2c-bffb-99b60eb876ff', + 'members': {'e657f950-a6a2-4d28-bffa-0c8a8c05f815': 'DOWN'}}} SAMPLE_BOGUS_POOL_STATUS = {LISTENER_ID1: { 'status': 'UP', @@ -112,11 +116,13 @@ SAMPLE_STATS_MSG = { 'tx': 0, 'rx': 0, 'ereq': 0}, 'status': 'OPEN'}, }, - 'pools': {'432fc8b3-d446-48d4-bb64-13beb90e22bc': { - 'members': {'302e33d9-dee1-4de9-98d5-36329a06fb58': 'DOWN'}, - 'status': 'UP'}, '432fc8b3-d446-48d4-bb64-13beb90e22bc': { - 'members': {'302e33d9-dee1-4de9-98d5-36329a06fb58': 'DOWN'}, - 'status': 'UP'}, + 'pools': { + '432fc8b3-d446-48d4-bb64-13beb90e22bc': { + 'members': {'302e33d9-dee1-4de9-98d5-36329a06fb58': 'DOWN'}, + 'status': 'UP'}, + '3661ed10-99db-4d2c-bffb-99b60eb876ff': { + 'members': {'e657f950-a6a2-4d28-bffa-0c8a8c05f815': 'DOWN'}, + 'status': 'UP'}, }, 'id': None, 'seq': 0, diff --git a/octavia/tests/unit/common/sample_configs/sample_configs_combined.py b/octavia/tests/unit/common/sample_configs/sample_configs_combined.py index b0b6453767..7374231aa2 100644 --- a/octavia/tests/unit/common/sample_configs/sample_configs_combined.py +++ b/octavia/tests/unit/common/sample_configs/sample_configs_combined.py @@ -602,9 +602,9 @@ def sample_listener_tuple(proto=None, monitor=True, alloc_default_pool=True, provisioning_status=constants.ACTIVE): proto = 'HTTP' if proto is None else proto if be_proto is None: - be_proto = 'HTTP' if proto is 'TERMINATED_HTTPS' else proto + be_proto = 'HTTP' if proto == 'TERMINATED_HTTPS' else proto topology = 'SINGLE' if topology is None else topology - port = '443' if proto is 'HTTPS' or proto is 'TERMINATED_HTTPS' else '80' + port = '443' if proto in ['HTTPS', 'TERMINATED_HTTPS'] else '80' peer_port = 1024 if peer_port is None else peer_port insert_headers = insert_headers or {} in_listener = collections.namedtuple( @@ -860,7 +860,7 @@ def sample_session_persistence_tuple(persistence_type=None, def sample_health_monitor_tuple(proto='HTTP', sample_hm=1, host_http_check=False, provisioning_status=constants.ACTIVE): - proto = 'HTTP' if proto is 'TERMINATED_HTTPS' else proto + proto = 'HTTP' if proto == 'TERMINATED_HTTPS' else proto monitor = collections.namedtuple( 'monitor', 'id, type, delay, timeout, fall_threshold, rise_threshold,' 'http_method, url_path, expected_codes, enabled, ' diff --git a/octavia/tests/unit/common/sample_configs/sample_configs_split.py b/octavia/tests/unit/common/sample_configs/sample_configs_split.py index 31d7478790..228bfe45b9 100644 --- a/octavia/tests/unit/common/sample_configs/sample_configs_split.py +++ b/octavia/tests/unit/common/sample_configs/sample_configs_split.py @@ -625,9 +625,9 @@ def sample_listener_tuple(proto=None, monitor=True, alloc_default_pool=True, provisioning_status=constants.ACTIVE): proto = 'HTTP' if proto is None else proto if be_proto is None: - be_proto = 'HTTP' if proto is 'TERMINATED_HTTPS' else proto + be_proto = 'HTTP' if proto == 'TERMINATED_HTTPS' else proto topology = 'SINGLE' if topology is None else topology - port = '443' if proto is 'HTTPS' or proto is 'TERMINATED_HTTPS' else '80' + port = '443' if proto in ['HTTPS', 'TERMINATED_HTTPS'] else '80' peer_port = 1024 if peer_port is None else peer_port insert_headers = insert_headers or {} in_listener = collections.namedtuple( @@ -879,7 +879,7 @@ def sample_session_persistence_tuple(persistence_type=None, def sample_health_monitor_tuple(proto='HTTP', sample_hm=1, host_http_check=False, provisioning_status=constants.ACTIVE): - proto = 'HTTP' if proto is 'TERMINATED_HTTPS' else proto + proto = 'HTTP' if proto == 'TERMINATED_HTTPS' else proto monitor = collections.namedtuple( 'monitor', 'id, type, delay, timeout, fall_threshold, rise_threshold,' 'http_method, url_path, expected_codes, enabled, ' diff --git a/octavia/tests/unit/controller/healthmanager/health_drivers/test_update_db.py b/octavia/tests/unit/controller/healthmanager/health_drivers/test_update_db.py index b0fd0078fd..0f58879983 100644 --- a/octavia/tests/unit/controller/healthmanager/health_drivers/test_update_db.py +++ b/octavia/tests/unit/controller/healthmanager/health_drivers/test_update_db.py @@ -460,7 +460,7 @@ class TestUpdateHealthDb(base.TestCase): "pool-id-1:listener-id-1": { "status": constants.UP, "members": {"member-id-1": constants.UP}}, - "pool-id-1:listener-id-1": { + "pool-id-1:listener-id-2": { "status": constants.UP, "members": {"member-id-1": constants.UP}}}, "recv_time": time.time() diff --git a/test-requirements.txt b/test-requirements.txt index 035b09071d..6bbd8979b2 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -9,7 +9,7 @@ flake8-import-order==0.12 # LGPLv3 mock>=2.0.0 # BSD python-subunit>=1.0.0 # Apache-2.0/BSD oslotest>=3.2.0 # Apache-2.0 -pylint>=1.9.2 # GPLv2 +pylint>=2.2.0 # GPLv2 testrepository>=0.0.18 # Apache-2.0/BSD testtools>=2.2.0 # MIT testresources>=2.0.0 # Apache-2.0/BSD