Merge "[Verify] Fixing issue with discovering images"
This commit is contained in:
commit
09aec84887
@ -650,13 +650,13 @@
|
||||
# Image container format to use when creating the image (string value)
|
||||
#container_format = bare
|
||||
|
||||
# Regular expression for name of an image to discover it in the cloud
|
||||
# and use it for the tests. Note that when Rally is searching for the
|
||||
# image, case insensitive matching is performed. Specify nothing
|
||||
# ('name_regex =') if you want to disable discovering. In this case
|
||||
# Rally will create needed resources by itself if the values for the
|
||||
# corresponding config options are not specified in the Tempest config
|
||||
# file (string value)
|
||||
# Regular expression for name of a public image to discover it in the
|
||||
# cloud and use it for the tests. Note that when Rally is searching
|
||||
# for the image, case insensitive matching is performed. Specify
|
||||
# nothing ('name_regex =') if you want to disable discovering. In this
|
||||
# case Rally will create needed resources by itself if the values for
|
||||
# the corresponding config options are not specified in the Tempest
|
||||
# config file (string value)
|
||||
#name_regex = ^.*(cirros|testvm).*$
|
||||
|
||||
|
||||
@ -689,7 +689,7 @@
|
||||
|
||||
# How many concurrent threads use for serving users context (integer
|
||||
# value)
|
||||
#resource_management_workers = 30
|
||||
#resource_management_workers = 20
|
||||
|
||||
# ID of domain in which projects will be created. (string value)
|
||||
#project_domain = default
|
||||
|
@ -50,14 +50,14 @@ IMAGE_OPTS = [
|
||||
help="Image container format to use when creating the image"),
|
||||
cfg.StrOpt("name_regex",
|
||||
default="^.*(cirros|testvm).*$",
|
||||
help="Regular expression for name of an image to discover it "
|
||||
"in the cloud and use it for the tests. Note that when "
|
||||
"Rally is searching for the image, case insensitive "
|
||||
"matching is performed. Specify nothing ('name_regex =') "
|
||||
"if you want to disable discovering. In this case Rally "
|
||||
"will create needed resources by itself if the values "
|
||||
"for the corresponding config options are not specified "
|
||||
"in the Tempest config file")
|
||||
help="Regular expression for name of a public image to "
|
||||
"discover it in the cloud and use it for the tests. "
|
||||
"Note that when Rally is searching for the image, case "
|
||||
"insensitive matching is performed. Specify nothing "
|
||||
"('name_regex =') if you want to disable discovering. "
|
||||
"In this case Rally will create needed resources by "
|
||||
"itself if the values for the corresponding config "
|
||||
"options are not specified in the Tempest config file")
|
||||
]
|
||||
|
||||
ROLE_OPTS = [
|
||||
@ -422,18 +422,20 @@ class TempestResourcesContext(utils.RandomNameGeneratorMixin):
|
||||
glance_wrap = glance_wrapper.wrap(self.clients.glance, self)
|
||||
|
||||
if CONF.image.name_regex:
|
||||
LOG.debug("Trying to discover an image with name matching "
|
||||
LOG.debug("Trying to discover a public image with name matching "
|
||||
"regular expression '%s'. Note that case insensitive "
|
||||
"matching is performed" % CONF.image.name_regex)
|
||||
img_list = [img for img in self.clients.glance().images.list()
|
||||
if img.status.lower() == "active" and img.name]
|
||||
for img in img_list:
|
||||
if re.match(CONF.image.name_regex, img.name, re.IGNORECASE):
|
||||
LOG.debug("The following image discovered: '{0}'. Using "
|
||||
"image '{0}' for the tests".format(img.name))
|
||||
images = glance_wrap.list_images(status="active",
|
||||
visibility="public")
|
||||
for img in images:
|
||||
if img.name and re.match(CONF.image.name_regex,
|
||||
img.name, re.IGNORECASE):
|
||||
LOG.debug(
|
||||
"The following public image discovered: '{0}'. "
|
||||
"Using image '{0}' for the tests".format(img.name))
|
||||
return img
|
||||
|
||||
LOG.debug("There is no image with name matching "
|
||||
LOG.debug("There is no public image with name matching "
|
||||
"regular expression '%s'" % CONF.image.name_regex)
|
||||
|
||||
params = {
|
||||
@ -442,7 +444,7 @@ class TempestResourcesContext(utils.RandomNameGeneratorMixin):
|
||||
"container_format": CONF.image.container_format,
|
||||
"image_location": os.path.join(_create_or_get_data_dir(),
|
||||
self.image_name),
|
||||
"is_public": True
|
||||
"visibility": "public"
|
||||
}
|
||||
LOG.debug("Creating image '%s'" % params["name"])
|
||||
image = glance_wrap.create_image(**params)
|
||||
|
@ -404,22 +404,14 @@ class TempestResourcesContextTestCase(test.TestCase):
|
||||
|
||||
@mock.patch("rally.plugins.openstack.wrappers.glance.wrap")
|
||||
def test__discover_or_create_image_when_image_exists(self, mock_wrap):
|
||||
client = self.context.clients.glance()
|
||||
client.images.list.return_value = [fakes.FakeImage(name="CirrOS",
|
||||
status="active")]
|
||||
client = mock_wrap.return_value
|
||||
client.list_images.return_value = [fakes.FakeImage(name="CirrOS")]
|
||||
|
||||
image = self.context._discover_or_create_image()
|
||||
self.assertEqual("CirrOS", image.name)
|
||||
self.assertEqual(0, client.create_image.call_count)
|
||||
self.assertEqual(0, len(self.context._created_images))
|
||||
|
||||
# @mock.patch("six.moves.builtins.open")
|
||||
# def test__discover_or_create_image(self, mock_wrap, mock_open):
|
||||
# client = self.context.clients.glance()
|
||||
# client.images.create.side_effect = [fakes.FakeImage(id="id1")]
|
||||
|
||||
# image = self.context._discover_or_create_image()
|
||||
# self.assertEqual("id1", image.id)
|
||||
# self.assertEqual("id1", self.context._created_images[0].id)
|
||||
|
||||
@mock.patch("rally.plugins.openstack.wrappers.glance.wrap")
|
||||
def test__discover_or_create_image(self, mock_wrap):
|
||||
client = mock_wrap.return_value
|
||||
@ -435,7 +427,7 @@ class TempestResourcesContextTestCase(test.TestCase):
|
||||
image_location=mock.ANY,
|
||||
disk_format=CONF.image.disk_format,
|
||||
name=mock.ANY,
|
||||
is_public=True)
|
||||
visibility="public")
|
||||
|
||||
def test__discover_or_create_flavor_when_flavor_exists(self):
|
||||
client = self.context.clients.nova()
|
||||
|
Loading…
x
Reference in New Issue
Block a user