diff --git a/ceilometer/event/storage/impl_sqlalchemy.py b/ceilometer/event/storage/impl_sqlalchemy.py index 6f62650af..bd2adee13 100644 --- a/ceilometer/event/storage/impl_sqlalchemy.py +++ b/ceilometer/event/storage/impl_sqlalchemy.py @@ -313,7 +313,8 @@ class Connection(base.Connection): .add_columns(models.TraitText.key, sa.null(), sa.null(), sa.null(), models.TraitText.value)) - for id_, key, t_date, t_int, t_float, t_text in trait_q.all(): + for id_, key, t_date, t_int, t_float, t_text in ( + trait_q.order_by('2')).all(): if t_int: dtype = api_models.Trait.INT_TYPE val = t_int diff --git a/ceilometer/tests/storage/test_storage_scenarios.py b/ceilometer/tests/storage/test_storage_scenarios.py index 317ab7866..f239f9d5b 100644 --- a/ceilometer/tests/storage/test_storage_scenarios.py +++ b/ceilometer/tests/storage/test_storage_scenarios.py @@ -3229,8 +3229,7 @@ class GetEventTest(EventTestBase): self.assertEqual(event.generated, self.event_models[i].generated) model_traits = self.event_models[i].traits - for j, trait in enumerate(sorted(event.traits, - key=operator.attrgetter("name"))): + for j, trait in enumerate(event.traits): if trait.dtype == event_models.Trait.DATETIME_TYPE: self.assertIsInstance(trait.value, datetime.datetime) self.assertEqual(trait.value, model_traits[j].value)