2023-09-05 15:45:54 +00:00
|
|
|
"""Benchmarks for minimal `tahoe` CLI interactions."""
|
|
|
|
|
2023-09-05 16:12:49 +00:00
|
|
|
from subprocess import Popen, PIPE
|
|
|
|
|
|
|
|
import pytest
|
|
|
|
|
|
|
|
from integration.util import cli
|
|
|
|
|
|
|
|
|
2023-09-08 14:26:17 +00:00
|
|
|
@pytest.fixture(scope="module", autouse=True)
|
2023-09-05 16:12:49 +00:00
|
|
|
def cli_alias(client_node):
|
|
|
|
cli(client_node.process, "create-alias", "cli")
|
|
|
|
|
|
|
|
|
2023-09-07 17:56:30 +00:00
|
|
|
@pytest.mark.parametrize("file_size", [1000, 100_000, 1_000_000, 10_000_000])
|
2023-09-08 14:26:17 +00:00
|
|
|
def test_get_put_files_sequentially(
|
2023-09-07 21:21:45 +00:00
|
|
|
file_size,
|
|
|
|
client_node,
|
|
|
|
tahoe_benchmarker,
|
|
|
|
number_of_nodes,
|
|
|
|
capsys,
|
2023-09-05 16:23:50 +00:00
|
|
|
):
|
2023-09-05 15:45:54 +00:00
|
|
|
"""
|
2023-09-08 14:26:17 +00:00
|
|
|
Upload 5 files with ``tahoe put`` and then download them with ``tahoe
|
|
|
|
get``, measuring the latency of both operations. We do multiple uploads
|
|
|
|
and downloads to try to reduce noise.
|
2023-09-05 15:45:54 +00:00
|
|
|
"""
|
2023-09-05 16:12:49 +00:00
|
|
|
DATA = b"0123456789" * (file_size // 10)
|
2023-09-05 16:23:50 +00:00
|
|
|
|
|
|
|
with tahoe_benchmarker.record(
|
2023-09-13 13:56:47 +00:00
|
|
|
capsys, "cli-put-5-file-sequentially", file_size=file_size, number_of_nodes=number_of_nodes
|
2023-09-05 16:23:50 +00:00
|
|
|
):
|
2023-09-08 14:26:17 +00:00
|
|
|
for i in range(5):
|
|
|
|
p = Popen(
|
|
|
|
[
|
|
|
|
"tahoe",
|
|
|
|
"--node-directory",
|
|
|
|
client_node.process.node_dir,
|
|
|
|
"put",
|
|
|
|
"-",
|
|
|
|
f"cli:get_put_files_sequentially{i}",
|
|
|
|
],
|
|
|
|
stdin=PIPE,
|
|
|
|
)
|
|
|
|
p.stdin.write(DATA)
|
|
|
|
p.stdin.write(str(i).encode("ascii"))
|
|
|
|
p.stdin.close()
|
|
|
|
assert p.wait() == 0
|
2023-09-05 16:23:50 +00:00
|
|
|
|
|
|
|
with tahoe_benchmarker.record(
|
2023-09-13 13:56:47 +00:00
|
|
|
capsys, "cli-get-5-files-sequentially", file_size=file_size, number_of_nodes=number_of_nodes
|
2023-09-05 16:23:50 +00:00
|
|
|
):
|
2023-09-08 14:26:17 +00:00
|
|
|
for i in range(5):
|
|
|
|
p = Popen(
|
|
|
|
[
|
|
|
|
"tahoe",
|
|
|
|
"--node-directory",
|
|
|
|
client_node.process.node_dir,
|
|
|
|
"get",
|
|
|
|
f"cli:get_put_files_sequentially{i}",
|
|
|
|
"-",
|
|
|
|
],
|
|
|
|
stdout=PIPE,
|
|
|
|
)
|
|
|
|
assert p.stdout.read() == DATA + str(i).encode("ascii")
|
|
|
|
assert p.wait() == 0
|