def test_daemon_extents_dirty(http_server, uhttp_server): handler = Daemon(http_server, uhttp_server) chunk_size = len(handler.image) // 2 handler.extents["dirty"] = [ { "start": 0, "length": chunk_size, "dirty": True }, { "start": chunk_size, "length": chunk_size, "dirty": False }, ] with Backend(http_server.url, http_server.cafile) as b: # Both "zero" and "dirty" extents are available. assert list(b.extents("zero")) == [ image.ZeroExtent(0, b.size(), True), ] assert list(b.extents("dirty")) == [ image.DirtyExtent(0, chunk_size, True), image.DirtyExtent(chunk_size, chunk_size, False), ]
def test_daemon_read_from(http_server, uhttp_server): handler = Daemon(http_server, uhttp_server) with Backend(http_server.url, http_server.cafile) as b: check_read_from(handler, b) assert handler.dirty b.flush() assert not handler.dirty
def test_daemon_no_unix_socket_read_from(http_server): handler = Daemon(http_server, extents=False) with Backend(http_server.url, http_server.cafile) as b: check_read_from(handler, b) assert handler.dirty b.flush() assert not handler.dirty
def test_daemon_extents_zero(http_server, uhttp_server): handler = Daemon(http_server, uhttp_server) chunk_size = len(handler.image) // 2 handler.extents["zero"] = [ { "start": 0, "length": chunk_size, "zero": False }, { "start": chunk_size, "length": chunk_size, "zero": True }, ] with Backend(http_server.url, http_server.cafile) as b: # Zero extents are available. assert list(b.extents()) == [ image.ZeroExtent(0, chunk_size, False), image.ZeroExtent(chunk_size, chunk_size, True), ] # Dirty extents are not available. with pytest.raises(errors.UnsupportedOperation): list(b.extents("dirty"))
def test_daemon_open(http_server, uhttp_server): handler = Daemon(http_server, uhttp_server) with Backend(http_server.url, http_server.cafile) as b: assert b.server_address == uhttp_server.server_address assert b.tell() == 0 assert b.size() == len(handler.image) # Client reports server extents (all zero). assert list(b.extents()) == [image.ZeroExtent(0, b.size(), True)]
def test_daemon_no_extents_open(http_server, uhttp_server): handler = Daemon(http_server, uhttp_server, extents=False) with Backend(http_server.url, http_server.cafile) as b: assert b.server_address == uhttp_server.server_address assert b.tell() == 0 assert b.size() == len(handler.image) # Client emulates extents (all non-zero). assert list(b.extents()) == [image.ZeroExtent(0, b.size(), False)]
def test_old_proxy_open(http_server): handler = OldProxy(http_server) with Backend(http_server.url, http_server.cafile) as b: assert b.server_address == http_server.server_address assert b.tell() == 0 assert b.size() == len(handler.image) # Client emulates extents (all non-zero). assert list(b.extents()) == [image.ZeroExtent(0, b.size(), False)]
def test_daemon_write_to(http_server, uhttp_server): handler = Daemon(http_server, uhttp_server) with Backend(http_server.url, http_server.cafile) as b: check_write_to(handler, b)
def test_daemon_open_insecure(http_server, uhttp_server): Daemon(http_server, uhttp_server) with Backend(http_server.url, None, secure=False) as b: assert b.server_address == uhttp_server.server_address
def test_daemon_no_unix_socket_write_to(http_server): handler = Daemon(http_server, extents=False) with Backend(http_server.url, http_server.cafile) as b: check_write_to(handler, b)
def test_old_proxy_write_to(http_server): handler = OldProxy(http_server) with Backend(http_server.url, http_server.cafile) as b: check_write_to(handler, b)
def test_old_proxy_read_from(http_server): handler = OldProxy(http_server) with Backend(http_server.url, http_server.cafile) as b: check_read_from(handler, b) assert not handler.dirty
def test_old_daemon_read_from(http_server): handler = OldDaemon(http_server) with Backend(http_server.url, http_server.cafile) as b: check_read_from(handler, b) assert not handler.dirty
def test_old_daemon_readinto(http_server): handler = OldDaemon(http_server) with Backend(http_server.url, http_server.cafile) as b: check_readinto(handler, b)