From 4c4734c4481aeaa3d7449c0693197dae9ef33df3 Mon Sep 17 00:00:00 2001 From: gordon chung Date: Thu, 19 Feb 2015 19:21:32 -0500 Subject: [PATCH] order traits returned within events - we order the traits by key in all the backends except sql. this keeps sql inline. - this reverts a patch to sort traits post query in test. Change-Id: I17009bdb01106dc07659a9198da2090ec63bcf51 Closes-Bug: #1423714 --- ceilometer/event/storage/impl_sqlalchemy.py | 3 ++- ceilometer/tests/storage/test_storage_scenarios.py | 3 +-- 2 files changed, 3 insertions(+), 3 deletions(-) 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)