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"
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"
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"
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)
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)
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)
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"
def mock_exec_instance(): return ExecutionInstance(MockScheduler(), MockStorage([]), [])