Merge "unit-tests: fix mocks' naming"
This commit is contained in:
commit
c072b9a8cd
@ -34,7 +34,8 @@ class TaskSampleTestCase(test.TestCase):
|
||||
|
||||
@mock.patch("rally.benchmark.engine.BenchmarkEngine"
|
||||
"._validate_config_semantic")
|
||||
def test_schema_is_valid(self, mock_semantic):
|
||||
def test_schema_is_valid(self,
|
||||
mock_benchmark_engine__validate_config_semantic):
|
||||
scenarios = set()
|
||||
|
||||
for dirname, dirnames, filenames in os.walk(self.samples_path):
|
||||
|
@ -22,8 +22,8 @@ class CinderQuotasTestCase(test.TestCase):
|
||||
|
||||
@mock.patch("rally.plugins.openstack.context."
|
||||
"quotas.quotas.osclients.Clients")
|
||||
def test_update(self, client_mock):
|
||||
cinder_quo = cinder_quotas.CinderQuotas(client_mock)
|
||||
def test_update(self, mock_clients):
|
||||
cinder_quo = cinder_quotas.CinderQuotas(mock_clients)
|
||||
tenant_id = mock.MagicMock()
|
||||
quotas_values = {
|
||||
"volumes": 10,
|
||||
@ -31,13 +31,13 @@ class CinderQuotasTestCase(test.TestCase):
|
||||
"gigabytes": 1000
|
||||
}
|
||||
cinder_quo.update(tenant_id, **quotas_values)
|
||||
client_mock.cinder().quotas.update.assert_called_once_with(
|
||||
mock_clients.cinder().quotas.update.assert_called_once_with(
|
||||
tenant_id, **quotas_values)
|
||||
|
||||
@mock.patch("rally.plugins.openstack.context."
|
||||
"quotas.quotas.osclients.Clients")
|
||||
def test_delete(self, client_mock):
|
||||
cinder_quo = cinder_quotas.CinderQuotas(client_mock)
|
||||
def test_delete(self, mock_clients):
|
||||
cinder_quo = cinder_quotas.CinderQuotas(mock_clients)
|
||||
tenant_id = mock.MagicMock()
|
||||
cinder_quo.delete(tenant_id)
|
||||
client_mock.cinder().quotas.delete.assert_called_once_with(tenant_id)
|
||||
mock_clients.cinder().quotas.delete.assert_called_once_with(tenant_id)
|
||||
|
@ -22,8 +22,8 @@ class DesignateQuotasTestCase(test.TestCase):
|
||||
|
||||
@mock.patch("rally.plugins.openstack.context."
|
||||
"quotas.quotas.osclients.Clients")
|
||||
def test_update(self, client_mock):
|
||||
quotas = designate_quotas.DesignateQuotas(client_mock)
|
||||
def test_update(self, mock_clients):
|
||||
quotas = designate_quotas.DesignateQuotas(mock_clients)
|
||||
tenant_id = mock.MagicMock()
|
||||
quotas_values = {
|
||||
"domains": 5,
|
||||
@ -32,14 +32,14 @@ class DesignateQuotasTestCase(test.TestCase):
|
||||
"recordset_records": 20,
|
||||
}
|
||||
quotas.update(tenant_id, **quotas_values)
|
||||
client_mock.designate().quotas.update.assert_called_once_with(
|
||||
mock_clients.designate().quotas.update.assert_called_once_with(
|
||||
tenant_id, quotas_values)
|
||||
|
||||
@mock.patch("rally.plugins.openstack.context."
|
||||
"quotas.quotas.osclients.Clients")
|
||||
def test_delete(self, client_mock):
|
||||
quotas = designate_quotas.DesignateQuotas(client_mock)
|
||||
def test_delete(self, mock_clients):
|
||||
quotas = designate_quotas.DesignateQuotas(mock_clients)
|
||||
tenant_id = mock.MagicMock()
|
||||
quotas.delete(tenant_id)
|
||||
client_mock.designate().quotas.reset.assert_called_once_with(
|
||||
mock_clients.designate().quotas.reset.assert_called_once_with(
|
||||
tenant_id)
|
||||
|
@ -22,8 +22,8 @@ class NeutronQuotasTestCase(test.TestCase):
|
||||
|
||||
@mock.patch("rally.plugins.openstack.context."
|
||||
"quotas.quotas.osclients.Clients")
|
||||
def test_update(self, client_mock):
|
||||
neutron_quotas = quotas.NeutronQuotas(client_mock)
|
||||
def test_update(self, mock_clients):
|
||||
neutron_quotas = quotas.NeutronQuotas(mock_clients)
|
||||
tenant_id = mock.MagicMock()
|
||||
quotas_values = {
|
||||
"network": 20,
|
||||
@ -36,13 +36,13 @@ class NeutronQuotasTestCase(test.TestCase):
|
||||
}
|
||||
neutron_quotas.update(tenant_id, **quotas_values)
|
||||
body = {"quota": quotas_values}
|
||||
client_mock.neutron().update_quota.assert_called_once_with(tenant_id,
|
||||
body=body)
|
||||
mock_clients.neutron().update_quota.assert_called_once_with(tenant_id,
|
||||
body=body)
|
||||
|
||||
@mock.patch("rally.plugins.openstack.context."
|
||||
"quotas.quotas.osclients.Clients")
|
||||
def test_delete(self, client_mock):
|
||||
neutron_quotas = quotas.NeutronQuotas(client_mock)
|
||||
def test_delete(self, mock_clients):
|
||||
neutron_quotas = quotas.NeutronQuotas(mock_clients)
|
||||
tenant_id = mock.MagicMock()
|
||||
neutron_quotas.delete(tenant_id)
|
||||
client_mock.neutron().delete_quota.assert_called_once_with(tenant_id)
|
||||
mock_clients.neutron().delete_quota.assert_called_once_with(tenant_id)
|
||||
|
@ -22,8 +22,8 @@ class NovaQuotasTestCase(test.TestCase):
|
||||
|
||||
@mock.patch("rally.plugins.openstack.context."
|
||||
"quotas.quotas.osclients.Clients")
|
||||
def test_update(self, client_mock):
|
||||
nova_quotas = quotas.NovaQuotas(client_mock)
|
||||
def test_update(self, mock_clients):
|
||||
nova_quotas = quotas.NovaQuotas(mock_clients)
|
||||
tenant_id = mock.MagicMock()
|
||||
quotas_values = {
|
||||
"instances": 10,
|
||||
@ -40,13 +40,13 @@ class NovaQuotasTestCase(test.TestCase):
|
||||
"security_group_rules": 50
|
||||
}
|
||||
nova_quotas.update(tenant_id, **quotas_values)
|
||||
client_mock.nova().quotas.update.assert_called_once_with(
|
||||
mock_clients.nova().quotas.update.assert_called_once_with(
|
||||
tenant_id, **quotas_values)
|
||||
|
||||
@mock.patch("rally.plugins.openstack.context."
|
||||
"quotas.quotas.osclients.Clients")
|
||||
def test_delete(self, client_mock):
|
||||
nova_quotas = quotas.NovaQuotas(client_mock)
|
||||
def test_delete(self, mock_clients):
|
||||
nova_quotas = quotas.NovaQuotas(mock_clients)
|
||||
tenant_id = mock.MagicMock()
|
||||
nova_quotas.delete(tenant_id)
|
||||
client_mock.nova().quotas.delete.assert_called_once_with(tenant_id)
|
||||
mock_clients.nova().quotas.delete.assert_called_once_with(tenant_id)
|
||||
|
@ -139,7 +139,7 @@ class QuotasTestCase(test.TestCase):
|
||||
"quotas.quotas.osclients.Clients")
|
||||
@mock.patch("rally.plugins.openstack.context."
|
||||
"quotas.cinder_quotas.CinderQuotas")
|
||||
def test_cinder_quotas(self, mock_quotas, mock_osclients):
|
||||
def test_cinder_quotas(self, mock_cinder_quotas, mock_clients):
|
||||
ctx = copy.deepcopy(self.context)
|
||||
ctx["config"]["quotas"] = {
|
||||
"cinder": {
|
||||
@ -158,19 +158,21 @@ class QuotasTestCase(test.TestCase):
|
||||
expected_setup_calls.append(mock.call()
|
||||
.update(tenant,
|
||||
**cinder_quotas))
|
||||
mock_quotas.assert_has_calls(expected_setup_calls, any_order=True)
|
||||
mock_quotas.reset_mock()
|
||||
mock_cinder_quotas.assert_has_calls(
|
||||
expected_setup_calls, any_order=True)
|
||||
mock_cinder_quotas.reset_mock()
|
||||
|
||||
expected_cleanup_calls = []
|
||||
for tenant in tenants:
|
||||
expected_cleanup_calls.append(mock.call().delete(tenant))
|
||||
mock_quotas.assert_has_calls(expected_cleanup_calls, any_order=True)
|
||||
mock_cinder_quotas.assert_has_calls(
|
||||
expected_cleanup_calls, any_order=True)
|
||||
|
||||
@mock.patch("rally.plugins.openstack.context."
|
||||
"quotas.quotas.osclients.Clients")
|
||||
@mock.patch("rally.plugins.openstack.context."
|
||||
"quotas.nova_quotas.NovaQuotas")
|
||||
def test_nova_quotas(self, mock_quotas, mock_osclients):
|
||||
def test_nova_quotas(self, mock_nova_quotas, mock_clients):
|
||||
ctx = copy.deepcopy(self.context)
|
||||
|
||||
ctx["config"]["quotas"] = {
|
||||
@ -198,19 +200,21 @@ class QuotasTestCase(test.TestCase):
|
||||
expected_setup_calls.append(mock.call()
|
||||
.update(tenant,
|
||||
**nova_quotas))
|
||||
mock_quotas.assert_has_calls(expected_setup_calls, any_order=True)
|
||||
mock_quotas.reset_mock()
|
||||
mock_nova_quotas.assert_has_calls(
|
||||
expected_setup_calls, any_order=True)
|
||||
mock_nova_quotas.reset_mock()
|
||||
|
||||
expected_cleanup_calls = []
|
||||
for tenant in ctx["tenants"]:
|
||||
expected_cleanup_calls.append(mock.call().delete(tenant))
|
||||
mock_quotas.assert_has_calls(expected_cleanup_calls, any_order=True)
|
||||
mock_nova_quotas.assert_has_calls(
|
||||
expected_cleanup_calls, any_order=True)
|
||||
|
||||
@mock.patch("rally.plugins.openstack.context."
|
||||
"quotas.quotas.osclients.Clients")
|
||||
@mock.patch("rally.plugins.openstack.context."
|
||||
"quotas.neutron_quotas.NeutronQuotas")
|
||||
def test_neutron_quotas(self, mock_quotas, mock_osclients):
|
||||
def test_neutron_quotas(self, mock_neutron_quotas, mock_clients):
|
||||
ctx = copy.deepcopy(self.context)
|
||||
|
||||
ctx["config"]["quotas"] = {
|
||||
@ -233,13 +237,15 @@ class QuotasTestCase(test.TestCase):
|
||||
expected_setup_calls.append(mock.call()
|
||||
.update(tenant,
|
||||
**neutron_quotas))
|
||||
mock_quotas.assert_has_calls(expected_setup_calls, any_order=True)
|
||||
mock_quotas.reset_mock()
|
||||
mock_neutron_quotas.assert_has_calls(
|
||||
expected_setup_calls, any_order=True)
|
||||
mock_neutron_quotas.reset_mock()
|
||||
|
||||
expected_cleanup_calls = []
|
||||
for tenant in ctx["tenants"]:
|
||||
expected_cleanup_calls.append(mock.call().delete(tenant))
|
||||
mock_quotas.assert_has_calls(expected_cleanup_calls, any_order=True)
|
||||
mock_neutron_quotas.assert_has_calls(
|
||||
expected_cleanup_calls, any_order=True)
|
||||
|
||||
@mock.patch("rally.plugins.openstack.context."
|
||||
"quotas.quotas.osclients.Clients")
|
||||
@ -249,8 +255,8 @@ class QuotasTestCase(test.TestCase):
|
||||
"quotas.cinder_quotas.CinderQuotas")
|
||||
@mock.patch("rally.plugins.openstack.context."
|
||||
"quotas.neutron_quotas.NeutronQuotas")
|
||||
def test_no_quotas(self, mock_neutron_quota, mock_cinder_quotas,
|
||||
mock_nova_quotas, mock_osclients):
|
||||
def test_no_quotas(self, mock_neutron_quotas, mock_cinder_quotas,
|
||||
mock_nova_quotas, mock_clients):
|
||||
ctx = copy.deepcopy(self.context)
|
||||
if "quotas" in ctx["config"]:
|
||||
del ctx["config"]["quotas"]
|
||||
@ -259,11 +265,11 @@ class QuotasTestCase(test.TestCase):
|
||||
quotas_ctx.setup()
|
||||
self.assertFalse(mock_cinder_quotas.update.called)
|
||||
self.assertFalse(mock_nova_quotas.update.called)
|
||||
self.assertFalse(mock_neutron_quota.update.called)
|
||||
self.assertFalse(mock_neutron_quotas.update.called)
|
||||
|
||||
self.assertFalse(mock_cinder_quotas.delete.called)
|
||||
self.assertFalse(mock_nova_quotas.delete.called)
|
||||
self.assertFalse(mock_neutron_quota.delete.called)
|
||||
self.assertFalse(mock_neutron_quotas.delete.called)
|
||||
|
||||
@ddt.data(
|
||||
{"quotas_ctxt": {"nova": {"cpu": 1}},
|
||||
|
@ -71,8 +71,9 @@ class SaharaClusterTestCase(test.TestCase):
|
||||
@mock.patch("%s.sahara_cluster.utils.SaharaScenario._launch_cluster" % CTX,
|
||||
return_value=mock.MagicMock(id=42))
|
||||
@mock.patch("%s.sahara_cluster.osclients" % CTX)
|
||||
def test_setup_and_cleanup(self, mock_osclients,
|
||||
mock_launch, mock_cleanup):
|
||||
def test_setup_and_cleanup(
|
||||
self, mock_osclients, mock_sahara_scenario__launch_cluster,
|
||||
mock_cleanup):
|
||||
|
||||
mock_sahara = mock_osclients.Clients(mock.MagicMock()).sahara()
|
||||
|
||||
@ -104,7 +105,8 @@ class SaharaClusterTestCase(test.TestCase):
|
||||
mock.MagicMock(status="active")]
|
||||
sahara_ctx.setup()
|
||||
|
||||
mock_launch.assert_has_calls(launch_cluster_calls)
|
||||
mock_sahara_scenario__launch_cluster.assert_has_calls(
|
||||
launch_cluster_calls)
|
||||
sahara_ctx.cleanup()
|
||||
mock_cleanup.assert_called_once_with(names=["sahara.clusters"],
|
||||
users=ctx["users"])
|
||||
@ -112,7 +114,8 @@ class SaharaClusterTestCase(test.TestCase):
|
||||
@mock.patch("%s.sahara_cluster.utils.SaharaScenario._launch_cluster" % CTX,
|
||||
return_value=mock.MagicMock(id=42))
|
||||
@mock.patch("%s.sahara_cluster.osclients" % CTX)
|
||||
def test_setup_and_cleanup_error(self, mock_osclients, mock_launch):
|
||||
def test_setup_and_cleanup_error(
|
||||
self, mock_osclients, mock_sahara_scenario__launch_cluster):
|
||||
|
||||
mock_sahara = mock_osclients.Clients(mock.MagicMock()).sahara()
|
||||
|
||||
|
@ -89,8 +89,9 @@ class SaharaImageTestCase(test.TestCase):
|
||||
return_value=mock.MagicMock(id=42))
|
||||
@mock.patch("%s.osclients" % CTX)
|
||||
@mock.patch("%s.resource_manager.cleanup" % CTX)
|
||||
def test_setup_and_cleanup_url_image(self, mock_cleanup, mock_osclients,
|
||||
mock_image_generator, mock_uuid):
|
||||
def test_setup_and_cleanup_url_image(
|
||||
self, mock_cleanup, mock_osclients,
|
||||
mock_glance_scenario__create_image, mock_generate_random_name):
|
||||
|
||||
ctx = self.url_image_context
|
||||
sahara_ctx = sahara_image.SaharaImage(ctx)
|
||||
@ -115,7 +116,7 @@ class SaharaImageTestCase(test.TestCase):
|
||||
new_tags=["test_plugin", "test_version"]))
|
||||
|
||||
sahara_ctx.setup()
|
||||
mock_image_generator.assert_has_calls(glance_calls)
|
||||
mock_glance_scenario__create_image.assert_has_calls(glance_calls)
|
||||
mock_osclients.Clients(
|
||||
mock.MagicMock()).sahara().images.update_image.assert_has_calls(
|
||||
sahara_update_image_calls)
|
||||
@ -131,11 +132,11 @@ class SaharaImageTestCase(test.TestCase):
|
||||
return_value=mock.MagicMock(id=42))
|
||||
@mock.patch("%s.resource_manager.cleanup" % CTX)
|
||||
@mock.patch("%s.osclients" % CTX)
|
||||
def test_setup_and_cleanup_existing_image(self, mock_os_clients,
|
||||
mock_cleanup,
|
||||
mock_image_generator):
|
||||
def test_setup_and_cleanup_existing_image(
|
||||
self, mock_osclients, mock_cleanup,
|
||||
mock_glance_scenario__create_image):
|
||||
|
||||
clients = mock_os_clients.Clients(mock.MagicMock())
|
||||
clients = mock_osclients.Clients(mock.MagicMock())
|
||||
clients.glance().images.get.return_value = mock.MagicMock(
|
||||
is_public=True)
|
||||
|
||||
@ -147,24 +148,24 @@ class SaharaImageTestCase(test.TestCase):
|
||||
image_id = sahara_ctx.context["tenants"][tenant_id]["sahara_image"]
|
||||
self.assertEqual("some_id", image_id)
|
||||
|
||||
self.assertEqual(False, mock_image_generator.called)
|
||||
self.assertEqual(False, mock_glance_scenario__create_image.called)
|
||||
|
||||
sahara_ctx.cleanup()
|
||||
self.assertEqual(False, mock_cleanup.called)
|
||||
|
||||
@mock.patch("%s.osclients" % CTX)
|
||||
def test_check_existing_image(self, mock_os_clients):
|
||||
def test_check_existing_image(self, mock_osclients):
|
||||
|
||||
ctx = self.existing_image_context
|
||||
sahara_ctx = sahara_image.SaharaImage(ctx)
|
||||
sahara_ctx.setup()
|
||||
|
||||
mock_os_clients.glance().images.get.asser_called_once_with("some_id")
|
||||
mock_osclients.glance().images.get.asser_called_once_with("some_id")
|
||||
|
||||
@mock.patch("%s.osclients" % CTX)
|
||||
def test_check_existing_image_fail(self, mock_os_clients):
|
||||
def test_check_existing_image_fail(self, mock_osclients):
|
||||
|
||||
clients = mock_os_clients.Clients(mock.MagicMock())
|
||||
clients = mock_osclients.Clients(mock.MagicMock())
|
||||
clients.glance().images.get.return_value = mock.MagicMock(
|
||||
is_public=False)
|
||||
|
||||
|
@ -68,16 +68,16 @@ class BaseCustomImageContextVMTestCase(test.TestCase):
|
||||
return_value="image")
|
||||
@mock.patch("%s.types.FlavorResourceType.transform" % BASE,
|
||||
return_value="flavor")
|
||||
def test_create_one_image(self, mock_flavor_transform,
|
||||
mock_image_transform, mock_osclients,
|
||||
mock_vmtasks):
|
||||
def test_create_one_image(
|
||||
self, mock_flavor_resource_type_transform,
|
||||
mock_image_resource_type_transform, mock_clients, mock_vm_tasks):
|
||||
ip = {"ip": "foo_ip", "id": "foo_id", "is_floating": True}
|
||||
fake_server = mock.Mock()
|
||||
|
||||
fake_image = mock.MagicMock(
|
||||
to_dict=mock.MagicMock(return_value={"id": "image"}))
|
||||
|
||||
mock_vm_scenario = mock_vmtasks.return_value = mock.MagicMock(
|
||||
mock_vm_scenario = mock_vm_tasks.return_value = mock.MagicMock(
|
||||
_create_image=mock.MagicMock(return_value=fake_image),
|
||||
_boot_server_with_fip=mock.MagicMock(
|
||||
return_value=(fake_server, ip)),
|
||||
@ -96,14 +96,14 @@ class BaseCustomImageContextVMTestCase(test.TestCase):
|
||||
custom_image = generator_ctx.create_one_image(user,
|
||||
foo_arg="foo_value")
|
||||
|
||||
mock_flavor_transform.assert_called_once_with(
|
||||
clients=mock_osclients.return_value,
|
||||
mock_flavor_resource_type_transform.assert_called_once_with(
|
||||
clients=mock_clients.return_value,
|
||||
resource_config={"name": "flavor"})
|
||||
mock_image_transform.assert_called_once_with(
|
||||
clients=mock_osclients.return_value,
|
||||
mock_image_resource_type_transform.assert_called_once_with(
|
||||
clients=mock_clients.return_value,
|
||||
resource_config={"name": "image"})
|
||||
mock_vmtasks.assert_called_once_with(
|
||||
self.context, clients=mock_osclients.return_value)
|
||||
mock_vm_tasks.assert_called_once_with(
|
||||
self.context, clients=mock_clients.return_value)
|
||||
|
||||
mock_vm_scenario._boot_server_with_fip.assert_called_once_with(
|
||||
image="image", flavor="flavor",
|
||||
@ -124,16 +124,16 @@ class BaseCustomImageContextVMTestCase(test.TestCase):
|
||||
self.assertEqual({"id": "image"}, custom_image)
|
||||
|
||||
@mock.patch("%s.osclients.Clients" % BASE)
|
||||
def test_make_image_public(self, mock_osclients):
|
||||
def test_make_image_public(self, mock_clients):
|
||||
fc = mock.MagicMock()
|
||||
mock_osclients.return_value = fc
|
||||
mock_clients.return_value = fc
|
||||
|
||||
generator_ctx = TestImageGenerator(self.context)
|
||||
custom_image = {"id": "image"}
|
||||
|
||||
generator_ctx.make_image_public(custom_image=custom_image)
|
||||
|
||||
mock_osclients.assert_called_once_with(
|
||||
mock_clients.assert_called_once_with(
|
||||
self.context["admin"]["endpoint"])
|
||||
|
||||
fc.glance.assert_called_once_with()
|
||||
@ -143,7 +143,7 @@ class BaseCustomImageContextVMTestCase(test.TestCase):
|
||||
|
||||
@mock.patch("%s.nova_utils.NovaScenario" % BASE)
|
||||
@mock.patch("%s.osclients.Clients" % BASE)
|
||||
def test_delete_one_image(self, mock_osclients, mock_nova_scenario):
|
||||
def test_delete_one_image(self, mock_clients, mock_nova_scenario):
|
||||
nova_scenario = mock_nova_scenario.return_value = mock.MagicMock()
|
||||
nova_client = nova_scenario.clients.return_value
|
||||
nova_client.images.get.return_value = "image_obj"
|
||||
@ -156,7 +156,7 @@ class BaseCustomImageContextVMTestCase(test.TestCase):
|
||||
generator_ctx.delete_one_image(user, custom_image)
|
||||
|
||||
mock_nova_scenario.assert_called_once_with(
|
||||
context=self.context, clients=mock_osclients.return_value)
|
||||
context=self.context, clients=mock_clients.return_value)
|
||||
|
||||
nova_scenario.clients.assert_called_once_with("nova")
|
||||
nova_client.images.get.assert_called_once_with("image")
|
||||
|
@ -27,119 +27,131 @@ class DesignateBasicTestCase(test.TestCase):
|
||||
|
||||
@mock.patch(DESIGNATE_BASIC + "._list_domains")
|
||||
@mock.patch(DESIGNATE_BASIC + "._create_domain")
|
||||
def test_create_and_list_domains(self, mock_create, mock_list):
|
||||
def test_create_and_list_domains(self, mock_designate_basic__create_domain,
|
||||
mock_designate_basic__list_domains):
|
||||
scenario = basic.DesignateBasic()
|
||||
|
||||
# Default options
|
||||
scenario.create_and_list_domains()
|
||||
mock_create.assert_called_once_with()
|
||||
mock_list.assert_called_once_with()
|
||||
mock_designate_basic__create_domain.assert_called_once_with()
|
||||
mock_designate_basic__list_domains.assert_called_once_with()
|
||||
|
||||
@mock.patch(DESIGNATE_BASIC + "._delete_domain")
|
||||
@mock.patch(DESIGNATE_BASIC + "._create_domain")
|
||||
def test_create_and_delete_domain(self, mock_create, mock_delete):
|
||||
def test_create_and_delete_domain(
|
||||
self, mock_designate_basic__create_domain,
|
||||
mock_designate_basic__delete_domain):
|
||||
|
||||
scenario = basic.DesignateBasic()
|
||||
|
||||
mock_create.return_value = {"id": "123"}
|
||||
mock_designate_basic__create_domain.return_value = {"id": "123"}
|
||||
|
||||
# Default options
|
||||
scenario.create_and_delete_domain()
|
||||
|
||||
mock_create.assert_called_once_with()
|
||||
mock_delete.assert_called_once_with("123")
|
||||
mock_designate_basic__create_domain.assert_called_once_with()
|
||||
mock_designate_basic__delete_domain.assert_called_once_with("123")
|
||||
|
||||
@mock.patch(DESIGNATE_BASIC + "._list_domains")
|
||||
def test_list_domains(self, mock_list):
|
||||
def test_list_domains(self, mock_designate_basic__list_domains):
|
||||
scenario = basic.DesignateBasic()
|
||||
|
||||
# Default options
|
||||
scenario.list_domains()
|
||||
mock_list.assert_called_once_with()
|
||||
mock_designate_basic__list_domains.assert_called_once_with()
|
||||
|
||||
@mock.patch(DESIGNATE_BASIC + "._list_records")
|
||||
@mock.patch(DESIGNATE_BASIC + "._create_record")
|
||||
@mock.patch(DESIGNATE_BASIC + "._create_domain")
|
||||
def test_create_and_list_records(self,
|
||||
mock_create_domain,
|
||||
mock_create_record,
|
||||
mock_list):
|
||||
def test_create_and_list_records(
|
||||
self, mock_designate_basic__create_domain,
|
||||
mock_designate_basic__create_record,
|
||||
mock_designate_basic__list_records):
|
||||
scenario = basic.DesignateBasic()
|
||||
domain = {
|
||||
"name": "zone.name",
|
||||
"email": "email@zone.name",
|
||||
"id": "123"}
|
||||
mock_create_domain.return_value = domain
|
||||
mock_designate_basic__create_domain.return_value = domain
|
||||
records_per_domain = 5
|
||||
|
||||
scenario.create_and_list_records(
|
||||
records_per_domain=records_per_domain)
|
||||
mock_create_domain.assert_called_once_with()
|
||||
self.assertEqual(mock_create_record.mock_calls,
|
||||
[mock.call(domain, atomic_action=False)]
|
||||
* records_per_domain)
|
||||
mock_list.assert_called_once_with(domain["id"])
|
||||
mock_designate_basic__create_domain.assert_called_once_with()
|
||||
self.assertEqual(
|
||||
mock_designate_basic__create_record.mock_calls,
|
||||
[mock.call(domain, atomic_action=False)]
|
||||
* records_per_domain)
|
||||
mock_designate_basic__list_records.assert_called_once_with(
|
||||
domain["id"])
|
||||
|
||||
@mock.patch(DESIGNATE_BASIC + "._delete_record")
|
||||
@mock.patch(DESIGNATE_BASIC + "._create_record")
|
||||
@mock.patch(DESIGNATE_BASIC + "._create_domain")
|
||||
def test_create_and_delete_records(self,
|
||||
mock_create_domain,
|
||||
mock_create_record,
|
||||
mock_delete):
|
||||
def test_create_and_delete_records(
|
||||
self, mock_designate_basic__create_domain,
|
||||
mock_designate_basic__create_record,
|
||||
mock_designate_basic__delete_record):
|
||||
scenario = basic.DesignateBasic()
|
||||
domain = {
|
||||
"name": "zone.name",
|
||||
"email": "email@zone.name",
|
||||
"id": "123"}
|
||||
mock_create_domain.return_value = domain
|
||||
mock_create_record.return_value = {"id": "321"}
|
||||
mock_designate_basic__create_domain.return_value = domain
|
||||
mock_designate_basic__create_record.return_value = {"id": "321"}
|
||||
records_per_domain = 5
|
||||
|
||||
scenario.create_and_delete_records(
|
||||
records_per_domain=records_per_domain)
|
||||
mock_create_domain.assert_called_once_with()
|
||||
self.assertEqual(mock_create_record.mock_calls,
|
||||
[mock.call(domain, atomic_action=False)]
|
||||
* records_per_domain)
|
||||
self.assertEqual(mock_delete.mock_calls,
|
||||
[mock.call(domain["id"], "321", atomic_action=False)]
|
||||
* records_per_domain)
|
||||
mock_designate_basic__create_domain.assert_called_once_with()
|
||||
self.assertEqual(
|
||||
mock_designate_basic__create_record.mock_calls,
|
||||
[mock.call(domain, atomic_action=False)]
|
||||
* records_per_domain)
|
||||
self.assertEqual(
|
||||
mock_designate_basic__delete_record.mock_calls,
|
||||
[mock.call(domain["id"], "321", atomic_action=False)]
|
||||
* records_per_domain)
|
||||
|
||||
@mock.patch(DESIGNATE_BASIC + "._list_records")
|
||||
def test_list_records(self, mock_list):
|
||||
def test_list_records(self, mock_designate_basic__list_records):
|
||||
scenario = basic.DesignateBasic()
|
||||
|
||||
# Default options
|
||||
scenario.list_records("123")
|
||||
mock_list.assert_called_once_with("123")
|
||||
mock_designate_basic__list_records.assert_called_once_with("123")
|
||||
|
||||
@mock.patch(DESIGNATE_BASIC + "._list_servers")
|
||||
@mock.patch(DESIGNATE_BASIC + "._create_server")
|
||||
def test_create_and_list_servers(self, mock_create, mock_list):
|
||||
def test_create_and_list_servers(
|
||||
self, mock_designate_basic__create_server,
|
||||
mock_designate_basic__list_servers):
|
||||
scenario = basic.DesignateBasic()
|
||||
|
||||
# Default options
|
||||
scenario.create_and_list_servers()
|
||||
mock_create.assert_called_once_with()
|
||||
mock_list.assert_called_once_with()
|
||||
mock_designate_basic__create_server.assert_called_once_with()
|
||||
mock_designate_basic__list_servers.assert_called_once_with()
|
||||
|
||||
@mock.patch(DESIGNATE_BASIC + "._delete_server")
|
||||
@mock.patch(DESIGNATE_BASIC + "._create_server")
|
||||
def test_create_and_delete_server(self, mock_create, mock_delete):
|
||||
def test_create_and_delete_server(
|
||||
self, mock_designate_basic__create_server,
|
||||
mock_designate_basic__delete_server):
|
||||
scenario = basic.DesignateBasic()
|
||||
|
||||
mock_create.return_value = {"id": "123"}
|
||||
mock_designate_basic__create_server.return_value = {"id": "123"}
|
||||
|
||||
# Default options
|
||||
scenario.create_and_delete_server()
|
||||
|
||||
mock_create.assert_called_once_with()
|
||||
mock_delete.assert_called_once_with("123")
|
||||
mock_designate_basic__create_server.assert_called_once_with()
|
||||
mock_designate_basic__delete_server.assert_called_once_with("123")
|
||||
|
||||
@mock.patch(DESIGNATE_BASIC + "._list_servers")
|
||||
def test_list_servers(self, mock_list):
|
||||
def test_list_servers(self, mock_designate_basic__list_servers):
|
||||
scenario = basic.DesignateBasic()
|
||||
|
||||
# Default options
|
||||
scenario.list_servers()
|
||||
mock_list.assert_called_once_with()
|
||||
mock_designate_basic__list_servers.assert_called_once_with()
|
||||
|
@ -29,15 +29,15 @@ class DesignateScenarioTestCase(test.ClientsTestCase):
|
||||
self.domain = mock.Mock()
|
||||
self.server = mock.Mock()
|
||||
|
||||
@mock.patch(DESIGNATE_UTILS + "DesignateScenario._generate_random_name")
|
||||
def test_create_domain(self, mock_random_name):
|
||||
@mock.patch("rally.common.utils.generate_random_name")
|
||||
def test_create_domain(self, mock_generate_random_name):
|
||||
scenario = utils.DesignateScenario()
|
||||
|
||||
random_name = "foo"
|
||||
explicit_name = "bar.io."
|
||||
email = "root@zone.name"
|
||||
|
||||
mock_random_name.return_value = random_name
|
||||
mock_generate_random_name.return_value = random_name
|
||||
self.clients("designate").domains.create.return_value = self.domain
|
||||
|
||||
# Check that the defaults / randoms are used if nothing is specified
|
||||
@ -72,15 +72,15 @@ class DesignateScenarioTestCase(test.ClientsTestCase):
|
||||
self._test_atomic_action_timer(scenario.atomic_actions(),
|
||||
"designate.delete_domain")
|
||||
|
||||
@mock.patch(DESIGNATE_UTILS + "DesignateScenario._generate_random_name")
|
||||
def test_create_record(self, mock_random_name):
|
||||
@mock.patch("rally.common.utils.generate_random_name")
|
||||
def test_create_record(self, mock_generate_random_name):
|
||||
scenario = utils.DesignateScenario()
|
||||
|
||||
random_name = "foo"
|
||||
domain_name = "zone.name."
|
||||
random_record_name = "%s.%s" % (random_name, domain_name)
|
||||
|
||||
mock_random_name.return_value = random_name
|
||||
mock_generate_random_name.return_value = random_name
|
||||
|
||||
domain = {"name": domain_name, "id": "123"}
|
||||
|
||||
@ -125,14 +125,14 @@ class DesignateScenarioTestCase(test.ClientsTestCase):
|
||||
self.clients("designate").records.delete.assert_called_once_with(
|
||||
domain_id, record_id)
|
||||
|
||||
@mock.patch(DESIGNATE_UTILS + "DesignateScenario._generate_random_name")
|
||||
def test_create_server(self, mock_random_name):
|
||||
@mock.patch("rally.common.utils.generate_random_name")
|
||||
def test_create_server(self, mock_generate_random_name):
|
||||
scenario = utils.DesignateScenario()
|
||||
|
||||
random_name = "foo"
|
||||
explicit_name = "bar.io."
|
||||
|
||||
mock_random_name.return_value = random_name
|
||||
mock_generate_random_name.return_value = random_name
|
||||
self.admin_clients(
|
||||
"designate").servers.create.return_value = self.server
|
||||
|
||||
|
@ -28,7 +28,8 @@ class EC2ServersTestCase(test.ClientsTestCase):
|
||||
@mock.patch(UTILS + "ec2_resource_is", return_value="foo_state")
|
||||
@mock.patch(UTILS + "time")
|
||||
@mock.patch(UTILS + "CONF")
|
||||
def test_boot_server(self, mock_conf, mock_time, mock_is, mock_wait):
|
||||
def test_boot_server(self, mock_conf, mock_time, mock_ec2_resource_is,
|
||||
mock_wait_for):
|
||||
mock_conf.benchmark.ec2_server_boot_prepoll_delay = "foo_delay"
|
||||
mock_conf.benchmark.ec2_server_boot_timeout = "foo_timeout"
|
||||
mock_conf.benchmark.ec2_server_boot_poll_interval = "foo_interval"
|
||||
@ -39,9 +40,9 @@ class EC2ServersTestCase(test.ClientsTestCase):
|
||||
self.clients("ec2").run_instances.return_value = mock_instances
|
||||
server = scenario._boot_server("foo_image", "foo_flavor", foo="bar")
|
||||
|
||||
mock_wait.assert_called_once_with("foo_inst", is_ready="foo_state",
|
||||
update_resource="foo_update",
|
||||
timeout="foo_timeout",
|
||||
check_interval="foo_interval")
|
||||
mock_wait_for.assert_called_once_with("foo_inst", is_ready="foo_state",
|
||||
update_resource="foo_update",
|
||||
timeout="foo_timeout",
|
||||
check_interval="foo_interval")
|
||||
mock_time.sleep.assert_called_once_with("foo_delay")
|
||||
self.assertEqual(server, "running_server")
|
||||
|
@ -27,55 +27,56 @@ class GlanceImagesTestCase(test.TestCase):
|
||||
@mock.patch(GLANCE_IMAGES + "._generate_random_name")
|
||||
@mock.patch(GLANCE_IMAGES + "._list_images")
|
||||
@mock.patch(GLANCE_IMAGES + "._create_image")
|
||||
def test_create_and_list_image(self, mock_create, mock_list,
|
||||
mock_random_name):
|
||||
def test_create_and_list_image(self, mock__create_image,
|
||||
mock__list_images,
|
||||
mock__generate_random_name):
|
||||
glance_scenario = images.GlanceImages()
|
||||
mock_random_name.return_value = "test-rally-image"
|
||||
mock__generate_random_name.return_value = "test-rally-image"
|
||||
glance_scenario.create_and_list_image("cf", "url", "df",
|
||||
fakearg="f")
|
||||
mock_create.assert_called_once_with("cf", "url", "df",
|
||||
fakearg="f")
|
||||
mock_list.assert_called_once_with()
|
||||
mock__create_image.assert_called_once_with(
|
||||
"cf", "url", "df", fakearg="f")
|
||||
mock__list_images.assert_called_once_with()
|
||||
|
||||
@mock.patch(GLANCE_IMAGES + "._list_images")
|
||||
def test_list_images(self, mock_list):
|
||||
def test_list_images(self, mock__list_images):
|
||||
glance_scenario = images.GlanceImages()
|
||||
glance_scenario.list_images()
|
||||
mock_list.assert_called_once_with()
|
||||
mock__list_images.assert_called_once_with()
|
||||
|
||||
@mock.patch(GLANCE_IMAGES + "._generate_random_name")
|
||||
@mock.patch(GLANCE_IMAGES + "._delete_image")
|
||||
@mock.patch(GLANCE_IMAGES + "._create_image")
|
||||
def test_create_and_delete_image(self, mock_create, mock_delete,
|
||||
mock_random_name):
|
||||
def test_create_and_delete_image(
|
||||
self, mock__create_image, mock__delete_image,
|
||||
mock__generate_random_name):
|
||||
glance_scenario = images.GlanceImages()
|
||||
fake_image = object()
|
||||
mock_create.return_value = fake_image
|
||||
mock_random_name.return_value = "test-rally-image"
|
||||
mock__create_image.return_value = fake_image
|
||||
mock__generate_random_name.return_value = "test-rally-image"
|
||||
glance_scenario.create_and_delete_image("cf", "url", "df",
|
||||
fakearg="f")
|
||||
|
||||
mock_create.assert_called_once_with("cf",
|
||||
"url", "df", fakearg="f")
|
||||
mock_delete.assert_called_once_with(fake_image)
|
||||
mock__create_image.assert_called_once_with(
|
||||
"cf", "url", "df", fakearg="f")
|
||||
mock__delete_image.assert_called_once_with(fake_image)
|
||||
|
||||
@mock.patch(GLANCE_IMAGES + "._boot_servers")
|
||||
@mock.patch(GLANCE_IMAGES + "._create_image")
|
||||
def test_create_image_and_boot_instances(self,
|
||||
mock_create_image,
|
||||
mock_boot_servers):
|
||||
def test_create_image_and_boot_instances(
|
||||
self, mock__create_image, mock__boot_servers):
|
||||
glance_scenario = images.GlanceImages()
|
||||
fake_image = fakes.FakeImage()
|
||||
fake_servers = [mock.Mock() for i in range(5)]
|
||||
mock_create_image.return_value = fake_image
|
||||
mock_boot_servers.return_value = fake_servers
|
||||
mock__create_image.return_value = fake_image
|
||||
mock__boot_servers.return_value = fake_servers
|
||||
kwargs = {"fakearg": "f"}
|
||||
with mock.patch("rally.plugins.openstack.scenarios."
|
||||
"glance.utils.time.sleep"):
|
||||
glance_scenario.create_image_and_boot_instances("cf", "url",
|
||||
"df", "fid",
|
||||
5, **kwargs)
|
||||
mock_create_image.assert_called_once_with("cf",
|
||||
"url", "df")
|
||||
mock_boot_servers.assert_called_once_with("image-id-0",
|
||||
"fid", 5, **kwargs)
|
||||
mock__create_image.assert_called_once_with(
|
||||
"cf", "url", "df")
|
||||
mock__boot_servers.assert_called_once_with(
|
||||
"image-id-0", "fid", 5, **kwargs)
|
||||
|
@ -33,26 +33,25 @@ class HeatStacksTestCase(test.ClientsTestCase):
|
||||
@mock.patch(HEAT_STACKS + "._generate_random_name")
|
||||
@mock.patch(HEAT_STACKS + "._list_stacks")
|
||||
@mock.patch(HEAT_STACKS + "._create_stack")
|
||||
def test_create_and_list_stack(self, mock_create, mock_list,
|
||||
mock_random_name):
|
||||
def test_create_and_list_stack(self, mock__create_stack, mock__list_stacks,
|
||||
mock__generate_random_name):
|
||||
heat_scenario = stacks.HeatStacks()
|
||||
mock_random_name.return_value = "test-rally-stack"
|
||||
mock__generate_random_name.return_value = "test-rally-stack"
|
||||
heat_scenario.create_and_list_stack(
|
||||
template_path=self.default_template,
|
||||
parameters=self.default_parameters,
|
||||
files=self.default_files,
|
||||
environment=self.default_environment
|
||||
)
|
||||
mock_create.assert_called_once_with(self.default_template,
|
||||
self.default_parameters,
|
||||
self.default_files,
|
||||
self.default_environment)
|
||||
mock_list.assert_called_once_with()
|
||||
mock__create_stack.assert_called_once_with(
|
||||
self.default_template, self.default_parameters, self.default_files,
|
||||
self.default_environment)
|
||||
mock__list_stacks.assert_called_once_with()
|
||||
|
||||
@mock.patch(HEAT_STACKS + "._list_stacks")
|
||||
def test_list_stack_and_resources(self, mock_list_stack):
|
||||
def test_list_stack_and_resources(self, mock__list_stacks):
|
||||
stack = mock.Mock()
|
||||
mock_list_stack.return_value = [stack]
|
||||
mock__list_stacks.return_value = [stack]
|
||||
heat_scenario = stacks.HeatStacks()
|
||||
heat_scenario.list_stacks_and_resources()
|
||||
self.clients("heat").resources.list.assert_called_once_with(stack.id)
|
||||
@ -60,9 +59,9 @@ class HeatStacksTestCase(test.ClientsTestCase):
|
||||
heat_scenario.atomic_actions(), "heat.list_resources_of_1_stacks")
|
||||
|
||||
@mock.patch(HEAT_STACKS + "._list_stacks")
|
||||
def test_list_stack_and_events(self, mock_list_stack):
|
||||
def test_list_stack_and_events(self, mock__list_stacks):
|
||||
stack = mock.Mock()
|
||||
mock_list_stack.return_value = [stack]
|
||||
mock__list_stacks.return_value = [stack]
|
||||
heat_scenario = stacks.HeatStacks()
|
||||
heat_scenario.list_stacks_and_events()
|
||||
self.clients("heat").events.list.assert_called_once_with(stack.id)
|
||||
@ -72,12 +71,13 @@ class HeatStacksTestCase(test.ClientsTestCase):
|
||||
@mock.patch(HEAT_STACKS + "._generate_random_name")
|
||||
@mock.patch(HEAT_STACKS + "._delete_stack")
|
||||
@mock.patch(HEAT_STACKS + "._create_stack")
|
||||
def test_create_and_delete_stack(self, mock_create, mock_delete,
|
||||
mock_random_name):
|
||||
def test_create_and_delete_stack(
|
||||
self, mock__create_stack, mock__delete_stack,
|
||||
mock__generate_random_name):
|
||||
heat_scenario = stacks.HeatStacks()
|
||||
fake_stack = object()
|
||||
mock_create.return_value = fake_stack
|
||||
mock_random_name.return_value = "test-rally-stack"
|
||||
mock__create_stack.return_value = fake_stack
|
||||
mock__generate_random_name.return_value = "test-rally-stack"
|
||||
heat_scenario.create_and_delete_stack(
|
||||
template_path=self.default_template,
|
||||
parameters=self.default_parameters,
|
||||
@ -85,42 +85,44 @@ class HeatStacksTestCase(test.ClientsTestCase):
|
||||
environment=self.default_environment
|
||||
)
|
||||
|
||||
mock_create.assert_called_once_with(self.default_template,
|
||||
self.default_parameters,
|
||||
self.default_files,
|
||||
self.default_environment)
|
||||
mock_delete.assert_called_once_with(fake_stack)
|
||||
mock__create_stack.assert_called_once_with(
|
||||
self.default_template,
|
||||
self.default_parameters,
|
||||
self.default_files,
|
||||
self.default_environment)
|
||||
mock__delete_stack.assert_called_once_with(fake_stack)
|
||||
|
||||
@mock.patch(HEAT_STACKS + "._delete_stack")
|
||||
@mock.patch(HEAT_STACKS + "._check_stack")
|
||||
@mock.patch(HEAT_STACKS + "._create_stack")
|
||||
def test_create_check_delete_stack(self, mock_create, mock_check,
|
||||
mock_delete):
|
||||
def test_create_check_delete_stack(
|
||||
self, mock__create_stack, mock__check_stack, mock__delete_stack):
|
||||
heat_scenario = stacks.HeatStacks()
|
||||
mock_create.return_value = "fake_stack_create_check_delete"
|
||||
heat_scenario.create_check_delete_stack(
|
||||
template_path=self.default_template,
|
||||
parameters=self.default_parameters,
|
||||
files=self.default_files,
|
||||
environment=self.default_environment
|
||||
)
|
||||
mock_create.assert_called_once_with(self.default_template,
|
||||
self.default_parameters,
|
||||
self.default_files,
|
||||
self.default_environment)
|
||||
mock_check.assert_called_once_with("fake_stack_create_check_delete")
|
||||
mock_delete.assert_called_once_with("fake_stack_create_check_delete")
|
||||
mock__create_stack.assert_called_once_with(
|
||||
self.default_template, self.default_parameters, self.default_files,
|
||||
self.default_environment)
|
||||
mock__check_stack.assert_called_once_with(
|
||||
mock__create_stack.return_value)
|
||||
mock__delete_stack.assert_called_once_with(
|
||||
mock__create_stack.return_value)
|
||||
|
||||
@mock.patch(HEAT_STACKS + "._generate_random_name")
|
||||
@mock.patch(HEAT_STACKS + "._delete_stack")
|
||||
@mock.patch(HEAT_STACKS + "._update_stack")
|
||||
@mock.patch(HEAT_STACKS + "._create_stack")
|
||||
def test_create_update_delete_stack(self, mock_create, mock_update,
|
||||
mock_delete, mock_random_name):
|
||||
def test_create_update_delete_stack(
|
||||
self, mock__create_stack, mock__update_stack, mock__delete_stack,
|
||||
mock__generate_random_name):
|
||||
heat_scenario = stacks.HeatStacks()
|
||||
fake_stack = object()
|
||||
mock_create.return_value = fake_stack
|
||||
mock_random_name.return_value = "test-rally-stack"
|
||||
mock__create_stack.return_value = fake_stack
|
||||
mock__generate_random_name.return_value = "test-rally-stack"
|
||||
heat_scenario.create_update_delete_stack(
|
||||
template_path=self.default_template,
|
||||
parameters=self.default_parameters,
|
||||
@ -129,27 +131,26 @@ class HeatStacksTestCase(test.ClientsTestCase):
|
||||
environment=self.default_environment
|
||||
)
|
||||
|
||||
mock_create.assert_called_once_with(self.default_template,
|
||||
self.default_parameters,
|
||||
self.default_files,
|
||||
self.default_environment)
|
||||
mock_update.assert_called_once_with(fake_stack, self.default_template,
|
||||
self.default_parameters,
|
||||
self.default_files,
|
||||
self.default_environment)
|
||||
mock_delete.assert_called_once_with(fake_stack)
|
||||
mock__create_stack.assert_called_once_with(
|
||||
self.default_template,
|
||||
self.default_parameters,
|
||||
self.default_files,
|
||||
self.default_environment)
|
||||
mock__update_stack.assert_called_once_with(
|
||||
fake_stack, self.default_template,
|
||||
self.default_parameters,
|
||||
self.default_files,
|
||||
self.default_environment)
|
||||
mock__delete_stack.assert_called_once_with(fake_stack)
|
||||
|
||||
@mock.patch(HEAT_STACKS + "._delete_stack")
|
||||
@mock.patch(HEAT_STACKS + "._resume_stack")
|
||||
@mock.patch(HEAT_STACKS + "._suspend_stack")
|
||||
@mock.patch(HEAT_STACKS + "._create_stack")
|
||||
def test_create_suspend_resume_delete_stack(self,
|
||||
mock_create,
|
||||
mock_suspend,
|
||||
mock_resume,
|
||||
mock_delete):
|
||||
def test_create_suspend_resume_delete_stack(
|
||||
self, mock__create_stack, mock__suspend_stack, mock__resume_stack,
|
||||
mock__delete_stack):
|
||||
heat_scenario = stacks.HeatStacks()
|
||||
mock_create.return_value = "fake_stack_create_suspend_resume_delete"
|
||||
heat_scenario.create_suspend_resume_delete_stack(
|
||||
template_path=self.default_template,
|
||||
parameters=self.default_parameters,
|
||||
@ -157,13 +158,16 @@ class HeatStacksTestCase(test.ClientsTestCase):
|
||||
environment=self.default_environment
|
||||
)
|
||||
|
||||
mock_create.assert_called_once_with(self.default_template,
|
||||
self.default_parameters,
|
||||
self.default_files,
|
||||
self.default_environment)
|
||||
mock_suspend.assert_called_once_with(
|
||||
"fake_stack_create_suspend_resume_delete")
|
||||
mock_resume.assert_called_once_with(
|
||||
"fake_stack_create_suspend_resume_delete")
|
||||
mock_delete.assert_called_once_with(
|
||||
"fake_stack_create_suspend_resume_delete")
|
||||
mock__create_stack.assert_called_once_with(
|
||||
self.default_template,
|
||||
self.default_parameters,
|
||||
self.default_files,
|
||||
self.default_environment
|
||||
)
|
||||
mock__suspend_stack.assert_called_once_with(
|
||||
mock__create_stack.return_value)
|
||||
mock__resume_stack.assert_called_once_with(
|
||||
mock__create_stack.return_value)
|
||||
mock__delete_stack.assert_called_once_with(
|
||||
mock__create_stack.return_value
|
||||
)
|
||||
|
@ -31,24 +31,22 @@ class KeystoneBasicTestCase(test.TestCase):
|
||||
"tenant": {"id": "fake"}
|
||||
}
|
||||
|
||||
@mock.patch(BASIC + "_generate_random_name")
|
||||
def test_create_user(self, mock_gen_name):
|
||||
@mock.patch("rally.common.utils.generate_random_name")
|
||||
def test_create_user(self, mock_generate_random_name):
|
||||
scenario = basic.KeystoneBasic()
|
||||
mock_gen_name.return_value = "teeeest"
|
||||
scenario._user_create = mock.MagicMock()
|
||||
scenario.create_user(name_length=20, password="tttt", tenant_id="id")
|
||||
scenario._user_create.assert_called_once_with(name_length=20,
|
||||
password="tttt",
|
||||
tenant_id="id")
|
||||
|
||||
@mock.patch(BASIC + "_generate_random_name")
|
||||
def test_create_delete_user(self, mock_gen_name):
|
||||
@mock.patch("rally.common.utils.generate_random_name")
|
||||
def test_create_delete_user(self, mock_generate_random_name):
|
||||
create_result = mock.MagicMock()
|
||||
|
||||
scenario = basic.KeystoneBasic()
|
||||
scenario._user_create = mock.MagicMock(return_value=create_result)
|
||||
scenario._resource_delete = mock.MagicMock()
|
||||
mock_gen_name.return_value = "teeeest"
|
||||
|
||||
scenario.create_delete_user(name_length=30, email="abcd", enabled=True)
|
||||
|
||||
@ -57,19 +55,17 @@ class KeystoneBasicTestCase(test.TestCase):
|
||||
enabled=True)
|
||||
scenario._resource_delete.assert_called_once_with(create_result)
|
||||
|
||||
@mock.patch(BASIC + "_generate_random_name")
|
||||
def test_create_tenant(self, mock_gen_name):
|
||||
@mock.patch("rally.common.utils.generate_random_name")
|
||||
def test_create_tenant(self, mock_generate_random_name):
|
||||
scenario = basic.KeystoneBasic()
|
||||
mock_gen_name.return_value = "teeeest"
|
||||
scenario._tenant_create = mock.MagicMock()
|
||||
scenario.create_tenant(name_length=20, enabled=True)
|
||||
scenario._tenant_create.assert_called_once_with(name_length=20,
|
||||
enabled=True)
|
||||
|
||||
@mock.patch(BASIC + "_generate_random_name")
|
||||
def test_create_tenant_with_users(self, mock_gen_name):
|
||||
@mock.patch("rally.common.utils.generate_random_name")
|
||||
def test_create_tenant_with_users(self, mock_generate_random_name):
|
||||
scenario = basic.KeystoneBasic()
|
||||
mock_gen_name.return_value = "teeeest"
|
||||
fake_tenant = mock.MagicMock()
|
||||
scenario._tenant_create = mock.MagicMock(return_value=fake_tenant)
|
||||
scenario._users_create = mock.MagicMock()
|
||||
@ -81,10 +77,9 @@ class KeystoneBasicTestCase(test.TestCase):
|
||||
users_per_tenant=1,
|
||||
name_length=20)
|
||||
|
||||
@mock.patch(BASIC + "_generate_random_name")
|
||||
def test_create_and_list_users(self, mock_gen_name):
|
||||
@mock.patch("rally.common.utils.generate_random_name")
|
||||
def test_create_and_list_users(self, mock_generate_random_name):
|
||||
scenario = basic.KeystoneBasic()
|
||||
mock_gen_name.return_value = "teeeest"
|
||||
scenario._user_create = mock.MagicMock()
|
||||
scenario._list_users = mock.MagicMock()
|
||||
scenario.create_and_list_users(name_length=20, password="tttt",
|
||||
@ -94,10 +89,9 @@ class KeystoneBasicTestCase(test.TestCase):
|
||||
tenant_id="id")
|
||||
scenario._list_users.assert_called_once_with()
|
||||
|
||||
@mock.patch(BASIC + "_generate_random_name")
|
||||
def test_create_and_list_tenants(self, mock_gen_name):
|
||||
@mock.patch("rally.common.utils.generate_random_name")
|
||||
def test_create_and_list_tenants(self, mock_generate_random_name):
|
||||
scenario = basic.KeystoneBasic()
|
||||
mock_gen_name.return_value = "teeeest"
|
||||
scenario._tenant_create = mock.MagicMock()
|
||||
scenario._list_tenants = mock.MagicMock()
|
||||
scenario.create_and_list_tenants(name_length=20, enabled=True)
|
||||
@ -152,10 +146,9 @@ class KeystoneBasicTestCase(test.TestCase):
|
||||
scenario._list_roles_for_user.assert_called_once_with(fake_user,
|
||||
fake_tenant)
|
||||
|
||||
@mock.patch(BASIC + "_generate_random_name")
|
||||
def test_get_entities(self, mock_gen_name):
|
||||
@mock.patch("rally.common.utils.generate_random_name")
|
||||
def test_get_entities(self, mock_generate_random_name):
|
||||
scenario = basic.KeystoneBasic()
|
||||
mock_gen_name.return_value = "teeeeest"
|
||||
fake_tenant = mock.MagicMock()
|
||||
fake_user = mock.MagicMock()
|
||||
fake_role = mock.MagicMock()
|
||||
|
@ -48,31 +48,31 @@ class KeystoneUtilsTestCase(test.TestCase):
|
||||
class KeystoneScenarioTestCase(test.ClientsTestCase):
|
||||
|
||||
@mock.patch(UTILS + "uuid.uuid4", return_value="pwd")
|
||||
@mock.patch(UTILS + "KeystoneScenario._generate_random_name",
|
||||
return_value="abc")
|
||||
def test_user_create(self, mock_gen_name, mock_uuid4):
|
||||
@mock.patch("rally.common.utils.generate_random_name",
|
||||
return_value="foobarov")
|
||||
def test_user_create(self, mock_generate_random_name, mock_uuid4):
|
||||
scenario = utils.KeystoneScenario()
|
||||
result = scenario._user_create()
|
||||
|
||||
self.assertEqual(
|
||||
self.admin_clients("keystone").users.create.return_value, result)
|
||||
self.admin_clients("keystone").users.create.assert_called_once_with(
|
||||
mock_gen_name.return_value,
|
||||
"foobarov",
|
||||
password=mock_uuid4.return_value,
|
||||
email=mock_gen_name.return_value + "@rally.me")
|
||||
email="foobarov@rally.me")
|
||||
mock_uuid4.assert_called_with()
|
||||
self._test_atomic_action_timer(scenario.atomic_actions(),
|
||||
"keystone.create_user")
|
||||
|
||||
@mock.patch(UTILS + "KeystoneScenario._generate_random_name")
|
||||
def test_role_create(self, mock_gen_name):
|
||||
@mock.patch("rally.common.utils.generate_random_name")
|
||||
def test_role_create(self, mock_generate_random_name):
|
||||
scenario = utils.KeystoneScenario()
|
||||
result = scenario._role_create()
|
||||
|
||||
self.assertEqual(
|
||||
self.admin_clients("keystone").roles.create.return_value, result)
|
||||
self.admin_clients("keystone").roles.create.assert_called_once_with(
|
||||
mock_gen_name.return_value)
|
||||
mock_generate_random_name.return_value)
|
||||
self._test_atomic_action_timer(scenario.atomic_actions(),
|
||||
"keystone.create_role")
|
||||
|
||||
@ -129,21 +129,21 @@ class KeystoneScenarioTestCase(test.ClientsTestCase):
|
||||
self._test_atomic_action_timer(scenario.atomic_actions(),
|
||||
"keystone.remove_role")
|
||||
|
||||
@mock.patch(UTILS + "KeystoneScenario._generate_random_name")
|
||||
def test_tenant_create(self, mock_gen_name):
|
||||
@mock.patch("rally.common.utils.generate_random_name")
|
||||
def test_tenant_create(self, mock_generate_random_name):
|
||||
scenario = utils.KeystoneScenario()
|
||||
result = scenario._tenant_create()
|
||||
|
||||
self.assertEqual(
|
||||
self.admin_clients("keystone").tenants.create.return_value, result)
|
||||
self.admin_clients("keystone").tenants.create.assert_called_once_with(
|
||||
mock_gen_name.return_value)
|
||||
mock_generate_random_name.return_value)
|
||||
self._test_atomic_action_timer(scenario.atomic_actions(),
|
||||
"keystone.create_tenant")
|
||||
|
||||
def test_service_create(self):
|
||||
name = "abc"
|
||||
service_type = name + "service_type"
|
||||
service_type = name + "_service_type"
|
||||
description = name + "_description"
|
||||
|
||||
scenario = utils.KeystoneScenario()
|
||||
@ -160,18 +160,16 @@ class KeystoneScenarioTestCase(test.ClientsTestCase):
|
||||
self._test_atomic_action_timer(scenario.atomic_actions(),
|
||||
"keystone.create_service")
|
||||
|
||||
@mock.patch(UTILS + "KeystoneScenario._generate_random_name")
|
||||
def test_tenant_create_with_users(self, mock_gen_name):
|
||||
name = "abc"
|
||||
mock_gen_name.return_value = name
|
||||
|
||||
@mock.patch("rally.common.utils.generate_random_name",
|
||||
return_value="foobarov")
|
||||
def test_tenant_create_with_users(self, mock_generate_random_name):
|
||||
tenant = mock.MagicMock()
|
||||
scenario = utils.KeystoneScenario()
|
||||
|
||||
scenario._users_create(tenant, users_per_tenant=1, name_length=10)
|
||||
|
||||
self.admin_clients("keystone").users.create.assert_called_once_with(
|
||||
name, password=name, email=name + "@rally.me",
|
||||
"foobarov", password="foobarov", email="foobarov@rally.me",
|
||||
tenant_id=tenant.id)
|
||||
self._test_atomic_action_timer(scenario.atomic_actions(),
|
||||
"keystone.create_users")
|
||||
|
@ -25,31 +25,33 @@ MISTRAL_WBS = ("rally.plugins.openstack.scenarios."
|
||||
class MistralWorkbooksTestCase(test.TestCase):
|
||||
|
||||
@mock.patch(MISTRAL_WBS + "._list_workbooks")
|
||||
def test_list_workbooks(self, mock_list):
|
||||
def test_list_workbooks(self, mock__list_workbooks):
|
||||
mistral_scenario = workbooks.MistralWorkbooks()
|
||||
mistral_scenario.list_workbooks()
|
||||
mock_list.assert_called_once_with()
|
||||
mock__list_workbooks.assert_called_once_with()
|
||||
|
||||
@mock.patch(MISTRAL_WBS + "._create_workbook")
|
||||
def test_create_workbook(self, mock_create):
|
||||
def test_create_workbook(self, mock__create_workbook):
|
||||
mistral_scenario = workbooks.MistralWorkbooks()
|
||||
definition = "---\nversion: \"2.0\"\nname: wb"
|
||||
fake_wb = mock.MagicMock()
|
||||
fake_wb.name = "wb"
|
||||
mock_create.return_value = fake_wb
|
||||
mock__create_workbook.return_value = fake_wb
|
||||
mistral_scenario.create_workbook(definition)
|
||||
|
||||
self.assertEqual(1, mock_create.called)
|
||||
self.assertEqual(1, mock__create_workbook.called)
|
||||
|
||||
@mock.patch(MISTRAL_WBS + "._delete_workbook")
|
||||
@mock.patch(MISTRAL_WBS + "._create_workbook")
|
||||
def test_create_delete_workbook(self, mock_create, mock_delete):
|
||||
def test_create_delete_workbook(self,
|
||||
mock__create_workbook,
|
||||
mock__delete_workbook):
|
||||
mistral_scenario = workbooks.MistralWorkbooks()
|
||||
definition = "---\nversion: \"2.0\"\nname: wb"
|
||||
fake_wb = mock.MagicMock()
|
||||
fake_wb.name = "wb"
|
||||
mock_create.return_value = fake_wb
|
||||
mock__create_workbook.return_value = fake_wb
|
||||
mistral_scenario.create_workbook(definition, do_delete=True)
|
||||
|
||||
self.assertEqual(1, mock_create.called)
|
||||
mock_delete.assert_called_once_with(fake_wb.name)
|
||||
self.assertEqual(1, mock__create_workbook.called)
|
||||
mock__delete_workbook.assert_called_once_with(fake_wb.name)
|
||||
|
@ -44,40 +44,40 @@ class MuranoEnvironmentsTestCase(test.TestCase):
|
||||
}
|
||||
|
||||
@mock.patch(MURANO_SCENARIO + "._list_environments")
|
||||
def test_list_environments(self, mock_list):
|
||||
def test_list_environments(self, mock__list_environments):
|
||||
scenario = environments.MuranoEnvironments()
|
||||
scenario._list_environments()
|
||||
mock_list.assert_called_once_with()
|
||||
mock__list_environments.assert_called_once_with()
|
||||
|
||||
@mock.patch(MURANO_SCENARIO + "._create_session")
|
||||
@mock.patch(MURANO_SCENARIO + "._delete_environment")
|
||||
@mock.patch(MURANO_SCENARIO + "._create_environment")
|
||||
@mock.patch(MURANO_SCENARIO + "._generate_random_name")
|
||||
def test_create_and_delete_environment(self, mock_random_name,
|
||||
mock_create, mock_delete,
|
||||
mock_session):
|
||||
def test_create_and_delete_environment(
|
||||
self, mock__generate_random_name, mock__create_environment,
|
||||
mock__delete_environment, mock__create_session):
|
||||
scenario = environments.MuranoEnvironments()
|
||||
fake_environment = mock.Mock(id="fake_id")
|
||||
mock_create.return_value = fake_environment
|
||||
mock_random_name.return_value = "foo"
|
||||
mock__create_environment.return_value = fake_environment
|
||||
mock__generate_random_name.return_value = "foo"
|
||||
scenario.create_and_delete_environment()
|
||||
mock_create.assert_called_once_with()
|
||||
mock_session.assert_called_once_with(fake_environment.id)
|
||||
mock_delete.assert_called_once_with(fake_environment)
|
||||
mock__create_environment.assert_called_once_with()
|
||||
mock__create_session.assert_called_once_with(fake_environment.id)
|
||||
mock__delete_environment.assert_called_once_with(fake_environment)
|
||||
|
||||
@mock.patch(MURANO_SCENARIO + "._create_environment")
|
||||
@mock.patch(MURANO_SCENARIO + "._create_session")
|
||||
@mock.patch(MURANO_SCENARIO + "._create_service")
|
||||
@mock.patch(MURANO_SCENARIO + "._deploy_environment")
|
||||
def test_create_and_deploy_environment(self, mock_deploy_env,
|
||||
mock_create_service, mock_session,
|
||||
mock_environment):
|
||||
def test_create_and_deploy_environment(
|
||||
self, mock__deploy_environment, mock__create_service,
|
||||
mock__create_session, mock__create_environment):
|
||||
|
||||
fake_environment = mock.MagicMock(id="fake_env_id")
|
||||
mock_environment.return_value = fake_environment
|
||||
mock__create_environment.return_value = fake_environment
|
||||
|
||||
fake_session = mock.Mock(id="fake_session_id")
|
||||
mock_session.return_value = fake_session
|
||||
mock__create_session.return_value = fake_session
|
||||
|
||||
scenario = environments.MuranoEnvironments()
|
||||
scenario.context = self._get_context()
|
||||
@ -89,9 +89,9 @@ class MuranoEnvironmentsTestCase(test.TestCase):
|
||||
|
||||
scenario.create_and_deploy_environment(1)
|
||||
|
||||
mock_environment.assert_called_once_with()
|
||||
mock_session.assert_called_once_with(fake_environment.id)
|
||||
mock_create_service.assert_called_once_with(
|
||||
mock__create_environment.assert_called_once_with()
|
||||
mock__create_session.assert_called_once_with(fake_environment.id)
|
||||
mock__create_service.assert_called_once_with(
|
||||
fake_environment, fake_session, "fake", atomic_action=False)
|
||||
mock_deploy_env.assert_called_once_with(fake_environment,
|
||||
fake_session)
|
||||
mock__deploy_environment.assert_called_once_with(
|
||||
fake_environment, fake_session)
|
||||
|
@ -26,25 +26,26 @@ class NeutronNetworksTestCase(test.ClientsTestCase):
|
||||
|
||||
@mock.patch(NEUTRON_NETWORKS + "._list_networks")
|
||||
@mock.patch(NEUTRON_NETWORKS + "._create_network")
|
||||
def test_create_and_list_networks(self, mock_create, mock_list):
|
||||
def test_create_and_list_networks(self, mock__create_network,
|
||||
mock__list_networks):
|
||||
neutron_scenario = network.NeutronNetworks()
|
||||
|
||||
# Default options
|
||||
network_create_args = {}
|
||||
neutron_scenario.create_and_list_networks(
|
||||
network_create_args=network_create_args)
|
||||
mock_create.assert_called_once_with(network_create_args)
|
||||
mock_list.assert_called_once_with()
|
||||
mock__create_network.assert_called_once_with(network_create_args)
|
||||
mock__list_networks.assert_called_once_with()
|
||||
|
||||
mock_create.reset_mock()
|
||||
mock_list.reset_mock()
|
||||
mock__create_network.reset_mock()
|
||||
mock__list_networks.reset_mock()
|
||||
|
||||
# Explicit network name is specified
|
||||
network_create_args = {"name": "given-name"}
|
||||
neutron_scenario.create_and_list_networks(
|
||||
network_create_args=network_create_args)
|
||||
mock_create.assert_called_once_with(network_create_args)
|
||||
mock_list.assert_called_once_with()
|
||||
mock__create_network.assert_called_once_with(network_create_args)
|
||||
mock__list_networks.assert_called_once_with()
|
||||
|
||||
@mock.patch(NEUTRON_NETWORKS + "._update_network")
|
||||
@mock.patch(NEUTRON_NETWORKS + "._create_network", return_value={
|
||||
@ -55,8 +56,8 @@ class NeutronNetworksTestCase(test.ClientsTestCase):
|
||||
}
|
||||
})
|
||||
def test_create_and_update_networks(self,
|
||||
mock_create_network,
|
||||
mock_update_network):
|
||||
mock__create_network,
|
||||
mock__update_network):
|
||||
scenario = network.NeutronNetworks()
|
||||
|
||||
network_update_args = {"name": "_updated", "admin_state_up": True}
|
||||
@ -65,13 +66,15 @@ class NeutronNetworksTestCase(test.ClientsTestCase):
|
||||
scenario.create_and_update_networks(
|
||||
network_update_args=network_update_args)
|
||||
|
||||
mock_create_network.assert_called_once_with({})
|
||||
mock__create_network.assert_called_once_with({})
|
||||
|
||||
mock_update_network.assert_has_calls(
|
||||
[mock.call(mock_create_network.return_value, network_update_args)])
|
||||
mock__update_network.assert_has_calls(
|
||||
[mock.call(
|
||||
mock__create_network.return_value, network_update_args
|
||||
)])
|
||||
|
||||
mock_create_network.reset_mock()
|
||||
mock_update_network.reset_mock()
|
||||
mock__create_network.reset_mock()
|
||||
mock__update_network.reset_mock()
|
||||
|
||||
# Explicit network name is specified
|
||||
network_create_args = {"name": "network-name", "admin_state_up": False}
|
||||
@ -79,55 +82,54 @@ class NeutronNetworksTestCase(test.ClientsTestCase):
|
||||
scenario.create_and_update_networks(
|
||||
network_create_args=network_create_args,
|
||||
network_update_args=network_update_args)
|
||||
mock_create_network.assert_called_once_with(network_create_args)
|
||||
mock_update_network.assert_has_calls(
|
||||
[mock.call(mock_create_network.return_value, network_update_args)])
|
||||
mock__create_network.assert_called_once_with(network_create_args)
|
||||
mock__update_network.assert_has_calls(
|
||||
[mock.call(mock__create_network.return_value,
|
||||
network_update_args)])
|
||||
|
||||
@mock.patch(NEUTRON_NETWORKS + "._delete_network")
|
||||
@mock.patch(NEUTRON_NETWORKS + "._create_network")
|
||||
def test_create_and_delete_networks(self, mock_create, mock_delete):
|
||||
def test_create_and_delete_networks(self, mock__create_network,
|
||||
mock__delete_network):
|
||||
neutron_scenario = network.NeutronNetworks()
|
||||
|
||||
# Default options
|
||||
network_create_args = {}
|
||||
neutron_scenario.create_and_delete_networks()
|
||||
mock_create.assert_called_once_with(network_create_args)
|
||||
self.assertEqual(1, mock_delete.call_count)
|
||||
mock__create_network.assert_called_once_with(network_create_args)
|
||||
self.assertEqual(1, mock__delete_network.call_count)
|
||||
|
||||
mock_create.reset_mock()
|
||||
mock_delete.reset_mock()
|
||||
mock__create_network.reset_mock()
|
||||
mock__delete_network.reset_mock()
|
||||
|
||||
# Explict network name is specified
|
||||
network_create_args = {"name": "given-name"}
|
||||
neutron_scenario.create_and_delete_networks(
|
||||
network_create_args=network_create_args)
|
||||
mock_create.assert_called_once_with(network_create_args)
|
||||
self.assertEqual(1, mock_delete.call_count)
|
||||
mock__create_network.assert_called_once_with(network_create_args)
|
||||
self.assertEqual(1, mock__delete_network.call_count)
|
||||
|
||||
@mock.patch(NEUTRON_NETWORKS + "._list_subnets")
|
||||
@mock.patch(NEUTRON_NETWORKS + "._create_network_and_subnets")
|
||||
def test_create_and_list_subnets(self,
|
||||
mock_create_network_and_subnets,
|
||||
mock_list):
|
||||
mock__create_network_and_subnets,
|
||||
mock__list_subnets):
|
||||
scenario = network.NeutronNetworks()
|
||||
subnets_per_network = 4
|
||||
subnet_cidr_start = "default_cidr"
|
||||
|
||||
mock_create_network_and_subnets.reset_mock()
|
||||
mock_list.reset_mock()
|
||||
|
||||
# Default options
|
||||
scenario.create_and_list_subnets(
|
||||
subnets_per_network=subnets_per_network,
|
||||
subnet_cidr_start=subnet_cidr_start)
|
||||
|
||||
mock_create_network_and_subnets.assert_has_calls(
|
||||
mock__create_network_and_subnets.assert_has_calls(
|
||||
[mock.call({}, {}, subnets_per_network,
|
||||
subnet_cidr_start)])
|
||||
mock_list.assert_called_once_with()
|
||||
mock__list_subnets.assert_called_once_with()
|
||||
|
||||
mock_create_network_and_subnets.reset_mock()
|
||||
mock_list.reset_mock()
|
||||
mock__create_network_and_subnets.reset_mock()
|
||||
mock__list_subnets.reset_mock()
|
||||
|
||||
# Custom options
|
||||
scenario.create_and_list_subnets(
|
||||
@ -135,16 +137,16 @@ class NeutronNetworksTestCase(test.ClientsTestCase):
|
||||
subnet_cidr_start="custom_cidr",
|
||||
subnets_per_network=subnets_per_network)
|
||||
|
||||
mock_create_network_and_subnets.assert_has_calls(
|
||||
mock__create_network_and_subnets.assert_has_calls(
|
||||
[mock.call({}, {"allocation_pools": []},
|
||||
subnets_per_network, "custom_cidr")])
|
||||
mock_list.assert_called_once_with()
|
||||
mock__list_subnets.assert_called_once_with()
|
||||
|
||||
@mock.patch(NEUTRON_NETWORKS + "._update_subnet")
|
||||
@mock.patch(NEUTRON_NETWORKS + "._create_network_and_subnets")
|
||||
def test_create_and_update_subnets(self,
|
||||
mock_create_network_and_subnets,
|
||||
mock_update_subnet):
|
||||
mock__create_network_and_subnets,
|
||||
mock__update_subnet):
|
||||
scenario = network.NeutronNetworks()
|
||||
subnets_per_network = 1
|
||||
subnet_cidr_start = "default_cidr"
|
||||
@ -160,25 +162,22 @@ class NeutronNetworksTestCase(test.ClientsTestCase):
|
||||
"enable_dhcp": False
|
||||
}
|
||||
}
|
||||
mock_create_network_and_subnets.return_value = (net, [subnet])
|
||||
mock__create_network_and_subnets.return_value = (net, [subnet])
|
||||
subnet_update_args = {"name": "_updated", "enable_dhcp": True}
|
||||
|
||||
mock_create_network_and_subnets.reset_mock()
|
||||
mock_update_subnet.reset_mock()
|
||||
|
||||
# Default options
|
||||
scenario.create_and_update_subnets(
|
||||
subnet_update_args=subnet_update_args,
|
||||
subnet_cidr_start=subnet_cidr_start,
|
||||
subnets_per_network=subnets_per_network)
|
||||
|
||||
mock_create_network_and_subnets.assert_has_calls(
|
||||
mock__create_network_and_subnets.assert_has_calls(
|
||||
[mock.call({}, {}, subnets_per_network, subnet_cidr_start)])
|
||||
mock_update_subnet.assert_has_calls(
|
||||
mock__update_subnet.assert_has_calls(
|
||||
[mock.call(subnet, subnet_update_args)])
|
||||
|
||||
mock_create_network_and_subnets.reset_mock()
|
||||
mock_update_subnet.reset_mock()
|
||||
mock__create_network_and_subnets.reset_mock()
|
||||
mock__update_subnet.reset_mock()
|
||||
|
||||
# Custom options
|
||||
subnet_cidr_start = "custom_cidr"
|
||||
@ -188,17 +187,17 @@ class NeutronNetworksTestCase(test.ClientsTestCase):
|
||||
subnet_cidr_start=subnet_cidr_start,
|
||||
subnets_per_network=subnets_per_network)
|
||||
|
||||
mock_create_network_and_subnets.assert_has_calls(
|
||||
mock__create_network_and_subnets.assert_has_calls(
|
||||
[mock.call({}, {"allocation_pools": []}, subnets_per_network,
|
||||
subnet_cidr_start)])
|
||||
mock_update_subnet.assert_has_calls(
|
||||
mock__update_subnet.assert_has_calls(
|
||||
[mock.call(subnet, subnet_update_args)])
|
||||
|
||||
@mock.patch(NEUTRON_NETWORKS + "._delete_subnet")
|
||||
@mock.patch(NEUTRON_NETWORKS + "._create_network_and_subnets")
|
||||
def test_create_and_delete_subnets(self,
|
||||
mock_create_network_and_subnets,
|
||||
mock_delete):
|
||||
mock__create_network_and_subnets,
|
||||
mock__delete_subnet):
|
||||
scenario = network.NeutronNetworks()
|
||||
net = {
|
||||
"network": {
|
||||
@ -212,26 +211,23 @@ class NeutronNetworksTestCase(test.ClientsTestCase):
|
||||
"enable_dhcp": False
|
||||
}
|
||||
}
|
||||
mock_create_network_and_subnets.return_value = (net, [subnet])
|
||||
mock__create_network_and_subnets.return_value = (net, [subnet])
|
||||
subnets_per_network = 1
|
||||
subnet_cidr_start = "default_cidr"
|
||||
|
||||
mock_create_network_and_subnets.reset_mock()
|
||||
mock_delete.reset_mock()
|
||||
|
||||
# Default options
|
||||
scenario.create_and_delete_subnets(
|
||||
subnets_per_network=subnets_per_network,
|
||||
subnet_cidr_start=subnet_cidr_start)
|
||||
|
||||
mock_create_network_and_subnets.assert_has_calls(
|
||||
mock__create_network_and_subnets.assert_has_calls(
|
||||
[mock.call({}, {}, subnets_per_network,
|
||||
subnet_cidr_start)])
|
||||
|
||||
mock_delete.assert_has_calls([mock.call(subnet)])
|
||||
mock__delete_subnet.assert_has_calls([mock.call(subnet)])
|
||||
|
||||
mock_create_network_and_subnets.reset_mock()
|
||||
mock_delete.reset_mock()
|
||||
mock__create_network_and_subnets.reset_mock()
|
||||
mock__delete_subnet.reset_mock()
|
||||
|
||||
# Custom options
|
||||
subnet_cidr_start = "custom_cidr"
|
||||
@ -240,18 +236,18 @@ class NeutronNetworksTestCase(test.ClientsTestCase):
|
||||
subnet_cidr_start="custom_cidr",
|
||||
subnets_per_network=subnets_per_network)
|
||||
|
||||
mock_create_network_and_subnets.assert_has_calls(
|
||||
mock__create_network_and_subnets.assert_has_calls(
|
||||
[mock.call({}, {"allocation_pools": []}, subnets_per_network,
|
||||
subnet_cidr_start)])
|
||||
mock_delete.assert_has_calls([mock.call(subnet)])
|
||||
mock__delete_subnet.assert_has_calls([mock.call(subnet)])
|
||||
|
||||
@mock.patch(NEUTRON_NETWORKS + "._list_routers")
|
||||
@mock.patch(NEUTRON_NETWORKS + "._create_router")
|
||||
@mock.patch(NEUTRON_NETWORKS + "._create_network_and_subnets")
|
||||
def test_create_and_list_routers(self,
|
||||
mock_create_network_and_subnets,
|
||||
mock_create_router,
|
||||
mock_list):
|
||||
mock__create_network_and_subnets,
|
||||
mock__create_router,
|
||||
mock__list_routers):
|
||||
scenario = network.NeutronNetworks()
|
||||
subnets_per_network = 1
|
||||
subnet_cidr_start = "default_cidr"
|
||||
@ -268,7 +264,7 @@ class NeutronNetworksTestCase(test.ClientsTestCase):
|
||||
"enable_dhcp": False
|
||||
}
|
||||
}
|
||||
mock_create_network_and_subnets.return_value = (net, [subnet])
|
||||
mock__create_network_and_subnets.return_value = (net, [subnet])
|
||||
self.clients("neutron").add_interface_router = mock.Mock()
|
||||
router = {
|
||||
"router": {
|
||||
@ -276,16 +272,16 @@ class NeutronNetworksTestCase(test.ClientsTestCase):
|
||||
"id": "router-id"
|
||||
}
|
||||
}
|
||||
mock_create_router.return_value = router
|
||||
mock__create_router.return_value = router
|
||||
|
||||
# Default options
|
||||
scenario.create_and_list_routers(
|
||||
subnet_cidr_start=subnet_cidr_start,
|
||||
subnets_per_network=subnets_per_network)
|
||||
mock_create_network_and_subnets.assert_has_calls(
|
||||
mock__create_network_and_subnets.assert_has_calls(
|
||||
[mock.call({}, {}, subnets_per_network, subnet_cidr_start)])
|
||||
|
||||
mock_create_router.assert_has_calls(
|
||||
mock__create_router.assert_has_calls(
|
||||
[mock.call({})] * subnets_per_network)
|
||||
|
||||
self.clients("neutron").add_interface_router.assert_has_calls(
|
||||
@ -293,11 +289,11 @@ class NeutronNetworksTestCase(test.ClientsTestCase):
|
||||
{"subnet_id": subnet["subnet"]["id"]})
|
||||
] * subnets_per_network)
|
||||
|
||||
mock_create_network_and_subnets.reset_mock()
|
||||
mock_create_router.reset_mock()
|
||||
mock__create_network_and_subnets.reset_mock()
|
||||
mock__create_router.reset_mock()
|
||||
|
||||
self.clients("neutron").add_interface_router.reset_mock()
|
||||
mock_list.reset_mock()
|
||||
mock__list_routers.reset_mock()
|
||||
|
||||
# Custom options
|
||||
subnet_cidr_start = "custom_cidr"
|
||||
@ -309,26 +305,26 @@ class NeutronNetworksTestCase(test.ClientsTestCase):
|
||||
subnets_per_network=subnets_per_network,
|
||||
router_create_args=router_create_args)
|
||||
|
||||
mock_create_network_and_subnets.assert_has_calls(
|
||||
mock__create_network_and_subnets.assert_has_calls(
|
||||
[mock.call({}, subnet_create_args, subnets_per_network,
|
||||
subnet_cidr_start)])
|
||||
|
||||
mock_create_router.assert_has_calls(
|
||||
mock__create_router.assert_has_calls(
|
||||
[mock.call(router_create_args)] * subnets_per_network)
|
||||
self.clients("neutron").add_interface_router.assert_has_calls(
|
||||
[mock.call(router["router"]["id"],
|
||||
{"subnet_id": subnet["subnet"]["id"]})
|
||||
] * subnets_per_network)
|
||||
|
||||
mock_list.assert_called_once_with()
|
||||
mock__list_routers.assert_called_once_with()
|
||||
|
||||
@mock.patch(NEUTRON_NETWORKS + "._update_router")
|
||||
@mock.patch(NEUTRON_NETWORKS + "._create_router")
|
||||
@mock.patch(NEUTRON_NETWORKS + "._create_network_and_subnets")
|
||||
def test_create_and_update_routers(self,
|
||||
mock_create_network_and_subnets,
|
||||
mock_create_router,
|
||||
mock_update_router):
|
||||
mock__create_network_and_subnets,
|
||||
mock__create_router,
|
||||
mock__update_router):
|
||||
scenario = network.NeutronNetworks()
|
||||
subnets_per_network = 1
|
||||
subnet_cidr_start = "default_cidr"
|
||||
@ -355,8 +351,8 @@ class NeutronNetworksTestCase(test.ClientsTestCase):
|
||||
"name": "_updated",
|
||||
"admin_state_up": False
|
||||
}
|
||||
mock_create_router.return_value = router
|
||||
mock_create_network_and_subnets.return_value = (net, [subnet])
|
||||
mock__create_router.return_value = router
|
||||
mock__create_network_and_subnets.return_value = (net, [subnet])
|
||||
self.clients("neutron").add_interface_router = mock.Mock()
|
||||
|
||||
# Default options
|
||||
@ -365,24 +361,24 @@ class NeutronNetworksTestCase(test.ClientsTestCase):
|
||||
subnet_cidr_start=subnet_cidr_start,
|
||||
subnets_per_network=subnets_per_network)
|
||||
|
||||
mock_create_network_and_subnets.assert_has_calls(
|
||||
mock__create_network_and_subnets.assert_has_calls(
|
||||
[mock.call({}, {}, subnets_per_network, subnet_cidr_start)])
|
||||
|
||||
mock_create_router.assert_has_calls(
|
||||
mock__create_router.assert_has_calls(
|
||||
[mock.call({})] * subnets_per_network)
|
||||
self.clients("neutron").add_interface_router.assert_has_calls(
|
||||
[mock.call(router["router"]["id"],
|
||||
{"subnet_id": subnet["subnet"]["id"]})
|
||||
] * subnets_per_network)
|
||||
|
||||
mock_update_router.assert_has_calls(
|
||||
mock__update_router.assert_has_calls(
|
||||
[mock.call(router, router_update_args)
|
||||
] * subnets_per_network)
|
||||
|
||||
mock_create_network_and_subnets.reset_mock()
|
||||
mock_create_router.reset_mock()
|
||||
mock__create_network_and_subnets.reset_mock()
|
||||
mock__create_router.reset_mock()
|
||||
self.clients("neutron").add_interface_router.reset_mock()
|
||||
mock_update_router.reset_mock()
|
||||
mock__update_router.reset_mock()
|
||||
|
||||
# Custom options
|
||||
subnet_cidr_start = "custom_cidr"
|
||||
@ -395,18 +391,18 @@ class NeutronNetworksTestCase(test.ClientsTestCase):
|
||||
subnets_per_network=subnets_per_network,
|
||||
router_create_args=router_create_args)
|
||||
|
||||
mock_create_network_and_subnets.assert_has_calls(
|
||||
mock__create_network_and_subnets.assert_has_calls(
|
||||
[mock.call({}, subnet_create_args, subnets_per_network,
|
||||
subnet_cidr_start)])
|
||||
|
||||
mock_create_router.assert_has_calls(
|
||||
mock__create_router.assert_has_calls(
|
||||
[mock.call(router_create_args)] * subnets_per_network)
|
||||
self.clients("neutron").add_interface_router.assert_has_calls(
|
||||
[mock.call(router["router"]["id"],
|
||||
{"subnet_id": subnet["subnet"]["id"]})
|
||||
] * subnets_per_network)
|
||||
|
||||
mock_update_router.assert_has_calls(
|
||||
mock__update_router.assert_has_calls(
|
||||
[mock.call(router, router_update_args)
|
||||
] * subnets_per_network)
|
||||
|
||||
@ -414,9 +410,9 @@ class NeutronNetworksTestCase(test.ClientsTestCase):
|
||||
@mock.patch(NEUTRON_NETWORKS + "._create_router")
|
||||
@mock.patch(NEUTRON_NETWORKS + "._create_network_and_subnets")
|
||||
def test_create_and_delete_routers(self,
|
||||
mock_create_network_and_subnets,
|
||||
mock_create_router,
|
||||
mock_delete_router):
|
||||
mock__create_network_and_subnets,
|
||||
mock__create_router,
|
||||
mock__delete_router):
|
||||
scenario = network.NeutronNetworks()
|
||||
subnets_per_network = 1
|
||||
subnet_cidr_start = "default_cidr"
|
||||
@ -440,8 +436,8 @@ class NeutronNetworksTestCase(test.ClientsTestCase):
|
||||
}
|
||||
}
|
||||
|
||||
mock_create_router.return_value = router
|
||||
mock_create_network_and_subnets.return_value = (net, [subnet])
|
||||
mock__create_router.return_value = router
|
||||
mock__create_network_and_subnets.return_value = (net, [subnet])
|
||||
self.clients("neutron").add_interface_router = mock.Mock()
|
||||
|
||||
# Default options
|
||||
@ -449,23 +445,23 @@ class NeutronNetworksTestCase(test.ClientsTestCase):
|
||||
subnet_cidr_start=subnet_cidr_start,
|
||||
subnets_per_network=subnets_per_network)
|
||||
|
||||
mock_create_network_and_subnets.assert_has_calls(
|
||||
mock__create_network_and_subnets.assert_has_calls(
|
||||
[mock.call({}, {}, subnets_per_network, subnet_cidr_start)])
|
||||
|
||||
mock_create_router.assert_has_calls(
|
||||
mock__create_router.assert_has_calls(
|
||||
[mock.call({})] * subnets_per_network)
|
||||
self.clients("neutron").add_interface_router.assert_has_calls(
|
||||
[mock.call(router["router"]["id"],
|
||||
{"subnet_id": subnet["subnet"]["id"]})
|
||||
] * subnets_per_network)
|
||||
|
||||
mock_delete_router.assert_has_calls(
|
||||
mock__delete_router.assert_has_calls(
|
||||
[mock.call(router)] * subnets_per_network)
|
||||
|
||||
mock_create_network_and_subnets.reset_mock()
|
||||
mock_create_router.reset_mock()
|
||||
mock__create_network_and_subnets.reset_mock()
|
||||
mock__create_router.reset_mock()
|
||||
self.clients("neutron").add_interface_router.reset_mock()
|
||||
mock_delete_router.reset_mock()
|
||||
mock__delete_router.reset_mock()
|
||||
|
||||
# Custom options
|
||||
subnet_cidr_start = "custom_cidr"
|
||||
@ -477,18 +473,18 @@ class NeutronNetworksTestCase(test.ClientsTestCase):
|
||||
subnets_per_network=subnets_per_network,
|
||||
router_create_args=router_create_args)
|
||||
|
||||
mock_create_network_and_subnets.assert_has_calls(
|
||||
mock__create_network_and_subnets.assert_has_calls(
|
||||
[mock.call({}, subnet_create_args, subnets_per_network,
|
||||
subnet_cidr_start)])
|
||||
|
||||
mock_create_router.assert_has_calls(
|
||||
mock__create_router.assert_has_calls(
|
||||
[mock.call(router_create_args)] * subnets_per_network)
|
||||
self.clients("neutron").add_interface_router.assert_has_calls(
|
||||
[mock.call(router["router"]["id"],
|
||||
{"subnet_id": subnet["subnet"]["id"]})
|
||||
] * subnets_per_network)
|
||||
|
||||
mock_delete_router.assert_has_calls(
|
||||
mock__delete_router.assert_has_calls(
|
||||
[mock.call(router)] * subnets_per_network)
|
||||
|
||||
@mock.patch(NEUTRON_NETWORKS + "._generate_random_name")
|
||||
@ -496,41 +492,41 @@ class NeutronNetworksTestCase(test.ClientsTestCase):
|
||||
@mock.patch(NEUTRON_NETWORKS + "._create_port")
|
||||
@mock.patch(NEUTRON_NETWORKS + "._create_network")
|
||||
def test_create_and_list_ports(self,
|
||||
mock_create_network,
|
||||
mock_create_port,
|
||||
mock_list,
|
||||
mock_random_name):
|
||||
mock__create_network,
|
||||
mock__create_port,
|
||||
mock__list_ports,
|
||||
mock__generate_random_name):
|
||||
scenario = network.NeutronNetworks()
|
||||
mock_random_name.return_value = "random-name"
|
||||
mock__generate_random_name.return_value = "random-name"
|
||||
net = {"network": {"id": "fake-id"}}
|
||||
mock_create_network.return_value = net
|
||||
mock__create_network.return_value = net
|
||||
ports_per_network = 10
|
||||
|
||||
self.assertRaises(TypeError, scenario.create_and_list_ports)
|
||||
|
||||
mock_create_network.reset_mock()
|
||||
mock__create_network.reset_mock()
|
||||
|
||||
# Defaults
|
||||
scenario.create_and_list_ports(ports_per_network=ports_per_network)
|
||||
mock_create_network.assert_called_once_with({})
|
||||
self.assertEqual(mock_create_port.mock_calls,
|
||||
mock__create_network.assert_called_once_with({})
|
||||
self.assertEqual(mock__create_port.mock_calls,
|
||||
[mock.call(net, {})] * ports_per_network)
|
||||
mock_list.assert_called_once_with()
|
||||
mock__list_ports.assert_called_once_with()
|
||||
|
||||
mock_create_network.reset_mock()
|
||||
mock_create_port.reset_mock()
|
||||
mock_list.reset_mock()
|
||||
mock__create_network.reset_mock()
|
||||
mock__create_port.reset_mock()
|
||||
mock__list_ports.reset_mock()
|
||||
|
||||
# Custom options
|
||||
scenario.create_and_list_ports(
|
||||
network_create_args={"name": "given-name"},
|
||||
port_create_args={"allocation_pools": []},
|
||||
ports_per_network=ports_per_network)
|
||||
mock_create_network.assert_called_once_with({"name": "given-name"})
|
||||
mock__create_network.assert_called_once_with({"name": "given-name"})
|
||||
self.assertEqual(
|
||||
mock_create_port.mock_calls,
|
||||
mock__create_port.mock_calls,
|
||||
[mock.call(net, {"allocation_pools": []})] * ports_per_network)
|
||||
mock_list.assert_called_once_with()
|
||||
mock__list_ports.assert_called_once_with()
|
||||
|
||||
@mock.patch(NEUTRON_NETWORKS + "._generate_random_name")
|
||||
@mock.patch(NEUTRON_NETWORKS + "._update_port")
|
||||
@ -544,12 +540,12 @@ class NeutronNetworksTestCase(test.ClientsTestCase):
|
||||
@mock.patch(NEUTRON_NETWORKS + "._create_network", return_value={
|
||||
"network": {"id": "fake-id"}})
|
||||
def test_create_and_update_ports(self,
|
||||
mock_create_network,
|
||||
mock_create_port,
|
||||
mock_update_port,
|
||||
mock_random_name):
|
||||
mock__create_network,
|
||||
mock__create_port,
|
||||
mock__update_port,
|
||||
mock__generate_random_name):
|
||||
scenario = network.NeutronNetworks()
|
||||
mock_random_name.return_value = "random-name"
|
||||
mock__generate_random_name.return_value = "random-name"
|
||||
ports_per_network = 10
|
||||
|
||||
port_update_args = {
|
||||
@ -561,18 +557,18 @@ class NeutronNetworksTestCase(test.ClientsTestCase):
|
||||
scenario.create_and_update_ports(
|
||||
port_update_args=port_update_args,
|
||||
ports_per_network=ports_per_network)
|
||||
mock_create_network.assert_called_once_with({})
|
||||
mock__create_network.assert_called_once_with({})
|
||||
|
||||
mock_create_port.assert_has_calls(
|
||||
mock__create_port.assert_has_calls(
|
||||
[mock.call({"network": {"id": "fake-id"}},
|
||||
{})] * ports_per_network)
|
||||
mock_update_port.assert_has_calls(
|
||||
[mock.call(mock_create_port.return_value, port_update_args)
|
||||
mock__update_port.assert_has_calls(
|
||||
[mock.call(mock__create_port.return_value, port_update_args)
|
||||
] * ports_per_network)
|
||||
|
||||
mock_create_network.reset_mock()
|
||||
mock_create_port.reset_mock()
|
||||
mock_update_port.reset_mock()
|
||||
mock__create_network.reset_mock()
|
||||
mock__create_port.reset_mock()
|
||||
mock__update_port.reset_mock()
|
||||
|
||||
# Custom options
|
||||
scenario.create_and_update_ports(
|
||||
@ -580,12 +576,12 @@ class NeutronNetworksTestCase(test.ClientsTestCase):
|
||||
network_create_args={"name": "given-name"},
|
||||
port_create_args={"allocation_pools": []},
|
||||
ports_per_network=ports_per_network)
|
||||
mock_create_network.assert_called_once_with({"name": "given-name"})
|
||||
mock_create_port.assert_has_calls(
|
||||
mock__create_network.assert_called_once_with({"name": "given-name"})
|
||||
mock__create_port.assert_has_calls(
|
||||
[mock.call({"network": {"id": "fake-id"}},
|
||||
{"allocation_pools": []})] * ports_per_network)
|
||||
mock_update_port.assert_has_calls(
|
||||
[mock.call(mock_create_port.return_value, port_update_args)
|
||||
mock__update_port.assert_has_calls(
|
||||
[mock.call(mock__create_port.return_value, port_update_args)
|
||||
] * ports_per_network)
|
||||
|
||||
@mock.patch(NEUTRON_NETWORKS + "._generate_random_name")
|
||||
@ -593,40 +589,41 @@ class NeutronNetworksTestCase(test.ClientsTestCase):
|
||||
@mock.patch(NEUTRON_NETWORKS + "._create_port")
|
||||
@mock.patch(NEUTRON_NETWORKS + "._create_network")
|
||||
def test_create_and_delete_ports(self,
|
||||
mock_create_network,
|
||||
mock_create_port,
|
||||
mock_delete,
|
||||
mock_random_name):
|
||||
mock__create_network,
|
||||
mock__create_port,
|
||||
mock__delete_port,
|
||||
mock__generate_random_name):
|
||||
scenario = network.NeutronNetworks()
|
||||
mock_random_name.return_value = "random-name"
|
||||
mock__generate_random_name.return_value = "random-name"
|
||||
net = {"network": {"id": "fake-id"}}
|
||||
mock_create_network.return_value = net
|
||||
mock__create_network.return_value = net
|
||||
ports_per_network = 10
|
||||
|
||||
self.assertRaises(TypeError, scenario.create_and_delete_ports)
|
||||
|
||||
mock_create_network.reset_mock()
|
||||
mock__create_network.reset_mock()
|
||||
|
||||
# Default options
|
||||
scenario.create_and_delete_ports(ports_per_network=ports_per_network)
|
||||
mock_create_network.assert_called_once_with({})
|
||||
self.assertEqual(mock_create_port.mock_calls,
|
||||
mock__create_network.assert_called_once_with({})
|
||||
self.assertEqual(mock__create_port.mock_calls,
|
||||
[mock.call(net, {})] * ports_per_network)
|
||||
self.assertEqual(mock_delete.mock_calls,
|
||||
[mock.call(mock_create_port())] * ports_per_network)
|
||||
self.assertEqual(mock__delete_port.mock_calls,
|
||||
[mock.call(mock__create_port())] * ports_per_network)
|
||||
|
||||
mock_create_network.reset_mock()
|
||||
mock_create_port.reset_mock()
|
||||
mock_delete.reset_mock()
|
||||
mock__create_network.reset_mock()
|
||||
mock__create_port.reset_mock()
|
||||
mock__delete_port.reset_mock()
|
||||
|
||||
# Custom options
|
||||
scenario.create_and_delete_ports(
|
||||
network_create_args={"name": "given-name"},
|
||||
port_create_args={"allocation_pools": []},
|
||||
ports_per_network=ports_per_network)
|
||||
mock_create_network.assert_called_once_with({"name": "given-name"})
|
||||
mock__create_network.assert_called_once_with({"name": "given-name"})
|
||||
self.assertEqual(
|
||||
mock_create_port.mock_calls,
|
||||
mock__create_port.mock_calls,
|
||||
[mock.call(net, {"allocation_pools": []})] * ports_per_network)
|
||||
self.assertEqual(mock_delete.mock_calls,
|
||||
[mock.call(mock_create_port())] * ports_per_network)
|
||||
self.assertEqual(
|
||||
mock__delete_port.mock_calls,
|
||||
[mock.call(mock__create_port.return_value)] * ports_per_network)
|
||||
|
@ -29,11 +29,11 @@ class NeutronScenarioTestCase(test.ClientsTestCase):
|
||||
self.network = mock.Mock()
|
||||
|
||||
@mock.patch(NEUTRON_UTILS + "NeutronScenario._generate_random_name")
|
||||
def test_create_network(self, mock_random_name):
|
||||
def test_create_network(self, mock__generate_random_name):
|
||||
neutron_scenario = utils.NeutronScenario()
|
||||
explicit_name = "explicit_name"
|
||||
random_name = "random_name"
|
||||
mock_random_name.return_value = random_name
|
||||
mock__generate_random_name.return_value = random_name
|
||||
self.clients("neutron").create_network.return_value = self.network
|
||||
|
||||
# Network name is specified
|
||||
@ -96,7 +96,7 @@ class NeutronScenarioTestCase(test.ClientsTestCase):
|
||||
|
||||
@mock.patch(NEUTRON_UTILS + "NeutronScenario._generate_random_name",
|
||||
return_value="test_subnet")
|
||||
def test_create_subnet(self, mock_random_name):
|
||||
def test_create_subnet(self, mock__generate_random_name):
|
||||
scenario = utils.NeutronScenario()
|
||||
network_id = "fake-id"
|
||||
start_cidr = "192.168.0.0/24"
|
||||
@ -107,7 +107,7 @@ class NeutronScenarioTestCase(test.ClientsTestCase):
|
||||
"network_id": network_id,
|
||||
"cidr": start_cidr,
|
||||
"ip_version": scenario.SUBNET_IP_VERSION,
|
||||
"name": mock_random_name.return_value
|
||||
"name": mock__generate_random_name.return_value
|
||||
}
|
||||
}
|
||||
|
||||
@ -171,12 +171,12 @@ class NeutronScenarioTestCase(test.ClientsTestCase):
|
||||
"neutron.delete_subnet")
|
||||
|
||||
@mock.patch(NEUTRON_UTILS + "NeutronScenario._generate_random_name")
|
||||
def test_create_router(self, mock_random_name):
|
||||
def test_create_router(self, mock__generate_random_name):
|
||||
scenario = utils.NeutronScenario()
|
||||
router = mock.Mock()
|
||||
explicit_name = "explicit_name"
|
||||
random_name = "random_name"
|
||||
mock_random_name.return_value = random_name
|
||||
mock__generate_random_name.return_value = random_name
|
||||
self.clients("neutron").create_router.return_value = router
|
||||
|
||||
# Default options
|
||||
@ -257,13 +257,13 @@ class NeutronScenarioTestCase(test.ClientsTestCase):
|
||||
self.assertEqual(utils.NeutronScenario.SUBNET_IP_VERSION, 4)
|
||||
|
||||
@mock.patch(NEUTRON_UTILS + "NeutronScenario._generate_random_name")
|
||||
def test_create_port(self, mock_rand_name):
|
||||
def test_create_port(self, mock__generate_random_name):
|
||||
scenario = utils.NeutronScenario()
|
||||
|
||||
net_id = "network-id"
|
||||
net = {"network": {"id": net_id}}
|
||||
rand_name = "random-name"
|
||||
mock_rand_name.return_value = rand_name
|
||||
mock__generate_random_name.return_value = rand_name
|
||||
expected_port_args = {
|
||||
"port": {
|
||||
"network_id": net_id,
|
||||
@ -354,29 +354,26 @@ class NeutronScenarioTestCase(test.ClientsTestCase):
|
||||
}
|
||||
})
|
||||
def test_create_network_and_subnets(self,
|
||||
mock_create_network,
|
||||
mock_create_subnet):
|
||||
mock__create_network,
|
||||
mock__create_subnet):
|
||||
scenario = utils.NeutronScenario()
|
||||
network_create_args = {}
|
||||
subnet_create_args = {}
|
||||
subnets_per_network = 4
|
||||
|
||||
mock_create_network.reset_mock()
|
||||
mock_create_subnet.reset_mock()
|
||||
|
||||
# Default options
|
||||
scenario._create_network_and_subnets(
|
||||
network_create_args=network_create_args,
|
||||
subnet_create_args=subnet_create_args,
|
||||
subnets_per_network=subnets_per_network)
|
||||
|
||||
mock_create_network.assert_called_once_with({})
|
||||
mock_create_subnet.assert_has_calls(
|
||||
mock__create_network.assert_called_once_with({})
|
||||
mock__create_subnet.assert_has_calls(
|
||||
[mock.call({"network": {"id": "fake-id"}},
|
||||
{}, "1.0.0.0/24")] * subnets_per_network)
|
||||
|
||||
mock_create_network.reset_mock()
|
||||
mock_create_subnet.reset_mock()
|
||||
mock__create_network.reset_mock()
|
||||
mock__create_subnet.reset_mock()
|
||||
|
||||
# Custom options
|
||||
scenario._create_network_and_subnets(
|
||||
@ -385,8 +382,8 @@ class NeutronScenarioTestCase(test.ClientsTestCase):
|
||||
subnet_cidr_start="10.10.10.0/24",
|
||||
subnets_per_network=subnets_per_network)
|
||||
|
||||
mock_create_network.assert_called_once_with({})
|
||||
mock_create_subnet.assert_has_calls(
|
||||
mock__create_network.assert_called_once_with({})
|
||||
mock__create_subnet.assert_has_calls(
|
||||
[mock.call({"network": {"id": "fake-id"}},
|
||||
{"allocation_pools": []},
|
||||
"10.10.10.0/24")] * subnets_per_network)
|
||||
@ -411,13 +408,13 @@ class NeutronScenarioTestCase(test.ClientsTestCase):
|
||||
neutron_scenario.atomic_actions(), "neutron.create_pool")
|
||||
|
||||
@mock.patch(NEUTRON_UTILS + "NeutronScenario._generate_random_name")
|
||||
def test_create_v1_pool_default(self, mock_random_name):
|
||||
def test_create_v1_pool_default(self, mock__generate_random_name):
|
||||
neutron_scenario = utils.NeutronScenario()
|
||||
random_name = "random_name"
|
||||
subnet = "fake-id"
|
||||
pool = mock.Mock()
|
||||
self.clients("neutron").create_pool.return_value = pool
|
||||
mock_random_name.return_value = random_name
|
||||
mock__generate_random_name.return_value = random_name
|
||||
# Random pool name
|
||||
pool_data = {}
|
||||
args = {"lb_method": "ROUND_ROBIN", "protocol": "HTTP",
|
||||
|
@ -25,7 +25,6 @@ from tests.unit import test
|
||||
|
||||
BM_UTILS = "rally.benchmark.utils"
|
||||
NOVA_UTILS = "rally.plugins.openstack.scenarios.nova.utils"
|
||||
SCN = "rally.benchmark.scenarios.base"
|
||||
CONF = cfg.CONF
|
||||
|
||||
|
||||
@ -95,9 +94,9 @@ class NovaScenarioTestCase(test.ClientsTestCase):
|
||||
self._test_atomic_action_timer(nova_scenario.atomic_actions(),
|
||||
"nova.list_servers")
|
||||
|
||||
@mock.patch(SCN + ".Scenario._generate_random_name",
|
||||
@mock.patch(NOVA_UTILS + ".NovaScenario._generate_random_name",
|
||||
return_value="foo_server_name")
|
||||
def test__boot_server(self, mock_generate_random_name):
|
||||
def test__boot_server(self, mock__generate_random_name):
|
||||
self.clients("nova").servers.create.return_value = self.server
|
||||
nova_scenario = utils.NovaScenario(context={})
|
||||
return_server = nova_scenario._boot_server("image_id",
|
||||
@ -113,9 +112,9 @@ class NovaScenarioTestCase(test.ClientsTestCase):
|
||||
self._test_atomic_action_timer(nova_scenario.atomic_actions(),
|
||||
"nova.boot_server")
|
||||
|
||||
@mock.patch(SCN + ".Scenario._generate_random_name",
|
||||
@mock.patch(NOVA_UTILS + ".NovaScenario._generate_random_name",
|
||||
return_value="foo_server_name")
|
||||
def test__boot_server_with_network(self, mock_generate_random_name):
|
||||
def test__boot_server_with_network(self, mock__generate_random_name):
|
||||
self.clients("nova").servers.create.return_value = self.server
|
||||
networks = [{"id": "foo_id", "external": False},
|
||||
{"id": "bar_id", "external": False}]
|
||||
@ -147,9 +146,9 @@ class NovaScenarioTestCase(test.ClientsTestCase):
|
||||
"image_id", "flavor_id",
|
||||
auto_assign_nic=True)
|
||||
|
||||
@mock.patch(SCN + ".Scenario._generate_random_name",
|
||||
@mock.patch(NOVA_UTILS + ".NovaScenario._generate_random_name",
|
||||
return_value="foo_server_name")
|
||||
def test__boot_server_with_ssh(self, mock_generate_random_name):
|
||||
def test__boot_server_with_ssh(self, mock__generate_random_name):
|
||||
self.clients("nova").servers.create.return_value = self.server
|
||||
nova_scenario = utils.NovaScenario(context={
|
||||
"user": {"secgroup": {"name": "test"}}}
|
||||
@ -167,9 +166,9 @@ class NovaScenarioTestCase(test.ClientsTestCase):
|
||||
self._test_atomic_action_timer(nova_scenario.atomic_actions(),
|
||||
"nova.boot_server")
|
||||
|
||||
@mock.patch(SCN + ".Scenario._generate_random_name",
|
||||
@mock.patch(NOVA_UTILS + ".NovaScenario._generate_random_name",
|
||||
return_value="foo_server_name")
|
||||
def test__boot_server_with_sec_group(self, mock_generate_random_name):
|
||||
def test__boot_server_with_sec_group(self, mock__generate_random_name):
|
||||
self.clients("nova").servers.create.return_value = self.server
|
||||
nova_scenario = utils.NovaScenario(context={
|
||||
"user": {"secgroup": {"name": "new"}}}
|
||||
@ -189,10 +188,10 @@ class NovaScenarioTestCase(test.ClientsTestCase):
|
||||
self._test_atomic_action_timer(nova_scenario.atomic_actions(),
|
||||
"nova.boot_server")
|
||||
|
||||
@mock.patch(SCN + ".Scenario._generate_random_name",
|
||||
@mock.patch(NOVA_UTILS + ".NovaScenario._generate_random_name",
|
||||
return_value="foo_server_name")
|
||||
def test__boot_server_with_similar_sec_group(self,
|
||||
mock_generate_random_name):
|
||||
mock__generate_random_name):
|
||||
self.clients("nova").servers.create.return_value = self.server
|
||||
nova_scenario = utils.NovaScenario(context={
|
||||
"user": {"secgroup": {"name": "test1"}}}
|
||||
@ -714,7 +713,7 @@ class NovaScenarioTestCase(test.ClientsTestCase):
|
||||
"nova.list_floating_ips_bulk")
|
||||
|
||||
@mock.patch(NOVA_UTILS + ".network_wrapper.generate_cidr")
|
||||
def test__create_floating_ips_bulk(self, mock_gencidr):
|
||||
def test__create_floating_ips_bulk(self, mock_generate_cidr):
|
||||
fake_cidr = "10.2.0.0/24"
|
||||
fake_pool = "test1"
|
||||
fake_floating_ips_bulk = mock.MagicMock()
|
||||
@ -724,7 +723,7 @@ class NovaScenarioTestCase(test.ClientsTestCase):
|
||||
fake_floating_ips_bulk)
|
||||
nova_scenario = utils.NovaScenario()
|
||||
return_iprange = nova_scenario._create_floating_ips_bulk(fake_cidr)
|
||||
mock_gencidr.assert_called_once_with(start_cidr=fake_cidr)
|
||||
mock_generate_cidr.assert_called_once_with(start_cidr=fake_cidr)
|
||||
self.assertEqual(return_iprange, fake_floating_ips_bulk)
|
||||
self._test_atomic_action_timer(nova_scenario.atomic_actions(),
|
||||
"nova.create_floating_ips_bulk")
|
||||
|
@ -28,8 +28,8 @@ class SaharaClustersTestCase(test.ClientsTestCase):
|
||||
@mock.patch(SAHARA_CLUSTERS + "._delete_cluster")
|
||||
@mock.patch(SAHARA_CLUSTERS + "._launch_cluster",
|
||||
return_value=mock.MagicMock(id=42))
|
||||
def test_create_and_delete_cluster(self, mock_launch_cluster,
|
||||
mock_delete_cluster):
|
||||
def test_create_and_delete_cluster(
|
||||
self, mock__launch_cluster, mock__delete_cluster):
|
||||
clusters_scenario = clusters.SaharaClusters()
|
||||
|
||||
clusters_scenario.context = {
|
||||
@ -43,7 +43,7 @@ class SaharaClustersTestCase(test.ClientsTestCase):
|
||||
plugin_name="test_plugin",
|
||||
hadoop_version="test_version")
|
||||
|
||||
mock_launch_cluster.assert_called_once_with(
|
||||
mock__launch_cluster.assert_called_once_with(
|
||||
flavor_id="test_flavor",
|
||||
image_id="test_image",
|
||||
workers_count=5,
|
||||
@ -58,16 +58,16 @@ class SaharaClustersTestCase(test.ClientsTestCase):
|
||||
cluster_configs=None,
|
||||
enable_anti_affinity=False)
|
||||
|
||||
mock_delete_cluster.assert_called_once_with(
|
||||
mock_launch_cluster.return_value)
|
||||
mock__delete_cluster.assert_called_once_with(
|
||||
mock__launch_cluster.return_value)
|
||||
|
||||
@mock.patch(SAHARA_CLUSTERS + "._delete_cluster")
|
||||
@mock.patch(SAHARA_CLUSTERS + "._scale_cluster")
|
||||
@mock.patch(SAHARA_CLUSTERS + "._launch_cluster",
|
||||
return_value=mock.MagicMock(id=42))
|
||||
def test_create_scale_delete_cluster(self, mock_launch_cluster,
|
||||
mock_scale_cluster,
|
||||
mock_delete_cluster):
|
||||
def test_create_scale_delete_cluster(
|
||||
self, mock__launch_cluster, mock__scale_cluster,
|
||||
mock__delete_cluster):
|
||||
self.clients("sahara").clusters.get.return_value = mock.MagicMock(
|
||||
id=42, status="active"
|
||||
)
|
||||
@ -86,7 +86,7 @@ class SaharaClustersTestCase(test.ClientsTestCase):
|
||||
plugin_name="test_plugin",
|
||||
hadoop_version="test_version")
|
||||
|
||||
mock_launch_cluster.assert_called_once_with(
|
||||
mock__launch_cluster.assert_called_once_with(
|
||||
flavor_id="test_flavor",
|
||||
image_id="test_image",
|
||||
workers_count=5,
|
||||
@ -101,10 +101,10 @@ class SaharaClustersTestCase(test.ClientsTestCase):
|
||||
cluster_configs=None,
|
||||
enable_anti_affinity=False)
|
||||
|
||||
mock_scale_cluster.assert_has_calls([
|
||||
mock__scale_cluster.assert_has_calls([
|
||||
mock.call(self.clients("sahara").clusters.get.return_value, 1),
|
||||
mock.call(self.clients("sahara").clusters.get.return_value, -1),
|
||||
])
|
||||
|
||||
mock_delete_cluster.assert_called_once_with(
|
||||
mock__delete_cluster.assert_called_once_with(
|
||||
self.clients("sahara").clusters.get.return_value)
|
||||
|
@ -33,11 +33,12 @@ class SaharaJobTestCase(test.ClientsTestCase):
|
||||
CONF.set_override("cluster_check_interval", 0, "benchmark")
|
||||
CONF.set_override("job_check_interval", 0, "benchmark")
|
||||
|
||||
@mock.patch(SAHARA_UTILS + ".SaharaScenario._generate_random_name",
|
||||
@mock.patch("rally.common.utils.generate_random_name",
|
||||
return_value="job_42")
|
||||
@mock.patch(SAHARA_JOB + "._run_job_execution")
|
||||
def test_create_launch_job_java(self, mock_run_execution,
|
||||
mock_random_name):
|
||||
def test_create_launch_job_java(self, mock__run_job_execution,
|
||||
mock_generate_random_name):
|
||||
|
||||
self.clients("sahara").jobs.create.return_value = mock.MagicMock(
|
||||
id="42")
|
||||
|
||||
@ -58,14 +59,14 @@ class SaharaJobTestCase(test.ClientsTestCase):
|
||||
job_idx=0
|
||||
)
|
||||
self.clients("sahara").jobs.create.assert_called_once_with(
|
||||
name=mock_random_name.return_value,
|
||||
name=mock_generate_random_name.return_value,
|
||||
type="java",
|
||||
description="",
|
||||
mains=["main_42"],
|
||||
libs=["lib_42"]
|
||||
)
|
||||
|
||||
mock_run_execution.assert_called_once_with(
|
||||
mock__run_job_execution.assert_called_once_with(
|
||||
job_id="42",
|
||||
cluster_id="cl_42",
|
||||
input_id=None,
|
||||
@ -74,13 +75,15 @@ class SaharaJobTestCase(test.ClientsTestCase):
|
||||
job_idx=0
|
||||
)
|
||||
|
||||
@mock.patch(SAHARA_UTILS + ".SaharaScenario._generate_random_name",
|
||||
@mock.patch("rally.common.utils.generate_random_name",
|
||||
return_value="job_42")
|
||||
@mock.patch(SAHARA_JOB + "._run_job_execution")
|
||||
@mock.patch(SAHARA_JOB + "._create_output_ds",
|
||||
return_value=mock.MagicMock(id="out_42"))
|
||||
def test_create_launch_job_pig(self, mock_create_ds,
|
||||
mock_run_execution, mock_random_name):
|
||||
def test_create_launch_job_pig(self, mock__create_output_ds,
|
||||
mock__run_job_execution,
|
||||
mock_generate_random_name):
|
||||
|
||||
self.clients("sahara").jobs.create.return_value = mock.MagicMock(
|
||||
id="42")
|
||||
|
||||
@ -101,14 +104,14 @@ class SaharaJobTestCase(test.ClientsTestCase):
|
||||
job_idx=0
|
||||
)
|
||||
self.clients("sahara").jobs.create.assert_called_once_with(
|
||||
name=mock_random_name.return_value,
|
||||
name=mock_generate_random_name.return_value,
|
||||
type="pig",
|
||||
description="",
|
||||
mains=["main_42"],
|
||||
libs=["lib_42"]
|
||||
)
|
||||
|
||||
mock_run_execution.assert_called_once_with(
|
||||
mock__run_job_execution.assert_called_once_with(
|
||||
job_id="42",
|
||||
cluster_id="cl_42",
|
||||
input_id="in_42",
|
||||
@ -117,11 +120,12 @@ class SaharaJobTestCase(test.ClientsTestCase):
|
||||
job_idx=0
|
||||
)
|
||||
|
||||
@mock.patch(SAHARA_UTILS + ".SaharaScenario._generate_random_name",
|
||||
@mock.patch("rally.common.utils.generate_random_name",
|
||||
return_value="job_42")
|
||||
@mock.patch(SAHARA_JOB + "._run_job_execution")
|
||||
def test_create_launch_job_sequence(self, mock_run_execution,
|
||||
mock_random_name):
|
||||
def test_create_launch_job_sequence(self, mock__run_job_execution,
|
||||
mock_generate_random_name):
|
||||
|
||||
self.clients("sahara").jobs.create.return_value = mock.MagicMock(
|
||||
id="42")
|
||||
|
||||
@ -147,7 +151,7 @@ class SaharaJobTestCase(test.ClientsTestCase):
|
||||
}])
|
||||
|
||||
jobs_create_call = mock.call(
|
||||
name=mock_random_name.return_value,
|
||||
name=mock_generate_random_name.return_value,
|
||||
type="java",
|
||||
description="",
|
||||
mains=["main_42"],
|
||||
@ -156,7 +160,7 @@ class SaharaJobTestCase(test.ClientsTestCase):
|
||||
self.clients("sahara").jobs.create.assert_has_calls([jobs_create_call,
|
||||
jobs_create_call])
|
||||
|
||||
mock_run_execution.assert_has_calls([
|
||||
mock__run_job_execution.assert_has_calls([
|
||||
mock.call(
|
||||
job_id="42",
|
||||
cluster_id="cl_42",
|
||||
@ -173,18 +177,18 @@ class SaharaJobTestCase(test.ClientsTestCase):
|
||||
job_idx=1)]
|
||||
)
|
||||
|
||||
@mock.patch(SAHARA_UTILS + ".SaharaScenario._generate_random_name",
|
||||
@mock.patch("rally.common.utils.generate_random_name",
|
||||
return_value="job_42")
|
||||
@mock.patch(SAHARA_JOB + "._run_job_execution")
|
||||
@mock.patch(SAHARA_JOB + "._scale_cluster")
|
||||
def test_create_launch_job_sequence_with_scaling(self, mock_scale,
|
||||
mock_run_execution,
|
||||
mock_random_name):
|
||||
def test_create_launch_job_sequence_with_scaling(
|
||||
self, mock__scale_cluster, mock__run_job_execution,
|
||||
mock_generate_random_name):
|
||||
|
||||
self.clients("sahara").jobs.create.return_value = mock.MagicMock(
|
||||
id="42")
|
||||
self.clients("sahara").clusters.get.return_value = mock.MagicMock(
|
||||
id="cl_42",
|
||||
status="active")
|
||||
id="cl_42", status="active")
|
||||
|
||||
jobs_scenario = jobs.SaharaJob()
|
||||
|
||||
@ -209,7 +213,7 @@ class SaharaJobTestCase(test.ClientsTestCase):
|
||||
deltas=[1, -1])
|
||||
|
||||
jobs_create_call = mock.call(
|
||||
name=mock_random_name.return_value,
|
||||
name=mock_generate_random_name.return_value,
|
||||
type="java",
|
||||
description="",
|
||||
mains=["main_42"],
|
||||
@ -224,5 +228,5 @@ class SaharaJobTestCase(test.ClientsTestCase):
|
||||
je_1 = mock.call(job_id="42", cluster_id="cl_42", input_id=None,
|
||||
output_id=None,
|
||||
configs={"conf_key2": "conf_val2"}, job_idx=1)
|
||||
mock_run_execution.assert_has_calls([je_0, je_1, je_0, je_1, je_0,
|
||||
je_1])
|
||||
mock__run_job_execution.assert_has_calls(
|
||||
[je_0, je_1, je_0, je_1, je_0, je_1])
|
||||
|
@ -30,33 +30,37 @@ class SaharaNodeGroupTemplatesTestCase(test.TestCase):
|
||||
return_value=object())
|
||||
@mock.patch(SAHARA_NGTS + "._create_worker_node_group_template",
|
||||
return_value=object)
|
||||
def test_create_and_list_node_group_templates(self, mock_create_worker,
|
||||
mock_create_master,
|
||||
mock_list):
|
||||
def test_create_and_list_node_group_templates(
|
||||
self,
|
||||
mock__create_worker_node_group_template,
|
||||
mock__create_master_node_group_template,
|
||||
mock__list_node_group_templates):
|
||||
|
||||
ngts_scenario = ngts.SaharaNodeGroupTemplates()
|
||||
ngts_scenario.create_and_list_node_group_templates("test_flavor",
|
||||
"test_plugin",
|
||||
"test_version")
|
||||
|
||||
mock_create_master.assert_called_once_with(
|
||||
mock__create_master_node_group_template.assert_called_once_with(
|
||||
flavor_id="test_flavor",
|
||||
plugin_name="test_plugin",
|
||||
hadoop_version="test_version")
|
||||
mock_create_worker.assert_called_once_with(
|
||||
mock__create_worker_node_group_template.assert_called_once_with(
|
||||
flavor_id="test_flavor",
|
||||
plugin_name="test_plugin",
|
||||
hadoop_version="test_version")
|
||||
mock_list.assert_called_once_with()
|
||||
mock__list_node_group_templates.assert_called_once_with()
|
||||
|
||||
@mock.patch(SAHARA_NGTS + "._delete_node_group_template")
|
||||
@mock.patch(SAHARA_NGTS + "._create_master_node_group_template",
|
||||
return_value=mock.MagicMock(id=1))
|
||||
@mock.patch(SAHARA_NGTS + "._create_worker_node_group_template",
|
||||
return_value=mock.MagicMock(id=2))
|
||||
def test_create_delete_node_group_templates(self, mock_create_worker,
|
||||
mock_create_master,
|
||||
mock_delete):
|
||||
def test_create_delete_node_group_templates(
|
||||
self,
|
||||
mock__create_worker_node_group_template,
|
||||
mock__create_master_node_group_template,
|
||||
mock__delete_node_group_template):
|
||||
|
||||
ngts_scenario = ngts.SaharaNodeGroupTemplates()
|
||||
ngts_scenario.create_delete_node_group_templates(
|
||||
@ -64,15 +68,15 @@ class SaharaNodeGroupTemplatesTestCase(test.TestCase):
|
||||
"test_plugin",
|
||||
"test_version")
|
||||
|
||||
mock_create_master.assert_called_once_with(
|
||||
mock__create_master_node_group_template.assert_called_once_with(
|
||||
flavor_id="test_flavor",
|
||||
plugin_name="test_plugin",
|
||||
hadoop_version="test_version")
|
||||
mock_create_worker.assert_called_once_with(
|
||||
mock__create_worker_node_group_template.assert_called_once_with(
|
||||
flavor_id="test_flavor",
|
||||
plugin_name="test_plugin",
|
||||
hadoop_version="test_version")
|
||||
|
||||
mock_delete.assert_has_calls(calls=[
|
||||
mock.call(mock_create_master.return_value),
|
||||
mock.call(mock_create_worker.return_value)])
|
||||
mock__delete_node_group_template.assert_has_calls(calls=[
|
||||
mock.call(mock__create_master_node_group_template.return_value),
|
||||
mock.call(mock__create_worker_node_group_template.return_value)])
|
||||
|
@ -28,10 +28,10 @@ CONF = cfg.CONF
|
||||
SAHARA_UTILS = "rally.plugins.openstack.scenarios.sahara.utils"
|
||||
|
||||
|
||||
class SaharaUtilsTestCase(test.ClientsTestCase):
|
||||
class SaharaScenarioTestCase(test.ClientsTestCase):
|
||||
|
||||
def setUp(self):
|
||||
super(SaharaUtilsTestCase, self).setUp()
|
||||
super(SaharaScenarioTestCase, self).setUp()
|
||||
|
||||
CONF.set_override("cluster_check_interval", 0, "benchmark")
|
||||
CONF.set_override("job_check_interval", 0, "benchmark")
|
||||
@ -50,8 +50,10 @@ class SaharaUtilsTestCase(test.ClientsTestCase):
|
||||
@mock.patch(SAHARA_UTILS + ".SaharaScenario._generate_random_name",
|
||||
return_value="random_name")
|
||||
@mock.patch(SAHARA_UTILS + ".sahara_consts")
|
||||
def test_create_node_group_templates(self, mock_constants,
|
||||
mock_random_name):
|
||||
def test_create_node_group_templates(
|
||||
self, mock_sahara_consts,
|
||||
mock__generate_random_name):
|
||||
|
||||
scenario = utils.SaharaScenario()
|
||||
mock_processes = {
|
||||
"test_plugin": {
|
||||
@ -62,7 +64,7 @@ class SaharaUtilsTestCase(test.ClientsTestCase):
|
||||
}
|
||||
}
|
||||
|
||||
mock_constants.NODE_PROCESSES = mock_processes
|
||||
mock_sahara_consts.NODE_PROCESSES = mock_processes
|
||||
|
||||
scenario._create_master_node_group_template(
|
||||
flavor_id="test_flavor",
|
||||
@ -114,7 +116,8 @@ class SaharaUtilsTestCase(test.ClientsTestCase):
|
||||
@mock.patch(SAHARA_UTILS + ".SaharaScenario._generate_random_name",
|
||||
return_value="random_name")
|
||||
@mock.patch(SAHARA_UTILS + ".sahara_consts")
|
||||
def test_launch_cluster(self, mock_constants, mock_random_name):
|
||||
def test_launch_cluster(self, mock_sahara_consts,
|
||||
mock__generate_random_name):
|
||||
|
||||
context = {
|
||||
"tenant": {
|
||||
@ -177,8 +180,8 @@ class SaharaUtilsTestCase(test.ClientsTestCase):
|
||||
}
|
||||
]
|
||||
|
||||
mock_constants.NODE_PROCESSES = mock_processes
|
||||
mock_constants.REPLICATION_CONFIGS = mock_configs
|
||||
mock_sahara_consts.NODE_PROCESSES = mock_processes
|
||||
mock_sahara_consts.REPLICATION_CONFIGS = mock_configs
|
||||
|
||||
self.clients("sahara").clusters.create.return_value = mock.MagicMock(
|
||||
id="test_cluster_id")
|
||||
@ -217,7 +220,9 @@ class SaharaUtilsTestCase(test.ClientsTestCase):
|
||||
@mock.patch(SAHARA_UTILS + ".SaharaScenario._generate_random_name",
|
||||
return_value="random_name")
|
||||
@mock.patch(SAHARA_UTILS + ".sahara_consts")
|
||||
def test_launch_cluster_error(self, mock_constants, mock_random_name):
|
||||
def test_launch_cluster_error(self, mock_sahara_consts,
|
||||
mock__generate_random_name):
|
||||
|
||||
scenario = utils.SaharaScenario(clients=mock.MagicMock())
|
||||
mock_processes = {
|
||||
"test_plugin": {
|
||||
@ -237,8 +242,8 @@ class SaharaUtilsTestCase(test.ClientsTestCase):
|
||||
}
|
||||
}
|
||||
|
||||
mock_constants.NODE_PROCESSES = mock_processes
|
||||
mock_constants.REPLICATION_CONFIGS = mock_configs
|
||||
mock_sahara_consts.NODE_PROCESSES = mock_processes
|
||||
mock_sahara_consts.REPLICATION_CONFIGS = mock_configs
|
||||
|
||||
self.clients("sahara").clusters.create.return_value = mock.MagicMock(
|
||||
id="test_cluster_id")
|
||||
@ -303,7 +308,7 @@ class SaharaUtilsTestCase(test.ClientsTestCase):
|
||||
|
||||
@mock.patch(SAHARA_UTILS + ".SaharaScenario._generate_random_name",
|
||||
return_value="42")
|
||||
def test_create_output_ds(self, mock_random_name):
|
||||
def test_create_output_ds(self, mock__generate_random_name):
|
||||
ctxt = {
|
||||
"sahara_output_conf": {
|
||||
"output_type": "hdfs",
|
||||
@ -323,7 +328,7 @@ class SaharaUtilsTestCase(test.ClientsTestCase):
|
||||
|
||||
@mock.patch(SAHARA_UTILS + ".SaharaScenario._generate_random_name",
|
||||
return_value="42")
|
||||
def test_create_output_ds_swift(self, mock_random_name):
|
||||
def test_create_output_ds_swift(self, mock__generate_random_name):
|
||||
ctxt = {
|
||||
"sahara_output_conf": {
|
||||
"output_type": "swift",
|
||||
|
@ -52,7 +52,7 @@ class VMScenarioTestCase(test.TestCase):
|
||||
mock_open.assert_called_once_with("foobar", "rb")
|
||||
|
||||
@mock.patch("%s.six.moves.StringIO" % VMTASKS_UTILS)
|
||||
def test__run_command_over_ssh_script_inline(self, mock_stringio):
|
||||
def test__run_command_over_ssh_script_inline(self, mock_string_io):
|
||||
mock_ssh = mock.MagicMock()
|
||||
vm_scenario = utils.VMScenario()
|
||||
vm_scenario._run_command_over_ssh(
|
||||
@ -64,8 +64,8 @@ class VMScenarioTestCase(test.TestCase):
|
||||
)
|
||||
mock_ssh.execute.assert_called_once_with(
|
||||
["interpreter", "interpreter_arg"],
|
||||
stdin=mock_stringio.return_value)
|
||||
mock_stringio.assert_called_once_with("foobar")
|
||||
stdin=mock_string_io.return_value)
|
||||
mock_string_io.assert_called_once_with("foobar")
|
||||
|
||||
def test__run_command_over_ssh_remote_path(self):
|
||||
mock_ssh = mock.MagicMock()
|
||||
@ -95,102 +95,93 @@ class VMScenarioTestCase(test.TestCase):
|
||||
@mock.patch(VMTASKS_UTILS + ".bench_utils.resource_is")
|
||||
@mock.patch(VMTASKS_UTILS + ".VMScenario._ping_ip_address",
|
||||
return_value=True)
|
||||
def test__wait_for_ping(self, mock__ping, mock_resource_is):
|
||||
def test__wait_for_ping(self, mock_vm_scenario__ping_ip_address,
|
||||
mock_resource_is):
|
||||
vm_scenario = utils.VMScenario()
|
||||
vm_scenario._wait_for_ping(netaddr.IPAddress("1.2.3.4"))
|
||||
self.wait_for.mock.assert_called_once_with(
|
||||
netaddr.IPAddress("1.2.3.4"),
|
||||
is_ready=mock_resource_is.return_value,
|
||||
timeout=120)
|
||||
mock_resource_is.assert_called_once_with("ICMP UP", mock__ping)
|
||||
mock_resource_is.assert_called_once_with(
|
||||
"ICMP UP", mock_vm_scenario__ping_ip_address)
|
||||
|
||||
@mock.patch(VMTASKS_UTILS + ".VMScenario._run_command_over_ssh")
|
||||
@mock.patch("rally.common.sshutils.SSH")
|
||||
def test__run_command(self, mock_ssh_class, mock_run_command_over_ssh):
|
||||
mock_ssh_instance = mock.MagicMock()
|
||||
mock_ssh_class.return_value = mock_ssh_instance
|
||||
|
||||
def test__run_command(self, mock_sshutils_ssh,
|
||||
mock_vm_scenario__run_command_over_ssh):
|
||||
vm_scenario = utils.VMScenario()
|
||||
vm_scenario.context = {"user": {"keypair": {"private": "ssh"}}}
|
||||
vm_scenario._run_command("1.2.3.4", 22, "username", "password",
|
||||
command={"script_file": "foo",
|
||||
"interpreter": "bar"})
|
||||
|
||||
mock_ssh_class.assert_called_once_with("username", "1.2.3.4", port=22,
|
||||
pkey="ssh",
|
||||
password="password")
|
||||
mock_ssh_instance.wait.assert_called_once_with()
|
||||
mock_run_command_over_ssh.assert_called_once_with(
|
||||
mock_ssh_instance,
|
||||
mock_sshutils_ssh.assert_called_once_with(
|
||||
"username", "1.2.3.4", port=22, pkey="ssh", password="password")
|
||||
mock_sshutils_ssh.return_value.wait.assert_called_once_with()
|
||||
mock_vm_scenario__run_command_over_ssh.assert_called_once_with(
|
||||
mock_sshutils_ssh.return_value,
|
||||
{"script_file": "foo", "interpreter": "bar"})
|
||||
|
||||
@mock.patch(VMTASKS_UTILS + ".sys")
|
||||
@mock.patch("subprocess.Popen")
|
||||
def test__ping_ip_address_linux(self, mock_subprocess, mock_sys):
|
||||
ping_process = mock.MagicMock()
|
||||
ping_process.returncode = 0
|
||||
mock_subprocess.return_value = ping_process
|
||||
def test__ping_ip_address_linux(self, mock_popen, mock_sys):
|
||||
mock_popen.return_value.returncode = 0
|
||||
mock_sys.platform = "linux2"
|
||||
|
||||
vm_scenario = utils.VMScenario()
|
||||
host_ip = netaddr.IPAddress("1.2.3.4")
|
||||
self.assertTrue(vm_scenario._ping_ip_address(host_ip))
|
||||
|
||||
mock_subprocess.assert_called_once_with(
|
||||
mock_popen.assert_called_once_with(
|
||||
["ping", "-c1", "-w1", str(host_ip)],
|
||||
stderr=subprocess.PIPE, stdout=subprocess.PIPE)
|
||||
ping_process.wait.assert_called_once_with()
|
||||
mock_popen.return_value.wait.assert_called_once_with()
|
||||
|
||||
@mock.patch(VMTASKS_UTILS + ".sys")
|
||||
@mock.patch("subprocess.Popen")
|
||||
def test__ping_ip_address_linux_ipv6(self, mock_subprocess, mock_sys):
|
||||
ping_process = mock.MagicMock()
|
||||
ping_process.returncode = 0
|
||||
mock_subprocess.return_value = ping_process
|
||||
def test__ping_ip_address_linux_ipv6(self, mock_popen, mock_sys):
|
||||
mock_popen.return_value.returncode = 0
|
||||
mock_sys.platform = "linux2"
|
||||
|
||||
vm_scenario = utils.VMScenario()
|
||||
host_ip = netaddr.IPAddress("1ce:c01d:bee2:15:a5:900d:a5:11fe")
|
||||
self.assertTrue(vm_scenario._ping_ip_address(host_ip))
|
||||
|
||||
mock_subprocess.assert_called_once_with(
|
||||
mock_popen.assert_called_once_with(
|
||||
["ping6", "-c1", "-w1", str(host_ip)],
|
||||
stderr=subprocess.PIPE, stdout=subprocess.PIPE)
|
||||
ping_process.wait.assert_called_once_with()
|
||||
mock_popen.return_value.wait.assert_called_once_with()
|
||||
|
||||
@mock.patch(VMTASKS_UTILS + ".sys")
|
||||
@mock.patch("subprocess.Popen")
|
||||
def test__ping_ip_address_other_os(self, mock_subprocess, mock_sys):
|
||||
ping_process = mock.MagicMock()
|
||||
ping_process.returncode = 0
|
||||
mock_subprocess.return_value = ping_process
|
||||
def test__ping_ip_address_other_os(self, mock_popen, mock_sys):
|
||||
mock_popen.return_value.returncode = 0
|
||||
mock_sys.platform = "freebsd10"
|
||||
|
||||
vm_scenario = utils.VMScenario()
|
||||
host_ip = netaddr.IPAddress("1.2.3.4")
|
||||
self.assertTrue(vm_scenario._ping_ip_address(host_ip))
|
||||
|
||||
mock_subprocess.assert_called_once_with(
|
||||
mock_popen.assert_called_once_with(
|
||||
["ping", "-c1", str(host_ip)],
|
||||
stderr=subprocess.PIPE, stdout=subprocess.PIPE)
|
||||
ping_process.wait.assert_called_once_with()
|
||||
mock_popen.return_value.wait.assert_called_once_with()
|
||||
|
||||
@mock.patch(VMTASKS_UTILS + ".sys")
|
||||
@mock.patch("subprocess.Popen")
|
||||
def test__ping_ip_address_other_os_ipv6(self, mock_subprocess, mock_sys):
|
||||
ping_process = mock.MagicMock()
|
||||
ping_process.returncode = 0
|
||||
mock_subprocess.return_value = ping_process
|
||||
def test__ping_ip_address_other_os_ipv6(self, mock_popen, mock_sys):
|
||||
mock_popen.return_value.returncode = 0
|
||||
mock_sys.platform = "freebsd10"
|
||||
|
||||
vm_scenario = utils.VMScenario()
|
||||
host_ip = netaddr.IPAddress("1ce:c01d:bee2:15:a5:900d:a5:11fe")
|
||||
self.assertTrue(vm_scenario._ping_ip_address(host_ip))
|
||||
|
||||
mock_subprocess.assert_called_once_with(
|
||||
mock_popen.assert_called_once_with(
|
||||
["ping6", "-c1", str(host_ip)],
|
||||
stderr=subprocess.PIPE, stdout=subprocess.PIPE)
|
||||
ping_process.wait.assert_called_once_with()
|
||||
mock_popen.return_value.wait.assert_called_once_with()
|
||||
|
||||
def get_scenario(self):
|
||||
server = mock.Mock(
|
||||
|
@ -24,14 +24,14 @@ BASIC = BASE + "basic.ZaqarBasic."
|
||||
class ZaqarBasicTestCase(test.TestCase):
|
||||
|
||||
@mock.patch(BASIC + "_generate_random_name", return_value="fizbit")
|
||||
def test_create_queue(self, mock_gen_name):
|
||||
def test_create_queue(self, mock__generate_random_name):
|
||||
scenario = basic.ZaqarBasic()
|
||||
scenario._queue_create = mock.MagicMock()
|
||||
scenario.create_queue(name_length=10)
|
||||
scenario._queue_create.assert_called_once_with(name_length=10)
|
||||
|
||||
@mock.patch(BASIC + "_generate_random_name", return_value="kitkat")
|
||||
def test_producer_consumer(self, mock_gen_name):
|
||||
def test_producer_consumer(self, mock__generate_random_name):
|
||||
scenario = basic.ZaqarBasic()
|
||||
messages = [{"body": {"id": idx}, "ttl": 360} for idx
|
||||
in range(20)]
|
||||
|
@ -25,7 +25,7 @@ class ZaqarScenarioTestCase(test.ClientsTestCase):
|
||||
|
||||
@mock.patch(UTILS + "ZaqarScenario._generate_random_name",
|
||||
return_value="kitkat")
|
||||
def test_queue_create(self, mock_gen_name):
|
||||
def test_queue_create(self, mock__generate_random_name):
|
||||
scenario = utils.ZaqarScenario()
|
||||
result = scenario._queue_create(name_length=10)
|
||||
|
||||
|
@ -45,21 +45,24 @@ class NovaNetworkWrapperTestCase(test.TestCase):
|
||||
service.client.networks.list.assert_called_once_with()
|
||||
|
||||
@mock.patch("rally.plugins.openstack.wrappers.network.generate_cidr")
|
||||
def test__generate_cidr(self, mock_cidr):
|
||||
def test__generate_cidr(self, mock_generate_cidr):
|
||||
skip_cidrs = [5, 7]
|
||||
cidrs = iter(range(7))
|
||||
mock_cidr.side_effect = lambda start_cidr: start_cidr + next(cidrs)
|
||||
mock_generate_cidr.side_effect = (
|
||||
lambda start_cidr: start_cidr + next(cidrs)
|
||||
)
|
||||
service = self.get_wrapper(*skip_cidrs, start_cidr=3)
|
||||
self.assertEqual(service._generate_cidr(), 3)
|
||||
self.assertEqual(service._generate_cidr(), 4)
|
||||
self.assertEqual(service._generate_cidr(), 6) # 5 is skipped
|
||||
self.assertEqual(service._generate_cidr(), 8) # 7 is skipped
|
||||
self.assertEqual(service._generate_cidr(), 9)
|
||||
self.assertEqual(mock_cidr.mock_calls, [mock.call(start_cidr=3)] * 7)
|
||||
self.assertEqual(mock_generate_cidr.mock_calls,
|
||||
[mock.call(start_cidr=3)] * 7)
|
||||
|
||||
@mock.patch("rally.common.utils.generate_random_name",
|
||||
return_value="foo_name")
|
||||
def test_create_network(self, mock_name):
|
||||
def test_create_network(self, mock_generate_random_name):
|
||||
service = self.get_wrapper()
|
||||
service.client.networks.create.side_effect = (
|
||||
lambda **kwargs: self.Net(id="foo_id", **kwargs))
|
||||
@ -71,7 +74,7 @@ class NovaNetworkWrapperTestCase(test.TestCase):
|
||||
"status": "ACTIVE",
|
||||
"external": False,
|
||||
"tenant_id": "foo_tenant"})
|
||||
mock_name.assert_called_once_with("rally_net_")
|
||||
mock_generate_random_name.assert_called_once_with("rally_net_")
|
||||
service._generate_cidr.assert_called_once_with()
|
||||
service.client.networks.create.assert_called_once_with(
|
||||
tenant_id="foo_tenant", cidr="foo_cidr", label="foo_name")
|
||||
@ -152,16 +155,19 @@ class NeutronWrapperTestCase(test.TestCase):
|
||||
self.assertEqual(network.NeutronWrapper.SUBNET_IP_VERSION, 4)
|
||||
|
||||
@mock.patch("rally.plugins.openstack.wrappers.network.generate_cidr")
|
||||
def test__generate_cidr(self, mock_cidr):
|
||||
def test__generate_cidr(self, mock_generate_cidr):
|
||||
cidrs = iter(range(5))
|
||||
mock_cidr.side_effect = lambda start_cidr: start_cidr + next(cidrs)
|
||||
mock_generate_cidr.side_effect = (
|
||||
lambda start_cidr: start_cidr + next(cidrs)
|
||||
)
|
||||
service = self.get_wrapper(start_cidr=3)
|
||||
self.assertEqual(service._generate_cidr(), 3)
|
||||
self.assertEqual(service._generate_cidr(), 4)
|
||||
self.assertEqual(service._generate_cidr(), 5)
|
||||
self.assertEqual(service._generate_cidr(), 6)
|
||||
self.assertEqual(service._generate_cidr(), 7)
|
||||
self.assertEqual(mock_cidr.mock_calls, [mock.call(start_cidr=3)] * 5)
|
||||
self.assertEqual(mock_generate_cidr.mock_calls,
|
||||
[mock.call(start_cidr=3)] * 5)
|
||||
|
||||
def test_external_networks(self):
|
||||
wrap = self.get_wrapper()
|
||||
@ -205,15 +211,15 @@ class NeutronWrapperTestCase(test.TestCase):
|
||||
name="foo_name")
|
||||
|
||||
@mock.patch("rally.common.utils.generate_random_name")
|
||||
def test_create_network(self, mock_name):
|
||||
mock_name.return_value = "foo_name"
|
||||
def test_create_network(self, mock_generate_random_name):
|
||||
mock_generate_random_name.return_value = "foo_name"
|
||||
service = self.get_wrapper()
|
||||
service.client.create_network.return_value = {
|
||||
"network": {"id": "foo_id",
|
||||
"name": "foo_name",
|
||||
"status": "foo_status"}}
|
||||
net = service.create_network("foo_tenant")
|
||||
mock_name.assert_called_once_with("rally_net_")
|
||||
mock_generate_random_name.assert_called_once_with("rally_net_")
|
||||
service.client.create_network.assert_called_once_with({
|
||||
"network": {"tenant_id": "foo_tenant", "name": "foo_name"}})
|
||||
self.assertEqual(net, {"id": "foo_id",
|
||||
@ -225,9 +231,9 @@ class NeutronWrapperTestCase(test.TestCase):
|
||||
"subnets": []})
|
||||
|
||||
@mock.patch("rally.common.utils.generate_random_name")
|
||||
def test_create_network_with_subnets(self, mock_name):
|
||||
def test_create_network_with_subnets(self, mock_generate_random_name):
|
||||
subnets_num = 4
|
||||
mock_name.return_value = "foo_name"
|
||||
mock_generate_random_name.return_value = "foo_name"
|
||||
service = self.get_wrapper()
|
||||
subnets_cidrs = iter(range(subnets_num))
|
||||
subnets_ids = iter(range(subnets_num))
|
||||
@ -263,8 +269,8 @@ class NeutronWrapperTestCase(test.TestCase):
|
||||
for i in range(subnets_num)])
|
||||
|
||||
@mock.patch("rally.common.utils.generate_random_name")
|
||||
def test_create_network_with_router(self, mock_name):
|
||||
mock_name.return_value = "foo_name"
|
||||
def test_create_network_with_router(self, mock_generate_random_name):
|
||||
mock_generate_random_name.return_value = "foo_name"
|
||||
service = self.get_wrapper()
|
||||
service.create_router = mock.Mock(return_value={"id": "foo_router"})
|
||||
service.client.create_network.return_value = {
|
||||
@ -283,9 +289,10 @@ class NeutronWrapperTestCase(test.TestCase):
|
||||
tenant_id="foo_tenant")
|
||||
|
||||
@mock.patch("rally.common.utils.generate_random_name")
|
||||
def test_create_network_with_router_and_subnets(self, mock_name):
|
||||
def test_create_network_with_router_and_subnets(self,
|
||||
mock_generate_random_name):
|
||||
subnets_num = 4
|
||||
mock_name.return_value = "foo_name"
|
||||
mock_generate_random_name.return_value = "foo_name"
|
||||
service = self.get_wrapper()
|
||||
service._generate_cidr = mock.Mock(return_value="foo_cidr")
|
||||
service.create_router = mock.Mock(return_value={"id": "foo_router"})
|
||||
@ -375,7 +382,7 @@ class NeutronWrapperTestCase(test.TestCase):
|
||||
service.client.list_networks.assert_called_once_with()
|
||||
|
||||
@mock.patch(SVC + "NeutronWrapper.external_networks")
|
||||
def test_create_floating_ip(self, mock_ext_networks):
|
||||
def test_create_floating_ip(self, mock_neutron_wrapper_external_networks):
|
||||
wrap = self.get_wrapper()
|
||||
wrap.create_port = mock.Mock(return_value={"id": "port_id"})
|
||||
wrap.client.create_floatingip = mock.Mock(
|
||||
@ -384,11 +391,13 @@ class NeutronWrapperTestCase(test.TestCase):
|
||||
|
||||
self.assertRaises(ValueError, wrap.create_floating_ip)
|
||||
|
||||
mock_ext_networks.__get__ = lambda *args: []
|
||||
mock_neutron_wrapper_external_networks.__get__ = lambda *args: []
|
||||
self.assertRaises(network.NetworkWrapperException,
|
||||
wrap.create_floating_ip, tenant_id="foo_tenant")
|
||||
|
||||
mock_ext_networks.__get__ = lambda *args: [{"id": "ext_id"}]
|
||||
mock_neutron_wrapper_external_networks.__get__ = (
|
||||
lambda *args: [{"id": "ext_id"}]
|
||||
)
|
||||
fip = wrap.create_floating_ip(tenant_id="foo_tenant")
|
||||
self.assertEqual(fip, {"id": "fip_id", "ip": "fip_ip"})
|
||||
|
||||
@ -416,11 +425,14 @@ class NeutronWrapperTestCase(test.TestCase):
|
||||
|
||||
@mock.patch(SVC + "NeutronWrapper.external_networks")
|
||||
@mock.patch("rally.common.utils.generate_random_name")
|
||||
def test_create_router(self, mock_random, mock_ext_networks):
|
||||
def test_create_router(self, mock_generate_random_name,
|
||||
mock_neutron_wrapper_external_networks):
|
||||
wrap = self.get_wrapper()
|
||||
mock_random.return_value = "random_name"
|
||||
mock_generate_random_name.return_value = "random_name"
|
||||
wrap.client.create_router.return_value = {"router": "foo_router"}
|
||||
mock_ext_networks.__get__ = lambda *args: [{"id": "ext_id"}]
|
||||
mock_neutron_wrapper_external_networks.__get__ = (
|
||||
lambda *args: [{"id": "ext_id"}]
|
||||
)
|
||||
|
||||
router = wrap.create_router(name="foo_name")
|
||||
wrap.client.create_router.assert_called_once_with(
|
||||
@ -436,9 +448,9 @@ class NeutronWrapperTestCase(test.TestCase):
|
||||
"foo": "bar"}})
|
||||
|
||||
@mock.patch("rally.common.utils.generate_random_name")
|
||||
def test_create_port(self, mock_random):
|
||||
def test_create_port(self, mock_generate_random_name):
|
||||
wrap = self.get_wrapper()
|
||||
mock_random.return_value = "random_name"
|
||||
mock_generate_random_name.return_value = "random_name"
|
||||
wrap.client.create_port.return_value = {"port": "foo_port"}
|
||||
|
||||
port = wrap.create_port("foo_net", name="foo_name")
|
||||
|
@ -30,7 +30,8 @@ class RallyJobsTestCase(test.TestCase):
|
||||
|
||||
@mock.patch("rally.benchmark.engine.BenchmarkEngine"
|
||||
"._validate_config_semantic")
|
||||
def test_schema_is_valid(self, mock_validate):
|
||||
def test_schema_is_valid(
|
||||
self, mock_benchmark_engine__validate_config_semantic):
|
||||
discover.load_plugins(os.path.join(self.rally_jobs_path, "plugins"))
|
||||
|
||||
for filename in ["rally.yaml", "rally-neutron.yaml",
|
||||
|
Loading…
Reference in New Issue
Block a user