Merge "Delete depracated types stuff from Rally"

This commit is contained in:
Jenkins 2016-05-16 16:00:35 +00:00 committed by Gerrit Code Review
commit d81cb30d98
6 changed files with 32 additions and 35 deletions

View File

@ -19,8 +19,8 @@ from rally import consts
from rally import osclients from rally import osclients
from rally.plugins.openstack.cleanup import manager as resource_manager from rally.plugins.openstack.cleanup import manager as resource_manager
from rally.plugins.openstack.scenarios.ec2 import utils as ec2_utils from rally.plugins.openstack.scenarios.ec2 import utils as ec2_utils
from rally.plugins.openstack import types
from rally.task import context from rally.task import context
from rally.task import types
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)
@ -68,8 +68,8 @@ class EC2ServerGenerator(context.Context):
flavor = self.config["flavor"] flavor = self.config["flavor"]
clients = osclients.Clients(self.context["users"][0]["credential"]) clients = osclients.Clients(self.context["users"][0]["credential"])
image_id = types.EC2ImageResourceType.transform(clients=clients, image_id = types.EC2Image.transform(clients=clients,
resource_config=image) resource_config=image)
for user, tenant_id in rutils.iterate_per_tenants( for user, tenant_id in rutils.iterate_per_tenants(
self.context["users"]): self.context["users"]):

View File

@ -19,8 +19,8 @@ from rally import consts
from rally import osclients from rally import osclients
from rally.plugins.openstack.cleanup import manager as resource_manager from rally.plugins.openstack.cleanup import manager as resource_manager
from rally.plugins.openstack.scenarios.nova import utils as nova_utils from rally.plugins.openstack.scenarios.nova import utils as nova_utils
from rally.plugins.openstack import types
from rally.task import context from rally.task import context
from rally.task import types
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)
@ -78,10 +78,10 @@ class ServerGenerator(context.Context):
servers_per_tenant = self.config["servers_per_tenant"] servers_per_tenant = self.config["servers_per_tenant"]
clients = osclients.Clients(self.context["users"][0]["credential"]) clients = osclients.Clients(self.context["users"][0]["credential"])
image_id = types.ImageResourceType.transform(clients=clients, image_id = types.GlanceImage.transform(clients=clients,
resource_config=image) resource_config=image)
flavor_id = types.FlavorResourceType.transform(clients=clients, flavor_id = types.Flavor.transform(clients=clients,
resource_config=flavor) resource_config=flavor)
for iter_, (user, tenant_id) in enumerate(rutils.iterate_per_tenants( for iter_, (user, tenant_id) in enumerate(rutils.iterate_per_tenants(
self.context["users"])): self.context["users"])):

View File

@ -25,8 +25,8 @@ from rally import consts
from rally import osclients from rally import osclients
from rally.plugins.openstack.scenarios.nova import utils as nova_utils from rally.plugins.openstack.scenarios.nova import utils as nova_utils
from rally.plugins.openstack.scenarios.vm import vmtasks from rally.plugins.openstack.scenarios.vm import vmtasks
from rally.plugins.openstack import types
from rally.task import context from rally.task import context
from rally.task import types
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)
@ -147,9 +147,9 @@ class BaseCustomImageGenerator(context.Context):
clients = osclients.Clients(user["credential"]) clients = osclients.Clients(user["credential"])
image_id = types.ImageResourceType.transform( image_id = types.GlanceImage.transform(
clients=clients, resource_config=self.config["image"]) clients=clients, resource_config=self.config["image"])
flavor_id = types.FlavorResourceType.transform( flavor_id = types.Flavor.transform(
clients=clients, resource_config=self.config["flavor"]) clients=clients, resource_config=self.config["flavor"])
vm_scenario = vmtasks.VMTasks(self.context, clients=clients) vm_scenario = vmtasks.VMTasks(self.context, clients=clients)

View File

@ -22,7 +22,7 @@ from tests.unit import test
CTX = "rally.plugins.openstack.context.ec2" CTX = "rally.plugins.openstack.context.ec2"
SCN = "rally.plugins.openstack.scenarios" SCN = "rally.plugins.openstack.scenarios"
TYP = "rally.task.types" TYP = "rally.plugins.openstack.types"
class EC2ServerGeneratorTestCase(test.TestCase): class EC2ServerGeneratorTestCase(test.TestCase):
@ -60,11 +60,10 @@ class EC2ServerGeneratorTestCase(test.TestCase):
@mock.patch("%s.ec2.utils.EC2Scenario._boot_servers" % SCN, @mock.patch("%s.ec2.utils.EC2Scenario._boot_servers" % SCN,
return_value=[fakes.FakeServer(id=str(i)) for i in range(5)]) return_value=[fakes.FakeServer(id=str(i)) for i in range(5)])
@mock.patch("%s.EC2ImageResourceType.transform" % TYP, @mock.patch("%s.EC2Image.transform" % TYP, return_value=mock.MagicMock())
return_value=mock.MagicMock())
@mock.patch("%s.servers.osclients" % CTX, return_value=fakes.FakeClients()) @mock.patch("%s.servers.osclients" % CTX, return_value=fakes.FakeClients())
def test_setup(self, mock_osclients, def test_setup(self, mock_osclients,
mock_ec2_image_resource_type_transform, mock_ec2_image_transform,
mock_ec2_scenario__boot_servers): mock_ec2_scenario__boot_servers):
tenants_count = 2 tenants_count = 2

View File

@ -23,7 +23,7 @@ from tests.unit import test
CTX = "rally.plugins.openstack.context.nova" CTX = "rally.plugins.openstack.context.nova"
SCN = "rally.plugins.openstack.scenarios" SCN = "rally.plugins.openstack.scenarios"
TYP = "rally.task.types" TYP = "rally.plugins.openstack.types"
class ServerGeneratorTestCase(test.ScenarioTestCase): class ServerGeneratorTestCase(test.ScenarioTestCase):
@ -57,13 +57,12 @@ class ServerGeneratorTestCase(test.ScenarioTestCase):
fakes.FakeServer(id="uuid"), fakes.FakeServer(id="uuid"),
fakes.FakeServer(id="uuid") fakes.FakeServer(id="uuid")
]) ])
@mock.patch("%s.ImageResourceType.transform" % TYP, @mock.patch("%s.GlanceImage.transform" % TYP,
return_value=mock.MagicMock())
@mock.patch("%s.FlavorResourceType.transform" % TYP,
return_value=mock.MagicMock()) return_value=mock.MagicMock())
@mock.patch("%s.Flavor.transform" % TYP, return_value=mock.MagicMock())
@mock.patch("%s.servers.osclients" % CTX, return_value=fakes.FakeClients()) @mock.patch("%s.servers.osclients" % CTX, return_value=fakes.FakeClients())
def test_setup(self, mock_osclients, mock_flavor_resource_type_transform, def test_setup(self, mock_osclients, mock_flavor_transform,
mock_image_resource_type_transform, mock_glance_image_transform,
mock_nova_scenario__boot_servers): mock_nova_scenario__boot_servers):
tenants_count = 2 tenants_count = 2
@ -111,8 +110,8 @@ class ServerGeneratorTestCase(test.ScenarioTestCase):
servers_ctx = servers.ServerGenerator(self.context) servers_ctx = servers.ServerGenerator(self.context)
servers_ctx.setup() servers_ctx.setup()
self.assertEqual(new_context, self.context) self.assertEqual(new_context, self.context)
image_id = mock_image_resource_type_transform.return_value image_id = mock_glance_image_transform.return_value
flavor_id = mock_flavor_resource_type_transform.return_value flavor_id = mock_flavor_transform.return_value
servers_ctx_config = self.context["config"]["servers"] servers_ctx_config = self.context["config"]["servers"]
expected_auto_nic = servers_ctx_config.get("auto_assign_nic", False) expected_auto_nic = servers_ctx_config.get("auto_assign_nic", False)
expected_requests = servers_ctx_config.get("servers_per_tenant", False) expected_requests = servers_ctx_config.get("servers_per_tenant", False)

View File

@ -64,13 +64,11 @@ class BaseCustomImageContextVMTestCase(test.TestCase):
@mock.patch("%s.vmtasks.VMTasks" % BASE) @mock.patch("%s.vmtasks.VMTasks" % BASE)
@mock.patch("%s.osclients.Clients" % BASE) @mock.patch("%s.osclients.Clients" % BASE)
@mock.patch("%s.types.ImageResourceType.transform" % BASE, @mock.patch("%s.types.GlanceImage.transform" % BASE, return_value="image")
return_value="image") @mock.patch("%s.types.Flavor.transform" % BASE, return_value="flavor")
@mock.patch("%s.types.FlavorResourceType.transform" % BASE,
return_value="flavor")
def test_create_one_image( def test_create_one_image(
self, mock_flavor_resource_type_transform, self, mock_flavor_transform, mock_glance_image_transform,
mock_image_resource_type_transform, mock_clients, mock_vm_tasks): mock_clients, mock_vm_tasks):
ip = {"ip": "foo_ip", "id": "foo_id", "is_floating": True} ip = {"ip": "foo_ip", "id": "foo_id", "is_floating": True}
fake_server = mock.Mock() fake_server = mock.Mock()
@ -95,10 +93,10 @@ class BaseCustomImageContextVMTestCase(test.TestCase):
custom_image = generator_ctx.create_one_image(user, custom_image = generator_ctx.create_one_image(user,
foo_arg="foo_value") foo_arg="foo_value")
mock_flavor_resource_type_transform.assert_called_once_with( mock_flavor_transform.assert_called_once_with(
clients=mock_clients.return_value, clients=mock_clients.return_value,
resource_config={"name": "flavor"}) resource_config={"name": "flavor"})
mock_image_resource_type_transform.assert_called_once_with( mock_glance_image_transform.assert_called_once_with(
clients=mock_clients.return_value, clients=mock_clients.return_value,
resource_config={"name": "image"}) resource_config={"name": "image"})
mock_vm_tasks.assert_called_once_with( mock_vm_tasks.assert_called_once_with(
@ -124,13 +122,14 @@ class BaseCustomImageContextVMTestCase(test.TestCase):
@mock.patch("%s.vmtasks.VMTasks" % BASE) @mock.patch("%s.vmtasks.VMTasks" % BASE)
@mock.patch("%s.osclients.Clients" % BASE) @mock.patch("%s.osclients.Clients" % BASE)
@mock.patch("%s.types.ImageResourceType.transform" % BASE, @mock.patch("%s.types.GlanceImage.transform" % BASE,
return_value="image") return_value="image")
@mock.patch("%s.types.FlavorResourceType.transform" % BASE, @mock.patch("%s.types.Flavor.transform" % BASE,
return_value="flavor") return_value="flavor")
def test_create_one_image_cleanup( def test_create_one_image_cleanup(
self, mock_flavor_resource_type_transform, self, mock_flavor_transform,
mock_image_resource_type_transform, mock_clients, mock_vm_tasks): mock_glance_image_transform, mock_clients,
mock_vm_tasks):
ip = {"ip": "foo_ip", "id": "foo_id", "is_floating": True} ip = {"ip": "foo_ip", "id": "foo_id", "is_floating": True}
fake_server = mock.Mock() fake_server = mock.Mock()