Ubuntu tests use image_file instead of image_url
In a previous patch, the tobiko roles where modified to download Ubuntu images prior to test execution With this patch, the Ubuntu tests stop downloading images and use the previously downloaded images instead Depends-On: I1dbf739850bfc3f963a789db0dcd2625ffe4a16f Change-Id: I8d0bc73bf1bb2e031a61b39d24fc1442978f07bd
This commit is contained in:
parent
4ad11e3710
commit
8b3fe3074b
@ -185,7 +185,7 @@ class GlanceImageFixture(_client.HasGlanceClientMixin, tobiko.SharedFixture):
|
||||
expected_status=expected_status)
|
||||
|
||||
|
||||
class UploadGranceImageFixture(GlanceImageFixture):
|
||||
class UploadGlanceImageFixture(GlanceImageFixture):
|
||||
|
||||
disk_format = "raw"
|
||||
container_format = "bare"
|
||||
@ -194,7 +194,7 @@ class UploadGranceImageFixture(GlanceImageFixture):
|
||||
|
||||
def __init__(self, disk_format=None, container_format=None, tags=None,
|
||||
**kwargs):
|
||||
super(UploadGranceImageFixture, self).__init__(**kwargs)
|
||||
super(UploadGlanceImageFixture, self).__init__(**kwargs)
|
||||
|
||||
if container_format:
|
||||
self.container_format = container_format
|
||||
@ -296,7 +296,7 @@ class UploadGranceImageFixture(GlanceImageFixture):
|
||||
raise NotImplementedError
|
||||
|
||||
|
||||
class FileGlanceImageFixture(UploadGranceImageFixture):
|
||||
class FileGlanceImageFixture(UploadGlanceImageFixture):
|
||||
|
||||
image_file = None
|
||||
image_dir = None
|
||||
@ -331,6 +331,7 @@ class FileGlanceImageFixture(UploadGranceImageFixture):
|
||||
return self.get_image_file(image_file=self.real_image_file)
|
||||
|
||||
def get_image_file(self, image_file: str):
|
||||
image_file = self.customize_image_file(base_file=image_file)
|
||||
image_size = os.path.getsize(image_file)
|
||||
LOG.debug('Uploading image %r data from file %r (%d bytes)',
|
||||
self.image_name, image_file, image_size)
|
||||
@ -339,6 +340,9 @@ class FileGlanceImageFixture(UploadGranceImageFixture):
|
||||
compression_type=self.compression_type)
|
||||
return image_data, image_size
|
||||
|
||||
def customize_image_file(self, base_file: str) -> str:
|
||||
return base_file
|
||||
|
||||
|
||||
class URLGlanceImageFixture(FileGlanceImageFixture):
|
||||
|
||||
@ -387,7 +391,6 @@ class URLGlanceImageFixture(FileGlanceImageFixture):
|
||||
self._download_image_file(image_file=image_file,
|
||||
chunks=chunks,
|
||||
expected_size=expected_size)
|
||||
image_file = self.customize_image_file(base_file=image_file)
|
||||
return super(URLGlanceImageFixture, self).get_image_file(
|
||||
image_file=image_file)
|
||||
|
||||
@ -412,11 +415,8 @@ class URLGlanceImageFixture(FileGlanceImageFixture):
|
||||
raise RuntimeError(message)
|
||||
os.rename(temp_file, image_file)
|
||||
|
||||
def customize_image_file(self, base_file: str) -> str:
|
||||
return base_file
|
||||
|
||||
|
||||
class CustomizedGlanceImageFixture(URLGlanceImageFixture):
|
||||
class CustomizedGlanceImageFixture(FileGlanceImageFixture):
|
||||
|
||||
@property
|
||||
def firstboot_commands(self) -> typing.List[str]:
|
||||
|
@ -26,24 +26,14 @@ from tobiko.shell import sh
|
||||
|
||||
CONF = config.CONF
|
||||
|
||||
UBUNTU_IMAGE_VERSION = 'jammy'
|
||||
|
||||
UBUNTU_IMAGE_VERSION_NUMBER = '22.04'
|
||||
|
||||
UBUNTU_MINIMAL_IMAGE_URL = (
|
||||
'https://cloud-images.ubuntu.com/minimal/releases/'
|
||||
f'{UBUNTU_IMAGE_VERSION}/release/'
|
||||
f'ubuntu-{UBUNTU_IMAGE_VERSION_NUMBER}-minimal-cloudimg-amd64.img')
|
||||
|
||||
|
||||
class UbuntuMinimalImageFixture(glance.URLGlanceImageFixture):
|
||||
image_url = CONF.tobiko.ubuntu.image_url or UBUNTU_MINIMAL_IMAGE_URL
|
||||
class UbuntuMinimalImageFixture(glance.FileGlanceImageFixture):
|
||||
image_name = CONF.tobiko.ubuntu.image_name
|
||||
image_file = CONF.tobiko.ubuntu.image_file
|
||||
disk_format = CONF.tobiko.ubuntu.disk_format or "qcow2"
|
||||
container_format = CONF.tobiko.ubuntu.container_format or "bare"
|
||||
username = CONF.tobiko.ubuntu.username or 'ubuntu'
|
||||
password = CONF.tobiko.ubuntu.password or 'ununtu'
|
||||
password = CONF.tobiko.ubuntu.password or 'ubuntu'
|
||||
connection_timeout = CONF.tobiko.ubuntu.connection_timeout or 1500.
|
||||
disabled_algorithms = CONF.tobiko.ubuntu.disabled_algorithms
|
||||
|
||||
@ -83,10 +73,9 @@ class UbuntuImageFixture(UbuntuMinimalImageFixture,
|
||||
"""
|
||||
|
||||
def __init__(self,
|
||||
image_url: str = None,
|
||||
ethernet_devide: str = None,
|
||||
**kwargs):
|
||||
super().__init__(image_url=image_url, **kwargs)
|
||||
super().__init__(**kwargs)
|
||||
self._ethernet_device = ethernet_devide
|
||||
|
||||
@property
|
||||
|
Loading…
x
Reference in New Issue
Block a user