Merge "Add create_and_update_secgroups scenario"
This commit is contained in:
commit
25450d3ff0
@ -484,6 +484,25 @@
|
||||
failure_rate:
|
||||
max: 0
|
||||
|
||||
NovaSecGroup.create_and_update_secgroups:
|
||||
-
|
||||
args:
|
||||
security_group_count: 5
|
||||
runner:
|
||||
type: "constant"
|
||||
times: 4
|
||||
concurrency: 4
|
||||
context:
|
||||
users:
|
||||
tenants: 3
|
||||
users_per_tenant: 2
|
||||
quotas:
|
||||
nova:
|
||||
security_groups: -1
|
||||
sla:
|
||||
failure_rate:
|
||||
max: 0
|
||||
|
||||
NovaSecGroup.create_and_list_secgroups:
|
||||
-
|
||||
args:
|
||||
|
@ -79,6 +79,22 @@ class NovaSecGroup(utils.NovaScenario):
|
||||
rules_per_security_group)
|
||||
self._list_security_groups()
|
||||
|
||||
@validation.required_parameters("security_group_count")
|
||||
@validation.required_services(consts.Service.NOVA)
|
||||
@validation.required_openstack(users=True)
|
||||
@scenario.configure(context={"cleanup": ["nova"]})
|
||||
def create_and_update_secgroups(self, security_group_count):
|
||||
"""Create and update security groups.
|
||||
|
||||
This scenario creates 'security_group_count' security groups
|
||||
then updates their name and description.
|
||||
|
||||
:param security_group_count: Number of security groups
|
||||
"""
|
||||
security_groups = self._create_security_groups(
|
||||
security_group_count)
|
||||
self._update_security_groups(security_groups)
|
||||
|
||||
@types.set(image=types.ImageResourceType,
|
||||
flavor=types.FlavorResourceType)
|
||||
@validation.image_valid_on_flavor("flavor", "image")
|
||||
|
@ -760,6 +760,20 @@ class NovaScenario(scenario.OpenStackScenario):
|
||||
ip_protocol=ip_protocol,
|
||||
cidr=cidr)
|
||||
|
||||
def _update_security_groups(self, security_groups):
|
||||
"""Update a list of security groups
|
||||
|
||||
:param security_groups: list, security_groups that are to be updated
|
||||
"""
|
||||
with atomic.ActionTimer(self, "nova.update_%s_security_groups" %
|
||||
len(security_groups)):
|
||||
for sec_group in security_groups:
|
||||
sg_new_name = self._generate_random_name()
|
||||
sg_new_desc = self._generate_random_name()
|
||||
self.clients("nova").security_groups.update(sec_group.id,
|
||||
sg_new_name,
|
||||
sg_new_desc)
|
||||
|
||||
def _delete_security_groups(self, security_group):
|
||||
with atomic.ActionTimer(self, "nova.delete_%s_security_groups" %
|
||||
len(security_group)):
|
||||
|
@ -0,0 +1,20 @@
|
||||
{
|
||||
"NovaSecGroup.create_and_update_secgroups": [
|
||||
{
|
||||
"args": {
|
||||
"security_group_count": 10
|
||||
},
|
||||
"runner": {
|
||||
"type": "constant",
|
||||
"times": 10,
|
||||
"concurrency": 2
|
||||
},
|
||||
"context": {
|
||||
"users": {
|
||||
"tenants": 3,
|
||||
"users_per_tenant": 2
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
---
|
||||
NovaSecGroup.create_and_update_secgroups:
|
||||
-
|
||||
args:
|
||||
security_group_count: 10
|
||||
runner:
|
||||
type: "constant"
|
||||
times: 10
|
||||
concurrency: 2
|
||||
context:
|
||||
users:
|
||||
tenants: 3
|
||||
users_per_tenant: 2
|
@ -55,6 +55,22 @@ class NovaSecurityGroupTestCase(test.TestCase):
|
||||
nova_scenario._delete_security_groups.assert_called_once_with(
|
||||
fake_secgroups)
|
||||
|
||||
def test_create_and_update_security_groups(self):
|
||||
fake_secgroups = [fakes.FakeSecurityGroup(None, None, 1, "uuid1"),
|
||||
fakes.FakeSecurityGroup(None, None, 2, "uuid2")]
|
||||
nova_scenario = security_group.NovaSecGroup()
|
||||
nova_scenario._create_security_groups = mock.MagicMock(
|
||||
return_value=fake_secgroups)
|
||||
nova_scenario._update_security_groups = mock.MagicMock()
|
||||
nova_scenario._generate_random_name = mock.Mock(
|
||||
return_value="_updated")
|
||||
security_group_count = 2
|
||||
nova_scenario.create_and_update_secgroups(security_group_count)
|
||||
nova_scenario._create_security_groups.assert_called_once_with(
|
||||
security_group_count)
|
||||
nova_scenario._update_security_groups.assert_called_once_with(
|
||||
fake_secgroups)
|
||||
|
||||
def test_create_and_list_secgroups(self):
|
||||
fake_secgroups = [fakes.FakeSecurityGroup(None, None, 1, "uuid1"),
|
||||
fakes.FakeSecurityGroup(None, None, 2, "uuid2")]
|
||||
|
@ -661,6 +661,18 @@ class NovaScenarioTestCase(test.ScenarioTestCase):
|
||||
"nova.create_%s_rules" %
|
||||
(rules_per_security_group * len(fake_secgroups)))
|
||||
|
||||
def test__update_security_groups(self):
|
||||
nova_scenario = utils.NovaScenario()
|
||||
fake_secgroups = [fakes.FakeSecurityGroup(None, None, 1, "uuid1"),
|
||||
fakes.FakeSecurityGroup(None, None, 2, "uuid2")]
|
||||
nova_scenario._update_security_groups(fake_secgroups)
|
||||
self.assertEqual(
|
||||
len(fake_secgroups),
|
||||
self.clients("nova").security_groups.update.call_count)
|
||||
self._test_atomic_action_timer(
|
||||
nova_scenario.atomic_actions(),
|
||||
"nova.update_%s_security_groups" % len(fake_secgroups))
|
||||
|
||||
def test__delete_security_groups(self):
|
||||
nova_scenario = utils.NovaScenario()
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user