Adds API Sample tests for os-instance_usage_audit_log extension.

Fixes Bug 1091752.
Partially implements bp nova-api-samples.

Change-Id: I2db83ac32283795ab0cbf254c6adbd352806b297
This commit is contained in:
Tiago Mello 2013-01-21 12:37:07 -02:00
parent 608cf6b518
commit 143fb274ef
9 changed files with 159 additions and 2 deletions

View File

@ -0,0 +1,17 @@
{
"instance_usage_audit_logs": {
"hosts_not_run": [
"f4eb7cfd155f4574967f8b55a7faed75"
],
"log": {},
"num_hosts": 1,
"num_hosts_done": 0,
"num_hosts_not_run": 1,
"num_hosts_running": 0,
"overall_status": "0 of 1 hosts done. 0 errors.",
"period_beginning": "2012-12-01 00:00:00",
"period_ending": "2013-01-01 00:00:00",
"total_errors": 0,
"total_instances": 0
}
}

View File

@ -0,0 +1,16 @@
<?xml version='1.0' encoding='UTF-8'?>
<instance_usage_audit_logs>
<total_errors>0</total_errors>
<total_instances>0</total_instances>
<log/>
<num_hosts_running>0</num_hosts_running>
<num_hosts_done>0</num_hosts_done>
<num_hosts_not_run>1</num_hosts_not_run>
<hosts_not_run>
<item>107debd115684f098d4c73ffac7ec515</item>
</hosts_not_run>
<overall_status>0 of 1 hosts done. 0 errors.</overall_status>
<period_ending>2013-01-01 00:00:00</period_ending>
<period_beginning>2012-12-01 00:00:00</period_beginning>
<num_hosts>1</num_hosts>
</instance_usage_audit_logs>

View File

@ -0,0 +1,17 @@
{
"instance_usage_audit_log": {
"hosts_not_run": [
"8e33da2b48684ef3ab165444d6a7384c"
],
"log": {},
"num_hosts": 1,
"num_hosts_done": 0,
"num_hosts_not_run": 1,
"num_hosts_running": 0,
"overall_status": "0 of 1 hosts done. 0 errors.",
"period_beginning": "2012-06-01 00:00:00",
"period_ending": "2012-07-01 00:00:00",
"total_errors": 0,
"total_instances": 0
}
}

View File

@ -0,0 +1,16 @@
<?xml version='1.0' encoding='UTF-8'?>
<instance_usage_audit_log>
<total_errors>0</total_errors>
<total_instances>0</total_instances>
<log/>
<num_hosts_running>0</num_hosts_running>
<num_hosts_done>0</num_hosts_done>
<num_hosts_not_run>1</num_hosts_not_run>
<hosts_not_run>
<item>4b54478b73734afcbf0e2676a3303d1a</item>
</hosts_not_run>
<overall_status>0 of 1 hosts done. 0 errors.</overall_status>
<period_ending>2012-07-01 00:00:00</period_ending>
<period_beginning>2012-06-01 00:00:00</period_beginning>
<num_hosts>1</num_hosts>
</instance_usage_audit_log>

View File

@ -0,0 +1,17 @@
{
"instance_usage_audit_logs": {
"hosts_not_run": [
"%(hostid)s"
],
"log": {},
"num_hosts": 1,
"num_hosts_done": 0,
"num_hosts_not_run": 1,
"num_hosts_running": 0,
"overall_status": "0 of 1 hosts done. 0 errors.",
"period_beginning": "%(timestamp)s",
"period_ending": "%(timestamp)s",
"total_errors": 0,
"total_instances": 0
}
}

View File

@ -0,0 +1,16 @@
<?xml version='1.0' encoding='UTF-8'?>
<instance_usage_audit_logs>
<total_errors>0</total_errors>
<total_instances>0</total_instances>
<log/>
<num_hosts_running>0</num_hosts_running>
<num_hosts_done>0</num_hosts_done>
<num_hosts_not_run>1</num_hosts_not_run>
<hosts_not_run>
<item>%(hostid)s</item>
</hosts_not_run>
<overall_status>0 of 1 hosts done. 0 errors.</overall_status>
<period_ending>%(timestamp)s</period_ending>
<period_beginning>%(timestamp)s</period_beginning>
<num_hosts>1</num_hosts>
</instance_usage_audit_logs>

View File

@ -0,0 +1,17 @@
{
"instance_usage_audit_log": {
"hosts_not_run": [
"%(hostid)s"
],
"log": {},
"num_hosts": 1,
"num_hosts_done": 0,
"num_hosts_not_run": 1,
"num_hosts_running": 0,
"overall_status": "0 of 1 hosts done. 0 errors.",
"period_beginning": "%(timestamp)s",
"period_ending": "%(timestamp)s",
"total_errors": 0,
"total_instances": 0
}
}

View File

@ -0,0 +1,16 @@
<?xml version='1.0' encoding='UTF-8'?>
<instance_usage_audit_log>
<total_errors>0</total_errors>
<total_instances>0</total_instances>
<log/>
<num_hosts_running>0</num_hosts_running>
<num_hosts_done>0</num_hosts_done>
<num_hosts_not_run>1</num_hosts_not_run>
<hosts_not_run>
<item>%(hostid)s</item>
</hosts_not_run>
<overall_status>0 of 1 hosts done. 0 errors.</overall_status>
<period_ending>%(timestamp)s</period_ending>
<period_beginning>%(timestamp)s</period_beginning>
<num_hosts>1</num_hosts>
</instance_usage_audit_log>

View File

@ -292,7 +292,7 @@ class ApiSampleTestBase(integrated_helpers._IntegratedTestBase):
# shouldn't be an issue for this case.
'timestamp': '\d{4}-[0,1]\d-[0-3]\d[ ,T]'
'\d{2}:\d{2}:\d{2}'
'(Z|(\+|-)\d{2}:\d{2}|\.\d{6})',
'(Z|(\+|-)\d{2}:\d{2}|\.\d{6}|)',
'password': '[0-9a-zA-Z]{1,12}',
'ip': '[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}',
'ip6': '([0-9a-zA-Z]{1,4}:){1,7}:?[0-9a-zA-Z]{1,4}',
@ -381,7 +381,6 @@ class ApiSamplesTrap(ApiSampleTestBase):
do_not_approve_additions.append('os-floating-ip-dns')
do_not_approve_additions.append('os-fping')
do_not_approve_additions.append('os-hypervisors')
do_not_approve_additions.append('os-instance_usage_audit_log')
do_not_approve_additions.append('os-networks')
do_not_approve_additions.append('os-services')
do_not_approve_additions.append('os-volumes')
@ -2688,3 +2687,29 @@ class FloatingIPPoolsSampleJsonTests(ApiSampleTestBase):
class FloatingIPPoolsSampleXmlTests(FloatingIPPoolsSampleJsonTests):
ctype = "xml"
class InstanceUsageAuditLogJsonTest(ApiSampleTestBase):
extension_name = ("nova.api.openstack.compute.contrib."
"instance_usage_audit_log.Instance_usage_audit_log")
def test_show_instance_usage_audit_log(self):
response = self._do_get('os-instance_usage_audit_log/%s' %
urllib.quote('2012-07-05 10:00:00'))
self.assertEqual(response.status, 200)
subs = self._get_regexes()
subs['hostid'] = '[a-f0-9]+'
return self._verify_response('inst-usage-audit-log-show-get-resp',
subs, response)
def test_index_instance_usage_audit_log(self):
response = self._do_get('os-instance_usage_audit_log')
self.assertEqual(response.status, 200)
subs = self._get_regexes()
subs['hostid'] = '[a-f0-9]+'
return self._verify_response('inst-usage-audit-log-index-get-resp',
subs, response)
class InstanceUsageAuditLogXmlTest(InstanceUsageAuditLogJsonTest):
ctype = 'xml'