Пример #1
0
def test_execute_platform_matching_both_empty():
    """Edge case where nothing specified on either side."""

    pairs = []
    exec_instance = ExecutionInstance(MockScheduler(), MockStorage(pairs),
                                      None)
    assert exec_instance.execute("fake", False) == "queued"
Пример #2
0
def test_execute_platform_matching_no_job_req():
    """If job doesn't specify platform key requirements, it should always pass."""

    pairs = [("OSFamily", "linux"), ("ISA", "x86-64")]
    exec_instance = ExecutionInstance(MockScheduler(), MockStorage(pairs),
                                      ["ChrootDigest"])
    assert exec_instance.execute("fake", False) == "queued"
Пример #3
0
def test_execute_platform_matching_success():
    """Will match due to platform keys matching."""

    pairs = [("ChrootDigest", "deadbeed")]
    exec_instance = ExecutionInstance(MockScheduler(), MockStorage(pairs),
                                      ["ChrootDigest"])
    assert exec_instance.execute("fake", False) == "queued"
Пример #4
0
def test_execute_platform_matching_failure():
    """Will not match due to platform-keys missing 'ChrootDigest'."""

    pairs = [("OSFamily", "linux"), ("ISA", "x86-64"),
             ("ChrootDigest", "deadbeef")]
    exec_instance = ExecutionInstance(MockScheduler(), MockStorage(pairs), [])
    with pytest.raises(FailedPreconditionError):
        exec_instance.execute("fake", False)
Пример #5
0
def test_execute_platform_matching_too_many_os():
    """Will not match due to too many OSFamilies being specified."""

    pairs = [("OSFamily", "linux"), ("OSFamily", "macos"), ("ISA", "x86-64"),
             ("ISA", "x86-avx")]
    exec_instance = ExecutionInstance(MockScheduler(), MockStorage(pairs), [])
    with pytest.raises(FailedPreconditionError):
        exec_instance.execute("fake", False)
Пример #6
0
def test_execute_platform_matching_too_many_os_platform_key():
    """Make sure adding standard keys to platform keys won't cause issues ."""

    pairs = [("OSFamily", "linux"), ("OSFamily", "macos"), ("ISA", "x86-64"),
             ("ISA", "x86-avx")]
    exec_instance = ExecutionInstance(MockScheduler(), MockStorage(pairs),
                                      ["OSFamily"])
    with pytest.raises(FailedPreconditionError):
        exec_instance.execute("fake", False)
Пример #7
0
def test_execute_platform_matching_simple():
    """Will match on standard keys."""

    pairs = [("OSFamily", "linux"), ("ISA", "x86-64"), ("ISA", "x86-avx")]
    exec_instance = ExecutionInstance(MockScheduler(), MockStorage(pairs), [])
    assert exec_instance.execute("fake", False) == "queued"
Пример #8
0
def mock_exec_instance():
    return ExecutionInstance(MockScheduler(), MockStorage([]), [])