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
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.fixture(scope="session")
|
|
|
|
def cli_alias(client_node):
|
|
|
|
cli(client_node.process, "create-alias", "cli")
|
|
|
|
|
|
|
|
|
|
|
|
def test_get_put_one_file(client_node, cli_alias, tmp_path):
|
2023-09-05 15:45:54 +00:00
|
|
|
"""
|
2023-09-05 16:12:49 +00:00
|
|
|
Upload a file with ``tahoe put`` and then download it with ``tahoe get``,
|
|
|
|
measuring the latency of both operations.
|
2023-09-05 15:45:54 +00:00
|
|
|
"""
|
2023-09-05 16:12:49 +00:00
|
|
|
file_size = 1000 # parameterize later on
|
|
|
|
file_path = tmp_path / "file"
|
|
|
|
DATA = b"0123456789" * (file_size // 10)
|
|
|
|
|
|
|
|
with file_path.open("wb") as f:
|
|
|
|
f.write(DATA)
|
|
|
|
cli(client_node.process, "put", str(file_path), "cli:tostdout")
|
|
|
|
|
|
|
|
p = Popen(
|
|
|
|
[
|
|
|
|
"tahoe",
|
|
|
|
"--node-directory",
|
|
|
|
client_node.process.node_dir,
|
|
|
|
"get",
|
|
|
|
"cli:tostdout",
|
|
|
|
"-",
|
|
|
|
],
|
|
|
|
stdout=PIPE,
|
|
|
|
)
|
|
|
|
assert p.stdout.read() == DATA
|
|
|
|
assert p.wait() == 0
|