From 1ddfa88fec6a32cdf5f31aac59156fe74783cd14 Mon Sep 17 00:00:00 2001 From: Andreas Jaeger Date: Tue, 31 Mar 2020 21:48:51 +0200 Subject: [PATCH] Update hacking for Python3 The repo is Python 3 now, so update hacking to version 3.0 which supports Python 3. Fix problems found by updated hacking version. The tempest plugin is used on older branches as well. We really only need hacking on master anyways, where we no longer support python 2, so here we make the requirement specific to python 3. Change-Id: I39f95e4ce193c1435c4901825bed949cdaaba72e --- monasca_tempest_tests/tests/api/constants.py | 4 ++-- monasca_tempest_tests/tests/api/test_alarm_definitions.py | 2 +- monasca_tempest_tests/tests/api/test_alarms_count.py | 2 +- test-requirements.txt | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/monasca_tempest_tests/tests/api/constants.py b/monasca_tempest_tests/tests/api/constants.py index 0caf3b6..9146d78 100644 --- a/monasca_tempest_tests/tests/api/constants.py +++ b/monasca_tempest_tests/tests/api/constants.py @@ -21,7 +21,7 @@ ALARM_DEFINITION_CREATION_WAIT = 3 MAX_METRIC_NAME_LENGTH = 255 MAX_DIMENSION_KEY_LENGTH = 255 MAX_DIMENSION_VALUE_LENGTH = 255 -INVALID_DIMENSION_CHARS = "<>={},\"\;&" +INVALID_DIMENSION_CHARS = "<>={},\"\\;&" INVALID_NAME_CHARS = INVALID_DIMENSION_CHARS + "()" MAX_ALARM_DEFINITION_NAME_LENGTH = 255 @@ -31,7 +31,7 @@ MAX_ALARM_DEFINITION_ACTIONS_LENGTH = 50 MAX_NOTIFICATION_METHOD_NAME_LENGTH = 250 MAX_NOTIFICATION_METHOD_TYPE_LENGTH = 100 MAX_NOTIFICATION_METHOD_ADDRESS_LENGTH = 512 -INVALID_CHARS_NOTIFICATION = "<>={}(),\"\;&" +INVALID_CHARS_NOTIFICATION = "<>={}(),\"\\;&" MAX_LIST_MEASUREMENTS_NAME_LENGTH = 255 diff --git a/monasca_tempest_tests/tests/api/test_alarm_definitions.py b/monasca_tempest_tests/tests/api/test_alarm_definitions.py index 6d0b4f8..af9c5a1 100644 --- a/monasca_tempest_tests/tests/api/test_alarm_definitions.py +++ b/monasca_tempest_tests/tests/api/test_alarm_definitions.py @@ -220,7 +220,7 @@ class TestAlarmDefinitions(base.BaseMonascaTest): alarm_def_name = data_utils.rand_name('monitoring_alarm') alarm_definition = helpers.create_alarm_definition( name=alarm_def_name, - expression="avg(mem_total_mb{dev=\\usr\local\bin}) gt 0", + expression="avg(mem_total_mb{dev=\\usr\local\bin}) gt 0", # noqa alarm_actions=[notification_id], ok_actions=[notification_id], undetermined_actions=[notification_id], diff --git a/monasca_tempest_tests/tests/api/test_alarms_count.py b/monasca_tempest_tests/tests/api/test_alarms_count.py index ac2de33..f9fcaf8 100644 --- a/monasca_tempest_tests/tests/api/test_alarms_count.py +++ b/monasca_tempest_tests/tests/api/test_alarms_count.py @@ -232,7 +232,7 @@ class TestAlarmsCount(base.BaseMonascaTest): resp, response_body = self.monasca_client.list_alarms() alarm_low_count = 0 for alarm in response_body['elements']: - if alarm['state'] is 'ALARM' and alarm['severity'] is 'LOW': + if alarm['state'] == 'ALARM' and alarm.get('severity', '') == 'LOW': alarm_low_count += 1 # Using urlencode mimics the CLI behavior. Without the urlencode, falcon diff --git a/test-requirements.txt b/test-requirements.txt index 1b760eb..97b2d45 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -2,7 +2,7 @@ # of appearance. Changing the order has an impact on the overall integration # process, which may cause wedges in the gate later. -hacking>=1.1.0,<1.2.0 # Apache-2.0 +hacking>=3.0,<3.1.0;python_version>='3.5' # Apache-2.0 sphinx!=1.6.6,!=1.6.7,!=2.1.0,>=1.6.2 # BSD openstackdocstheme>=1.20.0 # Apache-2.0