@@ -100,6 +100,56 @@ def test_new_encrypted_stratis(self):
100
100
passphrase = "secret" ,
101
101
key_file = None )
102
102
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
+
103
153
def test_device_id (self ):
104
154
bd = StorageDevice ("bd1" , fmt = blivet .formats .get_format ("stratis" ),
105
155
size = Size ("2 GiB" ), exists = False )
0 commit comments