Merge "Add option to configure flavor disk size"
This commit is contained in:
commit
e62315115a
|
@ -67,6 +67,15 @@ OPTS = {"openstack": [
|
||||||
deprecated_group="tempest",
|
deprecated_group="tempest",
|
||||||
help="Alternate reference flavor RAM size used by test that "
|
help="Alternate reference flavor RAM size used by test that "
|
||||||
"need two flavors, like those that resize an instance"),
|
"need two flavors, like those that resize an instance"),
|
||||||
|
cfg.IntOpt("flavor_ref_disk",
|
||||||
|
default="5",
|
||||||
|
help="Primary flavor disk size in GiB used by most of the test "
|
||||||
|
"cases"),
|
||||||
|
cfg.IntOpt("flavor_ref_alt_disk",
|
||||||
|
default="5",
|
||||||
|
help="Alternate reference flavor disk size in GiB used by "
|
||||||
|
"tests that need two flavors, like those that resize an "
|
||||||
|
"instance"),
|
||||||
cfg.IntOpt("heat_instance_type_ram",
|
cfg.IntOpt("heat_instance_type_ram",
|
||||||
default="64",
|
default="64",
|
||||||
deprecated_group="tempest",
|
deprecated_group="tempest",
|
||||||
|
|
|
@ -76,10 +76,13 @@ class TempestContext(context.VerifierContext):
|
||||||
helper_method=self._discover_or_create_image)
|
helper_method=self._discover_or_create_image)
|
||||||
self._configure_option("compute", "flavor_ref",
|
self._configure_option("compute", "flavor_ref",
|
||||||
helper_method=self._discover_or_create_flavor,
|
helper_method=self._discover_or_create_flavor,
|
||||||
flv_ram=conf.CONF.openstack.flavor_ref_ram)
|
flv_ram=conf.CONF.openstack.flavor_ref_ram,
|
||||||
|
flv_disk=conf.CONF.openstack.flavor_ref_disk)
|
||||||
self._configure_option("compute", "flavor_ref_alt",
|
self._configure_option("compute", "flavor_ref_alt",
|
||||||
helper_method=self._discover_or_create_flavor,
|
helper_method=self._discover_or_create_flavor,
|
||||||
flv_ram=conf.CONF.openstack.flavor_ref_alt_ram)
|
flv_ram=conf.CONF.openstack.flavor_ref_alt_ram,
|
||||||
|
flv_disk=conf.CONF.openstack.flavor_ref_alt_disk
|
||||||
|
)
|
||||||
if "neutron" in self.available_services:
|
if "neutron" in self.available_services:
|
||||||
neutronclient = self.clients.neutron()
|
neutronclient = self.clients.neutron()
|
||||||
if neutronclient.list_networks(shared=True)["networks"]:
|
if neutronclient.list_networks(shared=True)["networks"]:
|
||||||
|
@ -242,14 +245,15 @@ class TempestContext(context.VerifierContext):
|
||||||
|
|
||||||
return image_obj
|
return image_obj
|
||||||
|
|
||||||
def _discover_or_create_flavor(self, flv_ram):
|
def _discover_or_create_flavor(self, flv_ram, flv_disk):
|
||||||
novaclient = self.clients.nova()
|
novaclient = self.clients.nova()
|
||||||
|
|
||||||
LOG.debug("Trying to discover a flavor with the following "
|
LOG.debug("Trying to discover a flavor with the following properties: "
|
||||||
"properties: RAM = %dMB, VCPUs = 1, disk = 0GB." % flv_ram)
|
"RAM = %(ram)dMB, VCPUs = 1, disk >= %(disk)dGiB." %
|
||||||
|
{"ram": flv_ram, "disk": flv_disk})
|
||||||
for flavor in novaclient.flavors.list():
|
for flavor in novaclient.flavors.list():
|
||||||
if (flavor.ram == flv_ram and
|
if (flavor.ram == flv_ram and
|
||||||
flavor.vcpus == 1 and flavor.disk == 0):
|
flavor.vcpus == 1 and flavor.disk >= flv_disk):
|
||||||
LOG.debug("The following flavor discovered: '{0}'. "
|
LOG.debug("The following flavor discovered: '{0}'. "
|
||||||
"Using flavor '{0}' (ID = {1}) for the tests."
|
"Using flavor '{0}' (ID = {1}) for the tests."
|
||||||
.format(flavor.name, flavor.id))
|
.format(flavor.name, flavor.id))
|
||||||
|
@ -261,10 +265,11 @@ class TempestContext(context.VerifierContext):
|
||||||
"name": self.generate_random_name(),
|
"name": self.generate_random_name(),
|
||||||
"ram": flv_ram,
|
"ram": flv_ram,
|
||||||
"vcpus": 1,
|
"vcpus": 1,
|
||||||
"disk": 0
|
"disk": flv_disk
|
||||||
}
|
}
|
||||||
LOG.debug("Creating flavor '%s' with the following properties: RAM "
|
LOG.debug("Creating flavor '%s' with the following properties: RAM "
|
||||||
"= %dMB, VCPUs = 1, disk = 0GB." % (params["name"], flv_ram))
|
"= %dMB, VCPUs = 1, disk = %dGB." %
|
||||||
|
(params["name"], flv_ram, flv_disk))
|
||||||
flavor = novaclient.flavors.create(**params)
|
flavor = novaclient.flavors.create(**params)
|
||||||
LOG.debug("Flavor '%s' (ID = %s) has been successfully created!"
|
LOG.debug("Flavor '%s' (ID = %s) has been successfully created!"
|
||||||
% (flavor.name, flavor.id))
|
% (flavor.name, flavor.id))
|
||||||
|
|
|
@ -200,7 +200,8 @@ class TempestContextTestCase(test.TestCase):
|
||||||
|
|
||||||
self.context.conf.set("compute", "flavor_ref", "")
|
self.context.conf.set("compute", "flavor_ref", "")
|
||||||
self.context._configure_option("compute", "flavor_ref",
|
self.context._configure_option("compute", "flavor_ref",
|
||||||
helper_method=helper_method, flv_ram=64)
|
helper_method=helper_method, flv_ram=64,
|
||||||
|
flv_disk=5)
|
||||||
self.assertEqual(1, helper_method.call_count)
|
self.assertEqual(1, helper_method.call_count)
|
||||||
|
|
||||||
result = self.context.conf.get("compute", "flavor_ref")
|
result = self.context.conf.get("compute", "flavor_ref")
|
||||||
|
@ -234,9 +235,9 @@ class TempestContextTestCase(test.TestCase):
|
||||||
def test__discover_or_create_flavor_when_flavor_exists(self):
|
def test__discover_or_create_flavor_when_flavor_exists(self):
|
||||||
client = self.context.clients.nova()
|
client = self.context.clients.nova()
|
||||||
client.flavors.list.return_value = [fakes.FakeFlavor(id="id1", ram=64,
|
client.flavors.list.return_value = [fakes.FakeFlavor(id="id1", ram=64,
|
||||||
vcpus=1, disk=0)]
|
vcpus=1, disk=5)]
|
||||||
|
|
||||||
flavor = self.context._discover_or_create_flavor(64)
|
flavor = self.context._discover_or_create_flavor(64, 5)
|
||||||
self.assertEqual("id1", flavor.id)
|
self.assertEqual("id1", flavor.id)
|
||||||
self.assertEqual(0, len(self.context._created_flavors))
|
self.assertEqual(0, len(self.context._created_flavors))
|
||||||
|
|
||||||
|
@ -245,7 +246,7 @@ class TempestContextTestCase(test.TestCase):
|
||||||
client.flavors.list.return_value = []
|
client.flavors.list.return_value = []
|
||||||
client.flavors.create.side_effect = [fakes.FakeFlavor(id="id1")]
|
client.flavors.create.side_effect = [fakes.FakeFlavor(id="id1")]
|
||||||
|
|
||||||
flavor = self.context._discover_or_create_flavor(64)
|
flavor = self.context._discover_or_create_flavor(64, 5)
|
||||||
self.assertEqual("id1", flavor.id)
|
self.assertEqual("id1", flavor.id)
|
||||||
self.assertEqual("id1", self.context._created_flavors[0].id)
|
self.assertEqual("id1", self.context._created_flavors[0].id)
|
||||||
|
|
||||||
|
@ -363,10 +364,12 @@ class TempestContextTestCase(test.TestCase):
|
||||||
helper_method=ctx._discover_or_create_image),
|
helper_method=ctx._discover_or_create_image),
|
||||||
mock.call("compute", "flavor_ref",
|
mock.call("compute", "flavor_ref",
|
||||||
helper_method=ctx._discover_or_create_flavor,
|
helper_method=ctx._discover_or_create_flavor,
|
||||||
flv_ram=config.CONF.openstack.flavor_ref_ram),
|
flv_ram=config.CONF.openstack.flavor_ref_ram,
|
||||||
|
flv_disk=config.CONF.openstack.flavor_ref_disk),
|
||||||
mock.call("compute", "flavor_ref_alt",
|
mock.call("compute", "flavor_ref_alt",
|
||||||
helper_method=ctx._discover_or_create_flavor,
|
helper_method=ctx._discover_or_create_flavor,
|
||||||
flv_ram=config.CONF.openstack.flavor_ref_alt_ram)],
|
flv_ram=config.CONF.openstack.flavor_ref_alt_ram,
|
||||||
|
flv_disk=config.CONF.openstack.flavor_ref_alt_disk)],
|
||||||
mock__configure_option.call_args_list)
|
mock__configure_option.call_args_list)
|
||||||
|
|
||||||
mock_create_dir.reset_mock()
|
mock_create_dir.reset_mock()
|
||||||
|
@ -401,10 +404,12 @@ class TempestContextTestCase(test.TestCase):
|
||||||
helper_method=ctx._discover_or_create_image),
|
helper_method=ctx._discover_or_create_image),
|
||||||
mock.call("compute", "flavor_ref",
|
mock.call("compute", "flavor_ref",
|
||||||
helper_method=ctx._discover_or_create_flavor,
|
helper_method=ctx._discover_or_create_flavor,
|
||||||
flv_ram=config.CONF.openstack.flavor_ref_ram),
|
flv_ram=config.CONF.openstack.flavor_ref_ram,
|
||||||
|
flv_disk=config.CONF.openstack.flavor_ref_disk),
|
||||||
mock.call("compute", "flavor_ref_alt",
|
mock.call("compute", "flavor_ref_alt",
|
||||||
helper_method=ctx._discover_or_create_flavor,
|
helper_method=ctx._discover_or_create_flavor,
|
||||||
flv_ram=config.CONF.openstack.flavor_ref_alt_ram),
|
flv_ram=config.CONF.openstack.flavor_ref_alt_ram,
|
||||||
|
flv_disk=config.CONF.openstack.flavor_ref_alt_disk),
|
||||||
mock.call("compute", "fixed_network_name",
|
mock.call("compute", "fixed_network_name",
|
||||||
helper_method=ctx._create_network_resources),
|
helper_method=ctx._create_network_resources),
|
||||||
mock.call("orchestration", "instance_type",
|
mock.call("orchestration", "instance_type",
|
||||||
|
|
Loading…
Reference in New Issue