Add NovaFlavors.create_and_get_flavor
The scenario first creates a flavor,then get detailed information of the created flavor Change-Id: I99dd4f0ae39ed7587bbd71e83b205dc205acacca
This commit is contained in:
parent
bea20ca6ec
commit
a44191ba21
@ -1069,6 +1069,20 @@
|
||||
failure_rate:
|
||||
max: 0
|
||||
|
||||
NovaFlavors.create_and_get_flavor:
|
||||
-
|
||||
args:
|
||||
ram: 500
|
||||
vcpus: 1
|
||||
disk: 1
|
||||
runner:
|
||||
type: "constant"
|
||||
times: 5
|
||||
concurrency: 2
|
||||
sla:
|
||||
failure_rate:
|
||||
max: 0
|
||||
|
||||
NovaFlavors.create_and_list_flavor_access:
|
||||
-
|
||||
args:
|
||||
|
@ -73,3 +73,23 @@ class NovaFlavors(utils.NovaScenario):
|
||||
:param kwargs: Optional additional arguments for flavor creation
|
||||
"""
|
||||
self._create_flavor(ram, vcpus, disk, **kwargs)
|
||||
|
||||
|
||||
@validation.required_services(consts.Service.NOVA)
|
||||
@validation.required_openstack(admin=True)
|
||||
@scenario.configure(context={"admin_cleanup": ["nova"]},
|
||||
name="NovaFlavors.create_and_get_flavor")
|
||||
class CreateAndGetFlavor(utils.NovaScenario):
|
||||
"""Scenario for create and get flavor."""
|
||||
|
||||
def run(self, ram, vcpus, disk, **kwargs):
|
||||
"""Create flavor and get detailed information of the flavor.
|
||||
|
||||
: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 kwargs: Optional additional arguments for flavor creation
|
||||
|
||||
"""
|
||||
flavor = self._create_flavor(ram, vcpus, disk, **kwargs)
|
||||
self._get_flavor(flavor.id)
|
||||
|
@ -987,3 +987,11 @@ class NovaScenario(scenario.OpenStackScenario):
|
||||
description=description)
|
||||
else:
|
||||
return server.update(name=new_name)
|
||||
|
||||
@atomic.action_timer("nova.get_flavor")
|
||||
def _get_flavor(self, flavor_id):
|
||||
"""Show a flavor
|
||||
|
||||
:param flavor_id: The flavor ID to get
|
||||
"""
|
||||
return self.admin_clients("nova").flavors.get(flavor_id)
|
||||
|
27
samples/tasks/scenarios/nova/create-and-get-flavor.json
Normal file
27
samples/tasks/scenarios/nova/create-and-get-flavor.json
Normal file
@ -0,0 +1,27 @@
|
||||
{
|
||||
"NovaFlavors.create_and_get_flavor": [
|
||||
{
|
||||
"runner": {
|
||||
"type": "constant",
|
||||
"concurrency": 2,
|
||||
"times": 10
|
||||
},
|
||||
"args": {
|
||||
"ram": 500,
|
||||
"vcpus" : 1,
|
||||
"disk": 1
|
||||
},
|
||||
"context": {
|
||||
"users": {
|
||||
"tenants": 1,
|
||||
"users_per_tenant": 1
|
||||
}
|
||||
},
|
||||
"sla": {
|
||||
"failure_rate": {
|
||||
"max": 0
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
19
samples/tasks/scenarios/nova/create-and-get-flavor.yaml
Normal file
19
samples/tasks/scenarios/nova/create-and-get-flavor.yaml
Normal file
@ -0,0 +1,19 @@
|
||||
|
||||
---
|
||||
NovaFlavors.create_and_get_flavor:
|
||||
-
|
||||
runner:
|
||||
type: "constant"
|
||||
concurrency: 2
|
||||
times: 10
|
||||
args:
|
||||
ram: 500
|
||||
vcpus : 1
|
||||
disk: 1
|
||||
context:
|
||||
users:
|
||||
tenants: 1
|
||||
users_per_tenant: 1
|
||||
sla:
|
||||
failure_rate:
|
||||
max: 0
|
@ -54,3 +54,13 @@ class NovaFlavorsTestCase(test.TestCase):
|
||||
scenario.create_flavor(ram=100, vcpus=1, disk=1, fakeargs="fakeargs")
|
||||
scenario._create_flavor.assert_called_once_with(100, 1, 1,
|
||||
fakeargs="fakeargs")
|
||||
|
||||
def test_create_and_get_flavor(self, **kwargs):
|
||||
scenario = flavors.CreateAndGetFlavor()
|
||||
scenario._create_flavor = mock.Mock()
|
||||
scenario._get_flavor = mock.Mock()
|
||||
scenario.run(ram=100, vcpus=1, disk=1, **kwargs)
|
||||
|
||||
scenario._create_flavor.assert_called_once_with(100, 1, 1, **kwargs)
|
||||
scenario._get_flavor.assert_called_once_with(
|
||||
scenario._create_flavor.return_value.id)
|
||||
|
@ -995,6 +995,17 @@ class NovaScenarioTestCase(test.ScenarioTestCase):
|
||||
self._test_atomic_action_timer(nova_scenario.atomic_actions(),
|
||||
"nova.create_flavor")
|
||||
|
||||
def test__get_flavor(self):
|
||||
nova_scenario = utils.NovaScenario()
|
||||
result = nova_scenario._get_flavor("foo_flavor_id")
|
||||
self.assertEqual(
|
||||
self.admin_clients("nova").flavors.get.return_value,
|
||||
result)
|
||||
self.admin_clients("nova").flavors.get.assert_called_once_with(
|
||||
"foo_flavor_id")
|
||||
self._test_atomic_action_timer(nova_scenario.atomic_actions(),
|
||||
"nova.get_flavor")
|
||||
|
||||
def test__update_server(self):
|
||||
server = mock.Mock()
|
||||
nova_scenario = utils.NovaScenario()
|
||||
|
Loading…
Reference in New Issue
Block a user