Change counter to sample vocable in api tests

This changes counter to sample vocable in api tests

Parts of the blueprint remove-counter

Change-Id: I9e7cdf833302a41e13940c8f49a7cca36792f033
This commit is contained in:
Mehdi Abaakouk 2013-08-20 16:43:22 +02:00
parent 5bd759fd69
commit f13ad665a1
14 changed files with 135 additions and 151 deletions

View File

@ -49,7 +49,7 @@ class TestListEvents(tests_api.TestBase,
'resource-id',
timestamp=datetime.datetime(2012, 7, 2, 10, 40),
resource_metadata={'display_name': 'test-server',
'tag': 'self.counter'},
'tag': 'self.sample'},
source='source1',
),
sample.Sample(
@ -62,7 +62,7 @@ class TestListEvents(tests_api.TestBase,
'resource-id',
timestamp=datetime.datetime(2012, 7, 2, 10, 41),
resource_metadata={'display_name': 'test-server',
'tag': 'self.counter'},
'tag': 'self.sample'},
source='source1',
),
sample.Sample(
@ -75,7 +75,7 @@ class TestListEvents(tests_api.TestBase,
'resource-id-alternate',
timestamp=datetime.datetime(2012, 7, 2, 10, 42),
resource_metadata={'display_name': 'test-server',
'tag': 'self.counter2'},
'tag': 'self.sample2'},
source='source1',
),
]:
@ -186,24 +186,24 @@ class TestListEventsMetaquery(TestListEvents,
def test_metaquery1(self):
q = '/sources/source1/meters/instance'
data = self.get('%s?metadata.tag=self.counter2' % q)
data = self.get('%s?metadata.tag=self.sample2' % q)
self.assertEqual(1, len(data['events']))
def test_metaquery1_wrong_tenant(self):
q = '/sources/source1/meters/instance'
data = self.get('%s?metadata.tag=self.counter2' % q,
data = self.get('%s?metadata.tag=self.sample2' % q,
headers={"X-Roles": "Member",
"X-Project-Id": "project1"})
self.assertEqual(0, len(data['events']))
def test_metaquery2(self):
q = '/sources/source1/meters/instance'
data = self.get('%s?metadata.tag=self.counter' % q)
data = self.get('%s?metadata.tag=self.sample' % q)
self.assertEqual(2, len(data['events']))
def test_metaquery2_non_admin(self):
q = '/sources/source1/meters/instance'
data = self.get('%s?metadata.tag=self.counter' % q,
data = self.get('%s?metadata.tag=self.sample' % q,
headers={"X-Roles": "Member",
"X-Project-Id": "project1"})
self.assertEqual(2, len(data['events']))

View File

@ -61,7 +61,7 @@ class TestListMeters(tests_api.TestBase,
'resource-id',
timestamp=datetime.datetime(2012, 7, 2, 10, 40),
resource_metadata={'display_name': 'test-server',
'tag': 'self.counter'},
'tag': 'self.sample'},
source='test_list_resources'),
sample.Sample(
'meter.test',
@ -73,7 +73,7 @@ class TestListMeters(tests_api.TestBase,
'resource-id',
timestamp=datetime.datetime(2012, 7, 2, 11, 40),
resource_metadata={'display_name': 'test-server',
'tag': 'self.counter'},
'tag': 'self.sample'},
source='test_list_resources'),
sample.Sample(
'meter.mine',
@ -85,7 +85,7 @@ class TestListMeters(tests_api.TestBase,
'resource-id2',
timestamp=datetime.datetime(2012, 7, 2, 10, 41),
resource_metadata={'display_name': 'test-server',
'tag': 'two.counter'},
'tag': 'two.sample'},
source='test_list_resources'),
sample.Sample(
'meter.test',
@ -97,7 +97,7 @@ class TestListMeters(tests_api.TestBase,
'resource-id3',
timestamp=datetime.datetime(2012, 7, 2, 10, 42),
resource_metadata={'display_name': 'test-server',
'tag': 'three.counter'},
'tag': 'three.sample'},
source='test_list_resources'),
sample.Sample(
'meter.mine',
@ -109,7 +109,7 @@ class TestListMeters(tests_api.TestBase,
'resource-id4',
timestamp=datetime.datetime(2012, 7, 2, 10, 43),
resource_metadata={'display_name': 'test-server',
'tag': 'four.counter'},
'tag': 'four.sample'},
source='test_list_resources')]:
msg = rpc.meter_message_from_counter(
cnt,
@ -218,33 +218,33 @@ class TestListMetersMetaquery(TestListMeters,
tests_db.MixinTestsWithBackendScenarios):
def test_metaquery1(self):
data = self.get('/meters?metadata.tag=self.counter')
data = self.get('/meters?metadata.tag=self.sample')
self.assertEqual(1, len(data['meters']))
def test_metaquery1_non_admin(self):
data = self.get('/meters?metadata.tag=self.counter',
data = self.get('/meters?metadata.tag=self.sample',
headers={"X-Roles": "Member",
"X-Project-Id": "project-id"})
self.assertEqual(1, len(data['meters']))
def test_metaquery1_wrong_tenant(self):
data = self.get('/meters?metadata.tag=self.counter',
data = self.get('/meters?metadata.tag=self.sample',
headers={"X-Roles": "Member",
"X-Project-Id": "project-666"})
self.assertEqual(0, len(data['meters']))
def test_metaquery2(self):
data = self.get('/meters?metadata.tag=four.counter')
data = self.get('/meters?metadata.tag=four.sample')
self.assertEqual(1, len(data['meters']))
def test_metaquery2_non_admin(self):
data = self.get('/meters?metadata.tag=four.counter',
data = self.get('/meters?metadata.tag=four.sample',
headers={"X-Roles": "Member",
"X-Project-Id": "project-id2"})
self.assertEqual(1, len(data['meters']))
def test_metaquery2_non_admin_wrong_project(self):
data = self.get('/meters?metadata.tag=four.counter',
data = self.get('/meters?metadata.tag=four.sample',
headers={"X-Roles": "Member",
"X-Project-Id": "project-666"})
self.assertEqual(0, len(data['meters']))

View File

@ -49,7 +49,7 @@ class TestListProjects(tests_api.TestBase,
def setUp(self):
super(TestListProjects, self).setUp()
counter1 = sample.Sample(
sample1 = sample.Sample(
'instance',
'cumulative',
'instance',
@ -59,16 +59,16 @@ class TestListProjects(tests_api.TestBase,
'resource-id',
timestamp=datetime.datetime(2012, 7, 2, 10, 40),
resource_metadata={'display_name': 'test-server',
'tag': 'self.counter'},
'tag': 'self.sample'},
source='test_list_projects',
)
msg = rpc.meter_message_from_counter(
counter1,
sample1,
cfg.CONF.publisher_rpc.metering_secret,
)
self.conn.record_metering_data(msg)
counter2 = sample.Sample(
sample2 = sample.Sample(
'instance',
'cumulative',
'instance',
@ -78,11 +78,11 @@ class TestListProjects(tests_api.TestBase,
'resource-id-alternate',
timestamp=datetime.datetime(2012, 7, 2, 10, 41),
resource_metadata={'display_name': 'test-server',
'tag': 'self.counter2'},
'tag': 'self.sample2'},
source='test_list_users',
)
msg2 = rpc.meter_message_from_counter(
counter2,
sample2,
cfg.CONF.publisher_rpc.metering_secret,
)
self.conn.record_metering_data(msg2)

View File

@ -61,7 +61,7 @@ class TestListResourcesBase(tests_api.TestBase,
'resource-id',
timestamp=datetime.datetime(2012, 7, 2, 10, 40),
resource_metadata={'display_name': 'test-server',
'tag': 'self.counter'},
'tag': 'self.sample'},
source='test_list_resources',
),
sample.Sample(
@ -74,7 +74,7 @@ class TestListResourcesBase(tests_api.TestBase,
'resource-id-alternate',
timestamp=datetime.datetime(2012, 7, 2, 10, 41),
resource_metadata={'display_name': 'test-server',
'tag': 'self.counter2'},
'tag': 'self.sample2'},
source='test_list_resources',
),
sample.Sample(
@ -87,7 +87,7 @@ class TestListResourcesBase(tests_api.TestBase,
'resource-id2',
timestamp=datetime.datetime(2012, 7, 2, 10, 42),
resource_metadata={'display_name': 'test-server',
'tag': 'self.counter3'},
'tag': 'self.sample3'},
source='test_list_resources',
),
sample.Sample(
@ -100,7 +100,7 @@ class TestListResourcesBase(tests_api.TestBase,
'resource-id',
timestamp=datetime.datetime(2012, 7, 2, 10, 43),
resource_metadata={'display_name': 'test-server',
'tag': 'self.counter4'},
'tag': 'self.sample4'},
source='test_list_resources',
)]:
msg = rpc.meter_message_from_counter(
@ -282,12 +282,12 @@ class TestListResourcesMetaquery(TestListResourcesBase,
def test_metaquery2(self):
q = '/sources/test_list_resources/resources'
data = self.get('%s?metadata.tag=self.counter4' % q)
data = self.get('%s?metadata.tag=self.sample4' % q)
self.assertEqual(1, len(data['resources']))
def test_metaquery2_non_admin(self):
q = '/sources/test_list_resources/resources'
data = self.get('%s?metadata.tag=self.counter4' % q,
data = self.get('%s?metadata.tag=self.sample4' % q,
headers={"X-Roles": "Member",
"X-Project-Id": "project-id"})
self.assertEqual(1, len(data['resources']))

View File

@ -50,7 +50,7 @@ class TestListUsers(tests_api.TestBase,
def setUp(self):
super(TestListUsers, self).setUp()
counter1 = sample.Sample(
sample1 = sample.Sample(
'instance',
'cumulative',
'instance',
@ -60,17 +60,17 @@ class TestListUsers(tests_api.TestBase,
'resource-id',
timestamp=datetime.datetime(2012, 7, 2, 10, 40),
resource_metadata={'display_name': 'test-server',
'tag': 'self.counter',
'tag': 'self.sample',
},
source='test_list_users',
)
msg = rpc.meter_message_from_counter(
counter1,
sample1,
cfg.CONF.publisher_rpc.metering_secret,
)
self.conn.record_metering_data(msg)
counter2 = sample.Sample(
sample2 = sample.Sample(
'instance',
'cumulative',
'',
@ -80,12 +80,12 @@ class TestListUsers(tests_api.TestBase,
'resource-id-alternate',
timestamp=datetime.datetime(2012, 7, 2, 10, 41),
resource_metadata={'display_name': 'test-server',
'tag': 'self.counter2',
'tag': 'self.sample2',
},
source='not-test',
)
msg2 = rpc.meter_message_from_counter(
counter2,
sample2,
cfg.CONF.publisher_rpc.metering_secret,
)
self.conn.record_metering_data(msg2)

View File

@ -39,9 +39,8 @@ class TestMaxProjectVolume(tests_api.TestBase,
def setUp(self):
super(TestMaxProjectVolume, self).setUp()
self.counters = []
for i in range(3):
c = sample.Sample(
s = sample.Sample(
'volume.size',
'gauge',
'GiB',
@ -51,13 +50,12 @@ class TestMaxProjectVolume(tests_api.TestBase,
'resource-id-%s' % i,
timestamp=datetime.datetime(2012, 9, 25, 10 + i, 30 + i),
resource_metadata={'display_name': 'test-volume',
'tag': 'self.counter',
'tag': 'self.sample',
},
source='source1',
)
self.counters.append(c)
msg = rpc.meter_message_from_counter(
c,
s,
cfg.CONF.publisher_rpc.metering_secret,
)
self.conn.record_metering_data(msg)

View File

@ -38,9 +38,8 @@ class TestMaxResourceVolume(tests_api.TestBase,
def setUp(self):
super(TestMaxResourceVolume, self).setUp()
self.counters = []
for i in range(3):
c = sample.Sample(
s = sample.Sample(
'volume.size',
'gauge',
'GiB',
@ -50,13 +49,12 @@ class TestMaxResourceVolume(tests_api.TestBase,
'resource-id',
timestamp=datetime.datetime(2012, 9, 25, 10 + i, 30 + i),
resource_metadata={'display_name': 'test-volume',
'tag': 'self.counter',
'tag': 'self.sample',
},
source='source1',
)
self.counters.append(c)
msg = rpc.meter_message_from_counter(
c,
s,
cfg.CONF.publisher_rpc.metering_secret,
)
self.conn.record_metering_data(msg)

View File

@ -39,9 +39,8 @@ class TestSumProjectVolume(tests_api.TestBase,
def setUp(self):
super(TestSumProjectVolume, self).setUp()
self.counters = []
for i in range(3):
c = sample.Sample(
s = sample.Sample(
'volume.size',
'gauge',
'GiB',
@ -51,13 +50,12 @@ class TestSumProjectVolume(tests_api.TestBase,
'resource-id-%s' % i,
timestamp=datetime.datetime(2012, 9, 25, 10 + i, 30 + i),
resource_metadata={'display_name': 'test-volume',
'tag': 'self.counter',
'tag': 'self.sample',
},
source='source1',
)
self.counters.append(c)
msg = rpc.meter_message_from_counter(
c,
s,
cfg.CONF.publisher_rpc.metering_secret,
)
self.conn.record_metering_data(msg)

View File

@ -39,9 +39,8 @@ class TestSumResourceVolume(tests_api.TestBase,
def setUp(self):
super(TestSumResourceVolume, self).setUp()
self.counters = []
for i in range(3):
c = sample.Sample(
s = sample.Sample(
'volume.size',
'gauge',
'GiB',
@ -51,13 +50,12 @@ class TestSumResourceVolume(tests_api.TestBase,
'resource-id',
timestamp=datetime.datetime(2012, 9, 25, 10 + i, 30 + i),
resource_metadata={'display_name': 'test-volume',
'tag': 'self.counter',
'tag': 'self.sample',
},
source='source1',
)
self.counters.append(c)
msg = rpc.meter_message_from_counter(
c,
s,
cfg.CONF.publisher_rpc.metering_secret,
)
self.conn.record_metering_data(msg)

View File

@ -93,7 +93,7 @@ class TestAPIACL(FunctionalTest,
'resource-good',
timestamp=datetime.datetime(2012, 7, 2, 10, 40),
resource_metadata={'display_name': 'test-server',
'tag': 'self.counter'},
'tag': 'self.sample'},
source='test_source'),
sample.Sample(
'meter.mine',
@ -105,7 +105,7 @@ class TestAPIACL(FunctionalTest,
'resource-56',
timestamp=datetime.datetime(2012, 7, 2, 10, 43),
resource_metadata={'display_name': 'test-server',
'tag': 'self.counter4'},
'tag': 'self.sample4'},
source='test_source')]:
msg = rpc.meter_message_from_counter(
cnt,

View File

@ -41,7 +41,7 @@ class TestListEvents(FunctionalTest,
def setUp(self):
super(TestListEvents, self).setUp()
self.counter1 = sample.Sample(
self.sample1 = sample.Sample(
'instance',
'cumulative',
'',
@ -51,19 +51,19 @@ class TestListEvents(FunctionalTest,
'resource-id',
timestamp=datetime.datetime(2012, 7, 2, 10, 40),
resource_metadata={'display_name': 'test-server',
'tag': 'self.counter',
'tag': 'self.sample',
'dict_properties': {'key': 'value'},
'ignored_list': ['not-returned'],
},
source='test_source',
)
msg = rpc.meter_message_from_counter(
self.counter1,
self.sample1,
cfg.CONF.publisher_rpc.metering_secret,
)
self.conn.record_metering_data(msg)
self.counter2 = sample.Sample(
self.sample2 = sample.Sample(
'instance',
'cumulative',
'',
@ -73,12 +73,12 @@ class TestListEvents(FunctionalTest,
'resource-id-alternate',
timestamp=datetime.datetime(2012, 7, 2, 10, 41),
resource_metadata={'display_name': 'test-server',
'tag': 'self.counter2',
'tag': 'self.sample2',
},
source='source2',
)
msg2 = rpc.meter_message_from_counter(
self.counter2,
self.sample2,
cfg.CONF.publisher_rpc.metering_secret,
)
self.conn.record_metering_data(msg2)
@ -171,5 +171,5 @@ class TestListEvents(FunctionalTest,
list(sorted(sample['resource_metadata'].iteritems())),
[('dict_properties.key', 'value'),
('display_name', 'test-server'),
('tag', 'self.counter'),
('tag', 'self.sample'),
])

View File

@ -60,7 +60,7 @@ class TestListMeters(FunctionalTest,
'resource-id',
timestamp=datetime.datetime(2012, 7, 2, 10, 40),
resource_metadata={'display_name': 'test-server',
'tag': 'self.counter'},
'tag': 'self.sample'},
source='test_source'),
sample.Sample(
'meter.test',
@ -72,7 +72,7 @@ class TestListMeters(FunctionalTest,
'resource-id',
timestamp=datetime.datetime(2012, 7, 2, 11, 40),
resource_metadata={'display_name': 'test-server',
'tag': 'self.counter1'},
'tag': 'self.sample1'},
source='test_source'),
sample.Sample(
'meter.mine',
@ -84,7 +84,7 @@ class TestListMeters(FunctionalTest,
'resource-id2',
timestamp=datetime.datetime(2012, 7, 2, 10, 41),
resource_metadata={'display_name': 'test-server',
'tag': 'self.counter2'},
'tag': 'self.sample2'},
source='test_source'),
sample.Sample(
'meter.test',
@ -96,7 +96,7 @@ class TestListMeters(FunctionalTest,
'resource-id3',
timestamp=datetime.datetime(2012, 7, 2, 10, 42),
resource_metadata={'display_name': 'test-server',
'tag': 'self.counter3'},
'tag': 'self.sample3'},
source='test_source'),
sample.Sample(
'meter.mine',
@ -108,11 +108,11 @@ class TestListMeters(FunctionalTest,
'resource-id4',
timestamp=datetime.datetime(2012, 7, 2, 10, 43),
resource_metadata={'display_name': 'test-server',
'tag': 'self.counter4',
'tag': 'self.sample4',
'properties': {
'prop_1': 'prop_value',
'prop_2': {'sub_prop_1':
'sub_prop_value'}}
'prop_1': 'prop_value',
'prop_2': {'sub_prop_1':
'sub_prop_value'}}
},
source='test_source')]:
msg = rpc.meter_message_from_counter(
@ -142,14 +142,14 @@ class TestListMeters(FunctionalTest,
self.assertEqual('resource-id4', data[0]['resource_id'])
metadata = data[0]['resource_metadata']
self.assertIsNotNone(metadata)
self.assertEqual('self.counter4', metadata['tag'])
self.assertEqual('self.sample4', metadata['tag'])
self.assertEqual('prop_value', metadata['properties.prop_1'])
def test_list_meters_metadata_query(self):
data = self.get_json('/meters/meter.test',
q=[{'field': 'metadata.tag',
'op': 'eq',
'value': 'self.counter1',
'value': 'self.sample1',
}],)
self.assertEqual(1, len(data))
self.assertEqual(set(r['resource_id'] for r in data),
@ -161,7 +161,7 @@ class TestListMeters(FunctionalTest,
data = self.get_json('/meters/meter.test',
q=[{'field': 'metadata.tag',
'op': 'eq',
'value': 'self.counter1',
'value': 'self.sample1',
},
{'field': 'metadata.display_name',
'op': 'eq',
@ -188,7 +188,7 @@ class TestListMeters(FunctionalTest,
},
{'field': 'metadata.tag',
'op': 'eq',
'value': 'self.counter2',
'value': 'self.sample2',
}])
self.assertEqual(1, len(data))
self.assertEqual(set(r['resource_id'] for r in data),
@ -214,7 +214,7 @@ class TestListMeters(FunctionalTest,
},
{'field': 'metadata.tag',
'op': 'eq',
'value': 'self.counter2',
'value': 'self.sample2',
}])
self.assertEqual(1, len(data))
self.assertEqual(set(r['source'] for r in data), set(['test_source']))
@ -253,7 +253,7 @@ class TestListMeters(FunctionalTest,
},
{'field': 'metadata.tag',
'op': 'eq',
'value': 'self.counter1',
'value': 'self.sample1',
}])
self.assertEqual(1, len(data))
self.assertEqual(set(r['user_id'] for r in data), set(['user-id']))
@ -285,7 +285,7 @@ class TestListMeters(FunctionalTest,
},
{'field': 'metadata.tag',
'op': 'eq',
'value': 'self.counter1',
'value': 'self.sample1',
}])
self.assertEqual(1, len(data))
self.assertEqual(set(r['project_id'] for r in data),

View File

@ -45,7 +45,7 @@ class TestListResources(FunctionalTest,
self.assertEqual([], data)
def test_instance_no_metadata(self):
counter1 = sample.Sample(
sample1 = sample.Sample(
'instance',
'cumulative',
'',
@ -58,7 +58,7 @@ class TestListResources(FunctionalTest,
source='test',
)
msg = rpc.meter_message_from_counter(
counter1,
sample1,
cfg.CONF.publisher_rpc.metering_secret,
)
self.conn.record_metering_data(msg)
@ -67,7 +67,7 @@ class TestListResources(FunctionalTest,
self.assertEqual(1, len(data))
def test_instances(self):
counter1 = sample.Sample(
sample1 = sample.Sample(
'instance',
'cumulative',
'',
@ -77,17 +77,17 @@ class TestListResources(FunctionalTest,
'resource-id',
timestamp=datetime.datetime(2012, 7, 2, 10, 40),
resource_metadata={'display_name': 'test-server',
'tag': 'self.counter',
'tag': 'self.sample',
},
source='test',
)
msg = rpc.meter_message_from_counter(
counter1,
sample1,
cfg.CONF.publisher_rpc.metering_secret,
)
self.conn.record_metering_data(msg)
counter2 = sample.Sample(
sample2 = sample.Sample(
'instance',
'cumulative',
'',
@ -97,12 +97,12 @@ class TestListResources(FunctionalTest,
'resource-id-alternate',
timestamp=datetime.datetime(2012, 7, 2, 10, 41),
resource_metadata={'display_name': 'test-server',
'tag': 'self.counter2',
'tag': 'self.sample2',
},
source='test',
)
msg2 = rpc.meter_message_from_counter(
counter2,
sample2,
cfg.CONF.publisher_rpc.metering_secret,
)
self.conn.record_metering_data(msg2)
@ -111,7 +111,7 @@ class TestListResources(FunctionalTest,
self.assertEqual(2, len(data))
def test_instances_one(self):
counter1 = sample.Sample(
sample1 = sample.Sample(
'instance',
'cumulative',
'',
@ -121,17 +121,17 @@ class TestListResources(FunctionalTest,
'resource-id',
timestamp=datetime.datetime(2012, 7, 2, 10, 40),
resource_metadata={'display_name': 'test-server',
'tag': 'self.counter',
'tag': 'self.sample',
},
source='test',
)
msg = rpc.meter_message_from_counter(
counter1,
sample1,
cfg.CONF.publisher_rpc.metering_secret,
)
self.conn.record_metering_data(msg)
counter2 = sample.Sample(
sample2 = sample.Sample(
'instance',
'cumulative',
'',
@ -141,12 +141,12 @@ class TestListResources(FunctionalTest,
'resource-id-alternate',
timestamp=datetime.datetime(2012, 7, 2, 10, 41),
resource_metadata={'display_name': 'test-server',
'tag': 'self.counter2',
'tag': 'self.sample2',
},
source='test',
)
msg2 = rpc.meter_message_from_counter(
counter2,
sample2,
cfg.CONF.publisher_rpc.metering_secret,
)
self.conn.record_metering_data(msg2)
@ -155,7 +155,7 @@ class TestListResources(FunctionalTest,
self.assertEqual('resource-id', data['resource_id'])
def test_with_source(self):
counter1 = sample.Sample(
sample1 = sample.Sample(
'instance',
'cumulative',
'',
@ -165,17 +165,17 @@ class TestListResources(FunctionalTest,
'resource-id',
timestamp=datetime.datetime(2012, 7, 2, 10, 40),
resource_metadata={'display_name': 'test-server',
'tag': 'self.counter',
'tag': 'self.sample',
},
source='test_list_resources',
)
msg = rpc.meter_message_from_counter(
counter1,
sample1,
cfg.CONF.publisher_rpc.metering_secret,
)
self.conn.record_metering_data(msg)
counter2 = sample.Sample(
sample2 = sample.Sample(
'instance',
'cumulative',
'',
@ -185,12 +185,12 @@ class TestListResources(FunctionalTest,
'resource-id-alternate',
timestamp=datetime.datetime(2012, 7, 2, 10, 41),
resource_metadata={'display_name': 'test-server',
'tag': 'self.counter2',
'tag': 'self.sample2',
},
source='not-test',
)
msg2 = rpc.meter_message_from_counter(
counter2,
sample2,
cfg.CONF.publisher_rpc.metering_secret,
)
self.conn.record_metering_data(msg2)
@ -202,7 +202,7 @@ class TestListResources(FunctionalTest,
self.assertEqual(['resource-id'], ids)
def test_with_invalid_resource_id(self):
counter1 = sample.Sample(
sample1 = sample.Sample(
'instance',
'cumulative',
'',
@ -212,17 +212,17 @@ class TestListResources(FunctionalTest,
'resource-id-1',
timestamp=datetime.datetime(2012, 7, 2, 10, 40),
resource_metadata={'display_name': 'test-server',
'tag': 'self.counter',
'tag': 'self.sample',
},
source='test_list_resources',
)
msg = rpc.meter_message_from_counter(
counter1,
sample1,
cfg.CONF.publisher_rpc.metering_secret,
)
self.conn.record_metering_data(msg)
counter2 = sample.Sample(
sample2 = sample.Sample(
'instance',
'cumulative',
'',
@ -232,12 +232,12 @@ class TestListResources(FunctionalTest,
'resource-id-2',
timestamp=datetime.datetime(2012, 7, 2, 10, 41),
resource_metadata={'display_name': 'test-server',
'tag': 'self.counter2',
'tag': 'self.sample2',
},
source='test_list_resources',
)
msg2 = rpc.meter_message_from_counter(
counter2,
sample2,
cfg.CONF.publisher_rpc.metering_secret,
)
self.conn.record_metering_data(msg2)
@ -252,7 +252,7 @@ class TestListResources(FunctionalTest,
self.assertEqual(resp3.status_code, 400)
def test_with_user(self):
counter1 = sample.Sample(
sample1 = sample.Sample(
'instance',
'cumulative',
'',
@ -262,17 +262,17 @@ class TestListResources(FunctionalTest,
'resource-id',
timestamp=datetime.datetime(2012, 7, 2, 10, 40),
resource_metadata={'display_name': 'test-server',
'tag': 'self.counter',
'tag': 'self.sample',
},
source='test_list_resources',
)
msg = rpc.meter_message_from_counter(
counter1,
sample1,
cfg.CONF.publisher_rpc.metering_secret,
)
self.conn.record_metering_data(msg)
counter2 = sample.Sample(
sample2 = sample.Sample(
'instance',
'cumulative',
'',
@ -282,12 +282,12 @@ class TestListResources(FunctionalTest,
'resource-id-alternate',
timestamp=datetime.datetime(2012, 7, 2, 10, 41),
resource_metadata={'display_name': 'test-server',
'tag': 'self.counter2',
'tag': 'self.sample2',
},
source='not-test',
)
msg2 = rpc.meter_message_from_counter(
counter2,
sample2,
cfg.CONF.publisher_rpc.metering_secret,
)
self.conn.record_metering_data(msg2)
@ -299,7 +299,7 @@ class TestListResources(FunctionalTest,
self.assertEqual(['resource-id'], ids)
def test_with_project(self):
counter1 = sample.Sample(
sample1 = sample.Sample(
'instance',
'cumulative',
'',
@ -309,17 +309,17 @@ class TestListResources(FunctionalTest,
'resource-id',
timestamp=datetime.datetime(2012, 7, 2, 10, 40),
resource_metadata={'display_name': 'test-server',
'tag': 'self.counter',
'tag': 'self.sample',
},
source='test_list_resources',
)
msg = rpc.meter_message_from_counter(
counter1,
sample1,
cfg.CONF.publisher_rpc.metering_secret,
)
self.conn.record_metering_data(msg)
counter2 = sample.Sample(
sample2 = sample.Sample(
'instance',
'cumulative',
'',
@ -329,12 +329,12 @@ class TestListResources(FunctionalTest,
'resource-id-alternate',
timestamp=datetime.datetime(2012, 7, 2, 10, 41),
resource_metadata={'display_name': 'test-server',
'tag': 'self.counter2',
'tag': 'self.sample2',
},
source='not-test',
)
msg2 = rpc.meter_message_from_counter(
counter2,
sample2,
cfg.CONF.publisher_rpc.metering_secret,
)
self.conn.record_metering_data(msg2)
@ -346,7 +346,7 @@ class TestListResources(FunctionalTest,
self.assertEqual(['resource-id'], ids)
def test_with_user_non_admin(self):
counter1 = sample.Sample(
sample1 = sample.Sample(
'instance',
'cumulative',
'',
@ -356,12 +356,12 @@ class TestListResources(FunctionalTest,
'resource-id-alternate',
timestamp=datetime.datetime(2012, 7, 2, 10, 41),
resource_metadata={'display_name': 'test-server',
'tag': 'self.counter1',
'tag': 'self.sample1',
},
source='not-test',
)
msg2 = rpc.meter_message_from_counter(
counter1,
sample1,
cfg.CONF.publisher_rpc.metering_secret,
)
self.conn.record_metering_data(msg2)
@ -373,7 +373,7 @@ class TestListResources(FunctionalTest,
self.assertEqual(set(['resource-id-alternate']), ids)
def test_with_user_wrong_tenant(self):
counter1 = sample.Sample(
sample1 = sample.Sample(
'instance',
'cumulative',
'',
@ -383,12 +383,12 @@ class TestListResources(FunctionalTest,
'resource-id-alternate',
timestamp=datetime.datetime(2012, 7, 2, 10, 41),
resource_metadata={'display_name': 'test-server',
'tag': 'self.counter1',
'tag': 'self.sample1',
},
source='not-test',
)
msg2 = rpc.meter_message_from_counter(
counter1,
sample1,
cfg.CONF.publisher_rpc.metering_secret,
)
self.conn.record_metering_data(msg2)
@ -400,7 +400,7 @@ class TestListResources(FunctionalTest,
self.assertEqual(set(), ids)
def test_metadata(self):
counter1 = sample.Sample(
sample1 = sample.Sample(
'instance',
'cumulative',
'',
@ -410,14 +410,14 @@ class TestListResources(FunctionalTest,
'resource-id',
timestamp=datetime.datetime(2012, 7, 2, 10, 40),
resource_metadata={'display_name': 'test-server',
'tag': 'self.counter',
'tag': 'self.sample',
'dict_properties': {'key': 'value'},
'ignored_list': ['not-returned'],
},
source='test',
)
msg = rpc.meter_message_from_counter(
counter1,
sample1,
cfg.CONF.publisher_rpc.metering_secret,
)
self.conn.record_metering_data(msg)
@ -427,12 +427,12 @@ class TestListResources(FunctionalTest,
self.assertEqual(
[(u'dict_properties.key', u'value'),
(u'display_name', u'test-server'),
(u'tag', u'self.counter')
(u'tag', u'self.sample')
],
list(sorted(metadata.iteritems())))
def test_resource_meter_links(self):
counter1 = sample.Sample(
sample1 = sample.Sample(
'instance',
'cumulative',
'',
@ -442,12 +442,12 @@ class TestListResources(FunctionalTest,
'resource-id',
timestamp=datetime.datetime(2012, 7, 2, 10, 40),
resource_metadata={'display_name': 'test-server',
'tag': 'self.counter',
'tag': 'self.sample',
},
source='test_list_resources',
)
msg = rpc.meter_message_from_counter(
counter1,
sample1,
cfg.CONF.publisher_rpc.metering_secret,
)
self.conn.record_metering_data(msg)

View File

@ -38,9 +38,8 @@ class TestMaxProjectVolume(base.FunctionalTest,
def setUp(self):
super(TestMaxProjectVolume, self).setUp()
self.counters = []
for i in range(3):
c = sample.Sample(
s = sample.Sample(
'volume.size',
'gauge',
'GiB',
@ -50,13 +49,12 @@ class TestMaxProjectVolume(base.FunctionalTest,
'resource-id-%s' % i,
timestamp=datetime.datetime(2012, 9, 25, 10 + i, 30 + i),
resource_metadata={'display_name': 'test-volume',
'tag': 'self.counter',
'tag': 'self.sample',
},
source='source1',
)
self.counters.append(c)
msg = rpc.meter_message_from_counter(
c,
s,
cfg.CONF.publisher_rpc.metering_secret,
)
self.conn.record_metering_data(msg)
@ -139,9 +137,8 @@ class TestMaxResourceVolume(base.FunctionalTest,
def setUp(self):
super(TestMaxResourceVolume, self).setUp()
self.counters = []
for i in range(3):
c = sample.Sample(
s = sample.Sample(
'volume.size',
'gauge',
'GiB',
@ -151,13 +148,12 @@ class TestMaxResourceVolume(base.FunctionalTest,
'resource-id',
timestamp=datetime.datetime(2012, 9, 25, 10 + i, 30 + i),
resource_metadata={'display_name': 'test-volume',
'tag': 'self.counter',
'tag': 'self.sample',
},
source='source1',
)
self.counters.append(c)
msg = rpc.meter_message_from_counter(
c,
s,
cfg.CONF.publisher_rpc.metering_secret,
)
self.conn.record_metering_data(msg)
@ -263,9 +259,8 @@ class TestSumProjectVolume(base.FunctionalTest,
def setUp(self):
super(TestSumProjectVolume, self).setUp()
self.counters = []
for i in range(3):
c = sample.Sample(
s = sample.Sample(
'volume.size',
'gauge',
'GiB',
@ -275,13 +270,12 @@ class TestSumProjectVolume(base.FunctionalTest,
'resource-id-%s' % i,
timestamp=datetime.datetime(2012, 9, 25, 10 + i, 30 + i),
resource_metadata={'display_name': 'test-volume',
'tag': 'self.counter',
'tag': 'self.sample',
},
source='source1',
)
self.counters.append(c)
msg = rpc.meter_message_from_counter(
c,
s,
cfg.CONF.publisher_rpc.metering_secret,
)
self.conn.record_metering_data(msg)
@ -366,9 +360,8 @@ class TestSumResourceVolume(base.FunctionalTest,
def setUp(self):
super(TestSumResourceVolume, self).setUp()
self.counters = []
for i in range(3):
c = sample.Sample(
s = sample.Sample(
'volume.size',
'gauge',
'GiB',
@ -378,13 +371,12 @@ class TestSumResourceVolume(base.FunctionalTest,
'resource-id',
timestamp=datetime.datetime(2012, 9, 25, 10 + i, 30 + i),
resource_metadata={'display_name': 'test-volume',
'tag': 'self.counter',
'tag': 'self.sample',
},
source='source1',
)
self.counters.append(c)
msg = rpc.meter_message_from_counter(
c,
s,
cfg.CONF.publisher_rpc.metering_secret,
)
self.conn.record_metering_data(msg)