Merge "enable v2 api sqlalchemy tests"
This commit is contained in:
commit
9fda76d079
@ -501,10 +501,14 @@ class Connection(base.Connection):
|
||||
q = make_query_from_filter(sample_filter)
|
||||
|
||||
if period:
|
||||
map_stats = self.MAP_STATS_PERIOD % \
|
||||
(period,
|
||||
int(sample_filter.start.strftime('%s'))
|
||||
if sample_filter.start else 0)
|
||||
if sample_filter.start:
|
||||
period_start = sample_filter.start
|
||||
else:
|
||||
period_start = self.db.meter.find(
|
||||
limit=1, sort=[('timestamp',
|
||||
pymongo.ASCENDING)])[0]['timestamp']
|
||||
period_start = int(period_start.strftime('%s'))
|
||||
map_stats = self.MAP_STATS_PERIOD % (period, period_start)
|
||||
else:
|
||||
map_stats = self.MAP_STATS
|
||||
|
||||
|
@ -400,17 +400,6 @@ class Connection(base.Connection):
|
||||
message_signature=s.message_signature,
|
||||
)
|
||||
|
||||
@staticmethod
|
||||
def _make_volume_query(sample_filter, counter_volume_func):
|
||||
"""Returns complex Meter counter_volume query for max and sum."""
|
||||
session = sqlalchemy_session.get_session()
|
||||
subq = session.query(Meter.id)
|
||||
subq = make_query_from_filter(subq, sample_filter, require_meter=False)
|
||||
subq = subq.subquery()
|
||||
mainq = session.query(Resource.id, counter_volume_func)
|
||||
mainq = mainq.join(Meter).group_by(Resource.id)
|
||||
return mainq.filter(Meter.id.in_(subq))
|
||||
|
||||
@staticmethod
|
||||
def _make_stats_query(sample_filter):
|
||||
session = sqlalchemy_session.get_session()
|
||||
@ -455,7 +444,8 @@ class Connection(base.Connection):
|
||||
res = self._make_stats_query(sample_filter).all()[0]
|
||||
|
||||
if not period:
|
||||
yield self._stats_result_to_model(res, 0, res.tsmin, res.tsmax)
|
||||
if res.count:
|
||||
yield self._stats_result_to_model(res, 0, res.tsmin, res.tsmax)
|
||||
return
|
||||
|
||||
query = self._make_stats_query(sample_filter)
|
||||
|
@ -22,7 +22,6 @@ import datetime
|
||||
import logging
|
||||
|
||||
from ceilometer.openstack.common import timeutils
|
||||
from ceilometer.storage import impl_mongodb
|
||||
from ceilometer.storage import models
|
||||
from .base import FunctionalTest
|
||||
|
||||
@ -51,9 +50,7 @@ class TestComputeDurationByResource(FunctionalTest):
|
||||
self.late2 = datetime.datetime(2012, 8, 29, 19, 0)
|
||||
|
||||
def _stub_interval_func(self, func):
|
||||
self.stubs.Set(impl_mongodb.Connection,
|
||||
'get_meter_statistics',
|
||||
func)
|
||||
self.stubs.Set(type(self.conn), 'get_meter_statistics', func)
|
||||
|
||||
def _set_interval(self, start, end):
|
||||
def get_interval(ignore_self, event_filter, period):
|
||||
@ -176,7 +173,6 @@ class TestComputeDurationByResource(FunctionalTest):
|
||||
duration=None,
|
||||
duration_start=self.early1,
|
||||
duration_end=self.early2,
|
||||
#
|
||||
sum=0,
|
||||
period=None,
|
||||
period_start=None,
|
||||
|
@ -23,6 +23,7 @@ from oslo.config import cfg
|
||||
|
||||
from . import base
|
||||
from ceilometer import counter
|
||||
from ceilometer.storage.impl_mongodb import Connection as mongo_conn
|
||||
from ceilometer.storage.impl_mongodb import require_map_reduce
|
||||
from ceilometer.publisher import rpc
|
||||
|
||||
@ -33,7 +34,9 @@ class TestMaxProjectVolume(base.FunctionalTest):
|
||||
|
||||
def setUp(self):
|
||||
super(TestMaxProjectVolume, self).setUp()
|
||||
require_map_reduce(self.conn)
|
||||
# TODO(gordc): remove when we drop mim
|
||||
if isinstance(self.conn, mongo_conn):
|
||||
require_map_reduce(self.conn)
|
||||
|
||||
self.counters = []
|
||||
for i in range(3):
|
||||
@ -134,7 +137,9 @@ class TestMaxResourceVolume(base.FunctionalTest):
|
||||
|
||||
def setUp(self):
|
||||
super(TestMaxResourceVolume, self).setUp()
|
||||
require_map_reduce(self.conn)
|
||||
# TODO(gordc): remove when we drop mim
|
||||
if isinstance(self.conn, mongo_conn):
|
||||
require_map_reduce(self.conn)
|
||||
|
||||
self.counters = []
|
||||
for i in range(3):
|
||||
@ -178,9 +183,9 @@ class TestMaxResourceVolume(base.FunctionalTest):
|
||||
u'2012-09-25T11:31:00']))
|
||||
self.assertEqual(data[0]['period'], 3600)
|
||||
self.assertEqual(set(x['period_start'] for x in data),
|
||||
set([u'2012-09-25T10:00:00',
|
||||
u'2012-09-25T11:00:00',
|
||||
u'2012-09-25T12:00:00']))
|
||||
set([u'2012-09-25T10:30:00',
|
||||
u'2012-09-25T11:30:00',
|
||||
u'2012-09-25T12:30:00']))
|
||||
|
||||
def test_start_timestamp(self):
|
||||
data = self.get_json(self.PATH, q=[{'field': 'resource_id',
|
||||
@ -251,7 +256,9 @@ class TestSumProjectVolume(base.FunctionalTest):
|
||||
|
||||
def setUp(self):
|
||||
super(TestSumProjectVolume, self).setUp()
|
||||
require_map_reduce(self.conn)
|
||||
# TODO(gordc): remove when we drop mim
|
||||
if isinstance(self.conn, mongo_conn):
|
||||
require_map_reduce(self.conn)
|
||||
|
||||
self.counters = []
|
||||
for i in range(3):
|
||||
@ -354,7 +361,9 @@ class TestSumResourceVolume(base.FunctionalTest):
|
||||
|
||||
def setUp(self):
|
||||
super(TestSumResourceVolume, self).setUp()
|
||||
require_map_reduce(self.conn)
|
||||
# TODO(gordc): remove when we drop mim
|
||||
if isinstance(self.conn, mongo_conn):
|
||||
require_map_reduce(self.conn)
|
||||
|
||||
self.counters = []
|
||||
for i in range(3):
|
||||
|
@ -14,12 +14,12 @@
|
||||
|
||||
from . import acl
|
||||
from . import alarm
|
||||
# from . import compute_duration_by_resource
|
||||
from . import compute_duration_by_resource
|
||||
from . import list_events
|
||||
from . import list_meters
|
||||
from . import list_resources
|
||||
from . import post_samples
|
||||
# from . import statistics
|
||||
from . import statistics
|
||||
|
||||
|
||||
class TestAPIAcl(acl.TestAPIACL):
|
||||
@ -37,10 +37,10 @@ class TestListEmptyAlarms(alarm.TestListEmptyAlarms):
|
||||
class TestAlarms(alarm.TestAlarms):
|
||||
database_connection = 'sqlite://'
|
||||
|
||||
# TODO(jd) fix SQL driver to pass this test!
|
||||
# class TestComputeDurationByResource(
|
||||
# compute_duration_by_resource.TestComputeDurationByResource):
|
||||
# database_connection = 'sqlite://'
|
||||
|
||||
class TestComputeDurationByResource(
|
||||
compute_duration_by_resource.TestComputeDurationByResource):
|
||||
database_connection = 'sqlite://'
|
||||
|
||||
|
||||
class TestListEmptyMeters(list_meters.TestListEmptyMeters):
|
||||
@ -54,21 +54,21 @@ class TestListMeters(list_meters.TestListMeters):
|
||||
class TestListResources(list_resources.TestListResources):
|
||||
database_connection = 'sqlite://'
|
||||
|
||||
# TODO(jd) fix SQL driver to pass this test!
|
||||
# class TestMaxProjectVolume(statistics.TestMaxProjectVolume):
|
||||
# database_connection = 'sqlite://'
|
||||
|
||||
# TODO(jd) fix SQL driver to pass this test!
|
||||
# class TestMaxResourceVolume(statistics.TestMaxResourceVolume):
|
||||
# database_connection = 'sqlite://'
|
||||
class TestMaxProjectVolume(statistics.TestMaxProjectVolume):
|
||||
database_connection = 'sqlite://'
|
||||
|
||||
# TODO(jd) fix SQL driver to pass this test!
|
||||
# class TestSumProjectVolume(statistics.TestSumProjectVolume):
|
||||
# database_connection = 'sqlite:// '
|
||||
|
||||
# TODO(jd) fix SQL driver to pass this test!
|
||||
# class TestSumResourceVolume(statistics.TestSumProjectVolume):
|
||||
# database_connection = 'sqlite:// '
|
||||
class TestMaxResourceVolume(statistics.TestMaxResourceVolume):
|
||||
database_connection = 'sqlite://'
|
||||
|
||||
|
||||
class TestSumProjectVolume(statistics.TestSumProjectVolume):
|
||||
database_connection = 'sqlite:// '
|
||||
|
||||
|
||||
class TestSumResourceVolume(statistics.TestSumProjectVolume):
|
||||
database_connection = 'sqlite:// '
|
||||
|
||||
|
||||
class TestPostSamples(post_samples.TestPostSamples):
|
||||
|
Loading…
x
Reference in New Issue
Block a user