Beispiel #1
0
 def make_boot_source_cache(self):
     # Disable boot sources signals otherwise the test fails due to unrun
     # post-commit tasks at the end of the test.
     self.useFixture(SignalsDisabled("bootsources"))
     ubuntu = UbuntuDistroInfo()
     try:
         ubuntu_rows = ubuntu._rows
     except AttributeError:
         ubuntu_rows = [row.__dict__ for row in ubuntu._releases]
     supported_releases = [
         release
         for release in ubuntu_rows
         if int(release["version"].split(".")[0]) >= 12
     ]
     release = random.choice(supported_releases)
     ga_or_hwe = random.choice(["hwe", "ga"])
     subarch = "%s-%s" % (ga_or_hwe, release["version"].split(" ")[0])
     factory.make_BootSourceCache(
         os="ubuntu",
         arch=factory.make_name("arch"),
         subarch=subarch,
         release=release["series"],
         release_codename=release["codename"],
         release_title=release["version"],
         support_eol=release.get("eol_server", release.get("eol-server")),
     )
     return release
Beispiel #2
0
 def make_boot_source_cache(self):
     # Disable boot sources signals otherwise the test fails due to unrun
     # post-commit tasks at the end of the test.
     self.useFixture(SignalsDisabled("bootsources"))
     ubuntu = UbuntuDistroInfo()
     try:
         ubuntu_rows = ubuntu._rows
     except AttributeError:
         ubuntu_rows = [row.__dict__ for row in ubuntu._releases]
     supported_releases = [
         release for release in ubuntu_rows
         if int(release['version'].split('.')[0]) >= 12
     ]
     release = random.choice(supported_releases)
     ga_or_hwe = random.choice(['hwe', 'ga'])
     subarch = "%s-%s" % (ga_or_hwe, release['version'].split(' ')[0])
     factory.make_BootSourceCache(
         os='ubuntu',
         arch=factory.make_name('arch'),
         subarch=subarch,
         release=release['series'],
         release_codename=release['codename'],
         release_title=release['version'],
         support_eol=release.get('eol_server', release.get('eol-server')),
     )
     return release
Beispiel #3
0
 def test_make_hwe_kernel_ui_text_finds_release_from_bootsourcecache(self):
     self.useFixture(SignalsDisabled("bootsources"))
     release = factory.pick_ubuntu_release()
     kernel = "hwe-" + release[0]
     factory.make_BootSourceCache(os="ubuntu/%s" % release,
                                  subarch=kernel,
                                  release=release)
     self.assertEqual("%s (%s)" % (release, kernel),
                      make_hwe_kernel_ui_text(kernel))
Beispiel #4
0
 def test__skips_those_that_have_not_expired(self):
     self.useFixture(SignalsDisabled("power"))
     current_time = datetime.now()
     self.patch(status_monitor, "now").return_value = current_time
     expired_time = current_time + timedelta(minutes=1)
     nodes = [
         factory.make_Node(status=status, status_expires=expired_time)
         for status in NODE_FAILURE_MONITORED_STATUS_TRANSITIONS.keys()
     ]
     mark_nodes_failed_after_expiring()
     failed_statuses = [reload_object(node).status for node in nodes]
     self.assertItemsEqual(NODE_FAILURE_MONITORED_STATUS_TRANSITIONS.keys(),
                           failed_statuses)
 def test_skips_those_that_have_not_expired(self):
     maaslog = self.patch(status_monitor.maaslog, "info")
     self.useFixture(SignalsDisabled("power"))
     current_time = now()
     expired_time = current_time + timedelta(minutes=1)
     nodes = [
         factory.make_Node(status=status, status_expires=expired_time)
         for status in NODE_FAILURE_MONITORED_STATUS_TRANSITIONS.keys()
     ]
     mark_nodes_failed_after_expiring(current_time, 20)
     failed_statuses = [reload_object(node).status for node in nodes]
     self.assertItemsEqual(NODE_FAILURE_MONITORED_STATUS_TRANSITIONS.keys(),
                           failed_statuses)
     self.assertThat(maaslog, MockNotCalled())
    def test_mark_node_failed_changes_status_and_updates_error_msg(self):
        self.useFixture(SignalsDisabled("power"))
        system_id = yield deferToDatabase(self.create_deploying_node)

        error_description = factory.make_name('error-description')
        response = yield call_responder(Region(), MarkNodeFailed, {
            'system_id': system_id,
            'error_description': error_description
        })

        self.assertEqual({}, response)
        new_status = yield deferToDatabase(self.get_node_status, system_id)
        new_error_description = yield deferToDatabase(
            self.get_node_error_description, system_id)
        self.assertEqual((NODE_STATUS.FAILED_DEPLOYMENT, error_description),
                         (new_status, new_error_description))
 def test_commissioningform_contains_real_and_ui_choice(self):
     release = factory.pick_ubuntu_release()
     name = 'ubuntu/%s' % release
     arch = factory.make_name('arch')
     kernel = 'hwe-' + release[0]
     # Disable boot sources signals otherwise the test fails due to unrun
     # post-commit tasks at the end of the test.
     self.useFixture(SignalsDisabled('bootsources'))
     factory.make_BootSourceCache(os=name, subarch=kernel, release=release)
     factory.make_usable_boot_resource(name=name,
                                       architecture='%s/%s' %
                                       (arch, kernel),
                                       rtype=BOOT_RESOURCE_TYPE.SYNCED)
     Config.objects.set_config('commissioning_distro_series', release)
     form = CommissioningForm()
     self.assertItemsEqual([('', '--- No minimum kernel ---'),
                            (kernel, '%s (%s)' % (release, kernel))],
                           form.fields['default_min_hwe_kernel'].choices)
Beispiel #8
0
 def test__marks_all_possible_failed_status_as_failed(self):
     maaslog = self.patch(status_monitor.maaslog, 'info')
     self.useFixture(SignalsDisabled("power"))
     current_time = datetime.now()
     self.patch(status_monitor, "now").return_value = current_time
     expired_time = current_time - timedelta(minutes=1)
     nodes = [
         factory.make_Node(status=status, status_expires=expired_time)
         for status in NODE_FAILURE_MONITORED_STATUS_TRANSITIONS.keys()
     ]
     mark_nodes_failed_after_expiring()
     failed_statuses = [reload_object(node).status for node in nodes]
     self.assertItemsEqual(
         NODE_FAILURE_MONITORED_STATUS_TRANSITIONS.values(),
         failed_statuses)
     # MAAS logs in the status_monitor that the timeout was detected. It
     # then logs the transisition in the node signal handler.
     self.assertEquals(len(NODE_FAILURE_MONITORED_STATUS_TRANSITIONS),
                       len(maaslog.call_args_list) / 2)
Beispiel #9
0
    def test_Abort_aborts_disk_erasing(self):
        self.useFixture(SignalsDisabled("power"))
        with transaction.atomic():
            owner = factory.make_User()
            node = factory.make_Node(status=NODE_STATUS.DISK_ERASING,
                                     owner=owner)

        node_stop = self.patch_autospec(node, '_stop')
        # Return a post-commit hook from Node.stop().
        node_stop.side_effect = lambda user: post_commit()

        with post_commit_hooks:
            with transaction.atomic():
                Abort(node, owner).execute()

        with transaction.atomic():
            node = reload_object(node)
            self.assertEqual(NODE_STATUS.FAILED_DISK_ERASING, node.status)

        self.assertThat(node_stop, MockCalledOnceWith(owner))
Beispiel #10
0
 def test_commissioningform_contains_real_and_ui_choice(self):
     release = factory.pick_ubuntu_release()
     name = "ubuntu/%s" % release
     arch = factory.make_name("arch")
     kernel = "hwe-" + release[0]
     # Disable boot sources signals otherwise the test fails due to unrun
     # post-commit tasks at the end of the test.
     self.useFixture(SignalsDisabled("bootsources"))
     factory.make_BootSourceCache(os=name, subarch=kernel, release=release)
     factory.make_usable_boot_resource(
         name=name,
         architecture="%s/%s" % (arch, kernel),
         rtype=BOOT_RESOURCE_TYPE.SYNCED,
     )
     Config.objects.set_config("commissioning_distro_series", release)
     form = CommissioningForm()
     self.assertItemsEqual(
         [
             ("", "--- No minimum kernel ---"),
             (kernel, "%s (%s)" % (release, kernel)),
         ],
         form.fields["default_min_hwe_kernel"].choices,
     )
 def setUp(self):
     super().setUp()
     self.useFixture(SignalsDisabled("power"))
     self.mock_stop = self.patch(Node, 'stop')
     self.maaslog = self.patch(status_monitor.maaslog, 'info')
Beispiel #12
0
 def setUp(self):
     super().setUp()
     self.useFixture(SignalsDisabled("power"))
Beispiel #13
0
 def setUp(self):
     super().setUp()
     # Disable boot sources signals otherwise the test fails due to unrun
     # post-commit tasks at the end of the test.
     self.useFixture(SignalsDisabled("bootsources"))
Beispiel #14
0
 def setUp(self):
     super(TestStatusWorkerService, self).setUp()
     self.useFixture(SignalsDisabled("power"))
Beispiel #15
0
 def setUp(self):
     super().setUp()
     self.useFixture(SignalsDisabled("power"))
     self.mock_stop = self.patch(Node, 'stop')