Merge "Add nova.CreateFlavorAndSetKeys"
This commit is contained in:
commit
a40248f9b8
@ -1089,6 +1089,26 @@
|
||||
failure_rate:
|
||||
max: 0
|
||||
|
||||
NovaFlavors.create_flavor_and_set_keys:
|
||||
-
|
||||
args:
|
||||
ram: 500
|
||||
vcpus : 1
|
||||
disk: 1
|
||||
extra_specs:
|
||||
quota:disk_read_bytes_sec: 10240
|
||||
runner:
|
||||
type: "constant"
|
||||
concurrency: 2
|
||||
times: 10
|
||||
context:
|
||||
users:
|
||||
tenants: 2
|
||||
users_per_tenant: 2
|
||||
sla:
|
||||
failure_rate:
|
||||
max: 0
|
||||
|
||||
NovaFlavors.create_and_get_flavor:
|
||||
-
|
||||
args:
|
||||
|
@ -104,3 +104,24 @@ class CreateAndGetFlavor(utils.NovaScenario):
|
||||
"""
|
||||
flavor = self._create_flavor(ram, vcpus, disk, **kwargs)
|
||||
self._get_flavor(flavor.id)
|
||||
|
||||
|
||||
@validation.required_services(consts.Service.NOVA)
|
||||
@validation.required_openstack(admin=True)
|
||||
@scenario.configure(context={"admin_cleanup": ["nova"]},
|
||||
name="NovaFlavors.create_flavor_and_set_keys")
|
||||
class CreateFlavorAndSetKeys(utils.NovaScenario):
|
||||
def run(self, ram, vcpus, disk, extra_specs, **kwargs):
|
||||
"""Create flavor and set keys to the flavor.
|
||||
|
||||
Measure the "nova flavor-key" command performance.
|
||||
the scenario first create a flavor,then add the extra specs to it.
|
||||
|
||||
:param ram: Memory in MB for the flavor
|
||||
:param vcpus: Number of VCPUs for the flavor
|
||||
:param disk: Size of local disk in GB
|
||||
:param extra_specs: additional arguments for flavor set keys
|
||||
:param kwargs: Optional additional arguments for flavor creation
|
||||
"""
|
||||
flavor = self._create_flavor(ram, vcpus, disk, **kwargs)
|
||||
self._set_flavor_keys(flavor, extra_specs)
|
||||
|
@ -909,6 +909,15 @@ class NovaScenario(scenario.OpenStackScenario):
|
||||
"""
|
||||
return self.clients("nova").flavors.list(detailed, **kwargs)
|
||||
|
||||
@atomic.action_timer("nova.set_flavor_keys")
|
||||
def _set_flavor_keys(self, flavor, extra_specs):
|
||||
"""set flavor keys
|
||||
|
||||
:param flavor: flavor to set keys
|
||||
:param extra_specs: additional arguments for flavor set keys
|
||||
"""
|
||||
return flavor.set_keys(extra_specs)
|
||||
|
||||
@atomic.action_timer("nova.list_agents")
|
||||
def _list_agents(self, hypervisor=None):
|
||||
"""List all nova-agent builds.
|
||||
|
30
samples/tasks/scenarios/nova/create-flavor-and-set-keys.json
Normal file
30
samples/tasks/scenarios/nova/create-flavor-and-set-keys.json
Normal file
@ -0,0 +1,30 @@
|
||||
{
|
||||
"NovaFlavors.create_flavor_and_set_keys": [
|
||||
{
|
||||
"runner": {
|
||||
"type": "constant",
|
||||
"concurrency": 2,
|
||||
"times": 10
|
||||
},
|
||||
"args": {
|
||||
"ram": 500,
|
||||
"vcpus" : 1,
|
||||
"disk": 1,
|
||||
"extra_specs": {
|
||||
"quota:disk_read_bytes_sec": 10240
|
||||
}
|
||||
},
|
||||
"context": {
|
||||
"users": {
|
||||
"tenants": 3,
|
||||
"users_per_tenant": 2
|
||||
}
|
||||
},
|
||||
"sla": {
|
||||
"failure_rate": {
|
||||
"max": 0
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
20
samples/tasks/scenarios/nova/create-flavor-and-set-keys.yaml
Normal file
20
samples/tasks/scenarios/nova/create-flavor-and-set-keys.yaml
Normal file
@ -0,0 +1,20 @@
|
||||
---
|
||||
NovaFlavors.create_flavor_and_set_keys:
|
||||
-
|
||||
runner:
|
||||
type: "constant"
|
||||
concurrency: 2
|
||||
times: 10
|
||||
args:
|
||||
ram: 500
|
||||
vcpus : 1
|
||||
disk: 1
|
||||
extra_specs:
|
||||
quota:disk_read_bytes_sec: 10240
|
||||
context:
|
||||
users:
|
||||
tenants: 3
|
||||
users_per_tenant: 2
|
||||
sla:
|
||||
failure_rate:
|
||||
max: 0
|
@ -63,3 +63,16 @@ class NovaFlavorsTestCase(test.TestCase):
|
||||
scenario._create_flavor.assert_called_once_with(100, 1, 1, **kwargs)
|
||||
scenario._get_flavor.assert_called_once_with(
|
||||
scenario._create_flavor.return_value.id)
|
||||
|
||||
def test_create_flavor_and_set_keys(self):
|
||||
scenario = flavors.CreateFlavorAndSetKeys()
|
||||
scenario._create_flavor = mock.MagicMock()
|
||||
scenario._set_flavor_keys = mock.MagicMock()
|
||||
specs_args = {"fakeargs": "foo"}
|
||||
scenario.run(ram=100, vcpus=1, disk=1, extra_specs=specs_args,
|
||||
fakeargs="fakeargs")
|
||||
|
||||
scenario._create_flavor.assert_called_once_with(100, 1, 1,
|
||||
fakeargs="fakeargs")
|
||||
scenario._set_flavor_keys.assert_called_once_with(
|
||||
scenario._create_flavor.return_value, specs_args)
|
||||
|
@ -909,6 +909,19 @@ class NovaScenarioTestCase(test.ScenarioTestCase):
|
||||
self._test_atomic_action_timer(nova_scenario.atomic_actions(),
|
||||
"nova.list_flavors")
|
||||
|
||||
def test__set_flavor_keys(self):
|
||||
flavor = mock.MagicMock()
|
||||
nova_scenario = utils.NovaScenario()
|
||||
extra_specs = {"fakeargs": "foo"}
|
||||
flavor.set_keys = mock.MagicMock()
|
||||
|
||||
result = nova_scenario._set_flavor_keys(flavor, extra_specs)
|
||||
self.assertEqual(flavor.set_keys.return_value, result)
|
||||
flavor.set_keys.assert_called_once_with(extra_specs)
|
||||
|
||||
self._test_atomic_action_timer(nova_scenario.atomic_actions(),
|
||||
"nova.set_flavor_keys")
|
||||
|
||||
@ddt.data({},
|
||||
{"hypervisor": "foo_hypervisor"})
|
||||
@ddt.unpack
|
||||
|
Loading…
Reference in New Issue
Block a user