def test_master_invariants(): with pytest.raises(TypeError): Master(log_config=1) # Strings are converted to File objects m = Master(log_config='/test/path.properties') assert isinstance(m.log_config, File) assert m.log_config.type == 'file' # Relative paths are converted sol = 'file://%s' % os.path.join(os.getcwd(), 'foo/bar.properties') assert Master(log_config='foo/bar.properties').log_config.source == sol # setter/getter f = Master(log_level='debug') assert f.log_level == LogLevel.DEBUG f.log_level = 'info' assert f.log_level == LogLevel.INFO with pytest.raises(TypeError): Master(script=1) with pytest.raises(TypeError): Master(env={'a': 1}) # Mutable defaults properly set m = Master() assert isinstance(m.env, dict) assert isinstance(m.files, dict) # Strings are converted to File objects m = Master(files={'target': '/source.zip', 'target2': '/source2.txt'}) assert m.files['target'].type == 'archive' assert m.files['target2'].type == 'file'
def test_master(): m1 = Master(log_level='debug', log_config='/test/path.properties', security=Security.new_credentials()) m2 = Master(resources=Resources(memory='1 GiB', vcores=2), script='script', env={'FOO': 'BAR'}, files={'file': '/test/path'}) m3 = Master() check_specification_methods(m1, m3) check_specification_methods(m2, m3)
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)
def test_master_invariants(): with pytest.raises(TypeError): Master(log_config=1) # Strings are converted to File objects m = Master(log_config='/test/path.properties') assert isinstance(m.log_config, File) assert m.log_config.type == 'file' # Relative paths are converted sol = 'file://%s' % os.path.join(os.getcwd(), 'foo/bar.properties') assert Master(log_config='foo/bar.properties').log_config.source == sol # setter/getter f = Master(log_level='debug') assert f.log_level == LogLevel.DEBUG f.log_level = 'info' assert f.log_level == LogLevel.INFO
def test_application_spec_invariants(): s = Service(script="script", resources=Resources(memory=1024, vcores=1)) # No services with pytest.raises(ValueError): ApplicationSpec(name='dask', queue='default') # No master script with pytest.raises(ValueError): ApplicationSpec(name='dask', queue='default', master=Master()) 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) # Unknown dependency name with pytest.raises(ValueError): ApplicationSpec(services={'a': s, 'b': Service(resources=r, script="script", depends=['c', 'd'])}) # Cyclical dependencies with pytest.raises(ValueError): ApplicationSpec(services={'a': Service(resources=r, script="script", depends=['c']), 'b': Service(resources=r, script="script", depends=['a']), 'c': Service(resources=r, script="script", depends=['b'])})
def test_master(): m1 = Master(log_level='info', log_config='/test/path.properties') m2 = Master(log_level='debug') check_specification_methods(m1, m2)
def test_master(): m1 = Master(log_level='info', log_config='/test/path.properties', security=Security.new_credentials()) m2 = Master(log_level='debug') check_specification_methods(m1, m2)