def test_service(): 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)}) check_specification_methods(s1, s2)
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_service(): r = Resources(memory=1024, vcores=1) s1 = Service(resources=r, script='script', node_label="testlabel", files={'file': File(source='/test/path')}, nodes=['worker.example.com'], racks=['rack1', 'rack2'], relax_locality=True) s2 = Service(resources=r, script='script', files={'file': File(source='/test/path', size=1024)}) check_specification_methods(s1, s2)
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_file_invariants(): with pytest.raises(TypeError): File() with pytest.raises(TypeError): File(1) with pytest.raises(ValueError): File('/foo/bar.zip', type='invalid') with pytest.raises(ValueError): File('/foo/bar.zip', visibility='invalid') fil = File(source='/test/path') with pytest.raises(ValueError): fil.type = 'invalid' with pytest.raises(ValueError): fil.visibility = 'invalid' # relative paths sol = 'file://%s' % os.path.join(os.getcwd(), 'foo/bar.zip') assert File('foo/bar.zip').source == sol # relative path, with _origin specified (only used when reading from file) f = File.from_dict({'source': '../../file'}, _origin='/path/to/origin/spot') assert f.source == 'file:///path/to/file' # scheme specified assert File('hdfs:///foo/bar.zip').source == 'hdfs:///foo/bar.zip' assert (File('hdfs://foo.com:9000/foo/bar.zip').source == 'hdfs://foo.com:9000/foo/bar.zip') assert (File(source='/test/path', type='file') == File(source='/test/path', type='FILE')) assert File(source='/test/path').type == FileType.FILE assert File(source='/test/path.zip').type == FileType.ARCHIVE f = File(source='/test/path.zip', type='file') assert f.type == FileType.FILE f.type = 'archive' assert f.type == FileType.ARCHIVE
def test_file(): fil = File(source='/test/path') fil2 = File(source='/test/path', size=1024) check_specification_methods(fil, fil2)
def test_file_invariants(): with pytest.raises(TypeError): File() with pytest.raises(TypeError): File(1) with pytest.raises(ValueError): File('/foo/bar.zip', type='invalid') with pytest.raises(ValueError): File('/foo/bar.zip', visibility='invalid') with pytest.raises(ValueError): File('foo/bar.zip') fil = File(source='/test/path') with pytest.raises(ValueError): fil.type = 'invalid' with pytest.raises(ValueError): fil.visibility = 'invalid' assert (File(source='/test/path', type='file') == File(source='/test/path', type='FILE')) assert File(source='/test/path').type == FileType.FILE assert File(source='/test/path.zip').type == FileType.ARCHIVE f = File(source='/test/path.zip', type='file') assert f.type == FileType.FILE f.type = 'archive' assert f.type == FileType.ARCHIVE
def test_file(): fil = File(source='/test/path') fil2 = File(source='/test/path', size=1024) check_basic_methods(fil, fil2)