Add NovaAggregates.create_and_update_aggregate
This scenario first creates a aggregate and then update its name and availability_zone. Change-Id: I747b8adc0fae273dda4720731fa407d72fa5d286
This commit is contained in:
parent
3cd2fde697
commit
4e14129bf8
@ -1188,3 +1188,19 @@
|
||||
sla:
|
||||
failure_rate:
|
||||
max: 0
|
||||
|
||||
NovaAggregates.create_and_update_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
|
||||
|
@ -66,3 +66,21 @@ class CreateAndDeleteAggregate(utils.NovaScenario):
|
||||
"""
|
||||
aggregate = self._create_aggregate(availability_zone)
|
||||
self._delete_aggregate(aggregate)
|
||||
|
||||
|
||||
@validation.required_services(consts.Service.NOVA)
|
||||
@validation.required_openstack(admin=True)
|
||||
@scenario.configure(context={"admin_cleanup": ["nova"]},
|
||||
name="NovaAggregates.create_and_update_aggregate")
|
||||
class CreateAndUpdateAggregate(utils.NovaScenario):
|
||||
"""Scenario for create and update aggregate."""
|
||||
|
||||
def run(self, availability_zone):
|
||||
"""Create an aggregate and then update its name and availability_zone
|
||||
|
||||
This scenario first creates an aggregate and then update its name and
|
||||
availability_zone
|
||||
:param availability_zone: The availability zone of the aggregate
|
||||
"""
|
||||
aggregate = self._create_aggregate(availability_zone)
|
||||
self._update_aggregate(aggregate)
|
||||
|
@ -1131,3 +1131,17 @@ class NovaScenario(scenario.OpenStackScenario):
|
||||
"""
|
||||
self._shelve_server(server)
|
||||
self._unshelve_server(server)
|
||||
|
||||
@atomic.action_timer("nova.update_aggregate")
|
||||
def _update_aggregate(self, aggregate):
|
||||
"""Update the aggregate's name and availability_zone.
|
||||
|
||||
:param aggregate: The aggregate to update
|
||||
:return: The updated aggregate
|
||||
"""
|
||||
aggregate_name = self.generate_random_name()
|
||||
availability_zone = self.generate_random_name()
|
||||
values = {"name": aggregate_name,
|
||||
"availability_zone": availability_zone}
|
||||
return self.admin_clients("nova").aggregates.update(aggregate,
|
||||
values)
|
||||
|
@ -0,0 +1,25 @@
|
||||
{
|
||||
"NovaAggregates.create_and_update_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
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
---
|
||||
NovaAggregates.create_and_update_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
|
@ -43,3 +43,12 @@ class NovaAggregatesTestCase(test.TestCase):
|
||||
scenario._create_aggregate.assert_called_once_with("nova")
|
||||
aggregate = scenario._create_aggregate.return_value
|
||||
scenario._delete_aggregate.assert_called_once_with(aggregate)
|
||||
|
||||
def test_create_and_update_aggregate(self):
|
||||
scenario = aggregates.CreateAndUpdateAggregate()
|
||||
scenario._create_aggregate = mock.Mock()
|
||||
scenario._update_aggregate = mock.Mock()
|
||||
scenario.run(availability_zone="nova")
|
||||
scenario._create_aggregate.assert_called_once_with("nova")
|
||||
aggregate = scenario._create_aggregate.return_value
|
||||
scenario._update_aggregate.assert_called_once_with(aggregate)
|
||||
|
@ -1055,3 +1055,19 @@ class NovaScenarioTestCase(test.ScenarioTestCase):
|
||||
"fake_aggregate")
|
||||
self._test_atomic_action_timer(nova_scenario.atomic_actions(),
|
||||
"nova.delete_aggregate")
|
||||
|
||||
def test_update_aggregate(self):
|
||||
aggregate = mock.Mock()
|
||||
nova_scenario = utils.NovaScenario(context=self.context)
|
||||
nova_scenario.generate_random_name = mock.Mock(
|
||||
return_value="random_name")
|
||||
values = {"name": "random_name",
|
||||
"availability_zone": "random_name"}
|
||||
result = nova_scenario._update_aggregate(aggregate=aggregate)
|
||||
self.assertEqual(
|
||||
self.admin_clients("nova").aggregates.update.return_value,
|
||||
result)
|
||||
self.admin_clients("nova").aggregates.update.assert_called_once_with(
|
||||
aggregate, values)
|
||||
self._test_atomic_action_timer(nova_scenario.atomic_actions(),
|
||||
"nova.update_aggregate")
|
||||
|
Loading…
Reference in New Issue
Block a user