def test_snapshot_rm_rolling(dev): # NOQA offset = 0 length = 128 snap1_data = common.random_string(length) common.verify_data(dev, offset, snap1_data) snap1 = cmd.snapshot_create() snapList = cmd.snapshot_ls() assert snap1 in snapList cmd.snapshot_rm(snap1) snap2_data = common.random_string(length) common.verify_data(dev, offset, snap2_data) snap2 = cmd.snapshot_create() snapList = cmd.snapshot_ls() assert snap1 not in snapList assert snap2 in snapList # this should trigger real deletion of snap1 cmd.snapshot_rm(snap2) snap3_data = common.random_string(length) common.verify_data(dev, offset, snap3_data) snap3 = cmd.snapshot_create() snap4_data = common.random_string(length) common.verify_data(dev, offset, snap4_data) snap4 = cmd.snapshot_create() snapList = cmd.snapshot_ls() assert snap1 not in snapList assert snap2 not in snapList assert snap3 in snapList assert snap4 in snapList output = cmd.snapshot_info() info = json.loads(output) assert info[snap3]["size"] == "4096" assert info[snap4]["size"] == "4096" # this should trigger real deletion of snap2 and snap3 cmd.snapshot_rm(snap3) readed = read_dev(dev, offset, length) assert readed == snap4_data
def test_snapshot_revert(dev): # NOQA offset = 0 length = 128 snap1_data = common.random_string(length) common.verify_data(dev, offset, snap1_data) snap1 = cmd.snapshot_create() snap2_data = common.random_string(length) common.verify_data(dev, offset, snap2_data) snap2 = cmd.snapshot_create() snap3_data = common.random_string(length) common.verify_data(dev, offset, snap3_data) snap3 = cmd.snapshot_create() snapList = cmd.snapshot_ls() assert snap1 in snapList assert snap2 in snapList assert snap3 in snapList cmd.snapshot_revert(snap2) readed = read_dev(dev, offset, length) assert readed == snap2_data cmd.snapshot_revert(snap1) readed = read_dev(dev, offset, length) assert readed == snap1_data
def test_snapshot_rm_rolling(dev): # NOQA offset = 0 length = 128 snap1_data = common.random_string(length) common.verify_data(dev, offset, snap1_data) snap1 = cmd.snapshot_create() snapList = cmd.snapshot_ls() assert snap1 in snapList cmd.snapshot_rm(snap1) snap2_data = common.random_string(length) common.verify_data(dev, offset, snap2_data) snap2 = cmd.snapshot_create() snapList = cmd.snapshot_ls() assert snap1 not in snapList assert snap2 in snapList # this should trigger real deletion of snap1 cmd.snapshot_rm(snap2) snap3_data = common.random_string(length) common.verify_data(dev, offset, snap3_data) snap3 = cmd.snapshot_create() snap4_data = common.random_string(length) common.verify_data(dev, offset, snap4_data) snap4 = cmd.snapshot_create() snapList = cmd.snapshot_ls() assert snap1 not in snapList assert snap2 not in snapList assert snap3 in snapList assert snap4 in snapList # this should trigger real deletion of snap2 and snap3 cmd.snapshot_rm(snap3) readed = read_dev(dev, offset, length) assert readed == snap4_data
def snapshot_revert_test(dev, address, engine_name): # NOQA existings = {} snap1 = Snapshot(dev, generate_random_data(existings), address) snap2 = Snapshot(dev, generate_random_data(existings), address) snap3 = Snapshot(dev, generate_random_data(existings), address) snapList = cmd.snapshot_ls(address) assert snap1.name in snapList assert snap2.name in snapList assert snap3.name in snapList snapshot_revert_with_frontend(address, engine_name, snap2.name) snap3.refute_data() snap2.verify_checksum() snap1.verify_data() snapshot_revert_with_frontend(address, engine_name, snap1.name) snap3.refute_data() snap2.refute_data() snap1.verify_checksum()
def test_snapshot_revert(dev): # NOQA existings = {} snap1 = Snapshot(dev, generate_random_data(existings)) snap2 = Snapshot(dev, generate_random_data(existings)) snap3 = Snapshot(dev, generate_random_data(existings)) snapList = cmd.snapshot_ls() assert snap1.name in snapList assert snap2.name in snapList assert snap3.name in snapList cmd.snapshot_revert(snap2.name) snap3.refute_data() snap2.verify_checksum() snap1.verify_data() cmd.snapshot_revert(snap1.name) snap3.refute_data() snap2.refute_data() snap1.verify_checksum()
def test_snapshot_rm_rolling(dev): # NOQA offset = 0 length = 128 snap1_data = common.random_string(length) common.verify_data(dev, offset, snap1_data) snap1 = cmd.snapshot_create() snapList = cmd.snapshot_ls() assert snap1 in snapList cmd.snapshot_rm(snap1) # cannot do anything because it's the parent of volume head cmd.snapshot_purge() snap2_data = common.random_string(length) common.verify_data(dev, offset, snap2_data) snap2 = cmd.snapshot_create() info = cmd.snapshot_info() assert len(info) == 3 assert snap1 in info assert info[snap1]["removed"] is True assert snap2 in info assert info[snap2]["removed"] is False cmd.snapshot_rm(snap2) # this should trigger the deletion of snap1 cmd.snapshot_purge() snap3_data = common.random_string(length) common.verify_data(dev, offset, snap3_data) snap3 = cmd.snapshot_create() snap4_data = common.random_string(length) common.verify_data(dev, offset, snap4_data) snap4 = cmd.snapshot_create() snap5_data = common.random_string(length) common.verify_data(dev, offset, snap5_data) snap5 = cmd.snapshot_create() snapList = cmd.snapshot_ls() assert snap1 not in snapList assert snap2 not in snapList assert snap3 in snapList assert snap4 in snapList assert snap5 in snapList info = cmd.snapshot_info() assert len(info) == 5 assert snap1 not in info assert snap2 in info assert info[snap2]["removed"] is True assert snap3 in info assert info[snap3]["size"] == "4096" assert snap4 in info assert info[snap4]["size"] == "4096" assert snap5 in info assert info[snap5]["size"] == "4096" cmd.snapshot_rm(snap3) cmd.snapshot_rm(snap4) cmd.snapshot_rm(snap5) # this should trigger the deletion of snap2 - snap4 # and snap5 marked as removed cmd.snapshot_purge() info = cmd.snapshot_info() assert len(info) == 2 assert snap1 not in info assert snap2 not in info assert snap3 not in info assert snap4 not in info assert snap5 in info assert info[snap5]["removed"] is True assert info[snap5]["size"] == "4096" readed = read_dev(dev, offset, length) assert readed == snap5_data
def snapshot_tree_verify_relationship(snap, strict): info = cmd.snapshot_info() assert snap["0a"] in info assert info[snap["0a"]]["children"] == [snap["0b"]] assert snap["0b"] in info assert info[snap["0b"]]["parent"] == snap["0a"] assert len(info[snap["0b"]]["children"]) == 3 assert snap["0c"] in info[snap["0b"]]["children"] assert snap["1a"] in info[snap["0b"]]["children"] assert snap["2a"] in info[snap["0b"]]["children"] 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"] == [snap["1c"]] assert snap["1c"] in info assert info[snap["1c"]]["parent"] == snap["1b"] assert info[snap["1c"]]["children"] == [] assert snap["2a"] in info assert info[snap["2a"]]["parent"] == snap["0b"] assert len(info[snap["2a"]]["children"]) == 2 assert snap["2b"] in info[snap["2a"]]["children"] assert snap["3a"] in info[snap["2a"]]["children"] assert snap["2b"] in info assert info[snap["2b"]]["parent"] == snap["2a"] assert info[snap["2b"]]["children"] == [snap["2c"]] assert snap["2c"] in info assert info[snap["2c"]]["parent"] == snap["2b"] assert info[snap["2c"]]["children"] == [] assert snap["3a"] in info assert info[snap["3a"]]["parent"] == snap["2a"] assert info[snap["3a"]]["children"] == [snap["3b"]] assert snap["3b"] in info assert info[snap["3b"]]["parent"] == snap["3a"] assert info[snap["3b"]]["children"] == [snap["3c"]] assert snap["3c"] in info assert info[snap["3c"]]["parent"] == snap["3b"] if strict: assert len(info) == 13 assert info[snap["0a"]]["parent"] == "" assert info[snap["3c"]]["children"] == [VOLUME_HEAD] assert VOLUME_HEAD in info assert info[VOLUME_HEAD]["parent"] == snap["3c"] assert info[VOLUME_HEAD]["children"] == [] output = cmd.snapshot_ls() assert output == '''ID {} {} {} {} {} {} '''.format(snap["3c"], snap["3b"], snap["3a"], snap["2a"], snap["0b"], snap["0a"])
def snapshot_tree_verify_relationship(snap, strict): info = cmd.snapshot_info() assert snap["0a"] in info assert snap["0b"] in info[snap["0a"]]["children"] assert snap["0b"] in info assert info[snap["0b"]]["parent"] == snap["0a"] assert len(info[snap["0b"]]["children"]) == 3 assert snap["0c"] in info[snap["0b"]]["children"] assert snap["1a"] in info[snap["0b"]]["children"] assert snap["2a"] in info[snap["0b"]]["children"] 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 snap["1c"] in info[snap["1b"]]["children"] assert snap["1c"] in info assert info[snap["1c"]]["parent"] == snap["1b"] assert not info[snap["1c"]]["children"] assert snap["2a"] in info assert info[snap["2a"]]["parent"] == snap["0b"] assert len(info[snap["2a"]]["children"]) == 2 assert snap["2b"] in info[snap["2a"]]["children"] assert snap["3a"] in info[snap["2a"]]["children"] assert snap["2b"] in info assert info[snap["2b"]]["parent"] == snap["2a"] assert snap["2c"] in info[snap["2b"]]["children"] assert snap["2c"] in info assert info[snap["2c"]]["parent"] == snap["2b"] assert not info[snap["2c"]]["children"] assert snap["3a"] in info assert info[snap["3a"]]["parent"] == snap["2a"] assert snap["3b"] in info[snap["3a"]]["children"] assert snap["3b"] in info assert info[snap["3b"]]["parent"] == snap["3a"] assert snap["3c"] in info[snap["3b"]]["children"] assert snap["3c"] in info assert info[snap["3c"]]["parent"] == snap["3b"] if strict: assert len(info) == 13 assert info[snap["0a"]]["parent"] == "" assert VOLUME_HEAD in info[snap["3c"]]["children"] assert VOLUME_HEAD in info assert info[VOLUME_HEAD]["parent"] == snap["3c"] assert not info[VOLUME_HEAD]["children"] output = cmd.snapshot_ls() assert output == '''ID {} {} {} {} {} {} '''.format(snap["3c"], snap["3b"], snap["3a"], snap["2a"], snap["0b"], snap["0a"])
def test_snapshot_rm_rolling( grpc_controller, # NOQA grpc_replica1, grpc_replica2): # NOQA address = grpc_controller.address dev = get_dev(grpc_replica1, grpc_replica2, grpc_controller) existings = {} snap1 = Snapshot(dev, generate_random_data(existings), address) snapList = cmd.snapshot_ls(address) assert snap1.name in snapList cmd.snapshot_rm(address, snap1.name) # cannot do anything because it's the parent of volume head cmd.snapshot_purge(address) wait_for_purge_completion(address) snap2 = Snapshot(dev, generate_random_data(existings), address) info = cmd.snapshot_info(address) assert len(info) == 3 assert snap1.name in info assert snap2.name in info assert info[snap1.name]["removed"] is True assert info[snap2.name]["removed"] is False cmd.snapshot_rm(address, snap2.name) # this should trigger the deletion of snap1 cmd.snapshot_purge(address) wait_for_purge_completion(address) snap2.verify_checksum() snap1.verify_data() snap3 = Snapshot(dev, generate_random_data(existings), address) snap4 = Snapshot(dev, generate_random_data(existings), address) snap5 = Snapshot(dev, generate_random_data(existings), address) snapList = cmd.snapshot_ls(address) assert snap1.name not in snapList assert snap2.name not in snapList assert snap3.name in snapList assert snap4.name in snapList assert snap5.name in snapList info = cmd.snapshot_info(address) assert len(info) == 5 assert snap1.name not in info assert snap2.name in info assert snap3.name in info assert snap4.name in info assert snap5.name in info assert info[snap2.name]["removed"] is True cmd.snapshot_rm(address, snap3.name) cmd.snapshot_rm(address, snap4.name) cmd.snapshot_rm(address, snap5.name) # this should trigger the deletion of snap2 - snap4 # and snap5 marked as removed cmd.snapshot_purge(address) wait_for_purge_completion(address) info = cmd.snapshot_info(address) assert len(info) == 2 assert snap1.name not in info assert snap2.name not in info assert snap3.name not in info assert snap4.name not in info assert snap5.name in info assert info[snap5.name]["removed"] is True snap5.verify_checksum() snap4.verify_data() snap3.verify_data() snap2.verify_data() snap1.verify_data()
def test_snapshot_rm_rolling(dev): # NOQA existings = {} snap1 = Snapshot(dev, generate_random_data(existings)) snapList = cmd.snapshot_ls() assert snap1.name in snapList cmd.snapshot_rm(snap1.name) # cannot do anything because it's the parent of volume head cmd.snapshot_purge() snap2 = Snapshot(dev, generate_random_data(existings)) info = cmd.snapshot_info() assert len(info) == 3 assert snap1.name in info assert snap2.name in info assert info[snap1.name]["removed"] is True assert info[snap2.name]["removed"] is False cmd.snapshot_rm(snap2.name) # this should trigger the deletion of snap1 cmd.snapshot_purge() snap2.verify_checksum() snap1.verify_data() snap3 = Snapshot(dev, generate_random_data(existings)) snap4 = Snapshot(dev, generate_random_data(existings)) snap5 = Snapshot(dev, generate_random_data(existings)) snapList = cmd.snapshot_ls() assert snap1.name not in snapList assert snap2.name not in snapList assert snap3.name in snapList assert snap4.name in snapList assert snap5.name in snapList info = cmd.snapshot_info() assert len(info) == 5 assert snap1.name not in info assert snap2.name in info assert snap3.name in info assert snap4.name in info assert snap5.name in info assert info[snap2.name]["removed"] is True cmd.snapshot_rm(snap3.name) cmd.snapshot_rm(snap4.name) cmd.snapshot_rm(snap5.name) # this should trigger the deletion of snap2 - snap4 # and snap5 marked as removed cmd.snapshot_purge() info = cmd.snapshot_info() assert len(info) == 2 assert snap1.name not in info assert snap2.name not in info assert snap3.name not in info assert snap4.name not in info assert snap5.name in info assert info[snap5.name]["removed"] is True snap5.verify_checksum() snap4.verify_data() snap3.verify_data() snap2.verify_data() snap1.verify_data()