Пример #1
0
def test_checkwaitingjobs_one(mock_submit):
    """
    Check that in cases that when there are two jobs waiting and only slot,
    that only one job gets submitted.
    """

    jobs = {
        "lbowconf": {
            "test-machine-queue-slots": 1,
            "test-machine-queue-max": 2
        },
        "jobone": {
            "laststatus": "Running",
            "resource": "test-machine",
            "scheduler": "LSF"
        },
        "jobtwo": {
            "laststatus": "Waiting Submission",
            "resource": "test-machine",
            "scheduler": "LSF"
        },
        "jobthree": {
            "laststatus": "Waiting Submission",
            "resource": "test-machine",
            "scheduler": "LSF"
        }
    }

    mock_submit.side_effect = addjobid

    _checkwaitingjobs(jobs, False)

    assert mock_submit.call_count == 1, "Should be submitting one job"
    assert jobs["lbowconf"]["test-machine-queue-slots"] == "2"
Пример #2
0
def test_checkwaitingjobs_except1(mock_submit):
    """
    Check if the plugin is not found that the correct exception is raised.
    """

    jobs = {
        "lbowconf": {
            "test-machine-queue-slots": 1,
            "test-machine-queue-max": 8
        },
        "jobone": {
            "laststatus": "Running",
            "resource": "test-machine",
            "scheduler": "LSF"
        },
        "jobtwo": {
            "laststatus": "Waiting Submission",
            "resource": "test-machine",
            "scheduler": "LSF"
        },
        "jobthree": {
            "laststatus": "Waiting Submission",
            "resource": "test-machine",
            "scheduler": "LSF"
        }
    }

    mock_submit.side_effect = AttributeError

    with pytest.raises(exceptions.PluginattributeError):

        _checkwaitingjobs(jobs, False)
Пример #3
0
def test_checkwaitingjobs_except3(mock_submit):
    """
    Check that if the max queue error is thrown that the job is simply marked
    as in error state.
    """

    jobs = {
        "lbowconf": {
            "test-machine-queue-slots": 1,
            "test-machine-queue-max": 8
        },
        "jobone": {
            "laststatus": "Running",
            "resource": "test-machine",
            "scheduler": "LSF"
        },
        "jobtwo": {
            "laststatus": "Waiting Submission",
            "resource": "test-machine",
            "scheduler": "LSF"
        },
        "jobthree": {
            "laststatus": "Waiting Submission",
            "resource": "test-machine",
            "scheduler": "LSF"
        }
    }

    mock_submit.side_effect = exceptions.QueuemaxError

    _checkwaitingjobs(jobs, False)

    assert jobs["jobone"]["laststatus"] == "Running"
    assert jobs["jobtwo"]["laststatus"] == "Submit Error"
    assert jobs["jobthree"]["laststatus"] == "Submit Error"
Пример #4
0
def test_checkwaitingjobs_two(mock_submit):
    """
    Check that in cases where there are multiple jobs but a lot less than the
    number of slots available only the correct number of jobs are submitted.
    """

    jobs = {
        "lbowconf": {
            "test-machine-queue-slots": 1,
            "test-machine-queue-max": 8
        },
        "jobone": {
            "laststatus": "Running",
            "resource": "test-machine",
            "scheduler": "LSF"
        },
        "jobtwo": {
            "laststatus": "Waiting Submission",
            "resource": "test-machine",
            "scheduler": "LSF"
        },
        "jobthree": {
            "laststatus": "Waiting Submission",
            "resource": "test-machine",
            "scheduler": "LSF"
        }
    }

    mock_submit.side_effect = addjobid

    _checkwaitingjobs(jobs, False)

    assert mock_submit.call_count == 2, "Should be submitting two jobs"
    assert jobs["lbowconf"]["test-machine-queue-slots"] == "3"
Пример #5
0
def test_checkwaitingjobs_none(mock_submit):
    """
    Check that if no jobs are marked as waiting that nothing gets submitted.
    """

    jobs = {
        "jobone": {
            "laststatus": "Running",
            "resource": "hpc-1"
        },
        "jobtwo": {
            "laststatus": "Finished",
            "resource": "hpc-1"
        },
        "jobthree": {
            "laststatus": "Complete",
            "resource": "hpc-1"
        }
    }

    _checkwaitingjobs(jobs, False)

    assert mock_submit.call_count == 0, "Should not be trying to submit"