Skip to content

Commit

Permalink
issue-1795: LargeDeletionMarkers - simple integration test (#2122)
Browse files Browse the repository at this point in the history
  • Loading branch information
qkrorlqr committed Sep 25, 2024
1 parent 8da2a1f commit b9f413d
Show file tree
Hide file tree
Showing 5 changed files with 81 additions and 8 deletions.
3 changes: 3 additions & 0 deletions cloud/filestore/tests/client/canondata/result.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
"test.test_describe_sessions": {
"uri": "file://test.test_describe_sessions/results.txt"
},
"test.test_large_file": {
"uri": "file://test.test_large_file/results.txt"
},
"test.test_list_filestores": {
"uri": "file://test.test_list_filestores/results.txt"
},
Expand Down
Binary file not shown.
2 changes: 2 additions & 0 deletions cloud/filestore/tests/client/nfs-storage.txt
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
MultiTabletForwardingEnabled: true
LargeDeletionMarkersEnabled: true
MaxFileBlocks: 536870912
80 changes: 72 additions & 8 deletions cloud/filestore/tests/client/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,25 @@ def __init_test():
return client, results_path


def __process_stat(node):
def d(k):
if k in node:
del node[k]

d("ATime")
d("MTime")
d("CTime")
d("FollowerNodeName")

return node


def __exec_ls(client, *args):
output = str(client.ls(*args, "--json"), 'utf-8')
nodes: list = json.loads(output)['content']

for node in nodes:
def d(k):
if k in node:
del node[k]

d("ATime")
d("MTime")
d("CTime")
d("FollowerNodeName")
__process_stat(node)

return json.dumps(nodes, indent=4).encode('utf-8')

Expand Down Expand Up @@ -428,3 +434,61 @@ def test_multitablet_findgarbage():

ret = common.canonical_file(results_path, local=True)
return ret


def test_large_file():
TiB = 1024 * 1024 * 1024 * 1024

data_file = os.path.join(common.output_path(), "data.txt")
with open(data_file, "w") as f:
f.write("some data")

client, results_path = __init_test()
client.create(
"fs0",
"test_cloud",
"test_folder",
BLOCK_SIZE,
TiB // BLOCK_SIZE)
client.mkdir("fs0", "/aaa")
client.touch("fs0", "/aaa/bbb")

out = client.stat("fs0", "/aaa/bbb")
stat = json.loads(out)
node_id = stat["Id"]
result = json.dumps(__process_stat(stat))
result += "\n"

client.write("fs0", "/aaa/bbb", "--data", data_file)

client.set_node_attr("fs0", node_id, "--size", str(TiB))
result += client.read("fs0", "/aaa/bbb", "--length", "9").decode("utf8")
result += "\n"

out = client.stat("fs0", "/aaa/bbb")
stat = json.loads(out)
assert stat["Size"] == TiB
result += json.dumps(__process_stat(stat))
result += "\n"

client.set_node_attr("fs0", node_id, "--size", "1024")
result += client.read("fs0", "/aaa/bbb", "--length", "0").decode("utf8")
result += "\n"

out = client.stat("fs0", "/aaa/bbb")
new_stat = json.loads(out)
assert stat["Size"] == TiB
result += json.dumps(__process_stat(new_stat))
result += "\n"
result += client.read("fs0", "/aaa/bbb", "--length", "0").decode("utf8")
result += "\n"

client.rm("fs0", "/aaa/bbb")

client.destroy("fs0")

with open(results_path, "w") as results_file:
results_file.write(result)

ret = common.canonical_file(results_path, local=True)
return ret
4 changes: 4 additions & 0 deletions cloud/filestore/tests/python/lib/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,10 @@ def mkdir(self, cmd):
def write(self, cmd):
return common.execute(cmd).stdout

@standard_command("read")
def read(self, cmd):
return common.execute(cmd).stdout

@standard_command("touch")
def touch(self, cmd):
return common.execute(cmd).stdout
Expand Down

0 comments on commit b9f413d

Please sign in to comment.