Merge ~mwhudson/curtin:partition-verify-dasd into curtin:master
- Git
- lp:~mwhudson/curtin
- partition-verify-dasd
- Merge into master
Status: | Merged |
---|---|
Approved by: | Michael Hudson-Doyle |
Approved revision: | 0dafa72b72cf1fa6dab73230274e8c18a0442ce9 |
Merge reported by: | Server Team CI bot |
Merged at revision: | not available |
Proposed branch: | ~mwhudson/curtin:partition-verify-dasd |
Merge into: | curtin:master |
Diff against target: |
402 lines (+160/-117) 4 files modified
curtin/block/dasd.py (+90/-103) curtin/commands/block_meta.py (+22/-4) tests/unittests/test_block_dasd.py (+0/-5) tests/unittests/test_commands_block_meta.py (+48/-5) |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Server Team CI bot | continuous-integration | Approve | |
Dimitri John Ledkov (community) | Approve | ||
curtin developers | Pending | ||
Review via email: mp+393791@code.launchpad.net |
Commit message
fix verification of vtoc partitions
Currently curtin verifies the size and flags of a partition by
using sfdisk to inspect it and checking the results. But that
doesn't work on a dasd's vtoc partition table, so this branch
renames parition_verify to parition_
parition_
'vtoc'. The branch does a little more than is strictly necessary,
perhaps, but the other stuff will come in useful soon, I promise
:)
LP: #1899471
Description of the change
Server Team CI bot (server-team-bot) wrote : | # |
Server Team CI bot (server-team-bot) wrote : | # |
PASSED: Continuous integration, rev:e6073221da5
https:/
Executed test runs:
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
Click here to trigger a rebuild:
https:/
Server Team CI bot (server-team-bot) wrote : | # |
FAILED: Continuous integration, rev:a6f1f32c00e
https:/
Executed test runs:
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
Click here to trigger a rebuild:
https:/
Server Team CI bot (server-team-bot) wrote : | # |
PASSED: Continuous integration, rev:653bb0fd959
https:/
Executed test runs:
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
Click here to trigger a rebuild:
https:/
Dimitri John Ledkov (xnox) wrote : | # |
This is fine refactor.
Michael Hudson-Doyle (mwhudson) wrote : | # |
Thanks for the review. I actually think there is another branch I need to land before this one, let me get that up for review pronto.
Server Team CI bot (server-team-bot) wrote : | # |
PASSED: Continuous integration, rev:0dafa72b72c
https:/
Executed test runs:
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
Click here to trigger a rebuild:
https:/
Server Team CI bot (server-team-bot) wrote : | # |
Commit message lints:
- Line #2 has 360 too many characters. Line starts with: "Currently curtin verifies"...
Server Team CI bot (server-team-bot) : | # |
Preview Diff
1 | diff --git a/curtin/block/dasd.py b/curtin/block/dasd.py | |||
2 | index daafeb8..7450300 100644 | |||
3 | --- a/curtin/block/dasd.py | |||
4 | +++ b/curtin/block/dasd.py | |||
5 | @@ -2,7 +2,6 @@ | |||
6 | 2 | 2 | ||
7 | 3 | import collections | 3 | import collections |
8 | 4 | import os | 4 | import os |
9 | 5 | import re | ||
10 | 6 | import tempfile | 5 | import tempfile |
11 | 7 | from curtin import util | 6 | from curtin import util |
12 | 8 | from curtin.log import LOG, logged_time | 7 | from curtin.log import LOG, logged_time |
13 | @@ -10,6 +9,86 @@ from curtin.log import LOG, logged_time | |||
14 | 10 | Dasdvalue = collections.namedtuple('Dasdvalue', ['hex', 'dec', 'txt']) | 9 | Dasdvalue = collections.namedtuple('Dasdvalue', ['hex', 'dec', 'txt']) |
15 | 11 | 10 | ||
16 | 12 | 11 | ||
17 | 12 | class DasdPartition: | ||
18 | 13 | def __init__(self, table, device, start, end, length, id, system): | ||
19 | 14 | self.device = device | ||
20 | 15 | self.start = int(start) | ||
21 | 16 | self.end = int(end) | ||
22 | 17 | self.length = int(length) | ||
23 | 18 | self.id = id | ||
24 | 19 | self.system = system | ||
25 | 20 | |||
26 | 21 | |||
27 | 22 | class DasdPartitionTable: | ||
28 | 23 | def __init__(self, devname, blocks_per_track, bytes_per_block): | ||
29 | 24 | self.devname = devname | ||
30 | 25 | self.blocks_per_track = blocks_per_track | ||
31 | 26 | self.bytes_per_block = bytes_per_block | ||
32 | 27 | self.partitions = [] | ||
33 | 28 | |||
34 | 29 | @property | ||
35 | 30 | def bytes_per_track(self): | ||
36 | 31 | return self.bytes_per_block * self.blocks_per_track | ||
37 | 32 | |||
38 | 33 | def tracks_needed(self, size_in_bytes): | ||
39 | 34 | return ((size_in_bytes - 1) // self.bytes_per_track) + 1 | ||
40 | 35 | |||
41 | 36 | @classmethod | ||
42 | 37 | def from_fdasd(cls, devname): | ||
43 | 38 | """Use fdasd to construct a DasdPartitionTable. | ||
44 | 39 | |||
45 | 40 | % fdasd --table /dev/dasdc | ||
46 | 41 | reading volume label ..: VOL1 | ||
47 | 42 | reading vtoc ..........: ok | ||
48 | 43 | |||
49 | 44 | |||
50 | 45 | Disk /dev/dasdc: | ||
51 | 46 | cylinders ............: 10017 | ||
52 | 47 | tracks per cylinder ..: 15 | ||
53 | 48 | blocks per track .....: 12 | ||
54 | 49 | bytes per block ......: 4096 | ||
55 | 50 | volume label .........: VOL1 | ||
56 | 51 | volume serial ........: 0X1522 | ||
57 | 52 | max partitions .......: 3 | ||
58 | 53 | |||
59 | 54 | ------------------------------- tracks ------------------------------- | ||
60 | 55 | Device start end length Id System | ||
61 | 56 | /dev/dasdc1 2 43694 43693 1 Linux native | ||
62 | 57 | /dev/dasdc2 43695 87387 43693 2 Linux native | ||
63 | 58 | /dev/dasdc3 87388 131080 43693 3 Linux native | ||
64 | 59 | 131081 150254 19174 unused | ||
65 | 60 | exiting... | ||
66 | 61 | """ | ||
67 | 62 | cmd = ['fdasd', '--table', devname] | ||
68 | 63 | out, _err = util.subp(cmd, capture=True) | ||
69 | 64 | line_iter = iter(out.splitlines()) | ||
70 | 65 | for line in line_iter: | ||
71 | 66 | if line.startswith("Disk"): | ||
72 | 67 | break | ||
73 | 68 | kw = {'devname': devname} | ||
74 | 69 | label_to_attr = { | ||
75 | 70 | 'blocks per track': 'blocks_per_track', | ||
76 | 71 | 'bytes per block': 'bytes_per_block' | ||
77 | 72 | } | ||
78 | 73 | for line in line_iter: | ||
79 | 74 | if '--- tracks ---' in line: | ||
80 | 75 | break | ||
81 | 76 | if ':' in line: | ||
82 | 77 | label, value = line.split(':', 1) | ||
83 | 78 | label = label.strip(' .') | ||
84 | 79 | value = value.strip() | ||
85 | 80 | if label in label_to_attr: | ||
86 | 81 | kw[label_to_attr[label]] = int(value) | ||
87 | 82 | table = cls(**kw) | ||
88 | 83 | for line in line_iter: | ||
89 | 84 | if line.startswith('exiting'): | ||
90 | 85 | break | ||
91 | 86 | vals = line.split(maxsplit=5) | ||
92 | 87 | if vals[0].startswith('/dev/'): | ||
93 | 88 | table.partitions.append(DasdPartition(*vals)) | ||
94 | 89 | return table | ||
95 | 90 | |||
96 | 91 | |||
97 | 13 | def dasdinfo(device_id): | 92 | def dasdinfo(device_id): |
98 | 14 | ''' Run dasdinfo command and return the exported values. | 93 | ''' Run dasdinfo command and return the exported values. |
99 | 15 | 94 | ||
100 | @@ -325,83 +404,6 @@ class DasdDevice(CcwDevice): | |||
101 | 325 | def devname(self): | 404 | def devname(self): |
102 | 326 | return '/dev/%s' % self.kname | 405 | return '/dev/%s' % self.kname |
103 | 327 | 406 | ||
104 | 328 | def _bytes_to_tracks(self, geometry, request_size): | ||
105 | 329 | """ Return the number of tracks needed to hold the request size. | ||
106 | 330 | |||
107 | 331 | :param geometry: dictionary from dasdview output which includes | ||
108 | 332 | info on number of cylinders, tracks and blocksize. | ||
109 | 333 | :param request_size: size in Bytes | ||
110 | 334 | |||
111 | 335 | :raises: ValueError on missing or invalid geometry dict, missing | ||
112 | 336 | request_size. | ||
113 | 337 | |||
114 | 338 | Example geometry: | ||
115 | 339 | 'geometry': { | ||
116 | 340 | 'blocks_per_track': Dasdvalue(hex='0xc', dec=12, txt=None), | ||
117 | 341 | 'blocksize': Dasdvalue(hex='0x1000', dec=4096, txt=None), | ||
118 | 342 | 'number_of_cylinders': | ||
119 | 343 | Dasdvalue(hex='0x2721', dec=10017, txt=None), | ||
120 | 344 | 'tracks_per_cylinder': Dasdvalue(hex='0xf', dec=15, txt=None)} | ||
121 | 345 | } | ||
122 | 346 | """ | ||
123 | 347 | |||
124 | 348 | if not geometry or not isinstance(geometry, dict): | ||
125 | 349 | raise ValueError('Missing or invalid geometry parameter.') | ||
126 | 350 | |||
127 | 351 | if not all([key for key in geometry.keys() | ||
128 | 352 | if key in ['blocksize', 'blocks_per_track']]): | ||
129 | 353 | raise ValueError('Geometry dict missing required keys') | ||
130 | 354 | |||
131 | 355 | if not request_size or not isinstance(request_size, | ||
132 | 356 | util.numeric_types): | ||
133 | 357 | raise ValueError('Missing or invalid request_size.') | ||
134 | 358 | |||
135 | 359 | # helper to extract the decimal value from Dasdvalue objects | ||
136 | 360 | def _dval(dval): | ||
137 | 361 | return dval.dec | ||
138 | 362 | |||
139 | 363 | bytes_per_track = ( | ||
140 | 364 | _dval(geometry['blocksize']) * _dval(geometry['blocks_per_track'])) | ||
141 | 365 | tracks_needed = ((request_size - 1) // bytes_per_track) + 1 | ||
142 | 366 | return tracks_needed | ||
143 | 367 | |||
144 | 368 | def get_partition_table(self): | ||
145 | 369 | """ Use fdasd to query the partition table (VTOC). | ||
146 | 370 | |||
147 | 371 | Returns a list of tuples, each tuple composed of the first 6 | ||
148 | 372 | fields of matching lines in the output. | ||
149 | 373 | |||
150 | 374 | % fdasd --table /dev/dasdc | ||
151 | 375 | reading volume label ..: VOL1 | ||
152 | 376 | reading vtoc ..........: ok | ||
153 | 377 | |||
154 | 378 | |||
155 | 379 | Disk /dev/dasdc: | ||
156 | 380 | cylinders ............: 10017 | ||
157 | 381 | tracks per cylinder ..: 15 | ||
158 | 382 | blocks per track .....: 12 | ||
159 | 383 | bytes per block ......: 4096 | ||
160 | 384 | volume label .........: VOL1 | ||
161 | 385 | volume serial ........: 0X1522 | ||
162 | 386 | max partitions .......: 3 | ||
163 | 387 | |||
164 | 388 | ------------------------------- tracks ------------------------------- | ||
165 | 389 | Device start end length Id System | ||
166 | 390 | /dev/dasdc1 2 43694 43693 1 Linux native | ||
167 | 391 | /dev/dasdc2 43695 87387 43693 2 Linux native | ||
168 | 392 | /dev/dasdc3 87388 131080 43693 3 Linux native | ||
169 | 393 | 131081 150254 19174 unused | ||
170 | 394 | exiting... | ||
171 | 395 | """ | ||
172 | 396 | cmd = ['fdasd', '--table', self.devname] | ||
173 | 397 | out, _err = util.subp(cmd, capture=True) | ||
174 | 398 | lines = re.findall('.*%s.*Linux.*' % self.devname, out) | ||
175 | 399 | partitions = [] | ||
176 | 400 | for line in lines: | ||
177 | 401 | partitions.append(tuple(line.split()[0:5])) | ||
178 | 402 | |||
179 | 403 | return partitions | ||
180 | 404 | |||
181 | 405 | def partition(self, partnumber, partsize, strict=True): | 407 | def partition(self, partnumber, partsize, strict=True): |
182 | 406 | """ Add a partition to this DasdDevice specifying partnumber and size. | 408 | """ Add a partition to this DasdDevice specifying partnumber and size. |
183 | 407 | 409 | ||
184 | @@ -422,31 +424,24 @@ class DasdDevice(CcwDevice): | |||
185 | 422 | if strict and not os.path.exists(self.devname): | 424 | if strict and not os.path.exists(self.devname): |
186 | 423 | raise RuntimeError("devname '%s' does not exist" % self.devname) | 425 | raise RuntimeError("devname '%s' does not exist" % self.devname) |
187 | 424 | 426 | ||
198 | 425 | info = dasdview(self.devname) | 427 | pt = DasdPartitionTable.from_fdasd(self.devname) |
199 | 426 | geo = info['geometry'] | 428 | new_partitions = [] |
200 | 427 | 429 | for partinfo in pt.partitions[0:partnumber]: | |
201 | 428 | existing_partitions = self.get_partition_table() | 430 | new_partitions.append((partinfo.start, partinfo.end)) |
192 | 429 | partitions = [] | ||
193 | 430 | for partinfo in existing_partitions[0:partnumber]: | ||
194 | 431 | # (devpath, start_track, end_track, nr_tracks, partnum) | ||
195 | 432 | start = partinfo[1] | ||
196 | 433 | end = partinfo[2] | ||
197 | 434 | partitions.append((start, end)) | ||
202 | 435 | 431 | ||
203 | 436 | # first partition always starts at track 2 | 432 | # first partition always starts at track 2 |
204 | 437 | # all others start after the previous partition ends | 433 | # all others start after the previous partition ends |
205 | 438 | if partnumber == 1: | 434 | if partnumber == 1: |
206 | 439 | start = 2 | 435 | start = 2 |
207 | 440 | else: | 436 | else: |
213 | 441 | start = int(partitions[-1][1]) + 1 | 437 | start = int(pt.partitions[-1].end) + 1 |
214 | 442 | # end is size + 1 | 438 | # end is inclusive |
215 | 443 | tracks_needed = int(self._bytes_to_tracks(geo, partsize)) | 439 | end = start + pt.tracks_needed(partsize) - 1 |
216 | 444 | end = start + tracks_needed + 1 | 440 | new_partitions.append((start, end)) |
212 | 445 | partitions.append(("%s" % start, "%s" % end)) | ||
217 | 446 | 441 | ||
218 | 447 | content = "\n".join(["[%s,%s]" % (part[0], part[1]) | 442 | content = "\n".join(["[%s,%s]" % (part[0], part[1]) |
221 | 448 | for part in partitions]) | 443 | for part in new_partitions]) |
222 | 449 | LOG.debug("fdasd: partitions to be created: %s", partitions) | 444 | LOG.debug("fdasd: partitions to be created: %s", new_partitions) |
223 | 450 | LOG.debug("fdasd: content=\n%s", content) | 445 | LOG.debug("fdasd: content=\n%s", content) |
224 | 451 | wfp = tempfile.NamedTemporaryFile(suffix=".fdasd", delete=False) | 446 | wfp = tempfile.NamedTemporaryFile(suffix=".fdasd", delete=False) |
225 | 452 | wfp.close() | 447 | wfp.close() |
226 | @@ -479,14 +474,6 @@ class DasdDevice(CcwDevice): | |||
227 | 479 | """ | 474 | """ |
228 | 480 | return self.ccw_device_attr('online') == "1" | 475 | return self.ccw_device_attr('online') == "1" |
229 | 481 | 476 | ||
230 | 482 | def status(self): | ||
231 | 483 | """ Read and return device_id's 'status' sysfs attribute value' | ||
232 | 484 | |||
233 | 485 | :param device_id: string of device ccw bus_id. | ||
234 | 486 | :returns: string: the value inside the 'status' sysfs attribute. | ||
235 | 487 | """ | ||
236 | 488 | return self.ccw_device_attr('status') | ||
237 | 489 | |||
238 | 490 | def blocksize(self): | 477 | def blocksize(self): |
239 | 491 | """ Read and return device_id's 'blocksize' value. | 478 | """ Read and return device_id's 'blocksize' value. |
240 | 492 | 479 | ||
241 | diff --git a/curtin/commands/block_meta.py b/curtin/commands/block_meta.py | |||
242 | index 874ccbb..66dfdb4 100644 | |||
243 | --- a/curtin/commands/block_meta.py | |||
244 | +++ b/curtin/commands/block_meta.py | |||
245 | @@ -767,7 +767,7 @@ def verify_ptable_flag(devpath, expected_flag, sfdisk_info=None): | |||
246 | 767 | raise RuntimeError(msg) | 767 | raise RuntimeError(msg) |
247 | 768 | 768 | ||
248 | 769 | 769 | ||
250 | 770 | def partition_verify(devpath, info): | 770 | def partition_verify_sfdisk(devpath, info): |
251 | 771 | verify_exists(devpath) | 771 | verify_exists(devpath) |
252 | 772 | sfdisk_info = block.sfdisk_info(devpath) | 772 | sfdisk_info = block.sfdisk_info(devpath) |
253 | 773 | if not sfdisk_info: | 773 | if not sfdisk_info: |
254 | @@ -779,6 +779,21 @@ def partition_verify(devpath, info): | |||
255 | 779 | verify_ptable_flag(devpath, info['flag'], sfdisk_info=sfdisk_info) | 779 | verify_ptable_flag(devpath, info['flag'], sfdisk_info=sfdisk_info) |
256 | 780 | 780 | ||
257 | 781 | 781 | ||
258 | 782 | def partition_verify_fdasd(disk_path, partnumber, info): | ||
259 | 783 | verify_exists(disk_path) | ||
260 | 784 | pt = dasd.DasdPartitionTable.from_fdasd(disk_path) | ||
261 | 785 | pt_entry = pt.partitions[partnumber-1] | ||
262 | 786 | expected_tracks = pt.tracks_needed(util.human2bytes(info['size'])) | ||
263 | 787 | msg = ( | ||
264 | 788 | 'Verifying %s part %s size, expecting %s tracks, found %s tracks' % ( | ||
265 | 789 | disk_path, partnumber, expected_tracks, pt_entry.length)) | ||
266 | 790 | LOG.debug(msg) | ||
267 | 791 | if expected_tracks != pt_entry.length: | ||
268 | 792 | raise RuntimeError(msg) | ||
269 | 793 | if info.get('flag', 'linux') != 'linux': | ||
270 | 794 | raise RuntimeError("dasd partitions do not support flags") | ||
271 | 795 | |||
272 | 796 | |||
273 | 782 | def partition_handler(info, storage_config): | 797 | def partition_handler(info, storage_config): |
274 | 783 | device = info.get('device') | 798 | device = info.get('device') |
275 | 784 | size = info.get('size') | 799 | size = info.get('size') |
276 | @@ -870,9 +885,12 @@ def partition_handler(info, storage_config): | |||
277 | 870 | # Handle preserve flag | 885 | # Handle preserve flag |
278 | 871 | create_partition = True | 886 | create_partition = True |
279 | 872 | if config.value_as_boolean(info.get('preserve')): | 887 | if config.value_as_boolean(info.get('preserve')): |
283 | 873 | part_path = block.dev_path( | 888 | if disk_ptable == 'vtoc': |
284 | 874 | block.partition_kname(disk_kname, partnumber)) | 889 | partition_verify_fdasd(disk, partnumber, info) |
285 | 875 | partition_verify(part_path, info) | 890 | else: |
286 | 891 | part_path = block.dev_path( | ||
287 | 892 | block.partition_kname(disk_kname, partnumber)) | ||
288 | 893 | partition_verify_sfdisk(part_path, info) | ||
289 | 876 | LOG.debug('Partition %s already present, skipping create', part_path) | 894 | LOG.debug('Partition %s already present, skipping create', part_path) |
290 | 877 | create_partition = False | 895 | create_partition = False |
291 | 878 | 896 | ||
292 | diff --git a/tests/unittests/test_block_dasd.py b/tests/unittests/test_block_dasd.py | |||
293 | index 393e288..dfd62d3 100644 | |||
294 | --- a/tests/unittests/test_block_dasd.py | |||
295 | +++ b/tests/unittests/test_block_dasd.py | |||
296 | @@ -204,11 +204,6 @@ class TestDasdCcwDeviceAttr(CiTestCase): | |||
297 | 204 | self.m_loadfile.return_value = self.random_string() | 204 | self.m_loadfile.return_value = self.random_string() |
298 | 205 | self.assertFalse(self.dasd.is_online()) | 205 | self.assertFalse(self.dasd.is_online()) |
299 | 206 | 206 | ||
300 | 207 | def test_status_returns_device_status_attr(self): | ||
301 | 208 | status_val = self.random_string() | ||
302 | 209 | self.m_loadfile.return_value = status_val | ||
303 | 210 | self.assertEqual(status_val, self.dasd.status()) | ||
304 | 211 | |||
305 | 212 | def test_blocksize(self): | 207 | def test_blocksize(self): |
306 | 213 | blocksize_val = '%d' % random.choice([512, 1024, 2048, 4096]) | 208 | blocksize_val = '%d' % random.choice([512, 1024, 2048, 4096]) |
307 | 214 | self.m_loadfile.return_value = blocksize_val | 209 | self.m_loadfile.return_value = blocksize_val |
308 | diff --git a/tests/unittests/test_commands_block_meta.py b/tests/unittests/test_commands_block_meta.py | |||
309 | index ffec434..a5129a5 100644 | |||
310 | --- a/tests/unittests/test_commands_block_meta.py | |||
311 | +++ b/tests/unittests/test_commands_block_meta.py | |||
312 | @@ -5,7 +5,9 @@ from collections import OrderedDict | |||
313 | 5 | import copy | 5 | import copy |
314 | 6 | from mock import patch, call | 6 | from mock import patch, call |
315 | 7 | import os | 7 | import os |
316 | 8 | import random | ||
317 | 8 | 9 | ||
318 | 10 | from curtin.block import dasd | ||
319 | 9 | from curtin.commands import block_meta | 11 | from curtin.commands import block_meta |
320 | 10 | from curtin import paths, util | 12 | from curtin import paths, util |
321 | 11 | from .helpers import CiTestCase | 13 | from .helpers import CiTestCase |
322 | @@ -2398,10 +2400,10 @@ class TestCalcDMPartitionInfo(CiTestCase): | |||
323 | 2398 | self.m_subp.call_args_list) | 2400 | self.m_subp.call_args_list) |
324 | 2399 | 2401 | ||
325 | 2400 | 2402 | ||
327 | 2401 | class TestPartitionVerify(CiTestCase): | 2403 | class TestPartitionVerifySfdisk(CiTestCase): |
328 | 2402 | 2404 | ||
329 | 2403 | def setUp(self): | 2405 | def setUp(self): |
331 | 2404 | super(TestPartitionVerify, self).setUp() | 2406 | super(TestPartitionVerifySfdisk, self).setUp() |
332 | 2405 | base = 'curtin.commands.block_meta.' | 2407 | base = 'curtin.commands.block_meta.' |
333 | 2406 | self.add_patch(base + 'verify_exists', 'm_verify_exists') | 2408 | self.add_patch(base + 'verify_exists', 'm_verify_exists') |
334 | 2407 | self.add_patch(base + 'block.sfdisk_info', 'm_block_sfdisk_info') | 2409 | self.add_patch(base + 'block.sfdisk_info', 'm_block_sfdisk_info') |
335 | @@ -2418,8 +2420,8 @@ class TestPartitionVerify(CiTestCase): | |||
336 | 2418 | self.part_size = int(util.human2bytes(self.info['size'])) | 2420 | self.part_size = int(util.human2bytes(self.info['size'])) |
337 | 2419 | self.devpath = self.random_string() | 2421 | self.devpath = self.random_string() |
338 | 2420 | 2422 | ||
341 | 2421 | def test_partition_verify(self): | 2423 | def test_partition_verify_sfdisk(self): |
342 | 2422 | block_meta.partition_verify(self.devpath, self.info) | 2424 | block_meta.partition_verify_sfdisk(self.devpath, self.info) |
343 | 2423 | self.assertEqual( | 2425 | self.assertEqual( |
344 | 2424 | [call(self.devpath)], | 2426 | [call(self.devpath)], |
345 | 2425 | self.m_verify_exists.call_args_list) | 2427 | self.m_verify_exists.call_args_list) |
346 | @@ -2437,7 +2439,7 @@ class TestPartitionVerify(CiTestCase): | |||
347 | 2437 | 2439 | ||
348 | 2438 | def test_partition_verify_skips_ptable_no_flag(self): | 2440 | def test_partition_verify_skips_ptable_no_flag(self): |
349 | 2439 | del self.info['flag'] | 2441 | del self.info['flag'] |
351 | 2440 | block_meta.partition_verify(self.devpath, self.info) | 2442 | block_meta.partition_verify_sfdisk(self.devpath, self.info) |
352 | 2441 | self.assertEqual( | 2443 | self.assertEqual( |
353 | 2442 | [call(self.devpath)], | 2444 | [call(self.devpath)], |
354 | 2443 | self.m_verify_exists.call_args_list) | 2445 | self.m_verify_exists.call_args_list) |
355 | @@ -2451,6 +2453,47 @@ class TestPartitionVerify(CiTestCase): | |||
356 | 2451 | self.assertEqual([], self.m_verify_ptable_flag.call_args_list) | 2453 | self.assertEqual([], self.m_verify_ptable_flag.call_args_list) |
357 | 2452 | 2454 | ||
358 | 2453 | 2455 | ||
359 | 2456 | class TestPartitionVerifyFdasd(CiTestCase): | ||
360 | 2457 | |||
361 | 2458 | def setUp(self): | ||
362 | 2459 | super(TestPartitionVerifyFdasd, self).setUp() | ||
363 | 2460 | base = 'curtin.commands.block_meta.' | ||
364 | 2461 | self.add_patch(base + 'verify_exists', 'm_verify_exists') | ||
365 | 2462 | self.add_patch( | ||
366 | 2463 | base + 'dasd.DasdPartitionTable.from_fdasd', 'm_from_fdasd', | ||
367 | 2464 | autospec=False, spec=dasd.DasdPartitionTable.from_fdasd) | ||
368 | 2465 | self.add_patch(base + 'verify_size', 'm_verify_size') | ||
369 | 2466 | self.info = { | ||
370 | 2467 | 'id': 'disk-sda-part-2', | ||
371 | 2468 | 'type': 'partition', | ||
372 | 2469 | 'device': 'sda', | ||
373 | 2470 | 'number': 2, | ||
374 | 2471 | 'size': '5GB', | ||
375 | 2472 | 'flag': 'linux', | ||
376 | 2473 | } | ||
377 | 2474 | self.part_size = int(util.human2bytes(self.info['size'])) | ||
378 | 2475 | self.devpath = self.random_string() | ||
379 | 2476 | |||
380 | 2477 | def test_partition_verify_fdasd(self): | ||
381 | 2478 | blocks_per_track = random.randint(10, 20) | ||
382 | 2479 | bytes_per_block = random.randint(1, 8)*512 | ||
383 | 2480 | fake_pt = dasd.DasdPartitionTable( | ||
384 | 2481 | '/dev/dasdfoo', blocks_per_track, bytes_per_block) | ||
385 | 2482 | tracks_needed = fake_pt.tracks_needed( | ||
386 | 2483 | util.human2bytes(self.info['size'])) | ||
387 | 2484 | fake_pt.partitions = [ | ||
388 | 2485 | dasd.DasdPartition(fake_pt, '', 0, 0, tracks_needed, '1', 'Linux'), | ||
389 | 2486 | ] | ||
390 | 2487 | self.m_from_fdasd.side_effect = iter([fake_pt]) | ||
391 | 2488 | block_meta.partition_verify_fdasd(self.devpath, 1, self.info) | ||
392 | 2489 | self.assertEqual( | ||
393 | 2490 | [call(self.devpath)], | ||
394 | 2491 | self.m_verify_exists.call_args_list) | ||
395 | 2492 | self.assertEqual( | ||
396 | 2493 | [call(self.devpath)], | ||
397 | 2494 | self.m_from_fdasd.call_args_list) | ||
398 | 2495 | |||
399 | 2496 | |||
400 | 2454 | class TestVerifyExists(CiTestCase): | 2497 | class TestVerifyExists(CiTestCase): |
401 | 2455 | 2498 | ||
402 | 2456 | def setUp(self): | 2499 | def setUp(self): |
FAILED: Continuous integration, rev:89b3d5deef6 15f40bb5e76cb45 def6b292cb7097 /jenkins. ubuntu. com/server/ job/curtin- ci/3/ /jenkins. ubuntu. com/server/ job/curtin- ci/nodes= metal-amd64/ 3/ /jenkins. ubuntu. com/server/ job/curtin- ci/nodes= metal-arm64/ 3/ /jenkins. ubuntu. com/server/ job/curtin- ci/nodes= metal-ppc64el/ 3/ /jenkins. ubuntu. com/server/ job/curtin- ci/nodes= metal-s390x/ 3/
https:/
Executed test runs:
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
Click here to trigger a rebuild: /jenkins. ubuntu. com/server/ job/curtin- ci/3//rebuild
https:/