Ejemplo n.º 1
0
    def test_returns_scsi_bus_nums(self):
        controller = random.randint(0, 3)
        scsi_bus_nums = [random.randint(0, 127) for _ in range(3)]
        self.patch(smartctl.os.path, "exists").return_value = True
        self.patch(
            smartctl,
            "find_matching_megaraid_controller").return_value = controller
        mock_run_storcli = self.patch(smartctl, "run_storcli")
        mock_run_storcli.return_value = "".join([
            "%d:%d %d\n" % (
                random.randint(0, 255),
                random.randint(0, 255),
                scsi_bus_num,
            ) for scsi_bus_num in scsi_bus_nums
        ])

        self.assertItemsEqual(
            scsi_bus_nums,
            smartctl.detect_megaraid_config(factory.make_name("blockdevice")),
        )
        self.assertThat(
            mock_run_storcli,
            MockCalledOnceWith(["/c%d" % controller, "/eall", "/sall",
                                "show"]),
        )
Ejemplo n.º 2
0
    def test__returns_scsi_bus_nums(self):
        controller = random.randint(0, 3)
        scsi_bus_nums = [random.randint(0, 127) for _ in range(3)]
        self.patch(smartctl.os.path, 'exists').return_value = True
        self.patch(
            smartctl,
            'find_matching_megaraid_controller').return_value = controller
        mock_run_storcli = self.patch(smartctl, 'run_storcli')
        mock_run_storcli.return_value = ''.join([
            '%d:%d %d\n' %
            (random.randint(0, 255), random.randint(0, 255), scsi_bus_num)
            for scsi_bus_num in scsi_bus_nums
        ])

        self.assertItemsEqual(
            scsi_bus_nums,
            smartctl.detect_megaraid_config(factory.make_name('blockdevice')))
        self.assertThat(
            mock_run_storcli,
            MockCalledOnceWith(['/c%d' % controller, '/eall', '/sall',
                                'show']))
Ejemplo n.º 3
0
 def test__no_storcli(self):
     mock_exit_skipped = self.patch(smartctl, 'exit_skipped')
     smartctl.detect_megaraid_config(factory.make_name('blockdevice'))
     self.assertThat(mock_exit_skipped, MockCalledOnce())