diff --git a/ceilometer/api/controllers/v2/query.py b/ceilometer/api/controllers/v2/query.py index 77b5ff09..c9f283bd 100644 --- a/ceilometer/api/controllers/v2/query.py +++ b/ceilometer/api/controllers/v2/query.py @@ -201,7 +201,7 @@ class ValidatedComplexQuery(object): self._validate_filter(self.filter_expr) except (ValueError, jsonschema.exceptions.ValidationError) as e: raise base.ClientSideError( - _("Filter expression not valid: %s") % e.message) + _("Filter expression not valid: %s") % e) self._replace_isotime_with_datetime(self.filter_expr) self._convert_operator_to_lower_case(self.filter_expr) self._normalize_field_names_for_db_model(self.filter_expr) diff --git a/ceilometer/meter/notifications.py b/ceilometer/meter/notifications.py index b9584d70..f1062bbb 100644 --- a/ceilometer/meter/notifications.py +++ b/ceilometer/meter/notifications.py @@ -40,6 +40,7 @@ LOG = log.getLogger(__name__) class MeterDefinitionException(Exception): def __init__(self, message, definition_cfg): super(MeterDefinitionException, self).__init__(message) + self.message = message self.definition_cfg = definition_cfg def __str__(self): diff --git a/ceilometer/tests/api/v2/test_api_upgrade.py b/ceilometer/tests/api/v2/test_api_upgrade.py index 8f35b5d1..16fabcfa 100644 --- a/ceilometer/tests/api/v2/test_api_upgrade.py +++ b/ceilometer/tests/api/v2/test_api_upgrade.py @@ -47,7 +47,7 @@ class TestAPIUpgradePath(v2.FunctionalTest): for endpoint in ['meters', 'samples', 'resources']: response = self.app.get(self.PATH_PREFIX + '/' + endpoint, status=410) - self.assertIn('Gnocchi API', response.body) + self.assertIn(b'Gnocchi API', response.body) for endpoint in ['events', 'event_types']: self.app.get(self.PATH_PREFIX + '/' + endpoint, @@ -59,7 +59,7 @@ class TestAPIUpgradePath(v2.FunctionalTest): "orderby": '[{"timestamp": "DESC"}]', "limit": 3 }, status=410) - self.assertIn('Gnocchi API', response.body) + self.assertIn(b'Gnocchi API', response.body) def _do_test_alarm_redirect(self): response = self.app.get(self.PATH_PREFIX + '/alarms', @@ -95,9 +95,10 @@ class TestAPIUpgradePath(v2.FunctionalTest): def test_gnocchi_enabled_without_database_backend_keystone(self): self._setup_keystone_mock() self._do_test_gnocchi_enabled_without_database_backend() - self.assertEqual([mock.call(service_type="alarming"), - mock.call(service_type="metric")], - sorted(self.ks.service_catalog.url_for.mock_calls)) + self.ks.service_catalog.url_for.assert_has_calls([ + mock.call(service_type="alarming"), + mock.call(service_type="metric")], + any_order=True) def test_gnocchi_enabled_without_database_backend_configoptions(self): self._setup_osloconfig_options() diff --git a/ceilometer/utils.py b/ceilometer/utils.py index 5405b599..42e2c20c 100644 --- a/ceilometer/utils.py +++ b/ceilometer/utils.py @@ -73,8 +73,10 @@ def decode_unicode(input): # the tuple would become list. So we have to generate the value as # list here. return [decode_unicode(element) for element in input] - elif isinstance(input, six.text_type): + elif six.PY2 and isinstance(input, six.text_type): return input.encode('utf-8') + elif six.PY3 and isinstance(input, six.binary_type): + return input.decode('utf-8') else: return input diff --git a/tox.ini b/tox.ini index f7a90c45..064c93ec 100644 --- a/tox.ini +++ b/tox.ini @@ -49,11 +49,16 @@ commands = python -m testtools.run \ ceilometer.tests.api.v2.test_alarm_scenarios.TestAlarms.test_alarms_query_with_timestamp \ ceilometer.tests.api.v2.test_alarm_scenarios.TestAlarms.test_get_alarm_history_constrained_by_alarm_id_failed \ ceilometer.tests.api.v2.test_alarm_scenarios.TestAlarms.test_post_invalid_alarm_input_enabled_int \ + ceilometer.tests.api.v2.test_api_upgrade.TestAPIUpgradePath.test_gnocchi_enabled_without_database_backend_configoptions \ + ceilometer.tests.api.v2.test_api_upgrade.TestAPIUpgradePath.test_gnocchi_enabled_without_database_backend_keystone \ ceilometer.tests.api.v2.test_app \ ceilometer.tests.api.v2.test_complex_query_scenarios.TestQueryMetersController.test_query_with_isotime \ ceilometer.tests.api.v2.test_complex_query_scenarios.TestQueryMetersController.test_query_with_volume_field_name_orderby \ + ceilometer.tests.api.v2.test_complex_query_scenarios.TestQueryMetersController.test_query_with_wrong_json \ ceilometer.tests.api.v2.test_event_scenarios.TestEventAPI.test_get_events_filter_datetime_trait \ + ceilometer.tests.api.v2.test_list_events_scenarios.TestListEvents.test_metadata \ ceilometer.tests.api.v2.test_list_meters_scenarios.TestListMeters.test_query_samples_with_invalid_field_name_and_eq_operator \ + ceilometer.tests.api.v2.test_list_resources_scenarios.TestListResources.test_metadata \ ceilometer.tests.api.v2.test_list_resources_scenarios.TestListResources.test_with_invalid_resource_id \ ceilometer.tests.api.v2.test_post_samples_scenarios.TestPostSamples.test_missing_project_user_id \ ceilometer.tests.api.v2.test_post_samples_scenarios.TestPostSamples.test_multiple_project_id_and_admin \ @@ -71,6 +76,8 @@ commands = python -m testtools.run \ ceilometer.tests.dispatcher.test_http \ ceilometer.tests.energy.test_kwapi \ ceilometer.tests.ipmi.platform.test_intel_node_manager \ + ceilometer.tests.meter.test_notifications.TestMeterDefinition.test_bad_type_cfg_definition \ + ceilometer.tests.meter.test_notifications.TestMeterDefinition.test_config_missing_fields \ ceilometer.tests.network.services.test_fwaas \ ceilometer.tests.network.services.test_lbaas \ ceilometer.tests.network.services.test_vpnaas \ @@ -87,6 +94,7 @@ commands = python -m testtools.run \ ceilometer.tests.publisher.test_udp \ ceilometer.tests.storage.test_get_connection \ ceilometer.tests.storage.test_impl_sqlalchemy \ + ceilometer.tests.storage.test_pymongo_base.CompatibilityTest.test_alarm_get_old_format_matching_metadata_array \ ceilometer.tests.test_bin \ ceilometer.tests.test_collector \ ceilometer.tests.test_coordination \