예제 #1
0
def test_slot_reader():
    """
    Testing the slot fetching with an extract of a condor_status command output
    :return:
    """
    mocked_content = mocked_collector().query()
    collect.collect_slots(mocked_content)
예제 #2
0
def test_slot_result():
    """
    Tests the result slots for correct number of similar jobs based on RAM
    :return:
    """
    mocked_content = mocked_collector().query()

    slots = collect.collect_slots(mocked_content)

    ram = 10.0
    result = examine.check_slots(
        examine.filter_slots(slots, "Static"),
        examine.filter_slots(slots, "Partitionable"),
        1, ram, 0.0, 0, 1, 0.0, 0, verbose=False
    )
    slots = result["slots"]
    previews = result["preview"]

    for preview in previews:
        if preview['fits'] != 'YES':
            # Ignore results that do not fit
            continue

        # Find the slot referenced in results (same node-name and RAM)
        for slot in slots:
            slot_name = slot['Machine']

            if slot_name == preview["Machine"] and \
                    slot["TotalSlotMemory"] == preview['TotalSlotMemory']:
                ram_ratio = int(float(slot["TotalSlotMemory"]) / ram)

                # Assume that number of similar jobs does not exceed RAM ratio
                assert preview['sim_jobs'] <= ram_ratio
예제 #3
0
def test_slot_checking():
    """
    Tests the slot checking method.
    :return:
    """
    mocked_content = mocked_collector().query()

    slots = collect.collect_slots(mocked_content)

    assert "preview" in examine.check_slots(
        examine.filter_slots(slots, "static"),
        examine.filter_slots(slots, "partitionable"),
        1, 10.0, 0.0, 0, 1, 0.0, 0, verbose=False
    )
    assert "slots" in examine.check_slots(
        examine.filter_slots(slots, "static"),
        examine.filter_slots(slots, "partitionable"),
        1, 10.0, 0.0, 0, 1, 0.0, 0, verbose=False
    )
    assert examine.check_slots(
        examine.filter_slots(slots, "static"),
        examine.filter_slots(slots, "partitionable"),
        0, 10.0, 0.0, 0, 1, 0.0, 0, verbose=False
    ) == {'slots': [], 'preview': []}
    assert examine.check_slots(
        examine.filter_slots(slots, "static"),
        examine.filter_slots(slots, "partitionable"),
        0, 10.0, 0.0, 0, 1, 0.0, 0, verbose=False
    ) == {'slots': [], 'preview': []}
예제 #4
0
def test_slot_reader(root_dir):
    """
    Testing the slot fetching with an extract of a condor_status command output
    :return:
    """
    condor_status = path.join(root_dir, 'htcondor_status_long.txt')
    slots_in = collect.collect_slots(condor_status)
    collect.format_slots(slots_in["slots"])
예제 #5
0
def prepare(cpu: int, gpu: int, ram: str, disk: str, jobs: int,
            job_duration: str, maxnodes: int, verbose: bool,
            content: object) -> bool:
    """
    Prepares for the examination of job requests.

    Loads the slot configuration, handles user input, and invokes checks for a
    given job request provided the request is valid.

    Args:
        cpu: User input of CPU cores
        gpu: User input of GPU units
        ram: User input of the amount of RAM
        disk: User input of the amount of disk space
        jobs: User input of the number of similar jobs
        job_duration: User input of the duration time for a single job
        maxnodes:
        verbose:
        content: the loaded HTCondor slots configuration

    Returns:
        If all needed parameters were given
    """
    config = collect.collect_slots(content)

    slots_static = filter_slots(config, 'Static')
    slots_partitionable = filter_slots(config, 'Partitionable')

    [ram, ram_unit] = split_num_str(ram, 0.0, 'GiB')
    ram = to_binary_gigabyte(ram, ram_unit)
    [disk, disk_unit] = split_num_str(disk, 0.0, 'GiB')
    disk = to_binary_gigabyte(disk, disk_unit)

    [job_duration, duration_unit] = split_num_str(job_duration, 0.0, 'min')
    job_duration = to_minutes(job_duration, duration_unit)

    if cpu == 0:
        LOGGER.warning("No number of CPU workers given --- ABORTING")
    elif ram == 0.0:
        LOGGER.warning("No RAM amount given --- ABORTING")
    elif job_duration > 0.0 and jobs == 0:
        LOGGER.warning(
            "No Job amount for wall-time calculation given --- ABORTING")
    elif jobs > 1 and job_duration == 0.0:
        LOGGER.warning(
            "No execution time for Jobs has been given --- ABORTING")
    else:
        check_slots(slots_static, slots_partitionable, cpu, ram, disk, gpu,
                    jobs, job_duration, maxnodes, verbose)
        return True
    return False
예제 #6
0
def test_slot_config():
    """
    Tests the slot loading method.
    :return:
    """
    mocked_content = mocked_collector().query()

    slots = collect.collect_slots(mocked_content)

    assert "SlotType" in slots['cpu2'][0]

    assert "SlotType" in examine.filter_slots(slots, "Static")[0]
    assert examine.filter_slots(slots, "Static")[0]["SlotType"] == "Static"

    assert "SlotType" in examine.filter_slots(slots, "Partitionable")[0]
    assert examine.filter_slots(slots, "Partitionable")[0]["SlotType"] == "Partitionable"