def test_insert_item_sets_release_to_bootloader_type(self):
     boot_images_dict = BootImageMapping()
     dumper = RepoDumper(boot_images_dict)
     item, _ = self.make_item(arch="amd64",
                              bootloader_type="uefi",
                              os="grub-efi-signed")
     self.patch(download_descriptions,
                "products_exdata").return_value = item
     dumper.insert_item(
         {
             "bootloader_type": "uefi",
             "os": "grub-efi-signed",
             "arch": "amd64",
         },
         sentinel.src,
         sentinel.target,
         (
             "com.ubuntu.maas.daily:1:grub-efi-signed:uefi:amd64",
             factory.make_name("product_version"),
         ),
         sentinel.contentsource,
     )
     image_specs = [
         make_image_spec(
             os=item["os"],
             release="uefi",
             arch=item["arch"],
             subarch=subarch,
             kflavor="bootloader",
             label=item["label"],
         ) for subarch in item["subarches"].split(",")
     ]
     self.assertItemsEqual(image_specs, list(boot_images_dict.mapping))
 def test_insert_item_doesnt_validate_when_instructed(self):
     boot_images_dict = BootImageMapping()
     dumper = RepoDumper(boot_images_dict, validate_products=False)
     item, _ = self.make_item(os="ubuntu")
     self.patch(download_descriptions,
                "products_exdata").return_value = item
     dumper.insert_item(
         {"os": "ubuntu"},
         sentinel.src,
         sentinel.target,
         (
             factory.make_name("product_name"),
             factory.make_name("product_version"),
         ),
         sentinel.contentsource,
     )
     image_specs = [
         make_image_spec(
             os=item["os"],
             release=item["release"],
             arch=item["arch"],
             subarch=subarch,
             label=item["label"],
         ) for subarch in item["subarches"].split(",")
     ]
     self.assertItemsEqual(image_specs, list(boot_images_dict.mapping))
 def test_insert_item_adds_item_per_subarch(self):
     boot_images_dict = BootImageMapping()
     dumper = RepoDumper(boot_images_dict)
     subarches = [factory.make_name("subarch") for _ in range(3)]
     item, _ = self.make_item(subarch=subarches.pop(), subarches=subarches)
     self.patch(download_descriptions,
                "products_exdata").return_value = item
     dumper.insert_item(
         sentinel.data,
         sentinel.src,
         sentinel.target,
         (
             factory.make_name("product_name"),
             factory.make_name("product_version"),
         ),
         sentinel.contentsource,
     )
     image_specs = [
         make_image_spec(
             os=item["os"],
             release=item["release"],
             arch=item["arch"],
             subarch=subarch,
             label=item["label"],
         ) for subarch in subarches
     ]
     self.assertItemsEqual(image_specs, list(boot_images_dict.mapping))
Пример #4
0
 def test_insert_item_sets_release_to_bootloader_type(self):
     boot_images_dict = BootImageMapping()
     dumper = RepoDumper(boot_images_dict)
     item, _ = self.make_item(arch='amd64',
                              bootloader_type='uefi',
                              os='grub-efi-signed')
     self.patch(download_descriptions,
                'products_exdata').return_value = item
     dumper.insert_item(
         {
             'bootloader_type': 'uefi',
             'os': 'grub-efi-signed',
             'arch': 'amd64',
         }, sentinel.src, sentinel.target, (
             'com.ubuntu.maas.daily:1:grub-efi-signed:uefi:amd64',
             factory.make_name('product_version'),
         ), sentinel.contentsource)
     image_specs = [
         make_image_spec(os=item['os'],
                         release='uefi',
                         arch=item['arch'],
                         subarch=subarch,
                         kflavor='bootloader',
                         label=item['label'])
         for subarch in item['subarches'].split(',')
     ]
     self.assertItemsEqual(image_specs, list(boot_images_dict.mapping))
Пример #5
0
 def test_insert_item_sets_compat_item_specific_to_subarch(self):
     boot_images_dict = BootImageMapping()
     dumper = RepoDumper(boot_images_dict)
     subarches = [factory.make_name('subarch') for _ in range(5)]
     compat_subarch = subarches.pop()
     item, _ = self.make_item(subarch=subarches.pop(), subarches=subarches)
     second_item, compat_item = self.make_item(os=item['os'],
                                               release=item['release'],
                                               arch=item['arch'],
                                               subarch=compat_subarch,
                                               subarches=[compat_subarch],
                                               label=item['label'])
     self.patch(download_descriptions,
                'products_exdata').side_effect = [item, second_item]
     for _ in range(2):
         dumper.insert_item(sentinel.data, sentinel.src, sentinel.target,
                            (factory.make_name('product_name'),
                             factory.make_name('product_version')),
                            sentinel.contentsource)
     image_spec = make_image_spec(os=item['os'],
                                  release=item['release'],
                                  arch=item['arch'],
                                  subarch=compat_subarch,
                                  label=item['label'])
     self.assertEqual(compat_item, boot_images_dict.mapping[image_spec])
Пример #6
0
 def test_insert_item_validates(self):
     boot_images_dict = BootImageMapping()
     dumper = RepoDumper(boot_images_dict)
     item, _ = self.make_item(os='ubuntu')
     self.patch(download_descriptions,
                'products_exdata').return_value = item
     dumper.insert_item({'os': 'ubuntu'}, sentinel.src, sentinel.target, (
         factory.make_name('product_name'),
         factory.make_name('product_version'),
     ), sentinel.contentsource)
     self.assertItemsEqual([], list(boot_images_dict.mapping))
 def test_insert_item_sets_generic_to_release_item_for_hwe_version(self):
     boot_images_dict = BootImageMapping()
     dumper = RepoDumper(boot_images_dict)
     os = "ubuntu"
     release = "xenial"
     arch = "amd64"
     label = "release"
     hwep_subarch = "hwe-16.04"
     hwep_subarches = ["generic", "hwe-16.04", "hwe-16.10"]
     hwes_subarch = "hwe-16.10"
     hwes_subarches = ["generic", "hwe-16.04", "hwe-16.10"]
     hwep_item, compat_item = self.make_item(
         os=os,
         release=release,
         arch=arch,
         subarch=hwep_subarch,
         subarches=hwep_subarches,
         label=label,
     )
     hwes_item, _ = self.make_item(
         os=os,
         release=release,
         arch=arch,
         subarch=hwes_subarch,
         subarches=hwes_subarches,
         label=label,
     )
     self.patch(download_descriptions, "products_exdata").side_effect = [
         hwep_item,
         hwes_item,
     ]
     for _ in range(2):
         dumper.insert_item(
             {"os": "ubuntu"},
             sentinel.src,
             sentinel.target,
             (
                 "com.ubuntu.maas.daily:v3:boot:12.04:amd64:hwe-p",
                 factory.make_name("product_version"),
             ),
             sentinel.contentsource,
         )
     image_spec = make_image_spec(os=os,
                                  release=release,
                                  arch=arch,
                                  subarch="generic",
                                  label=label)
     self.assertEqual(compat_item, boot_images_dict.mapping[image_spec])
Пример #8
0
 def test_insert_item_doesnt_validate_when_instructed(self):
     boot_images_dict = BootImageMapping()
     dumper = RepoDumper(boot_images_dict, validate_products=False)
     item, _ = self.make_item(os='ubuntu')
     self.patch(download_descriptions,
                'products_exdata').return_value = item
     dumper.insert_item({'os': 'ubuntu'}, sentinel.src, sentinel.target, (
         factory.make_name('product_name'),
         factory.make_name('product_version'),
     ), sentinel.contentsource)
     image_specs = [
         make_image_spec(os=item['os'],
                         release=item['release'],
                         arch=item['arch'],
                         subarch=subarch,
                         label=item['label'])
         for subarch in item['subarches'].split(',')
     ]
     self.assertItemsEqual(image_specs, list(boot_images_dict.mapping))
    def test_sync_does_propagate_ioerror(self):
        io_error = factory.make_exception_type(bases=(IOError, ))

        mock_sync = self.patch(download_descriptions.BasicMirrorWriter, "sync")
        mock_sync.side_effect = io_error()

        boot_images_dict = BootImageMapping()
        dumper = RepoDumper(boot_images_dict)

        with FakeLogger("maas.import-images", level=logging.INFO) as maaslog:
            self.assertRaises(io_error, dumper.sync, sentinel.reader,
                              sentinel.path)
            self.assertDocTestMatches("...error...syncing boot images...",
                                      maaslog.output)
Пример #10
0
 def test_insert_item_sets_generic_to_release_item_for_hwe_version(self):
     boot_images_dict = BootImageMapping()
     dumper = RepoDumper(boot_images_dict)
     os = 'ubuntu'
     release = 'xenial'
     arch = 'amd64'
     label = 'release'
     hwep_subarch = 'hwe-16.04'
     hwep_subarches = ['generic', 'hwe-16.04', 'hwe-16.10']
     hwes_subarch = 'hwe-16.10'
     hwes_subarches = ['generic', 'hwe-16.04', 'hwe-16.10']
     hwep_item, compat_item = self.make_item(os=os,
                                             release=release,
                                             arch=arch,
                                             subarch=hwep_subarch,
                                             subarches=hwep_subarches,
                                             label=label)
     hwes_item, _ = self.make_item(os=os,
                                   release=release,
                                   arch=arch,
                                   subarch=hwes_subarch,
                                   subarches=hwes_subarches,
                                   label=label)
     self.patch(download_descriptions,
                'products_exdata').side_effect = [hwep_item, hwes_item]
     for _ in range(2):
         dumper.insert_item(
             {'os': 'ubuntu'}, sentinel.src, sentinel.target, (
                 'com.ubuntu.maas.daily:v3:boot:12.04:amd64:hwe-p',
                 factory.make_name('product_version'),
             ), sentinel.contentsource)
     image_spec = make_image_spec(os=os,
                                  release=release,
                                  arch=arch,
                                  subarch='generic',
                                  label=label)
     self.assertEqual(compat_item, boot_images_dict.mapping[image_spec])