Skip to content

Commit 3f28f59

Browse files
committed
Merge branch '3.9-devel' into 3.10-devel
2 parents 2b0f02b + 66914f0 commit 3f28f59

File tree

2 files changed

+52
-0
lines changed

2 files changed

+52
-0
lines changed

blivet/devices/stratis.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,8 @@ class StratisFilesystemDevice(StorageDevice):
203203
_min_size = Size("512 MiB")
204204

205205
def __init__(self, name, parents=None, size=None, uuid=None, exists=False):
206+
if size is None:
207+
size = devicelibs.stratis.STRATIS_FS_SIZE
206208
if not exists and parents[0].free_space <= devicelibs.stratis.filesystem_md_size(size):
207209
raise StratisError("cannot create new stratis filesystem, not enough free space in the pool")
208210

tests/unit_tests/devices_test/stratis_test.py

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,56 @@ def test_new_encrypted_stratis(self):
100100
passphrase="secret",
101101
key_file=None)
102102

103+
def test_new_stratis_no_size(self):
104+
b = blivet.Blivet()
105+
bd = StorageDevice("bd1", fmt=blivet.formats.get_format("stratis"),
106+
size=Size("2 GiB"), exists=False)
107+
108+
b.devicetree._add_device(bd)
109+
110+
with patch("blivet.devicetree.DeviceTree.names", []):
111+
pool = b.new_stratis_pool(name="testpool", parents=[bd])
112+
self.assertEqual(pool.name, "testpool")
113+
self.assertEqual(pool.size, bd.size)
114+
115+
with patch("blivet.devicelibs.stratis.pool_used", lambda _d, _e: Size("512 MiB")):
116+
self.assertAlmostEqual(pool.free_space, Size("1.5 GiB"))
117+
118+
with patch("blivet.devicetree.DeviceTree.names", []):
119+
fs = b.new_stratis_filesystem(name="testfs", parents=[pool])
120+
121+
self.assertEqual(fs.name, "testpool/testfs")
122+
self.assertEqual(fs.path, "/dev/stratis/%s" % fs.name)
123+
self.assertEqual(fs.size, Size("1 TiB"))
124+
self.assertEqual(fs.pool, pool)
125+
self.assertEqual(fs.format.type, "stratis xfs")
126+
# for 1 TiB filesystem, metadata should take around 1 GiB
127+
self.assertAlmostEqual(fs.used_size, Size("1 GiB"), delta=Size("50 MiB"))
128+
129+
b.create_device(pool)
130+
b.create_device(fs)
131+
132+
with patch("blivet.devicelibs.stratis") as stratis_dbus:
133+
with patch.object(pool, "_pre_create"):
134+
with patch.object(pool, "_post_create"):
135+
pool.create()
136+
stratis_dbus.create_pool.assert_called_with(name='testpool',
137+
devices=['/dev/bd1'],
138+
encrypted=False,
139+
passphrase=None,
140+
key_file=None)
141+
142+
# we would get this from pool._post_create
143+
pool.uuid = "c4fc9ebe-e173-4cab-8d81-cc6abddbe02d"
144+
145+
with patch("blivet.devicelibs.stratis") as stratis_dbus:
146+
with patch.object(fs, "_pre_create"):
147+
with patch.object(fs, "_post_create"):
148+
fs.create()
149+
stratis_dbus.create_filesystem.assert_called_with(name="testfs",
150+
pool_uuid="c4fc9ebe-e173-4cab-8d81-cc6abddbe02d",
151+
fs_size=Size("1 TiB"))
152+
103153
def test_device_id(self):
104154
bd = StorageDevice("bd1", fmt=blivet.formats.get_format("stratis"),
105155
size=Size("2 GiB"), exists=False)

0 commit comments

Comments
 (0)