| |
@@ -0,0 +1,574 @@
|
| |
+ import json
|
| |
+ import os
|
| |
+ from unittest import mock
|
| |
+
|
| |
+ import freezegun
|
| |
+ import pytest
|
| |
+ from fedora_image_uploader_messages import GcpPublishedV1
|
| |
+ from fedora_messaging import config, message
|
| |
+ from fedora_messaging import testing as fm_testing
|
| |
+ from google.cloud import compute_v1, storage
|
| |
+
|
| |
+ from fedora_image_uploader import Uploader
|
| |
+
|
| |
+
|
| |
+ @mock.patch.dict(
|
| |
+ config.conf,
|
| |
+ {
|
| |
+ "consumer_config": {
|
| |
+ "gcp": {
|
| |
+ "project": "fedora-cloud-devel",
|
| |
+ "bucket_name": "some-unique-bucket-name",
|
| |
+ "storage_locations": ["us"],
|
| |
+ "publish_amqp_messages": True,
|
| |
+ }
|
| |
+ },
|
| |
+ },
|
| |
+ )
|
| |
+ def test_image_filter(fixtures_dir):
|
| |
+ consumer = Uploader()
|
| |
+ handler = consumer.handlers["gcp"]
|
| |
+ handler.upload_disk_image = mock.Mock()
|
| |
+ image = {
|
| |
+ "arch": "aarch64",
|
| |
+ "format": "tar.gz",
|
| |
+ "subvariant": "Cloud_Base",
|
| |
+ }
|
| |
+ ffrel = mock.Mock(relnum=42, release="Rawhide")
|
| |
+
|
| |
+ # Arch isn't supported
|
| |
+ image["arch"] = "ppc64le"
|
| |
+ handler(image, ffrel)
|
| |
+ handler.upload_disk_image.call_count == 0
|
| |
+ image["arch"] = "aarch64"
|
| |
+
|
| |
+ # Format isn't tar.gz
|
| |
+ image["format"] = "qcow2"
|
| |
+ handler(image, ffrel)
|
| |
+ handler.upload_disk_image.call_count == 0
|
| |
+ image["format"] = "tar.gz"
|
| |
+
|
| |
+ # Subvariant isn't supported
|
| |
+ image["subvariant"] = "CoreOS"
|
| |
+ handler(image, ffrel)
|
| |
+ handler.upload_disk_image.call_count == 0
|
| |
+
|
| |
+ # Don't bother with 39
|
| |
+ handler(image, mock.Mock(relnum=39, release="39"))
|
| |
+ handler.upload_disk_image.call_count == 0
|
| |
+
|
| |
+
|
| |
+ @pytest.mark.vcr
|
| |
+ @mock.patch.dict(
|
| |
+ config.conf,
|
| |
+ {
|
| |
+ "consumer_config": {
|
| |
+ "gcp": {
|
| |
+ "project": "fedora-cloud-devel",
|
| |
+ "bucket_name": "some-unique-bucket-name",
|
| |
+ "storage_locations": ["us"],
|
| |
+ "publish_amqp_messages": True,
|
| |
+ }
|
| |
+ },
|
| |
+ },
|
| |
+ )
|
| |
+ def test_messages(fixtures_dir):
|
| |
+ with open(os.path.join(fixtures_dir, "messages/rc_compose.json")) as fd:
|
| |
+ msg = message.load_message(json.load(fd))
|
| |
+ fake_images = [
|
| |
+ mock.Mock(
|
| |
+ family="fedora-cloud-40",
|
| |
+ name="fedora-cloud-40-1-14-aarch64",
|
| |
+ self_link="http://example.com/link",
|
| |
+ storage_locations=["us"],
|
| |
+ ),
|
| |
+ mock.Mock(
|
| |
+ family="fedora-cloud-40",
|
| |
+ name="fedora-cloud-40-1-14-x86-64",
|
| |
+ self_link="http://example.com/link",
|
| |
+ storage_locations=["us"],
|
| |
+ ),
|
| |
+ ]
|
| |
+ fake_images[0].name = "fedora-cloud-40-1-14-aarch64"
|
| |
+ fake_images[1].name = "fedora-cloud-40-1-14-x86-64"
|
| |
+ consumer = Uploader()
|
| |
+ handler = consumer.handlers["gcp"]
|
| |
+ handler.upload_disk_image = mock.Mock()
|
| |
+ handler.import_image = mock.Mock(side_effect=fake_images)
|
| |
+ handler.promote_image = mock.Mock()
|
| |
+ handler.cleanup_old_images = mock.Mock()
|
| |
+
|
| |
+ expected_messages = [
|
| |
+ GcpPublishedV1(
|
| |
+ topic="fedora_image_uploader.published.v1.gcp.rc.Cloud_Base.aarch64",
|
| |
+ body={
|
| |
+ "architecture": "aarch64",
|
| |
+ "compose_id": "Fedora-40-20240414.0",
|
| |
+ "release": 40,
|
| |
+ "subvariant": "Cloud_Base",
|
| |
+ "family": "fedora-cloud-40",
|
| |
+ "image_name": "fedora-cloud-40-1-14-aarch64",
|
| |
+ "image_url": "http://example.com/link",
|
| |
+ "storage_locations": ["us"],
|
| |
+ },
|
| |
+ ),
|
| |
+ GcpPublishedV1(
|
| |
+ topic="fedora_image_uploader.published.v1.gcp.rc.Cloud_Base.x86_64",
|
| |
+ body={
|
| |
+ "architecture": "x86_64",
|
| |
+ "compose_id": "Fedora-40-20240414.0",
|
| |
+ "release": 40,
|
| |
+ "subvariant": "Cloud_Base",
|
| |
+ "family": "fedora-cloud-40",
|
| |
+ "image_name": "fedora-cloud-40-1-14-x86-64",
|
| |
+ "image_url": "http://example.com/link",
|
| |
+ "storage_locations": ["us"],
|
| |
+ },
|
| |
+ ),
|
| |
+ ]
|
| |
+ with fm_testing.mock_sends(*expected_messages):
|
| |
+ consumer(msg)
|
| |
+
|
| |
+
|
| |
+ @pytest.mark.vcr
|
| |
+ @mock.patch.dict(
|
| |
+ config.conf,
|
| |
+ {
|
| |
+ "consumer_config": {
|
| |
+ "gcp": {
|
| |
+ "project": "fedora-cloud-devel",
|
| |
+ "bucket_name": "some-unique-bucket-name",
|
| |
+ "storage_locations": ["us"],
|
| |
+ }
|
| |
+ },
|
| |
+ },
|
| |
+ )
|
| |
+ def test_import_image(fixtures_dir):
|
| |
+ consumer = Uploader()
|
| |
+ handler = consumer.handlers["gcp"]
|
| |
+ handler.images_client = mock.Mock()
|
| |
+ handler.upload_disk_image = mock.Mock()
|
| |
+ handler.promote_image = mock.Mock()
|
| |
+ handler.cleanup_old_image = mock.Mock()
|
| |
+ handler.images_client.list.return_value = []
|
| |
+ handler.images_client.insert.return_value.warnings = []
|
| |
+ handler.upload_disk_image.return_value = mock.Mock(
|
| |
+ spec=storage.Blob, self_link="http://example.com/link"
|
| |
+ )
|
| |
+ expected_calls = [
|
| |
+ mock.call(
|
| |
+ compute_v1.InsertImageRequest(
|
| |
+ request_id="7153713f-2a44-6073-76b4-5786f609026c",
|
| |
+ project="fedora-cloud-devel",
|
| |
+ image_resource=compute_v1.Image(
|
| |
+ architecture="ARM64",
|
| |
+ family="fedora-cloud-40",
|
| |
+ description="Fedora Cloud base image version 40.1.14",
|
| |
+ deprecated=compute_v1.DeprecationStatus(state="ACTIVE"),
|
| |
+ guest_os_features=[
|
| |
+ compute_v1.GuestOsFeature(
|
| |
+ type_=compute_v1.GuestOsFeature.Type.UEFI_COMPATIBLE.name
|
| |
+ ),
|
| |
+ compute_v1.GuestOsFeature(
|
| |
+ type_=compute_v1.GuestOsFeature.Type.VIRTIO_SCSI_MULTIQUEUE.name
|
| |
+ ),
|
| |
+ compute_v1.GuestOsFeature(type_=compute_v1.GuestOsFeature.Type.IDPF.name),
|
| |
+ compute_v1.GuestOsFeature(type_=compute_v1.GuestOsFeature.Type.GVNIC.name),
|
| |
+ ],
|
| |
+ labels={
|
| |
+ "fedora-compose-id": "fedora-40-20240414-0",
|
| |
+ "fedora-subvariant": "cloud_base",
|
| |
+ "fedora-release": "40",
|
| |
+ "fedora-version": "40",
|
| |
+ "end-of-life": "2025-05-13",
|
| |
+ "fedora-image-uploader-managed": "true",
|
| |
+ },
|
| |
+ name="fedora-cloud-40-1-14-aarch64",
|
| |
+ raw_disk=compute_v1.RawDisk(
|
| |
+ source=handler.upload_disk_image.return_value.self_link
|
| |
+ ),
|
| |
+ storage_locations=["us"],
|
| |
+ ),
|
| |
+ ),
|
| |
+ timeout=60,
|
| |
+ ),
|
| |
+ mock.call(
|
| |
+ compute_v1.InsertImageRequest(
|
| |
+ request_id="dcc05425-e07b-87f6-f53f-142c693bff3d",
|
| |
+ project="fedora-cloud-devel",
|
| |
+ image_resource=compute_v1.Image(
|
| |
+ architecture="X86_64",
|
| |
+ family="fedora-cloud-40",
|
| |
+ description="Fedora Cloud base image version 40.1.14",
|
| |
+ deprecated=compute_v1.DeprecationStatus(state="ACTIVE"),
|
| |
+ guest_os_features=[
|
| |
+ compute_v1.GuestOsFeature(
|
| |
+ type_=compute_v1.GuestOsFeature.Type.UEFI_COMPATIBLE.name
|
| |
+ ),
|
| |
+ compute_v1.GuestOsFeature(
|
| |
+ type_=compute_v1.GuestOsFeature.Type.VIRTIO_SCSI_MULTIQUEUE.name
|
| |
+ ),
|
| |
+ compute_v1.GuestOsFeature(type_=compute_v1.GuestOsFeature.Type.IDPF.name),
|
| |
+ compute_v1.GuestOsFeature(type_=compute_v1.GuestOsFeature.Type.GVNIC.name),
|
| |
+ compute_v1.GuestOsFeature(
|
| |
+ type_=compute_v1.GuestOsFeature.Type.SECURE_BOOT.name
|
| |
+ ),
|
| |
+ ],
|
| |
+ labels={
|
| |
+ "fedora-compose-id": "fedora-40-20240414-0",
|
| |
+ "fedora-subvariant": "cloud_base",
|
| |
+ "fedora-release": "40",
|
| |
+ "fedora-version": "40",
|
| |
+ "end-of-life": "2025-05-13",
|
| |
+ "fedora-image-uploader-managed": "true",
|
| |
+ },
|
| |
+ name="fedora-cloud-40-1-14-x86-64",
|
| |
+ raw_disk=compute_v1.RawDisk(
|
| |
+ source=handler.upload_disk_image.return_value.self_link
|
| |
+ ),
|
| |
+ storage_locations=["us"],
|
| |
+ ),
|
| |
+ ),
|
| |
+ timeout=60,
|
| |
+ ),
|
| |
+ ]
|
| |
+
|
| |
+ with open(os.path.join(fixtures_dir, "messages/rc_compose.json")) as fd:
|
| |
+ consumer(message.load_message(json.load(fd)))
|
| |
+
|
| |
+ for call in handler.images_client.insert.call_args_list:
|
| |
+ assert call in expected_calls
|
| |
+
|
| |
+
|
| |
+ @mock.patch.dict(
|
| |
+ config.conf,
|
| |
+ {
|
| |
+ "consumer_config": {
|
| |
+ "gcp": {
|
| |
+ "project": "fedora-cloud-devel",
|
| |
+ "bucket_name": "some-unique-bucket-name",
|
| |
+ "storage_locations": ["us"],
|
| |
+ }
|
| |
+ },
|
| |
+ },
|
| |
+ )
|
| |
+ def test_promote_image_eln_rawhide():
|
| |
+ """Assert this is a no-op for eln and rawhide"""
|
| |
+ consumer = Uploader()
|
| |
+ handler = consumer.handlers["gcp"]
|
| |
+ handler.images_client = mock.Mock()
|
| |
+
|
| |
+ # rawhide
|
| |
+ handler.promote_image(
|
| |
+ compute_v1.Image(
|
| |
+ architecture="X86_64",
|
| |
+ family="fedora-40",
|
| |
+ description="Fedora Cloud base image version",
|
| |
+ labels={
|
| |
+ "fedora-release": "rawhide",
|
| |
+ "fedora-image-uploader-managed": "true",
|
| |
+ },
|
| |
+ name="fedora-40-1-14-x86-64",
|
| |
+ raw_disk=compute_v1.RawDisk(source="http://example.com/link"),
|
| |
+ storage_locations=["us"],
|
| |
+ creation_timestamp="2024-10-01T00:00:00Z",
|
| |
+ )
|
| |
+ )
|
| |
+ handler.images_client.list.call_count = 0
|
| |
+
|
| |
+ # eln
|
| |
+ handler.promote_image(
|
| |
+ compute_v1.Image(
|
| |
+ architecture="X86_64",
|
| |
+ family="fedora-40",
|
| |
+ description="Fedora Cloud base image version",
|
| |
+ labels={
|
| |
+ "fedora-release": "eln",
|
| |
+ "fedora-image-uploader-managed": "true",
|
| |
+ },
|
| |
+ name="fedora-40-1-14-x86-64",
|
| |
+ raw_disk=compute_v1.RawDisk(source="http://example.com/link"),
|
| |
+ storage_locations=["us"],
|
| |
+ creation_timestamp="2024-10-01T00:00:00Z",
|
| |
+ )
|
| |
+ )
|
| |
+ handler.images_client.list.call_count = 0
|
| |
+
|
| |
+
|
| |
+ @mock.patch.dict(
|
| |
+ config.conf,
|
| |
+ {
|
| |
+ "consumer_config": {
|
| |
+ "gcp": {
|
| |
+ "project": "fedora-cloud-devel",
|
| |
+ "bucket_name": "some-unique-bucket-name",
|
| |
+ "storage_locations": ["us"],
|
| |
+ }
|
| |
+ },
|
| |
+ },
|
| |
+ )
|
| |
+ def test_needs_promotion():
|
| |
+ consumer = Uploader()
|
| |
+ handler = consumer.handlers["gcp"]
|
| |
+ handler.images_client = mock.Mock()
|
| |
+ handler.images_client.list.side_effect = (
|
| |
+ [
|
| |
+ compute_v1.Image(
|
| |
+ architecture="X86_64",
|
| |
+ family="fedora-40",
|
| |
+ description="Fedora Cloud base image version",
|
| |
+ labels={
|
| |
+ "fedora-release": "40",
|
| |
+ "fedora-image-uploader-managed": "true",
|
| |
+ },
|
| |
+ name="olde",
|
| |
+ raw_disk=compute_v1.RawDisk(source="http://example.com/link"),
|
| |
+ storage_locations=["us"],
|
| |
+ creation_timestamp="2024-10-01T00:00:00Z",
|
| |
+ )
|
| |
+ ],
|
| |
+ )
|
| |
+ handler.images_client.deprecate.return_value.warnings = []
|
| |
+
|
| |
+ with freezegun.freeze_time("2024-10-16"):
|
| |
+ handler.promote_image(
|
| |
+ compute_v1.Image(
|
| |
+ architecture="X86_64",
|
| |
+ family="fedora-40",
|
| |
+ description="Fedora Cloud base image version",
|
| |
+ labels={
|
| |
+ "fedora-release": "40",
|
| |
+ "fedora-image-uploader-managed": "true",
|
| |
+ },
|
| |
+ name="promoted",
|
| |
+ raw_disk=compute_v1.RawDisk(source="http://example.com/link"),
|
| |
+ storage_locations=["us"],
|
| |
+ creation_timestamp="2024-10-15T00:00:00Z",
|
| |
+ )
|
| |
+ )
|
| |
+
|
| |
+ handler.images_client.deprecate.assert_called_once_with(
|
| |
+ request=compute_v1.DeprecateImageRequest(
|
| |
+ project="fedora-cloud-devel",
|
| |
+ image="promoted",
|
| |
+ deprecation_status_resource=compute_v1.DeprecationStatus(
|
| |
+ state=compute_v1.DeprecationStatus.State.ACTIVE.name,
|
| |
+ ),
|
| |
+ ),
|
| |
+ timeout=60,
|
| |
+ )
|
| |
+
|
| |
+
|
| |
+ @mock.patch.dict(
|
| |
+ config.conf,
|
| |
+ {
|
| |
+ "consumer_config": {
|
| |
+ "gcp": {
|
| |
+ "project": "fedora-cloud-devel",
|
| |
+ "bucket_name": "some-unique-bucket-name",
|
| |
+ "storage_locations": ["us"],
|
| |
+ }
|
| |
+ },
|
| |
+ },
|
| |
+ )
|
| |
+ def test_no_promotion():
|
| |
+ consumer = Uploader()
|
| |
+ handler = consumer.handlers["gcp"]
|
| |
+ handler.images_client = mock.Mock()
|
| |
+ handler.images_client.list.side_effect = (
|
| |
+ [
|
| |
+ compute_v1.Image(
|
| |
+ architecture="X86_64",
|
| |
+ family="fedora-40",
|
| |
+ description="Fedora Cloud base image version",
|
| |
+ labels={
|
| |
+ "fedora-release": "40",
|
| |
+ "fedora-image-uploader-managed": "true",
|
| |
+ },
|
| |
+ name="olde",
|
| |
+ raw_disk=compute_v1.RawDisk(source="http://example.com/link"),
|
| |
+ storage_locations=["us"],
|
| |
+ creation_timestamp="2024-10-05T00:00:00Z",
|
| |
+ )
|
| |
+ ],
|
| |
+ )
|
| |
+ handler.images_client.deprecate.return_value.warnings = []
|
| |
+
|
| |
+ with freezegun.freeze_time("2024-10-16"):
|
| |
+ handler.promote_image(
|
| |
+ compute_v1.Image(
|
| |
+ architecture="X86_64",
|
| |
+ family="fedora-40",
|
| |
+ description="Fedora Cloud base image version",
|
| |
+ labels={
|
| |
+ "fedora-release": "40",
|
| |
+ "fedora-image-uploader-managed": "true",
|
| |
+ },
|
| |
+ name="promoted",
|
| |
+ raw_disk=compute_v1.RawDisk(source="http://example.com/link"),
|
| |
+ storage_locations=["us"],
|
| |
+ creation_timestamp="2024-10-15T00:00:00Z",
|
| |
+ )
|
| |
+ )
|
| |
+
|
| |
+ assert handler.images_client.deprecate.call_count == 0
|
| |
+
|
| |
+
|
| |
+ @mock.patch.dict(
|
| |
+ config.conf,
|
| |
+ {
|
| |
+ "consumer_config": {
|
| |
+ "gcp": {
|
| |
+ "project": "fedora-cloud-devel",
|
| |
+ "bucket_name": "some-unique-bucket-name",
|
| |
+ "storage_locations": ["us"],
|
| |
+ }
|
| |
+ },
|
| |
+ },
|
| |
+ )
|
| |
+ def test_cleanup_skips_unmanaged_images():
|
| |
+ consumer = Uploader()
|
| |
+ handler = consumer.handlers["gcp"]
|
| |
+ handler.images_client = mock.Mock()
|
| |
+ handler.images_client.list.return_value = [
|
| |
+ compute_v1.Image(
|
| |
+ architecture="X86_64",
|
| |
+ family="fedora-40",
|
| |
+ description="Fedora Cloud base image version",
|
| |
+ name="fedora-40-1-14-aarch64",
|
| |
+ raw_disk=compute_v1.RawDisk(source="http://example.com/link"),
|
| |
+ storage_locations=["us"],
|
| |
+ )
|
| |
+ ]
|
| |
+
|
| |
+ # Test that cleanup_old_images is not called when the image is not managed
|
| |
+ handler.cleanup_old_images()
|
| |
+ assert handler.images_client.delete.call_count == 0
|
| |
+
|
| |
+
|
| |
+ @mock.patch.dict(
|
| |
+ config.conf,
|
| |
+ {
|
| |
+ "consumer_config": {
|
| |
+ "gcp": {
|
| |
+ "project": "fedora-cloud-devel",
|
| |
+ "bucket_name": "some-unique-bucket-name",
|
| |
+ "storage_locations": ["us"],
|
| |
+ }
|
| |
+ },
|
| |
+ },
|
| |
+ )
|
| |
+ def test_cleanup_rawhide():
|
| |
+ consumer = Uploader()
|
| |
+ handler = consumer.handlers["gcp"]
|
| |
+ handler.images_client = mock.Mock()
|
| |
+ handler.images_client.list.side_effect = (
|
| |
+ [
|
| |
+ compute_v1.Image(
|
| |
+ architecture="X86_64",
|
| |
+ family="fedora-40",
|
| |
+ description="Fedora Cloud base image version",
|
| |
+ labels={
|
| |
+ "fedora-release": "rawhide",
|
| |
+ "fedora-image-uploader-managed": "true",
|
| |
+ },
|
| |
+ name="gone-but-not-forgotten",
|
| |
+ raw_disk=compute_v1.RawDisk(source="http://example.com/link"),
|
| |
+ storage_locations=["us"],
|
| |
+ creation_timestamp="2024-10-01T00:00:00Z",
|
| |
+ ),
|
| |
+ compute_v1.Image(
|
| |
+ architecture="X86_64",
|
| |
+ family="fedora-40",
|
| |
+ description="Fedora Cloud base image version",
|
| |
+ labels={
|
| |
+ "fedora-release": "rawhide",
|
| |
+ "fedora-image-uploader-managed": "true",
|
| |
+ },
|
| |
+ name="soon-to-go-but-not-yet",
|
| |
+ raw_disk=compute_v1.RawDisk(source="http://example.com/link"),
|
| |
+ storage_locations=["us"],
|
| |
+ creation_timestamp="2024-10-02T00:00:00Z",
|
| |
+ ),
|
| |
+ ],
|
| |
+ [],
|
| |
+ )
|
| |
+ handler.images_client.delete.return_value.warnings = []
|
| |
+
|
| |
+ # Test that cleanup_old_images is not called when the image is not managed
|
| |
+ with freezegun.freeze_time("2024-10-16"):
|
| |
+ handler.cleanup_old_images()
|
| |
+ assert handler.images_client.delete.call_count == 1
|
| |
+ handler.images_client.delete.assert_called_once_with(
|
| |
+ compute_v1.DeleteImageRequest(
|
| |
+ project="fedora-cloud-devel",
|
| |
+ image="gone-but-not-forgotten",
|
| |
+ request_id="347bf095-cee1-dc0f-8b0b-287da4300d98",
|
| |
+ ),
|
| |
+ timeout=600,
|
| |
+ )
|
| |
+
|
| |
+
|
| |
+ @mock.patch.dict(
|
| |
+ config.conf,
|
| |
+ {
|
| |
+ "consumer_config": {
|
| |
+ "gcp": {
|
| |
+ "project": "fedora-cloud-devel",
|
| |
+ "bucket_name": "some-unique-bucket-name",
|
| |
+ "storage_locations": ["us"],
|
| |
+ }
|
| |
+ },
|
| |
+ },
|
| |
+ )
|
| |
+ def test_cleanup_eol():
|
| |
+ consumer = Uploader()
|
| |
+ handler = consumer.handlers["gcp"]
|
| |
+ handler.images_client = mock.Mock()
|
| |
+ handler.images_client.list.side_effect = (
|
| |
+ [],
|
| |
+ [
|
| |
+ compute_v1.Image(
|
| |
+ architecture="X86_64",
|
| |
+ family="fedora-40",
|
| |
+ description="Fedora Cloud base image version",
|
| |
+ labels={
|
| |
+ "fedora-release": "40",
|
| |
+ "fedora-image-uploader-managed": "true",
|
| |
+ "end-of-life": "2024-10-01",
|
| |
+ },
|
| |
+ name="gone-but-not-forgotten",
|
| |
+ raw_disk=compute_v1.RawDisk(source="http://example.com/link"),
|
| |
+ storage_locations=["us"],
|
| |
+ creation_timestamp="2024-10-01T00:00:00Z",
|
| |
+ ),
|
| |
+ compute_v1.Image(
|
| |
+ architecture="X86_64",
|
| |
+ family="fedora-40",
|
| |
+ description="Fedora Cloud base image version",
|
| |
+ labels={
|
| |
+ "fedora-release": "40",
|
| |
+ "fedora-image-uploader-managed": "true",
|
| |
+ "end-of-life": "2024-10-17",
|
| |
+ },
|
| |
+ name="still-alive",
|
| |
+ raw_disk=compute_v1.RawDisk(source="http://example.com/link"),
|
| |
+ storage_locations=["us"],
|
| |
+ creation_timestamp="2024-10-01T00:00:00Z",
|
| |
+ ),
|
| |
+ ],
|
| |
+ )
|
| |
+ handler.images_client.delete.return_value.warnings = []
|
| |
+
|
| |
+ # Test that cleanup_old_images is not called when the image is not managed
|
| |
+ with freezegun.freeze_time("2024-10-16"):
|
| |
+ handler.cleanup_old_images()
|
| |
+
|
| |
+ handler.images_client.delete.assert_called_once_with(
|
| |
+ compute_v1.DeleteImageRequest(
|
| |
+ project="fedora-cloud-devel",
|
| |
+ image="gone-but-not-forgotten",
|
| |
+ request_id="347bf095-cee1-dc0f-8b0b-287da4300d98",
|
| |
+ ),
|
| |
+ timeout=600,
|
| |
+ )
|
| |
Introduce a handler to upload the images we're building for Google's
cloud.