Merge "Reorganize Openstack context plugins"
This commit is contained in:
@@ -17,7 +17,7 @@ import itertools
|
||||
from rally.common import log
|
||||
from rally import exceptions
|
||||
from rally import osclients
|
||||
from rally.plugins.openstack.context import users
|
||||
from rally.plugins.openstack.context.keystone import users
|
||||
from rally.plugins.openstack.scenarios.cinder import utils as cinder_utils
|
||||
from rally.plugins.openstack.scenarios.ec2 import utils as ec2_utils
|
||||
from rally.plugins.openstack.scenarios.glance import utils as glance_utils
|
||||
|
0
rally/plugins/openstack/context/cinder/__init__.py
Normal file
0
rally/plugins/openstack/context/cinder/__init__.py
Normal file
0
rally/plugins/openstack/context/glance/__init__.py
Normal file
0
rally/plugins/openstack/context/glance/__init__.py
Normal file
0
rally/plugins/openstack/context/heat/__init__.py
Normal file
0
rally/plugins/openstack/context/heat/__init__.py
Normal file
0
rally/plugins/openstack/context/murano/__init__.py
Normal file
0
rally/plugins/openstack/context/murano/__init__.py
Normal file
0
rally/plugins/openstack/context/network/__init__.py
Normal file
0
rally/plugins/openstack/context/network/__init__.py
Normal file
0
rally/plugins/openstack/context/nova/__init__.py
Normal file
0
rally/plugins/openstack/context/nova/__init__.py
Normal file
@@ -28,8 +28,8 @@ from rally import consts
|
||||
from rally import exceptions
|
||||
from rally import objects
|
||||
from rally import osclients
|
||||
from rally.plugins.openstack.context import existing_users as existingusers_ctx
|
||||
from rally.plugins.openstack.context import users as users_ctx
|
||||
from rally.plugins.openstack.context.keystone import existing_users
|
||||
from rally.plugins.openstack.context.keystone import users as users_ctx
|
||||
from rally.task import context
|
||||
from rally.task import runner
|
||||
from rally.task.scenarios import base as base_scenario
|
||||
@@ -157,7 +157,7 @@ class BenchmarkEngine(object):
|
||||
def _get_user_ctx_for_validation(self, ctx):
|
||||
if self.existing_users:
|
||||
ctx["config"] = {"existing_users": self.existing_users}
|
||||
user_context = existingusers_ctx.ExistingUsers(ctx)
|
||||
user_context = existing_users.ExistingUsers(ctx)
|
||||
else:
|
||||
user_context = users_ctx.UserGenerator(ctx)
|
||||
|
||||
|
@@ -27,7 +27,7 @@ from rally import consts
|
||||
from rally import exceptions
|
||||
from rally import objects
|
||||
from rally import osclients
|
||||
from rally.plugins.openstack.context import flavors as flavors_ctx
|
||||
from rally.plugins.openstack.context.nova import flavors as flavors_ctx
|
||||
from rally.task import types
|
||||
from rally.verification.tempest import tempest
|
||||
|
||||
|
@@ -17,11 +17,10 @@ import copy
|
||||
|
||||
import mock
|
||||
|
||||
from rally.plugins.openstack.context import ceilometer
|
||||
from rally.plugins.openstack.context.ceilometer import samples
|
||||
from tests.unit import test
|
||||
|
||||
CTX = "rally.plugins.openstack.context"
|
||||
SCN = "rally.task.scenarios"
|
||||
CTX = "rally.plugins.openstack.context.ceilometer"
|
||||
|
||||
|
||||
class CeilometerSampleGeneratorTestCase(test.TestCase):
|
||||
@@ -79,10 +78,10 @@ class CeilometerSampleGeneratorTestCase(test.TestCase):
|
||||
}
|
||||
}
|
||||
|
||||
inst = ceilometer.CeilometerSampleGenerator(context)
|
||||
inst = samples.CeilometerSampleGenerator(context)
|
||||
self.assertEqual(inst.config, context["config"]["ceilometer"])
|
||||
|
||||
@mock.patch("%s.ceilometer.ceilo_utils.CeilometerScenario._create_sample"
|
||||
@mock.patch("%s.samples.ceilo_utils.CeilometerScenario._create_sample"
|
||||
% CTX)
|
||||
def test_setup(self, mock_ceilometer_scenario__create_sample):
|
||||
tenants_count = 2
|
||||
@@ -115,11 +114,11 @@ class CeilometerSampleGeneratorTestCase(test.TestCase):
|
||||
mock_ceilometer_scenario__create_sample.return_value = [
|
||||
mock.MagicMock(to_dict=lambda: sample, **sample)]
|
||||
|
||||
ceilometer_ctx = ceilometer.CeilometerSampleGenerator(real_context)
|
||||
ceilometer_ctx = samples.CeilometerSampleGenerator(real_context)
|
||||
ceilometer_ctx.setup()
|
||||
self.assertEqual(new_context, ceilometer_ctx.context)
|
||||
|
||||
def test_cleanup(self):
|
||||
tenants, context = self._gen_context(2, 5, 3, 3)
|
||||
ceilometer_ctx = ceilometer.CeilometerSampleGenerator(context)
|
||||
ceilometer_ctx = samples.CeilometerSampleGenerator(context)
|
||||
ceilometer_ctx.cleanup()
|
@@ -17,7 +17,7 @@ import copy
|
||||
|
||||
import mock
|
||||
|
||||
from rally.plugins.openstack.context import volumes
|
||||
from rally.plugins.openstack.context.cinder import volumes
|
||||
from tests.unit import fakes
|
||||
from tests.unit import test
|
||||
|
||||
@@ -90,7 +90,7 @@ class VolumeGeneratorTestCase(test.ScenarioTestCase):
|
||||
volumes_ctx.setup()
|
||||
self.assertEqual(new_context, real_context)
|
||||
|
||||
@mock.patch("%s.volumes.resource_manager.cleanup" % CTX)
|
||||
@mock.patch("%s.cinder.volumes.resource_manager.cleanup" % CTX)
|
||||
def test_cleanup(self, mock_cleanup):
|
||||
|
||||
tenants_count = 2
|
@@ -18,12 +18,12 @@ import copy
|
||||
import jsonschema
|
||||
import mock
|
||||
|
||||
from rally.plugins.openstack.context import images
|
||||
from rally.plugins.openstack.context.glance import images
|
||||
from tests.unit import fakes
|
||||
from tests.unit import test
|
||||
|
||||
CTX = "rally.plugins.openstack.context"
|
||||
SCN = "rally.plugins.openstack.scenarios"
|
||||
CTX = "rally.plugins.openstack.context.glance"
|
||||
SCN = "rally.plugins.openstack.scenarios.glance"
|
||||
|
||||
|
||||
class ImageGeneratorTestCase(test.ScenarioTestCase):
|
||||
@@ -65,7 +65,7 @@ class ImageGeneratorTestCase(test.ScenarioTestCase):
|
||||
self.assertRaises(jsonschema.ValidationError,
|
||||
images.ImageGenerator.validate, context)
|
||||
|
||||
@mock.patch("%s.glance.utils.GlanceScenario._create_image" % SCN,
|
||||
@mock.patch("%s.utils.GlanceScenario._create_image" % SCN,
|
||||
return_value=fakes.FakeImage(id="uuid"))
|
||||
def test_setup(self, mock_glance_scenario__create_image):
|
||||
|
@@ -15,7 +15,7 @@
|
||||
|
||||
import mock
|
||||
|
||||
from rally.plugins.openstack.context import stacks
|
||||
from rally.plugins.openstack.context.heat import stacks
|
||||
from tests.unit import fakes
|
||||
from tests.unit import test
|
||||
|
||||
@@ -85,7 +85,7 @@ class TestStackGenerator(test.ScenarioTestCase):
|
||||
self.assertEqual(stacks_per_tenant,
|
||||
len(context["tenants"][ten_id]["stacks"]))
|
||||
|
||||
@mock.patch("%s.stacks.resource_manager.cleanup" % CTX)
|
||||
@mock.patch("%s.heat.stacks.resource_manager.cleanup" % CTX)
|
||||
def test_cleanup(self, mock_cleanup):
|
||||
context = {
|
||||
"task": mock.MagicMock(),
|
@@ -14,16 +14,16 @@
|
||||
|
||||
import mock
|
||||
|
||||
from rally.plugins.openstack.context import existing_users
|
||||
from rally.plugins.openstack.context.keystone import existing_users
|
||||
from tests.unit import test
|
||||
|
||||
CTX = "rally.plugins.openstack.context"
|
||||
|
||||
|
||||
class ExistingUserTestCase(test.TestCase):
|
||||
|
||||
@mock.patch("rally.plugins.openstack.context."
|
||||
"existing_users.osclients.Clients")
|
||||
@mock.patch("rally.plugins.openstack.context."
|
||||
"existing_users.objects.Endpoint")
|
||||
@mock.patch("%s.keystone.existing_users.osclients.Clients" % CTX)
|
||||
@mock.patch("%s.keystone.existing_users.objects.Endpoint" % CTX)
|
||||
def test_setup(self, mock_endpoint, mock_clients):
|
||||
user1 = mock.MagicMock(tenant_id="1")
|
||||
user2 = mock.MagicMock(tenant_id="1")
|
@@ -16,10 +16,12 @@
|
||||
import mock
|
||||
|
||||
from rally import exceptions
|
||||
from rally.plugins.openstack.context import roles
|
||||
from rally.plugins.openstack.context.keystone import roles
|
||||
from tests.unit import fakes
|
||||
from tests.unit import test
|
||||
|
||||
CTX = "rally.plugins.openstack.context.keystone.roles"
|
||||
|
||||
|
||||
class RoleGeneratorTestCase(test.TestCase):
|
||||
|
||||
@@ -43,7 +45,7 @@ class RoleGeneratorTestCase(test.TestCase):
|
||||
"task": mock.MagicMock()
|
||||
}
|
||||
|
||||
@mock.patch("rally.plugins.openstack.context.roles.osclients")
|
||||
@mock.patch("%s.osclients" % CTX)
|
||||
def test_add_role(self, mock_osclients):
|
||||
fc = fakes.FakeClients()
|
||||
mock_osclients.Clients.return_value = fc
|
||||
@@ -58,7 +60,7 @@ class RoleGeneratorTestCase(test.TestCase):
|
||||
expected = {"id": "r1", "name": "test_role1"}
|
||||
self.assertEqual(expected, result)
|
||||
|
||||
@mock.patch("rally.plugins.openstack.context.roles.osclients")
|
||||
@mock.patch("%s.osclients" % CTX)
|
||||
def test_add_role_which_does_not_exist(self, mock_osclients):
|
||||
fc = fakes.FakeClients()
|
||||
mock_osclients.Clients.return_value = fc
|
||||
@@ -73,7 +75,7 @@ class RoleGeneratorTestCase(test.TestCase):
|
||||
expected = "There is no role with name `unknown_role`."
|
||||
self.assertEqual(expected, str(ex))
|
||||
|
||||
@mock.patch("rally.plugins.openstack.context.roles.osclients")
|
||||
@mock.patch("%s.osclients" % CTX)
|
||||
def test_remove_role(self, mock_osclients):
|
||||
role = mock.MagicMock()
|
||||
fc = fakes.FakeClients()
|
||||
@@ -91,7 +93,7 @@ class RoleGeneratorTestCase(test.TestCase):
|
||||
mock_keystone = mock_osclients.Clients().keystone()
|
||||
mock_keystone.roles.remove_user_role.assert_has_calls(calls)
|
||||
|
||||
@mock.patch("rally.plugins.openstack.context.roles.osclients")
|
||||
@mock.patch("%s.osclients" % CTX)
|
||||
def test_setup_and_cleanup(self, mock_osclients):
|
||||
fc = fakes.FakeClients()
|
||||
mock_osclients.Clients.return_value = fc
|
@@ -18,9 +18,11 @@ import mock
|
||||
from rally import consts
|
||||
from rally import exceptions
|
||||
from rally import objects
|
||||
from rally.plugins.openstack.context import users
|
||||
from rally.plugins.openstack.context.keystone import users
|
||||
from tests.unit import test
|
||||
|
||||
CTX = "rally.plugins.openstack.context.keystone.users"
|
||||
|
||||
|
||||
class UserGeneratorTestCase(test.TestCase):
|
||||
|
||||
@@ -45,15 +47,14 @@ class UserGeneratorTestCase(test.TestCase):
|
||||
|
||||
def setUp(self):
|
||||
super(UserGeneratorTestCase, self).setUp()
|
||||
self.osclients_patcher = mock.patch(
|
||||
"rally.plugins.openstack.context.users.osclients")
|
||||
self.osclients_patcher = mock.patch("%s.osclients" % CTX)
|
||||
self.osclients = self.osclients_patcher.start()
|
||||
|
||||
def tearDown(self):
|
||||
self.osclients_patcher.stop()
|
||||
super(UserGeneratorTestCase, self).tearDown()
|
||||
|
||||
@mock.patch("rally.plugins.openstack.context.users.network.wrap")
|
||||
@mock.patch("%s.network.wrap" % CTX)
|
||||
def test__remove_default_security_group_not_needed(self, mock_wrap):
|
||||
services = {"compute": consts.Service.NOVA}
|
||||
self.osclients.Clients().services.return_value = services
|
||||
@@ -61,7 +62,7 @@ class UserGeneratorTestCase(test.TestCase):
|
||||
user_generator._remove_default_security_group()
|
||||
self.assertFalse(mock_wrap.called)
|
||||
|
||||
@mock.patch("rally.plugins.openstack.context.users.network.wrap")
|
||||
@mock.patch("%s.network.wrap" % CTX)
|
||||
def test__remove_default_security_group_neutron_no_sg(self, mock_wrap):
|
||||
net_wrapper = mock.Mock(SERVICE_IMPL=consts.Service.NEUTRON)
|
||||
net_wrapper.supports_security_group.return_value = (False, None)
|
||||
@@ -82,7 +83,7 @@ class UserGeneratorTestCase(test.TestCase):
|
||||
net_wrapper.supports_security_group.assert_called_once_with()
|
||||
|
||||
@mock.patch("rally.common.utils.iterate_per_tenants")
|
||||
@mock.patch("rally.plugins.openstack.context.users.network")
|
||||
@mock.patch("%s.network" % CTX)
|
||||
@mock.patch("rally.task.utils.check_service_status",
|
||||
return_value=False)
|
||||
def test__remove_default_security_group(
|
||||
@@ -180,8 +181,8 @@ class UserGeneratorTestCase(test.TestCase):
|
||||
"nova-network")
|
||||
nova_admin.networks.disassociate.assert_called_once_with(networks[0])
|
||||
|
||||
@mock.patch("rally.plugins.openstack.context.users.broker.time.sleep")
|
||||
@mock.patch("rally.plugins.openstack.context.users.keystone")
|
||||
@mock.patch("%s.broker.time.sleep" % CTX)
|
||||
@mock.patch("%s.keystone" % CTX)
|
||||
def test__create_tenants(self, mock_keystone, mock_sleep):
|
||||
user_generator = users.UserGenerator(self.context)
|
||||
user_generator.config["tenants"] = 1
|
||||
@@ -190,8 +191,8 @@ class UserGeneratorTestCase(test.TestCase):
|
||||
id, tenant = tenants.popitem()
|
||||
self.assertIn("name", tenant)
|
||||
|
||||
@mock.patch("rally.plugins.openstack.context.users.broker.time.sleep")
|
||||
@mock.patch("rally.plugins.openstack.context.users.keystone")
|
||||
@mock.patch("%s.broker.time.sleep" % CTX)
|
||||
@mock.patch("%s.keystone" % CTX)
|
||||
def test__create_users(self, mock_keystone, mock_sleep):
|
||||
user_generator = users.UserGenerator(self.context)
|
||||
user_generator.context["tenants"] = {"t1": dict(id="t1", name="t1"),
|
||||
@@ -203,7 +204,7 @@ class UserGeneratorTestCase(test.TestCase):
|
||||
self.assertIn("id", user)
|
||||
self.assertIn("endpoint", user)
|
||||
|
||||
@mock.patch("rally.plugins.openstack.context.users.keystone")
|
||||
@mock.patch("%s.keystone" % CTX)
|
||||
def test__delete_tenants(self, mock_keystone):
|
||||
user_generator = users.UserGenerator(self.context)
|
||||
user_generator.context["tenants"] = {"t1": dict(id="t1", name="t1"),
|
||||
@@ -211,7 +212,7 @@ class UserGeneratorTestCase(test.TestCase):
|
||||
user_generator._delete_tenants()
|
||||
self.assertEqual(len(user_generator.context["tenants"]), 0)
|
||||
|
||||
@mock.patch("rally.plugins.openstack.context.users.keystone")
|
||||
@mock.patch("%s.keystone" % CTX)
|
||||
def test__delete_tenants_failure(self, mock_keystone):
|
||||
wrapped_keystone = mock_keystone.wrap.return_value
|
||||
wrapped_keystone.delete_project.side_effect = Exception()
|
||||
@@ -221,7 +222,7 @@ class UserGeneratorTestCase(test.TestCase):
|
||||
user_generator._delete_tenants()
|
||||
self.assertEqual(len(user_generator.context["tenants"]), 0)
|
||||
|
||||
@mock.patch("rally.plugins.openstack.context.users.keystone")
|
||||
@mock.patch("%s.keystone" % CTX)
|
||||
def test__delete_users(self, mock_keystone):
|
||||
user_generator = users.UserGenerator(self.context)
|
||||
user1 = mock.MagicMock()
|
||||
@@ -230,7 +231,7 @@ class UserGeneratorTestCase(test.TestCase):
|
||||
user_generator._delete_users()
|
||||
self.assertEqual(len(user_generator.context["users"]), 0)
|
||||
|
||||
@mock.patch("rally.plugins.openstack.context.users.keystone")
|
||||
@mock.patch("%s.keystone" % CTX)
|
||||
def test__delete_users_failure(self, mock_keystone):
|
||||
wrapped_keystone = mock_keystone.wrap.return_value
|
||||
wrapped_keystone.delete_user.side_effect = Exception()
|
||||
@@ -241,7 +242,7 @@ class UserGeneratorTestCase(test.TestCase):
|
||||
user_generator._delete_users()
|
||||
self.assertEqual(len(user_generator.context["users"]), 0)
|
||||
|
||||
@mock.patch("rally.plugins.openstack.context.users.keystone")
|
||||
@mock.patch("%s.keystone" % CTX)
|
||||
def test_setup_and_cleanup(self, mock_keystone):
|
||||
wrapped_keystone = mock.MagicMock()
|
||||
mock_keystone.wrap.return_value = wrapped_keystone
|
||||
@@ -258,7 +259,7 @@ class UserGeneratorTestCase(test.TestCase):
|
||||
self.assertEqual(len(ctx.context["users"]), 0)
|
||||
self.assertEqual(len(ctx.context["tenants"]), 0)
|
||||
|
||||
@mock.patch("rally.plugins.openstack.context.users.keystone")
|
||||
@mock.patch("%s.keystone" % CTX)
|
||||
def test_setup_and_cleanup_failure(self, mock_keystone):
|
||||
wrapped_keystone = mock_keystone.wrap.return_value
|
||||
wrapped_keystone.create_user.side_effect = Exception()
|
||||
@@ -268,7 +269,7 @@ class UserGeneratorTestCase(test.TestCase):
|
||||
# Ensure that tenants get deleted anyway
|
||||
self.assertEqual(len(ctx.context["tenants"]), 0)
|
||||
|
||||
@mock.patch("rally.plugins.openstack.context.users.keystone")
|
||||
@mock.patch("%s.keystone" % CTX)
|
||||
def test_users_and_tenants_in_context(self, mock_keystone):
|
||||
wrapped_keystone = mock.MagicMock()
|
||||
mock_keystone.wrap.return_value = wrapped_keystone
|
||||
@@ -313,7 +314,7 @@ class UserGeneratorTestCase(test.TestCase):
|
||||
self.assertEqual(user["id"], orig_user.id)
|
||||
self.assertEqual(user["tenant_id"], tenant_id)
|
||||
|
||||
@mock.patch("rally.plugins.openstack.context.users.keystone")
|
||||
@mock.patch("%s.keystone" % CTX)
|
||||
def test_users_contains_correct_endpoint_type(self, mock_keystone):
|
||||
endpoint = objects.Endpoint("foo_url", "foo", "foo_pass",
|
||||
endpoint_type=consts.EndpointType.INTERNAL)
|
||||
@@ -335,7 +336,7 @@ class UserGeneratorTestCase(test.TestCase):
|
||||
for user in users_:
|
||||
self.assertEqual("internal", user["endpoint"].endpoint_type)
|
||||
|
||||
@mock.patch("rally.plugins.openstack.context.users.keystone")
|
||||
@mock.patch("%s.keystone" % CTX)
|
||||
def test_users_contains_default_endpoint_type(self, mock_keystone):
|
||||
endpoint = objects.Endpoint("foo_url", "foo", "foo_pass")
|
||||
config = {
|
@@ -15,10 +15,10 @@
|
||||
|
||||
import mock
|
||||
|
||||
from rally.plugins.openstack.context import murano_packages
|
||||
from rally.plugins.openstack.context.murano import murano_packages
|
||||
from tests.unit import test
|
||||
|
||||
CTX = "rally.plugins.openstack.context"
|
||||
CTX = "rally.plugins.openstack.context.murano.murano_packages"
|
||||
|
||||
|
||||
class MuranoGeneratorTestCase(test.TestCase):
|
||||
@@ -64,7 +64,7 @@ class MuranoGeneratorTestCase(test.TestCase):
|
||||
}
|
||||
}
|
||||
|
||||
@mock.patch("rally.plugins.openstack.context.murano_packages.osclients")
|
||||
@mock.patch("%s.osclients" % CTX)
|
||||
def test_setup(self, mock_osclients):
|
||||
mock_app = mock.MagicMock(id="fake_app_id")
|
||||
(mock_osclients.Clients().murano().
|
||||
@@ -78,8 +78,8 @@ class MuranoGeneratorTestCase(test.TestCase):
|
||||
self.assertEqual([mock_app],
|
||||
murano_ctx.context["tenants"][tenant_id]["packages"])
|
||||
|
||||
@mock.patch("rally.plugins.openstack.context.murano_packages.osclients")
|
||||
@mock.patch("%s.images.resource_manager.cleanup" % CTX)
|
||||
@mock.patch("%s.osclients" % CTX)
|
||||
@mock.patch("%s.resource_manager.cleanup" % CTX)
|
||||
def test_cleanup(self, mock_cleanup, mock_osclients):
|
||||
mock_app = mock.Mock(id="fake_app_id")
|
||||
(mock_osclients.Clients().murano().
|
@@ -15,18 +15,21 @@
|
||||
|
||||
import mock
|
||||
|
||||
from rally.plugins.openstack.context import secgroup
|
||||
from rally.plugins.openstack.context.network import allow_ssh
|
||||
from tests.unit import fakes
|
||||
from tests.unit import test
|
||||
|
||||
|
||||
class SecGroupContextTestCase(test.TestCase):
|
||||
CTX = "rally.plugins.openstack.context.network.allow_ssh"
|
||||
|
||||
|
||||
class AllowSSHContextTestCase(test.TestCase):
|
||||
|
||||
def setUp(self):
|
||||
super(SecGroupContextTestCase, self).setUp()
|
||||
super(AllowSSHContextTestCase, self).setUp()
|
||||
self.users = 2
|
||||
task = {"uuid": "foo_task_id"}
|
||||
self.secgroup_name = secgroup.SSH_GROUP_NAME + "_foo"
|
||||
self.secgroup_name = allow_ssh.SSH_GROUP_NAME + "_foo"
|
||||
self.ctx_with_secgroup = {
|
||||
"users": [
|
||||
{
|
||||
@@ -49,7 +52,7 @@ class SecGroupContextTestCase(test.TestCase):
|
||||
"task": task
|
||||
}
|
||||
|
||||
@mock.patch("rally.plugins.openstack.context.secgroup.osclients.Clients")
|
||||
@mock.patch("%s.osclients.Clients" % CTX)
|
||||
def test__prepare_open_secgroup(self, mock_clients):
|
||||
fake_nova = fakes.FakeNovaClient()
|
||||
self.assertEqual(len(fake_nova.security_groups.list()), 1)
|
||||
@@ -57,7 +60,7 @@ class SecGroupContextTestCase(test.TestCase):
|
||||
mock_cl.nova.return_value = fake_nova
|
||||
mock_clients.return_value = mock_cl
|
||||
|
||||
ret = secgroup._prepare_open_secgroup("endpoint", self.secgroup_name)
|
||||
ret = allow_ssh._prepare_open_secgroup("endpoint", self.secgroup_name)
|
||||
self.assertEqual(self.secgroup_name, ret["name"])
|
||||
|
||||
self.assertEqual(2, len(fake_nova.security_groups.list()))
|
||||
@@ -66,10 +69,10 @@ class SecGroupContextTestCase(test.TestCase):
|
||||
[sg.name for sg in fake_nova.security_groups.list()])
|
||||
|
||||
# run prep again, check that another security group is not created
|
||||
secgroup._prepare_open_secgroup("endpoint", self.secgroup_name)
|
||||
allow_ssh._prepare_open_secgroup("endpoint", self.secgroup_name)
|
||||
self.assertEqual(2, len(fake_nova.security_groups.list()))
|
||||
|
||||
@mock.patch("rally.plugins.openstack.context.secgroup.osclients.Clients")
|
||||
@mock.patch("%s.osclients.Clients" % CTX)
|
||||
def test__prepare_open_secgroup_rules(self, mock_clients):
|
||||
fake_nova = fakes.FakeNovaClient()
|
||||
|
||||
@@ -79,20 +82,19 @@ class SecGroupContextTestCase(test.TestCase):
|
||||
mock_cl.nova.return_value = fake_nova
|
||||
mock_clients.return_value = mock_cl
|
||||
|
||||
secgroup._prepare_open_secgroup("endpoint", self.secgroup_name)
|
||||
allow_ssh._prepare_open_secgroup("endpoint", self.secgroup_name)
|
||||
|
||||
self.assertEqual(2, len(fake_nova.security_groups.list()))
|
||||
rally_open = fake_nova.security_groups.find(self.secgroup_name)
|
||||
self.assertEqual(3, len(rally_open.rules))
|
||||
|
||||
# run prep again, check that extra rules are not created
|
||||
secgroup._prepare_open_secgroup("endpoint", self.secgroup_name)
|
||||
allow_ssh._prepare_open_secgroup("endpoint", self.secgroup_name)
|
||||
rally_open = fake_nova.security_groups.find(self.secgroup_name)
|
||||
self.assertEqual(3, len(rally_open.rules))
|
||||
|
||||
@mock.patch("rally.plugins.openstack.context.secgroup.osclients.Clients")
|
||||
@mock.patch("rally.plugins.openstack.context."
|
||||
"secgroup._prepare_open_secgroup")
|
||||
@mock.patch("%s.osclients.Clients" % CTX)
|
||||
@mock.patch("%s._prepare_open_secgroup" % CTX)
|
||||
@mock.patch("rally.plugins.openstack.wrappers.network.wrap")
|
||||
def test_secgroup_setup_cleanup_with_secgroup_supported(
|
||||
self, mock_network_wrap, mock__prepare_open_secgroup,
|
||||
@@ -106,7 +108,7 @@ class SecGroupContextTestCase(test.TestCase):
|
||||
"id": "secgroup_id"}
|
||||
mock_clients.return_value = mock.MagicMock()
|
||||
|
||||
secgrp_ctx = secgroup.AllowSSH(self.ctx_without_secgroup)
|
||||
secgrp_ctx = allow_ssh.AllowSSH(self.ctx_without_secgroup)
|
||||
secgrp_ctx.setup()
|
||||
self.assertEqual(self.ctx_with_secgroup, secgrp_ctx.context)
|
||||
secgrp_ctx.cleanup()
|
||||
@@ -124,7 +126,7 @@ class SecGroupContextTestCase(test.TestCase):
|
||||
mock_network_wrap.assert_called_once_with(
|
||||
mock_clients.return_value, {})
|
||||
|
||||
@mock.patch("rally.plugins.openstack.context.secgroup.osclients.Clients")
|
||||
@mock.patch("%s.osclients.Clients" % CTX)
|
||||
@mock.patch("rally.plugins.openstack.wrappers.network.wrap")
|
||||
def test_secgroup_setup_with_secgroup_unsupported(
|
||||
self, mock_network_wrap, mock_clients):
|
||||
@@ -134,7 +136,7 @@ class SecGroupContextTestCase(test.TestCase):
|
||||
mock_network_wrap.return_value = mock_network_wrapper
|
||||
mock_clients.return_value = mock.MagicMock()
|
||||
|
||||
secgrp_ctx = secgroup.AllowSSH(dict(self.ctx_without_secgroup))
|
||||
secgrp_ctx = allow_ssh.AllowSSH(dict(self.ctx_without_secgroup))
|
||||
secgrp_ctx.setup()
|
||||
self.assertEqual(self.ctx_without_secgroup, secgrp_ctx.context)
|
||||
|
@@ -16,7 +16,7 @@
|
||||
import mock
|
||||
import netaddr
|
||||
|
||||
from rally.plugins.openstack.context import network as network_context
|
||||
from rally.plugins.openstack.context.network import networks as network_context
|
||||
from tests.unit import test
|
||||
|
||||
NET = "rally.plugins.openstack.wrappers.network."
|
||||
@@ -49,7 +49,7 @@ class NetworkTestCase(test.TestCase):
|
||||
self.assertEqual(context.config["start_cidr"], "foo_cidr")
|
||||
|
||||
@mock.patch(NET + "wrap")
|
||||
@mock.patch("rally.plugins.openstack.context.network.utils")
|
||||
@mock.patch("rally.plugins.openstack.context.network.networks.utils")
|
||||
@mock.patch("rally.osclients.Clients")
|
||||
def test_setup(self, mock_clients, mock_utils, mock_wrap):
|
||||
mock_utils.iterate_per_tenants.return_value = [
|
@@ -16,13 +16,13 @@
|
||||
import mock
|
||||
|
||||
from rally import exceptions
|
||||
from rally.plugins.openstack.context import tempest
|
||||
from rally.plugins.openstack.context.not_for_production import tempest
|
||||
from rally.verification.tempest import config
|
||||
from rally.verification.tempest import tempest as tempest_verifier
|
||||
from tests.unit import test
|
||||
|
||||
|
||||
CONTEXT = "rally.plugins.openstack.context.tempest"
|
||||
CONTEXT = "rally.plugins.openstack.context.not_for_production.tempest"
|
||||
TEMPEST = "rally.verification.tempest.tempest"
|
||||
|
||||
|
@@ -18,10 +18,10 @@ import copy
|
||||
import mock
|
||||
from novaclient import exceptions as nova_exceptions
|
||||
|
||||
from rally.plugins.openstack.context import flavors
|
||||
from rally.plugins.openstack.context.nova import flavors
|
||||
from tests.unit import test
|
||||
|
||||
CTX = "rally.plugins.openstack.context"
|
||||
CTX = "rally.plugins.openstack.context.nova"
|
||||
|
||||
|
||||
class FlavorsGeneratorTestCase(test.TestCase):
|
@@ -15,10 +15,10 @@
|
||||
|
||||
import mock
|
||||
|
||||
from rally.plugins.openstack.context import keypair
|
||||
from rally.plugins.openstack.context.nova import keypairs
|
||||
from tests.unit import test
|
||||
|
||||
CTX = "rally.plugins.openstack.context"
|
||||
CTX = "rally.plugins.openstack.context.nova"
|
||||
|
||||
|
||||
class KeyPairContextTestCase(test.TestCase):
|
||||
@@ -26,7 +26,7 @@ class KeyPairContextTestCase(test.TestCase):
|
||||
def setUp(self):
|
||||
super(KeyPairContextTestCase, self).setUp()
|
||||
self.users = 2
|
||||
self.keypair_name = keypair.Keypair.KEYPAIR_NAME + "_foo_task_id"
|
||||
self.keypair_name = keypairs.Keypair.KEYPAIR_NAME + "_foo_task_id"
|
||||
|
||||
task = {"uuid": "foo_task_id"}
|
||||
self.ctx_with_keys = {
|
||||
@@ -47,14 +47,14 @@ class KeyPairContextTestCase(test.TestCase):
|
||||
"task": task
|
||||
}
|
||||
|
||||
@mock.patch("%s.keypair.Keypair._generate_keypair" % CTX)
|
||||
@mock.patch("%s.keypairs.Keypair._generate_keypair" % CTX)
|
||||
def test_keypair_setup(self, mock_keypair__generate_keypair):
|
||||
mock_keypair__generate_keypair.side_effect = [
|
||||
{"id": "key_id", "key": "key", "name": self.keypair_name},
|
||||
{"id": "key_id", "key": "key", "name": self.keypair_name},
|
||||
]
|
||||
|
||||
keypair_ctx = keypair.Keypair(self.ctx_without_keys)
|
||||
keypair_ctx = keypairs.Keypair(self.ctx_without_keys)
|
||||
keypair_ctx.setup()
|
||||
self.assertEqual(self.ctx_with_keys, keypair_ctx.context)
|
||||
|
||||
@@ -62,9 +62,9 @@ class KeyPairContextTestCase(test.TestCase):
|
||||
[mock.call("endpoint")] * 2,
|
||||
mock_keypair__generate_keypair.mock_calls)
|
||||
|
||||
@mock.patch("%s.keypair.resource_manager.cleanup" % CTX)
|
||||
@mock.patch("%s.keypairs.resource_manager.cleanup" % CTX)
|
||||
def test_keypair_cleanup(self, mock_cleanup):
|
||||
keypair_ctx = keypair.Keypair(self.ctx_with_keys)
|
||||
keypair_ctx = keypairs.Keypair(self.ctx_with_keys)
|
||||
keypair_ctx.cleanup()
|
||||
mock_cleanup.assert_called_once_with(names=["nova.keypairs"],
|
||||
users=self.ctx_with_keys["users"])
|
||||
@@ -76,7 +76,7 @@ class KeyPairContextTestCase(test.TestCase):
|
||||
mock_keypair.public_key = "public_key"
|
||||
mock_keypair.private_key = "private_key"
|
||||
mock_keypair.id = "key_id"
|
||||
keypair_ctx = keypair.Keypair(self.ctx_without_keys)
|
||||
keypair_ctx = keypairs.Keypair(self.ctx_without_keys)
|
||||
key = keypair_ctx._generate_keypair("endpoint")
|
||||
|
||||
self.assertEqual({
|
@@ -17,11 +17,11 @@ import copy
|
||||
|
||||
import mock
|
||||
|
||||
from rally.plugins.openstack.context import servers
|
||||
from rally.plugins.openstack.context.nova import servers
|
||||
from tests.unit import fakes
|
||||
from tests.unit import test
|
||||
|
||||
CTX = "rally.plugins.openstack.context"
|
||||
CTX = "rally.plugins.openstack.context.nova"
|
||||
SCN = "rally.plugins.openstack.scenarios"
|
||||
TYP = "rally.task.types"
|
||||
|
@@ -181,7 +181,7 @@ class BenchmarkEngineTestCase(test.TestCase):
|
||||
eng._validate_config_semantic_helper, "a", "u", "n",
|
||||
"p", mock.MagicMock(), {})
|
||||
|
||||
@mock.patch("rally.task.engine.existingusers_ctx.ExistingUsers")
|
||||
@mock.patch("rally.task.engine.existing_users.ExistingUsers")
|
||||
def test_get_user_ctx_for_validation_existing_users(
|
||||
self, mock_existing_users):
|
||||
|
||||
|
Reference in New Issue
Block a user