Exemple #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)
Exemple #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
Exemple #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': []}
Exemple #4
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"
Exemple #5
0
def test_calc_manager():
    """
    Tests the method for preparing the slot checking.
    :return:
    """
    mocked_content = mocked_collector().query()

    assert examine.prepare(
        cpu=1, gpu=0, ram="10GB", disk="0", jobs=1, job_duration="10m",
        maxnodes=0, verbose=True, content=mocked_content
    )
    assert not examine.prepare(
        cpu=0, gpu=1, ram="10GB", disk="0", jobs=1, job_duration="10m",
        maxnodes=0, verbose=True, content=mocked_content
    )
    assert not examine.prepare(
        cpu=1, gpu=0, ram="0", disk="", jobs=1, job_duration="", maxnodes=0,
        verbose=True, content=mocked_content
    )
    assert examine.prepare(
        cpu=1, gpu=1, ram="20GB", disk="", jobs=1, job_duration="10m",
        maxnodes=0, verbose=True, content=mocked_content
    )
    assert examine.prepare(
        cpu=1, gpu=0, ram="10GB", disk="10GB", jobs=1, job_duration="10m",
        maxnodes=0, verbose=True, content=mocked_content
    )
    assert examine.prepare(
        cpu=1, gpu=0, ram="10GB", disk="10GB", jobs=128, job_duration="15m",
        maxnodes=0, verbose=True, content=mocked_content
    )
    assert examine.prepare(
        cpu=1, gpu=0, ram="10GB", disk="", jobs=1, job_duration="10m",
        maxnodes=1, verbose=True, content=mocked_content
    )
    assert examine.prepare(
        cpu=8, gpu=0, ram="10GB", disk="", jobs=1, job_duration="10m",
        maxnodes=0, verbose=True, content=mocked_content
    )
    assert examine.prepare(
        cpu=8, gpu=0, ram="80GB", disk="", jobs=4, job_duration="1h",
        maxnodes=0, verbose=True, content=mocked_content
    )
    assert examine.prepare(
        cpu=2, gpu=0, ram="10GB", disk="", jobs=1, job_duration="10m",
        maxnodes=3, verbose=True, content=mocked_content
    )
    assert examine.prepare(
        cpu=1, gpu=0, ram="20GB", disk="", jobs=1, job_duration="10m",
        maxnodes=2, verbose=True, content=mocked_content
    )
    assert examine.prepare(
        cpu=2, gpu=0, ram="20GB", disk="", jobs=1, job_duration="",
        maxnodes=2, verbose=True, content=mocked_content
    )
    assert not examine.prepare(
        cpu=2, gpu=0, ram="20GB", disk="", jobs=2, job_duration="",
        maxnodes=2, verbose=True, content=mocked_content
    )
    assert not examine.prepare(
        cpu=2, gpu=0, ram="20GB", disk="", jobs=0, job_duration="10m",
        maxnodes=2, verbose=True, content=mocked_content
    )
    assert examine.prepare(
        cpu=2, gpu=0, ram="20GB", disk="", jobs=32, job_duration="10m",
        maxnodes=1, verbose=True, content=mocked_content
    )
    assert examine.prepare(
        cpu=2, gpu=5, ram="10GB", disk="", jobs=32, job_duration="10m",
        maxnodes=1, verbose=True, content=mocked_content
    )