Merge ~ltrager/maas:lp1869958 into maas:master

Proposed by Lee Trager
Status: Merged
Approved by: Lee Trager
Approved revision: c5fb0ccba014f601c489d151f7d8361d04828af0
Merge reported by: MAAS Lander
Merged at revision: not available
Proposed branch: ~ltrager/maas:lp1869958
Merge into: maas:master
Diff against target: 62 lines (+12/-3)
2 files modified
src/metadataserver/builtin_scripts/fio.py (+9/-2)
src/metadataserver/builtin_scripts/tests/test_fio.py (+3/-1)
Reviewer Review Type Date Requested Status
Dougal Matthews (community) Approve
MAAS Lander Approve
Review via email: mp+383741@code.launchpad.net

Commit message

LP: #1869958 - Run fio using the native block size of the disk.

To post a comment you must log in.
Revision history for this message
MAAS Lander (maas-lander) wrote :

UNIT TESTS
-b lp1869958 lp:~ltrager/maas/+git/maas into -b master lp:~maas-committers/maas

STATUS: SUCCESS
COMMIT: c5fb0ccba014f601c489d151f7d8361d04828af0

review: Approve
Revision history for this message
Dougal Matthews (d0ugal) wrote :

LGTM, I wonder if we ever need the old default?

review: Approve
Revision history for this message
Lee Trager (ltrager) wrote :

Linus is really strict about not breaking compatibility with user space so we should always have a value. The old value was arbitrary so I don't think there is a need to keep it around.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/src/metadataserver/builtin_scripts/fio.py b/src/metadataserver/builtin_scripts/fio.py
2index 71d2d70..da3d218 100644
3--- a/src/metadataserver/builtin_scripts/fio.py
4+++ b/src/metadataserver/builtin_scripts/fio.py
5@@ -5,7 +5,7 @@
6 # Author: Newell Jensen <newell.jensen@canonical.com>
7 # Lee Trager <lee.trager@canonical.com>
8 #
9-# Copyright (C) 2017-2018 Canonical
10+# Copyright (C) 2017-2020 Canonical
11 #
12 # This program is free software: you can redistribute it and/or modify
13 # it under the terms of the GNU Affero General Public License as
14@@ -83,7 +83,6 @@ CMD = [
15 "--direct=1",
16 "--gtod_reduce=1",
17 "--name=fio_test",
18- "--bs=4k",
19 "--iodepth=64",
20 "--size=4G",
21 "--output-format=normal,json",
22@@ -108,6 +107,13 @@ REGEX = re.compile(
23 )
24
25
26+def get_blocksize(blockdevice):
27+ """Return the block size of the block device."""
28+ blockname = os.path.basename(blockdevice)
29+ with open("/sys/block/%s/queue/physical_block_size" % blockname, "r") as f:
30+ return int(f.read())
31+
32+
33 def run_cmd(readwrite, result_break=True):
34 """Execute `CMD` and return output or exit if error."""
35 cmd = deepcopy(CMD)
36@@ -163,6 +169,7 @@ def run_fio(blockdevice):
37 Performs random and sequential read and write tests.
38 """
39 CMD.append("--filename=%s" % blockdevice)
40+ CMD.append("--bs=%s" % get_blocksize(blockdevice))
41 random_read = run_cmd("randread")
42 sequential_read = run_cmd("read")
43 random_write = run_cmd("randwrite")
44diff --git a/src/metadataserver/builtin_scripts/tests/test_fio.py b/src/metadataserver/builtin_scripts/tests/test_fio.py
45index 24a3702..25f004e 100644
46--- a/src/metadataserver/builtin_scripts/tests/test_fio.py
47+++ b/src/metadataserver/builtin_scripts/tests/test_fio.py
48@@ -1,4 +1,4 @@
49-# Copyright 2017-2018 Canonical Ltd. This software is licensed under the
50+# Copyright 2017-2020 Canonical Ltd. This software is licensed under the
51 # GNU Affero General Public License version 3 (see the file LICENSE).
52
53 """Test builtin_script fio."""
54@@ -202,6 +202,8 @@ class TestFioTestRunFio(MAASTestCase):
55 self.mock_stdout_write = self.patch(fio.sys.stdout, "write")
56 self.mock_stderr_write = self.patch(fio.sys.stderr, "write")
57 self.mock_check_output = self.patch(fio, "check_output")
58+ self.mock_get_blocksize = self.patch(fio, "get_blocksize")
59+ self.mock_get_blocksize.return_value = 512
60
61 def test_run_fio_writes_yaml_file(self):
62 tmp_path = Path(self.useFixture(TempDirectory()).path)

Subscribers

People subscribed via source and target branches