From 99f6d5803653c23f9fd3a78c00d1557c5f0c2eb6 Mon Sep 17 00:00:00 2001 From: nayna-patel Date: Thu, 6 Aug 2015 05:22:41 +0000 Subject: [PATCH] Add create_and_update_secgroups scenario Add scenario that creates N security groups and then updates their name and description.Also added supporting method '_update_security_groups' to "rally/plugins/openstack/scenarios/nova/utils.py". Change-Id: Ieff30655cc04e66a85bb6dfd7c3f90f59ac14384 --- rally-jobs/nova.yaml | 19 +++++++++++++++++++ .../plugins/openstack/scenarios/nova/utils.py | 14 ++++++++++++++ .../openstack/scenarios/nova/test_utils.py | 12 ++++++++++++ 3 files changed, 45 insertions(+) diff --git a/rally-jobs/nova.yaml b/rally-jobs/nova.yaml index 112f88c8..6f6e3ab9 100644 --- a/rally-jobs/nova.yaml +++ b/rally-jobs/nova.yaml @@ -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: diff --git a/rally/plugins/openstack/scenarios/nova/utils.py b/rally/plugins/openstack/scenarios/nova/utils.py index 758539a1..1fca54f0 100644 --- a/rally/plugins/openstack/scenarios/nova/utils.py +++ b/rally/plugins/openstack/scenarios/nova/utils.py @@ -752,6 +752,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)): diff --git a/tests/unit/plugins/openstack/scenarios/nova/test_utils.py b/tests/unit/plugins/openstack/scenarios/nova/test_utils.py index a4fb19c7..58b9511b 100644 --- a/tests/unit/plugins/openstack/scenarios/nova/test_utils.py +++ b/tests/unit/plugins/openstack/scenarios/nova/test_utils.py @@ -636,6 +636,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()