source: trunk/benchmarks/test_cli.py

Last change on this file was 8f87827, checked in by Itamar Turner-Trauring <itamar@…>, at 2023-09-13T13:56:47Z

More accurate description

  • Property mode set to 100644
File size: 1.9 KB
Line 
1"""Benchmarks for minimal `tahoe` CLI interactions."""
2
3from subprocess import Popen, PIPE
4
5import pytest
6
7from integration.util import cli
8
9
10@pytest.fixture(scope="module", autouse=True)
11def cli_alias(client_node):
12    cli(client_node.process, "create-alias", "cli")
13
14
15@pytest.mark.parametrize("file_size", [1000, 100_000, 1_000_000, 10_000_000])
16def test_get_put_files_sequentially(
17    file_size,
18    client_node,
19    tahoe_benchmarker,
20    number_of_nodes,
21    capsys,
22):
23    """
24    Upload 5 files with ``tahoe put`` and then download them with ``tahoe
25    get``, measuring the latency of both operations.  We do multiple uploads
26    and downloads to try to reduce noise.
27    """
28    DATA = b"0123456789" * (file_size // 10)
29
30    with tahoe_benchmarker.record(
31        capsys, "cli-put-5-file-sequentially", file_size=file_size, number_of_nodes=number_of_nodes
32    ):
33        for i in range(5):
34            p = Popen(
35                [
36                    "tahoe",
37                    "--node-directory",
38                    client_node.process.node_dir,
39                    "put",
40                    "-",
41                    f"cli:get_put_files_sequentially{i}",
42                ],
43                stdin=PIPE,
44            )
45            p.stdin.write(DATA)
46            p.stdin.write(str(i).encode("ascii"))
47            p.stdin.close()
48            assert p.wait() == 0
49
50    with tahoe_benchmarker.record(
51        capsys, "cli-get-5-files-sequentially", file_size=file_size, number_of_nodes=number_of_nodes
52    ):
53        for i in range(5):
54            p = Popen(
55                [
56                    "tahoe",
57                    "--node-directory",
58                    client_node.process.node_dir,
59                    "get",
60                    f"cli:get_put_files_sequentially{i}",
61                    "-",
62                ],
63                stdout=PIPE,
64            )
65            assert p.stdout.read() == DATA + str(i).encode("ascii")
66            assert p.wait() == 0
Note: See TracBrowser for help on using the repository browser.