def test_application_spec_invariants(): s = Service(commands=['command'], resources=Resources(memory=1024, vcores=1)) # No services with pytest.raises(ValueError): ApplicationSpec(name='dask', queue='default', services={}) for k, v in [('name', 1), ('queue', 1), ('tags', 1), ('tags', {1, 2, 3}), ('max_attempts', 'foo')]: with pytest.raises(TypeError): ApplicationSpec(services={'service': s}, **{k: v}) with pytest.raises(ValueError): ApplicationSpec(max_attempts=0, services={'service': s}) r = Resources(memory=1024, vcores=1) c = ['commands'] # Unknown dependency name with pytest.raises(ValueError): ApplicationSpec( services={ 'a': s, 'b': Service(resources=r, commands=c, depends=['c', 'd']) }) # Cyclical dependencies with pytest.raises(ValueError): ApplicationSpec( services={ 'a': Service(resources=r, commands=c, depends=['c']), 'b': Service(resources=r, commands=c, depends=['a']), 'c': Service(resources=r, commands=c, depends=['b']) })
def test_application_spec(): r = Resources(memory=1024, vcores=1) c = ['commands'] s1 = Service(resources=r, commands=c, files={'file': File(source='/test/path')}) s2 = Service(resources=r, commands=c, files={'file': File(source='/test/path', size=1024)}) spec1 = ApplicationSpec(services={'service': s1}) spec2 = ApplicationSpec(services={'service': s2}) check_specification_methods(spec1, spec2)
def test_application_spec(): r = Resources(memory=1024, vcores=1) s1 = Service(resources=r, script="script", files={'file': File(source='/test/path')}) s2 = Service(resources=r, script="script", files={'file': File(source='/test/path', size=1024)}) spec1 = ApplicationSpec(name='test', queue='testqueue', node_label='testlabel', services={'service': s1}) spec2 = ApplicationSpec(master=Master(script='script', resources=r)) spec3 = ApplicationSpec(services={'service': s2}) check_specification_methods(spec1, spec3) check_specification_methods(spec2, spec3)