Beispiel #1
0
    def setUp(self):
        self.cpu_ratio = 0.9
        self.memory_ratio = 0.8
        self.command = (
            "condor_status -af:t Machine Name State Activity TardisDroneUuid "
            "'Real(TotalSlotCpus-Cpus)/TotalSlotCpus' "
            "'Real(TotalSlotMemory-Memory)/TotalSlotMemory' -constraint PartitionableSlot=?=True"  # noqa: B950
            " -pool my-htcondor.local -test")

        self.command_wo_options = (
            "condor_status -af:t Machine Name State Activity TardisDroneUuid "
            "'Real(TotalSlotCpus-Cpus)/TotalSlotCpus' "
            "'Real(TotalSlotMemory-Memory)/TotalSlotMemory' -constraint PartitionableSlot=?=True"  # noqa: B950
        )

        return_value = "\n".join([
            f"test\tslot1@test\tUnclaimed\tIdle\tundefined\t{self.cpu_ratio}\t{self.memory_ratio}",  # noqa: B950
            f"test_drain\tslot1@test\tDrained\tRetiring\tundefined\t{self.cpu_ratio}\t{self.memory_ratio}",  # noqa: B950
            f"test_drained\tslot1@test\tDrained\tIdle\tundefined\t{self.cpu_ratio}\t{self.memory_ratio}",  # noqa: B950
            f"test_owner\tslot1@test\tOwner\tIdle\tundefined\t{self.cpu_ratio}\t{self.memory_ratio}",  # noqa: B950
            f"test_uuid_plus\tslot1@test_uuid@test\tUnclaimed\tIdle\ttest_uuid\t{self.cpu_ratio}\t{self.memory_ratio}",  # noqa: B950
            "exoscale-26d361290f\tslot1@exoscale-26d361290f\tUnclaimed\tIdle\tundefined\t0.125\t0.125",  # noqa: B950
        ])
        self.mock_async_run_command.return_value = async_return(
            return_value=return_value)

        self.setup_config_mock(options={
            "pool": "my-htcondor.local",
            "test": None
        })

        self.htcondor_adapter = HTCondorAdapter()
Beispiel #2
0
    def setUp(self):
        self.cpu_ratio = 0.9
        self.memory_ratio = 0.8
        self.command = "condor_status -af:t Machine State Activity TardisDroneUuid " \
                       "'Real(TotalSlotCpus-Cpus)/TotalSlotCpus' " \
                       "'Real(TotalSlotCpus-Cpus)/TotalSlotCpus' -constraint PartitionableSlot=?=True" \
                       " -pool my-htcondor.local -test"

        self.command_wo_options = "condor_status -af:t Machine State Activity TardisDroneUuid " \
                                  "'Real(TotalSlotCpus-Cpus)/TotalSlotCpus' " \
                                  "'Real(TotalSlotCpus-Cpus)/TotalSlotCpus' -constraint PartitionableSlot=?=True"

        return_value = "\n".join([
            f"test\tUnclaimed\tIdle\tundefined\t{self.cpu_ratio}\t{self.memory_ratio}",
            f"test_drain\tDrained\tRetiring\tundefined\t{self.cpu_ratio}\t{self.memory_ratio}",
            f"test_drained\tDrained\tIdle\tundefined\t{self.cpu_ratio}\t{self.memory_ratio}",
            f"test_owner\tOwner\tIdle\tundefined\t{self.cpu_ratio}\t{self.memory_ratio}",
            f"test_uuid_plus\tUnclaimed\tIdle\ttest_uuid\t{self.cpu_ratio}\t{self.memory_ratio}",
            "exoscale-26d361290f\tUnclaimed\tIdle\tundefined\t0.125\t0.125"
        ])
        self.mock_async_run_command.return_value = async_return(
            return_value=return_value)

        self.config = self.mock_config.return_value
        self.config.BatchSystem.ratios = {
            'cpu_ratio': 'Real(TotalSlotCpus-Cpus)/TotalSlotCpus',
            'memory_ratio': 'Real(TotalSlotCpus-Cpus)/TotalSlotCpus'
        }
        self.config.BatchSystem.max_age = 10
        self.config.BatchSystem.options = {
            'pool': 'my-htcondor.local',
            'test': None
        }

        self.htcondor_adapter = HTCondorAdapter()
Beispiel #3
0
    def test_drain_machine_without_options(self):
        self.setup_config_mock()
        self.htcondor_adapter = HTCondorAdapter()

        run_async(self.htcondor_adapter.drain_machine, drone_uuid='test')
        self.mock_async_run_command.assert_called_with(
            'condor_drain -graceful test')
Beispiel #4
0
    def test_get_resource_ratios_without_options(self):
        del self.config.BatchSystem.options
        htcondor_adapter_wo_options = HTCondorAdapter()

        self.assertCountEqual(
            list(
                run_async(htcondor_adapter_wo_options.get_resource_ratios,
                          drone_uuid='test')),
            [self.cpu_ratio, self.memory_ratio])

        self.mock_async_run_command.assert_called_with(self.command_wo_options)
Beispiel #5
0
    def test_drain_machine_without_options(self):
        self.setup_config_mock()
        self.htcondor_adapter = HTCondorAdapter()

        run_async(self.htcondor_adapter.drain_machine, drone_uuid="test")
        self.mock_executor.return_value.run_command.assert_called_with(
            "condor_drain -graceful slot1@test")

        self.mock_executor.reset_mock()

        run_async(self.htcondor_adapter.drain_machine, drone_uuid="test_uuid")
        self.mock_executor.return_value.run_command.assert_called_with(
            "condor_drain -graceful slot1@test_uuid@test")
Beispiel #6
0
    def test_get_resource_ratios_without_options(self):
        self.setup_config_mock()
        del self.config.BatchSystem.options
        self.htcondor_adapter = HTCondorAdapter()

        self.assertCountEqual(
            list(
                run_async(self.htcondor_adapter.get_resource_ratios,
                          drone_uuid="test")),
            [self.cpu_ratio, self.memory_ratio],
        )

        self.mock_async_run_command.assert_called_with(self.command_wo_options)
Beispiel #7
0
    def setUp(self):
        self.cpu_ratio = CPU_RATIO
        self.memory_ratio = MEMORY_RATIO
        self.command = (
            "condor_status -af:t Machine Name State Activity TardisDroneUuid "
            "'Real(TotalSlotCpus-Cpus)/TotalSlotCpus' "
            "'Real(TotalSlotMemory-Memory)/TotalSlotMemory' -constraint PartitionableSlot=?=True"  # noqa: B950
            " -pool my-htcondor.local -test")

        self.command_wo_options = (
            "condor_status -af:t Machine Name State Activity TardisDroneUuid "
            "'Real(TotalSlotCpus-Cpus)/TotalSlotCpus' "
            "'Real(TotalSlotMemory-Memory)/TotalSlotMemory' -constraint PartitionableSlot=?=True"  # noqa: B950
        )

        self.setup_config_mock(options={
            "pool": "my-htcondor.local",
            "test": None
        })

        self.htcondor_adapter = HTCondorAdapter()