Add NovaAggregates.create_and_delete_aggregate

This scenario first creates a aggregate and then delete it.

Change-Id: I35d34f9ea899c234cb79d2ba484c957a64e7fddd
This commit is contained in:
maxinjian 2016-09-29 00:27:51 -04:00
parent 69dc43f81f
commit e24740f5ab
7 changed files with 102 additions and 0 deletions

View File

@ -1172,3 +1172,19 @@
sla:
failure_rate:
max: 0
NovaAggregates.create_and_delete_aggregate:
-
args:
availability_zone: "nova"
runner:
type: "constant"
times: 10
concurrency: 2
context:
users:
tenants: 3
users_per_tenant: 2
sla:
failure_rate:
max: 0

View File

@ -48,3 +48,19 @@ class CreateAndListAggregates(utils.NovaScenario):
"""
self._create_aggregate(availability_zone)
self._list_aggregates()
@validation.required_services(consts.Service.NOVA)
@validation.required_openstack(admin=True)
@scenario.configure(context={"admin_cleanup": ["nova"]},
name="NovaAggregates.create_and_delete_aggregate")
class CreateAndDeleteAggregate(utils.NovaScenario):
"""Scenario for create and delete aggregate."""
def run(self, availability_zone):
"""Create an aggregate and then delete it.
This scenario first creates an aggregate and then delete it.
"""
aggregate = self._create_aggregate(availability_zone)
self._delete_aggregate(aggregate)

View File

@ -1006,3 +1006,12 @@ class NovaScenario(scenario.OpenStackScenario):
aggregate_name = self.generate_random_name()
return self.admin_clients("nova").aggregates.create(aggregate_name,
availability_zone)
@atomic.action_timer("nova.delete_aggregate")
def _delete_aggregate(self, aggregate):
"""Delete the specified aggregate.
:param aggregate: The aggregate to delete
:returns: An instance of novaclient.base.TupleWithMeta
"""
return self.admin_clients("nova").aggregates.delete(aggregate)

View File

@ -0,0 +1,25 @@
{
"NovaAggregates.create_and_delete_aggregate": [
{
"args": {
"availability_zone": "nova"
},
"runner": {
"type": "constant",
"times": 10,
"concurrency": 2
},
"context": {
"users": {
"tenants": 3,
"users_per_tenant": 2
}
},
"sla": {
"failure_rate": {
"max": 0
}
}
}
]
}

View File

@ -0,0 +1,16 @@
---
NovaAggregates.create_and_delete_aggregate:
-
args:
availability_zone: "nova"
runner:
type: "constant"
times: 10
concurrency: 2
context:
users:
tenants: 3
users_per_tenant: 2
sla:
failure_rate:
max: 0

View File

@ -34,3 +34,12 @@ class NovaAggregatesTestCase(test.TestCase):
scenario.run(availability_zone="nova")
scenario._create_aggregate.assert_called_once_with("nova")
scenario._list_aggregates.assert_called_once_with()
def test_create_and_delete_aggregate(self):
scenario = aggregates.CreateAndDeleteAggregate()
scenario._create_aggregate = mock.Mock()
scenario._delete_aggregate = mock.Mock()
scenario.run(availability_zone="nova")
scenario._create_aggregate.assert_called_once_with("nova")
aggregate = scenario._create_aggregate.return_value
scenario._delete_aggregate.assert_called_once_with(aggregate)

View File

@ -1044,3 +1044,14 @@ class NovaScenarioTestCase(test.ScenarioTestCase):
random_name, "nova")
self._test_atomic_action_timer(nova_scenario.atomic_actions(),
"nova.create_aggregate")
def test_delete_aggregate(self):
nova_scenario = utils.NovaScenario(context=self.context)
result = nova_scenario._delete_aggregate("fake_aggregate")
self.assertEqual(
self.admin_clients("nova").aggregates.delete.return_value,
result)
self.admin_clients("nova").aggregates.delete.assert_called_once_with(
"fake_aggregate")
self._test_atomic_action_timer(nova_scenario.atomic_actions(),
"nova.delete_aggregate")