def snapshot_tree_backup_test( backup_target, engine_name, # NOQA grpc_controller, grpc_replica1, grpc_replica2): # NOQA address = grpc_controller.address dev = get_dev(grpc_replica1, grpc_replica2, grpc_controller) offset = 0 length = 128 backup = {} snap, data = snapshot_tree_build(dev, address, engine_name, offset, length) backup["0b"] = create_backup(address, snap["0b"], backup_target)["URL"] backup["0c"] = create_backup(address, snap["0c"], backup_target)["URL"] backup["1c"] = create_backup(address, snap["1c"], backup_target)["URL"] backup["2b"] = create_backup(address, snap["2b"], backup_target)["URL"] backup["2c"] = create_backup(address, snap["2c"], backup_target)["URL"] backup["3c"] = create_backup(address, snap["3c"], backup_target)["URL"] snapshot_tree_verify_backup_node(dev, address, engine_name, offset, length, backup, data, "0b") snapshot_tree_verify_backup_node(dev, address, engine_name, offset, length, backup, data, "0c") snapshot_tree_verify_backup_node(dev, address, engine_name, offset, length, backup, data, "1c") snapshot_tree_verify_backup_node(dev, address, engine_name, offset, length, backup, data, "2b") snapshot_tree_verify_backup_node(dev, address, engine_name, offset, length, backup, data, "2c") snapshot_tree_verify_backup_node(dev, address, engine_name, offset, length, backup, data, "3c")
def test_snapshot_tree_rebuild( grpc_controller, # NOQA grpc_replica1, grpc_replica2): # NOQA address = grpc_controller.address offset = 0 length = 128 open_replica(grpc_replica1) open_replica(grpc_replica2) replicas = grpc_controller.replica_list() assert len(replicas) == 0 r1_url = grpc_replica1.url r2_url = grpc_replica2.url v = grpc_controller.volume_start(replicas=[r1_url, r2_url]) assert v.name == VOLUME_NAME assert v.replicaCount == 2 replicas = grpc_controller.replica_list() assert len(replicas) == 2 assert replicas[0].mode == "RW" assert replicas[1].mode == "RW" dev = get_blockdev(VOLUME_NAME) snap, snap_data = snapshot_tree_build(dev, address, ENGINE_NAME, offset, length) data = random_string(128) data_offset = 1024 verify_data(dev, data_offset, data) # Cleanup replica2 cleanup_replica(grpc_replica2) verify_async(dev, 10, 128, 1) verify_replica_state(grpc_controller, 1, "ERR") verify_read(dev, data_offset, data) grpc_controller.replica_delete(replicas[1].address) # Rebuild replica2 open_replica(grpc_replica2) cmd.add_replica(address, r2_url) verify_async(dev, 10, 128, 1) verify_replica_state(grpc_controller, 1, "RW") snapshot_tree_verify(dev, address, ENGINE_NAME, offset, length, snap, snap_data)
def test_snapshot_tree_basic(dev): # NOQA offset = 0 length = 128 snap, data = snapshot_tree_build(dev, offset, length) cmd.snapshot_revert(snap["1b"]) cmd.snapshot_rm(snap["0a"]) cmd.snapshot_rm(snap["0b"]) cmd.snapshot_rm(snap["1c"]) cmd.snapshot_rm(snap["2a"]) cmd.snapshot_rm(snap["2b"]) cmd.snapshot_rm(snap["2c"]) cmd.snapshot_rm(snap["3a"]) cmd.snapshot_rm(snap["3b"]) cmd.snapshot_rm(snap["3c"]) cmd.snapshot_purge() # the result should looks like this # snap["0b"](r) -> snap["0c"] # \-> snap["1a"] -> snap["1b"] -> head info = cmd.snapshot_info() assert len(info) == 5 assert snap["0b"] in info assert info[snap["0b"]]["parent"] == "" assert len(info[snap["0b"]]["children"]) == 2 assert snap["0c"] in info[snap["0b"]]["children"] assert snap["1a"] in info[snap["0b"]]["children"] assert info[snap["0b"]]["removed"] is True assert snap["0c"] in info assert info[snap["0c"]]["parent"] == snap["0b"] assert info[snap["0c"]]["children"] == [] assert snap["1a"] in info assert info[snap["1a"]]["parent"] == snap["0b"] assert info[snap["1a"]]["children"] == [snap["1b"]] assert snap["1b"] in info assert info[snap["1b"]]["parent"] == snap["1a"] assert info[snap["1b"]]["children"] == [VOLUME_HEAD] assert VOLUME_HEAD in info assert info[VOLUME_HEAD]["parent"] == snap["1b"] snapshot_tree_verify_node(dev, offset, length, snap, data, "0b") snapshot_tree_verify_node(dev, offset, length, snap, data, "0c") snapshot_tree_verify_node(dev, offset, length, snap, data, "1a") snapshot_tree_verify_node(dev, offset, length, snap, data, "1b")
def test_snapshot_tree_rebuild( grpc_controller, # NOQA grpc_replica1, grpc_replica2): # NOQA offset = 0 length = 128 open_replica(grpc_replica1) open_replica(grpc_replica2) replicas = grpc_controller.replica_list() assert len(replicas) == 0 v = grpc_controller.volume_start( replicas=[common.REPLICA1, common.REPLICA2]) assert v.replicaCount == 2 replicas = grpc_controller.replica_list() assert len(replicas) == 2 assert replicas[0].mode == "RW" assert replicas[1].mode == "RW" dev = get_blockdev() snap, snap_data = snapshot_tree_build(dev, offset, length) data = common.random_string(128) data_offset = 1024 verify_data(dev, data_offset, data) # Cleanup replica2 cleanup_replica(grpc_replica2) verify_async(dev, 10, 128, 1) common.verify_replica_state(grpc_controller, 1, "ERR") verify_read(dev, data_offset, data) grpc_controller.replica_delete(replicas[1].address) # Rebuild replica2 open_replica(grpc_replica2) cmd.add_replica(common.REPLICA2) verify_async(dev, 10, 128, 1) common.verify_replica_state(grpc_controller, 1, "RW") snapshot_tree_verify(dev, offset, length, snap, snap_data)
def test_snapshot_tree_rebuild(controller, replica1, replica2): # NOQA offset = 0 length = 128 open_replica(replica1) open_replica(replica2) replicas = controller.list_replica() assert len(replicas) == 0 v = controller.list_volume()[0] v = v.start(replicas=[ common.REPLICA1, common.REPLICA2 ]) assert v.replicaCount == 2 replicas = controller.list_replica() assert len(replicas) == 2 assert replicas[0].mode == "RW" assert replicas[1].mode == "RW" dev = get_blockdev() snap, snap_data = snapshot_tree_build(dev, offset, length) data = common.random_string(128) data_offset = 1024 verify_data(dev, data_offset, data) # Cleanup replica2 cleanup_replica(replica2) verify_async(dev, 10, 128, 1) common.verify_replica_state(controller, 1, "ERR") verify_read(dev, data_offset, data) controller.delete(replicas[1]) # Rebuild replica2 common.open_replica(replica2) cmd.add_replica(common.REPLICA2) verify_async(dev, 10, 128, 1) common.verify_replica_state(controller, 1, "RW") snapshot_tree_verify(dev, offset, length, snap, snap_data)
def test_snapshot_tree_backup(dev): # NOQA offset = 0 length = 128 backup = {} snap, data = snapshot_tree_build(dev, offset, length) backup["0b"] = cmd.backup_create(snap["0b"], BACKUP_DEST) backup["0c"] = cmd.backup_create(snap["0c"], BACKUP_DEST) backup["1c"] = cmd.backup_create(snap["1c"], BACKUP_DEST) backup["2b"] = cmd.backup_create(snap["2b"], BACKUP_DEST) backup["2c"] = cmd.backup_create(snap["2c"], BACKUP_DEST) backup["3c"] = cmd.backup_create(snap["3c"], BACKUP_DEST) snapshot_tree_verify_backup_node(dev, offset, length, backup, data, "0b") snapshot_tree_verify_backup_node(dev, offset, length, backup, data, "0c") snapshot_tree_verify_backup_node(dev, offset, length, backup, data, "1c") snapshot_tree_verify_backup_node(dev, offset, length, backup, data, "2b") snapshot_tree_verify_backup_node(dev, offset, length, backup, data, "2c") snapshot_tree_verify_backup_node(dev, offset, length, backup, data, "3c")
def snapshot_tree_backup_test(dev, backup_target): # NOQA offset = 0 length = 128 backup = {} snap, data = snapshot_tree_build(dev, offset, length) backup["0b"] = cmd.backup_create(snap["0b"], backup_target) backup["0c"] = cmd.backup_create(snap["0c"], backup_target) backup["1c"] = cmd.backup_create(snap["1c"], backup_target) backup["2b"] = cmd.backup_create(snap["2b"], backup_target) backup["2c"] = cmd.backup_create(snap["2c"], backup_target) backup["3c"] = cmd.backup_create(snap["3c"], backup_target) snapshot_tree_verify_backup_node(dev, offset, length, backup, data, "0b") snapshot_tree_verify_backup_node(dev, offset, length, backup, data, "0c") snapshot_tree_verify_backup_node(dev, offset, length, backup, data, "1c") snapshot_tree_verify_backup_node(dev, offset, length, backup, data, "2b") snapshot_tree_verify_backup_node(dev, offset, length, backup, data, "2c") snapshot_tree_verify_backup_node(dev, offset, length, backup, data, "3c")
def test_snapshot_tree_basic( grpc_controller, # NOQA grpc_replica1, grpc_replica2): # NOQA address = grpc_controller.address dev = get_dev(grpc_replica1, grpc_replica2, grpc_controller) offset = 0 length = 128 snap, data = snapshot_tree_build(dev, address, ENGINE_NAME, offset, length) snapshot_revert_with_frontend(address, ENGINE_NAME, snap["1b"]) cmd.snapshot_rm(address, snap["0a"]) cmd.snapshot_rm(address, snap["0b"]) cmd.snapshot_rm(address, snap["1c"]) cmd.snapshot_rm(address, snap["2a"]) cmd.snapshot_rm(address, snap["2b"]) cmd.snapshot_rm(address, snap["2c"]) cmd.snapshot_rm(address, snap["3a"]) cmd.snapshot_rm(address, snap["3b"]) cmd.snapshot_rm(address, snap["3c"]) cmd.snapshot_purge(address) wait_for_purge_completion(address) # the result should looks like this # snap["0b"](r) -> snap["0c"] # \-> snap["1a"] -> snap["1b"] -> head info = cmd.snapshot_info(address) assert len(info) == 5 assert snap["0b"] in info assert info[snap["0b"]]["parent"] == "" assert len(info[snap["0b"]]["children"]) == 2 assert snap["0c"] in info[snap["0b"]]["children"] assert snap["1a"] in info[snap["0b"]]["children"] assert info[snap["0b"]]["removed"] is True assert snap["0c"] in info assert info[snap["0c"]]["parent"] == snap["0b"] assert not info[snap["0c"]]["children"] assert snap["1a"] in info assert info[snap["1a"]]["parent"] == snap["0b"] assert snap["1b"] in info[snap["1a"]]["children"] assert snap["1b"] in info assert info[snap["1b"]]["parent"] == snap["1a"] assert VOLUME_HEAD in info[snap["1b"]]["children"] assert VOLUME_HEAD in info assert info[VOLUME_HEAD]["parent"] == snap["1b"] snapshot_tree_verify_node(dev, address, ENGINE_NAME, offset, length, snap, data, "0b") snapshot_tree_verify_node(dev, address, ENGINE_NAME, offset, length, snap, data, "0c") snapshot_tree_verify_node(dev, address, ENGINE_NAME, offset, length, snap, data, "1a") snapshot_tree_verify_node(dev, address, ENGINE_NAME, offset, length, snap, data, "1b")