1 | #!/usr/bin/env python
|
---|
2 | # -*- coding: utf-8 -*-
|
---|
3 | # $Id: tdStorageBenchmark1.py 57289 2015-08-12 12:15:31Z vboxsync $
|
---|
4 |
|
---|
5 | """
|
---|
6 | VirtualBox Validation Kit - Storage benchmark.
|
---|
7 | """
|
---|
8 |
|
---|
9 | __copyright__ = \
|
---|
10 | """
|
---|
11 | Copyright (C) 2012-2015 Oracle Corporation
|
---|
12 |
|
---|
13 | This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
14 | available from http://www.virtualbox.org. This file is free software;
|
---|
15 | you can redistribute it and/or modify it under the terms of the GNU
|
---|
16 | General Public License (GPL) as published by the Free Software
|
---|
17 | Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
18 | VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
19 | hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
20 |
|
---|
21 | The contents of this file may alternatively be used under the terms
|
---|
22 | of the Common Development and Distribution License Version 1.0
|
---|
23 | (CDDL) only, as it comes in the "COPYING.CDDL" file of the
|
---|
24 | VirtualBox OSE distribution, in which case the provisions of the
|
---|
25 | CDDL are applicable instead of those of the GPL.
|
---|
26 |
|
---|
27 | You may elect to license modified versions of this file under the
|
---|
28 | terms and conditions of either the GPL or the CDDL or both.
|
---|
29 | """
|
---|
30 | __version__ = "$Revision: 57289 $"
|
---|
31 |
|
---|
32 |
|
---|
33 | # Standard Python imports.
|
---|
34 | import array;
|
---|
35 | import os;
|
---|
36 | import sys;
|
---|
37 | import StringIO;
|
---|
38 |
|
---|
39 | # Only the main script needs to modify the path.
|
---|
40 | try: __file__
|
---|
41 | except: __file__ = sys.argv[0];
|
---|
42 | g_ksValidationKitDir = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))));
|
---|
43 | sys.path.append(g_ksValidationKitDir);
|
---|
44 |
|
---|
45 | # Validation Kit imports.
|
---|
46 | from testdriver import reporter;
|
---|
47 | from testdriver import base;
|
---|
48 | from testdriver import vbox;
|
---|
49 | from testdriver import vboxcon;
|
---|
50 |
|
---|
51 | def _ControllerTypeToName(eControllerType):
|
---|
52 | """ Translate a controller type to a name. """
|
---|
53 | if eControllerType == vboxcon.StorageControllerType_PIIX3 or eControllerType == vboxcon.StorageControllerType_PIIX4:
|
---|
54 | sType = "IDE Controller";
|
---|
55 | elif eControllerType == vboxcon.StorageControllerType_IntelAhci:
|
---|
56 | sType = "SATA Controller";
|
---|
57 | elif eControllerType == vboxcon.StorageControllerType_LsiLogicSas:
|
---|
58 | sType = "SAS Controller";
|
---|
59 | elif eControllerType == vboxcon.StorageControllerType_LsiLogic or eControllerType == vboxcon.StorageControllerType_BusLogic:
|
---|
60 | sType = "SCSI Controller";
|
---|
61 | else:
|
---|
62 | sType = "Storage Controller";
|
---|
63 | return sType;
|
---|
64 |
|
---|
65 | class IozoneStdOutWrapper(object):
|
---|
66 | """ Parser for iozone standard output """
|
---|
67 | def __init__(self):
|
---|
68 | self.fpInitWriter = 0.0;
|
---|
69 | self.fpRewriter = 0.0;
|
---|
70 | self.fpReader = 0.0;
|
---|
71 | self.fpRereader = 0.0;
|
---|
72 | self.fpReverseReader = 0.0;
|
---|
73 | self.fpStrideReader = 0.0;
|
---|
74 | self.fpRandomReader = 0.0;
|
---|
75 | self.fpMixedWorkload = 0.0;
|
---|
76 | self.fpRandomWriter = 0.0;
|
---|
77 | self.fpPWrite = 0.0;
|
---|
78 | self.fpPRead = 0.0;
|
---|
79 |
|
---|
80 | def read(self, cb):
|
---|
81 | """file.read"""
|
---|
82 | _ = cb;
|
---|
83 | return "";
|
---|
84 |
|
---|
85 | def write(self, sText):
|
---|
86 | """iozone stdout write"""
|
---|
87 | if isinstance(sText, array.array):
|
---|
88 | try:
|
---|
89 | sText = sText.tostring();
|
---|
90 | except:
|
---|
91 | pass;
|
---|
92 | try:
|
---|
93 | asLines = sText.splitlines();
|
---|
94 | for sLine in asLines:
|
---|
95 | sLine = sLine.strip();
|
---|
96 | if sLine.startswith('Children') is True:
|
---|
97 | # Extract the value
|
---|
98 | idxValue = sLine.rfind('=');
|
---|
99 | if idxValue is -1:
|
---|
100 | raise Exception('IozoneStdOutWrapper: Invalid state');
|
---|
101 |
|
---|
102 | idxValue += 1;
|
---|
103 | while sLine[idxValue] == ' ':
|
---|
104 | idxValue += 1;
|
---|
105 |
|
---|
106 | idxValueEnd = idxValue;
|
---|
107 | while sLine[idxValueEnd] == '.' or sLine[idxValueEnd].isdigit():
|
---|
108 | idxValueEnd += 1;
|
---|
109 |
|
---|
110 | fpValue = float(sLine[idxValue:idxValueEnd]);
|
---|
111 |
|
---|
112 | if sLine.rfind('initial writers') is not -1:
|
---|
113 | self.fpInitWriter = fpValue;
|
---|
114 | elif sLine.rfind('rewriters') is not -1:
|
---|
115 | self.fpRewriter = fpValue;
|
---|
116 | elif sLine.rfind('re-readers') is not -1:
|
---|
117 | self.fpRereader = fpValue;
|
---|
118 | elif sLine.rfind('reverse readers') is not -1:
|
---|
119 | self.fpReverseReader = fpValue;
|
---|
120 | elif sLine.rfind('stride readers') is not -1:
|
---|
121 | self.fpStrideReader = fpValue;
|
---|
122 | elif sLine.rfind('random readers') is not -1:
|
---|
123 | self.fpRandomReader = fpValue;
|
---|
124 | elif sLine.rfind('mixed workload') is not -1:
|
---|
125 | self.fpMixedWorkload = fpValue;
|
---|
126 | elif sLine.rfind('random writers') is not -1:
|
---|
127 | self.fpRandomWriter = fpValue;
|
---|
128 | elif sLine.rfind('pwrite writers') is not -1:
|
---|
129 | self.fpPWrite = fpValue;
|
---|
130 | elif sLine.rfind('pread readers') is not -1:
|
---|
131 | self.fpPRead = fpValue;
|
---|
132 | elif sLine.rfind('readers') is not -1:
|
---|
133 | self.fpReader = fpValue;
|
---|
134 | else:
|
---|
135 | reporter.log('Unknown test returned %s' % sLine);
|
---|
136 | except:
|
---|
137 | pass;
|
---|
138 | return None;
|
---|
139 |
|
---|
140 | def getInitWriter(self):
|
---|
141 | """Get value for initial writers"""
|
---|
142 | return self.fpInitWriter;
|
---|
143 |
|
---|
144 | def getRewriter(self):
|
---|
145 | """Get value for re-writers"""
|
---|
146 | return self.fpRewriter;
|
---|
147 |
|
---|
148 | def getReader(self):
|
---|
149 | """Get value for initial readers"""
|
---|
150 | return self.fpReader;
|
---|
151 |
|
---|
152 | def getRereader(self):
|
---|
153 | """Get value for re-writers"""
|
---|
154 | return self.fpRereader;
|
---|
155 |
|
---|
156 | def getReverseReader(self):
|
---|
157 | """Get value for reverse readers"""
|
---|
158 | return self.fpReverseReader;
|
---|
159 |
|
---|
160 | def getStrideReader(self):
|
---|
161 | """Get value for stride readers"""
|
---|
162 | return self.fpStrideReader;
|
---|
163 |
|
---|
164 | def getRandomReader(self):
|
---|
165 | """Get value for random readers"""
|
---|
166 | return self.fpRandomReader;
|
---|
167 |
|
---|
168 | def getMixedWorkload(self):
|
---|
169 | """Get value for mixed workload"""
|
---|
170 | return self.fpMixedWorkload;
|
---|
171 |
|
---|
172 | def getRandomWriter(self):
|
---|
173 | """Get value for random writers"""
|
---|
174 | return self.fpRandomWriter;
|
---|
175 |
|
---|
176 | def getPWrite(self):
|
---|
177 | """Get value for pwrite writers"""
|
---|
178 | return self.fpPWrite;
|
---|
179 |
|
---|
180 | def getPRead(self):
|
---|
181 | """Get value for pread readers"""
|
---|
182 | return self.fpPRead;
|
---|
183 |
|
---|
184 | class FioWrapper(object):
|
---|
185 | """ Fio stdout parser and config file creator """
|
---|
186 | def __init__(self, sRecordSize, sTestsetSize, sQueueDepth, sPath):
|
---|
187 |
|
---|
188 | self.configBuf = StringIO.StringIO();
|
---|
189 | self.configBuf.write('[global]\n');
|
---|
190 | self.configBuf.write('bs=' + sRecordSize + '\n');
|
---|
191 | self.configBuf.write('ioengine=libaio\n');
|
---|
192 | self.configBuf.write('iodepth=' + sQueueDepth + '\n');
|
---|
193 | self.configBuf.write('size=' + sTestsetSize + '\n');
|
---|
194 | self.configBuf.write('direct=1\n');
|
---|
195 | self.configBuf.write('directory=' + sPath + '\n');
|
---|
196 |
|
---|
197 | self.configBuf.write('[seq-write]\n');
|
---|
198 | self.configBuf.write('rw=write\n');
|
---|
199 | self.configBuf.write('stonewall\n');
|
---|
200 |
|
---|
201 | self.configBuf.write('[rand-write]\n');
|
---|
202 | self.configBuf.write('rw=randwrite\n');
|
---|
203 | self.configBuf.write('stonewall\n');
|
---|
204 |
|
---|
205 | self.configBuf.write('[seq-read]\n');
|
---|
206 | self.configBuf.write('rw=read\n');
|
---|
207 | self.configBuf.write('stonewall\n');
|
---|
208 |
|
---|
209 | self.configBuf.write('[rand-read]\n');
|
---|
210 | self.configBuf.write('rw=randread\n');
|
---|
211 | self.configBuf.write('stonewall\n');
|
---|
212 | return;
|
---|
213 |
|
---|
214 | def getConfig(self):
|
---|
215 | """fio stdin feeder, gives the config file based on the given config values"""
|
---|
216 | return self.configBuf.getvalue();
|
---|
217 |
|
---|
218 | def write(self, sText):
|
---|
219 | """fio stdout write"""
|
---|
220 | if isinstance(sText, array.array):
|
---|
221 | try:
|
---|
222 | sText = sText.tostring();
|
---|
223 | except:
|
---|
224 | pass;
|
---|
225 | try:
|
---|
226 | asLines = sText.splitlines();
|
---|
227 | for sLine in asLines:
|
---|
228 | reporter.log(sLine);
|
---|
229 | except:
|
---|
230 | pass;
|
---|
231 | return None;
|
---|
232 |
|
---|
233 |
|
---|
234 | class tdStorageBenchmark(vbox.TestDriver): # pylint: disable=R0902
|
---|
235 | """
|
---|
236 | Storage benchmark.
|
---|
237 | """
|
---|
238 |
|
---|
239 | def __init__(self):
|
---|
240 | vbox.TestDriver.__init__(self);
|
---|
241 | self.asRsrcs = None;
|
---|
242 | self.oGuestToGuestVM = None;
|
---|
243 | self.oGuestToGuestSess = None;
|
---|
244 | self.oGuestToGuestTxs = None;
|
---|
245 | self.asTestVMsDef = ['tst-debian'];
|
---|
246 | self.asTestVMs = self.asTestVMsDef;
|
---|
247 | self.asSkipVMs = [];
|
---|
248 | self.asVirtModesDef = ['hwvirt', 'hwvirt-np', 'raw',]
|
---|
249 | self.asVirtModes = self.asVirtModesDef
|
---|
250 | self.acCpusDef = [1, 2,]
|
---|
251 | self.acCpus = self.acCpusDef;
|
---|
252 | self.asStorageCtrlsDef = ['AHCI', 'IDE', 'LsiLogicSAS', 'LsiLogic', 'BusLogic'];
|
---|
253 | self.asStorageCtrls = self.asStorageCtrlsDef;
|
---|
254 | self.asDiskFormatsDef = ['VDI', 'VMDK', 'VHD', 'QED', 'Parallels', 'QCOW', 'iSCSI'];
|
---|
255 | self.asDiskFormats = self.asDiskFormatsDef;
|
---|
256 | self.asTestsDef = ['iozone', 'fio'];
|
---|
257 | self.asTests = self.asTestsDef;
|
---|
258 | self.asDirsDef = ['/run/media/alexander/OWCSSD/alexander', \
|
---|
259 | '/run/media/alexander/CrucialSSD/alexander', \
|
---|
260 | '/run/media/alexander/HardDisk/alexander', \
|
---|
261 | '/home/alexander'];
|
---|
262 | self.asDirs = self.asDirsDef;
|
---|
263 | self.asIscsiTargetsDef = ['aurora|iqn.2011-03.home.aurora:aurora.storagebench|1'];
|
---|
264 | self.asIscsiTargets = self.asIscsiTargetsDef;
|
---|
265 |
|
---|
266 | #
|
---|
267 | # Overridden methods.
|
---|
268 | #
|
---|
269 | def showUsage(self):
|
---|
270 | rc = vbox.TestDriver.showUsage(self);
|
---|
271 | reporter.log('');
|
---|
272 | reporter.log('tdStorageBenchmark1 Options:');
|
---|
273 | reporter.log(' --virt-modes <m1[:m2[:]]');
|
---|
274 | reporter.log(' Default: %s' % (':'.join(self.asVirtModesDef)));
|
---|
275 | reporter.log(' --cpu-counts <c1[:c2[:]]');
|
---|
276 | reporter.log(' Default: %s' % (':'.join(str(c) for c in self.acCpusDef)));
|
---|
277 | reporter.log(' --storage-ctrls <type1[:type2[:...]]>');
|
---|
278 | reporter.log(' Default: %s' % (':'.join(self.asStorageCtrls)));
|
---|
279 | reporter.log(' --disk-formats <type1[:type2[:...]]>');
|
---|
280 | reporter.log(' Default: %s' % (':'.join(self.asDiskFormats)));
|
---|
281 | reporter.log(' --disk-dirs <path1[:path2[:...]]>');
|
---|
282 | reporter.log(' Default: %s' % (':'.join(self.asDirs)));
|
---|
283 | reporter.log(' --iscsi-targets <target1[:target2[:...]]>');
|
---|
284 | reporter.log(' Default: %s' % (':'.join(self.asIscsiTargets)));
|
---|
285 | reporter.log(' --tests <test1[:test2[:...]]>');
|
---|
286 | reporter.log(' Default: %s' % (':'.join(self.asTests)));
|
---|
287 | reporter.log(' --test-vms <vm1[:vm2[:...]]>');
|
---|
288 | reporter.log(' Test the specified VMs in the given order. Use this to change');
|
---|
289 | reporter.log(' the execution order or limit the choice of VMs');
|
---|
290 | reporter.log(' Default: %s (all)' % (':'.join(self.asTestVMsDef)));
|
---|
291 | reporter.log(' --skip-vms <vm1[:vm2[:...]]>');
|
---|
292 | reporter.log(' Skip the specified VMs when testing.');
|
---|
293 | return rc;
|
---|
294 |
|
---|
295 | def parseOption(self, asArgs, iArg): # pylint: disable=R0912,R0915
|
---|
296 | if asArgs[iArg] == '--virt-modes':
|
---|
297 | iArg += 1;
|
---|
298 | if iArg >= len(asArgs): raise base.InvalidOption('The "--virt-modes" takes a colon separated list of modes');
|
---|
299 | self.asVirtModes = asArgs[iArg].split(':');
|
---|
300 | for s in self.asVirtModes:
|
---|
301 | if s not in self.asVirtModesDef:
|
---|
302 | raise base.InvalidOption('The "--virt-modes" value "%s" is not valid; valid values are: %s' \
|
---|
303 | % (s, ' '.join(self.asVirtModesDef)));
|
---|
304 | elif asArgs[iArg] == '--cpu-counts':
|
---|
305 | iArg += 1;
|
---|
306 | if iArg >= len(asArgs): raise base.InvalidOption('The "--cpu-counts" takes a colon separated list of cpu counts');
|
---|
307 | self.acCpus = [];
|
---|
308 | for s in asArgs[iArg].split(':'):
|
---|
309 | try: c = int(s);
|
---|
310 | except: raise base.InvalidOption('The "--cpu-counts" value "%s" is not an integer' % (s,));
|
---|
311 | if c <= 0: raise base.InvalidOption('The "--cpu-counts" value "%s" is zero or negative' % (s,));
|
---|
312 | self.acCpus.append(c);
|
---|
313 | elif asArgs[iArg] == '--storage-ctrls':
|
---|
314 | iArg += 1;
|
---|
315 | if iArg >= len(asArgs):
|
---|
316 | raise base.InvalidOption('The "--storage-ctrls" takes a colon separated list of Storage controller types');
|
---|
317 | self.asStorageCtrls = asArgs[iArg].split(':');
|
---|
318 | elif asArgs[iArg] == '--disk-formats':
|
---|
319 | iArg += 1;
|
---|
320 | if iArg >= len(asArgs): raise base.InvalidOption('The "--disk-formats" takes a colon separated list of disk formats');
|
---|
321 | self.asDiskFormats = asArgs[iArg].split(':');
|
---|
322 | elif asArgs[iArg] == '--disk-dirs':
|
---|
323 | iArg += 1;
|
---|
324 | if iArg >= len(asArgs): raise base.InvalidOption('The "--disk-dirs" takes a colon separated list of directories');
|
---|
325 | self.asDirs = asArgs[iArg].split(':');
|
---|
326 | elif asArgs[iArg] == '--iscsi-targets':
|
---|
327 | iArg += 1;
|
---|
328 | if iArg >= len(asArgs):
|
---|
329 | raise base.InvalidOption('The "--iscsi-targets" takes a colon separated list of iscsi targets');
|
---|
330 | self.asIscsiTargets = asArgs[iArg].split(':');
|
---|
331 | elif asArgs[iArg] == '--tests':
|
---|
332 | iArg += 1;
|
---|
333 | if iArg >= len(asArgs): raise base.InvalidOption('The "--tests" takes a colon separated list of disk formats');
|
---|
334 | self.asTests = asArgs[iArg].split(':');
|
---|
335 | elif asArgs[iArg] == '--test-vms':
|
---|
336 | iArg += 1;
|
---|
337 | if iArg >= len(asArgs): raise base.InvalidOption('The "--test-vms" takes colon separated list');
|
---|
338 | self.asTestVMs = asArgs[iArg].split(':');
|
---|
339 | for s in self.asTestVMs:
|
---|
340 | if s not in self.asTestVMsDef:
|
---|
341 | raise base.InvalidOption('The "--test-vms" value "%s" is not valid; valid values are: %s' \
|
---|
342 | % (s, ' '.join(self.asTestVMsDef)));
|
---|
343 | elif asArgs[iArg] == '--skip-vms':
|
---|
344 | iArg += 1;
|
---|
345 | if iArg >= len(asArgs): raise base.InvalidOption('The "--skip-vms" takes colon separated list');
|
---|
346 | self.asSkipVMs = asArgs[iArg].split(':');
|
---|
347 | for s in self.asSkipVMs:
|
---|
348 | if s not in self.asTestVMsDef:
|
---|
349 | reporter.log('warning: The "--test-vms" value "%s" does not specify any of our test VMs.' % (s));
|
---|
350 | else:
|
---|
351 | return vbox.TestDriver.parseOption(self, asArgs, iArg);
|
---|
352 | return iArg + 1;
|
---|
353 |
|
---|
354 | def completeOptions(self):
|
---|
355 | # Remove skipped VMs from the test list.
|
---|
356 | for sVM in self.asSkipVMs:
|
---|
357 | try: self.asTestVMs.remove(sVM);
|
---|
358 | except: pass;
|
---|
359 |
|
---|
360 | return vbox.TestDriver.completeOptions(self);
|
---|
361 |
|
---|
362 | def getResourceSet(self):
|
---|
363 | # Construct the resource list the first time it's queried.
|
---|
364 | if self.asRsrcs is None:
|
---|
365 | self.asRsrcs = [];
|
---|
366 | if 'tst-debian' in self.asTestVMs:
|
---|
367 | self.asRsrcs.append('4.2/storage/debian.vdi');
|
---|
368 |
|
---|
369 | return self.asRsrcs;
|
---|
370 |
|
---|
371 | def actionConfig(self):
|
---|
372 |
|
---|
373 | # Make sure vboxapi has been imported so we can use the constants.
|
---|
374 | if not self.importVBoxApi():
|
---|
375 | return False;
|
---|
376 |
|
---|
377 | #
|
---|
378 | # Configure the VMs we're going to use.
|
---|
379 | #
|
---|
380 |
|
---|
381 | # Linux VMs
|
---|
382 | if 'tst-debian' in self.asTestVMs:
|
---|
383 | oVM = self.createTestVM('tst-debian', 1, '4.2/storage/debian.vdi', sKind = 'Debian_64', fIoApic = True, \
|
---|
384 | eNic0AttachType = vboxcon.NetworkAttachmentType_NAT, \
|
---|
385 | eNic0Type = vboxcon.NetworkAdapterType_Am79C973);
|
---|
386 | if oVM is None:
|
---|
387 | return False;
|
---|
388 |
|
---|
389 | return True;
|
---|
390 |
|
---|
391 | def actionExecute(self):
|
---|
392 | """
|
---|
393 | Execute the testcase.
|
---|
394 | """
|
---|
395 | fRc = self.test1();
|
---|
396 | return fRc;
|
---|
397 |
|
---|
398 |
|
---|
399 | #
|
---|
400 | # Test execution helpers.
|
---|
401 | #
|
---|
402 |
|
---|
403 | def test1RunTestProgs(self, oSession, oTxsSession, fRc, sTestName):
|
---|
404 | """
|
---|
405 | Runs all the test programs on the test machine.
|
---|
406 | """
|
---|
407 | reporter.testStart(sTestName);
|
---|
408 |
|
---|
409 | # Prepare test disk, just create filesystem without partition
|
---|
410 | reporter.testStart('mkfs.ext4');
|
---|
411 | fRc = self.txsRunTest(oTxsSession, 'Create FS', 60000,
|
---|
412 | '/sbin/mkfs.ext4',
|
---|
413 | ('mkfs.ext4', '-F', '/dev/vboxtest'));
|
---|
414 | reporter.testDone();
|
---|
415 |
|
---|
416 | reporter.testStart('mount');
|
---|
417 | fRc = self.txsRunTest(oTxsSession, 'Mount FS', 30000,
|
---|
418 | '/bin/mount',
|
---|
419 | ('mount', '/dev/vboxtest', '/mnt'));
|
---|
420 | reporter.testDone();
|
---|
421 |
|
---|
422 | reporter.testStart('iozone');
|
---|
423 | if fRc and 'iozone' in self.asTests:
|
---|
424 | oStdOut = IozoneStdOutWrapper();
|
---|
425 | fRc = self.txsRunTestRedirectStd(oTxsSession, '2G', 3600000,
|
---|
426 | '/usr/bin/iozone',
|
---|
427 | ('iozone', '-r', '64k', '-s', '2g', '-t', '1', '-T', '-I',
|
---|
428 | '-H', '32','-F', '/mnt/iozone'),
|
---|
429 | (), '', '/dev/null', oStdOut, '/dev/null', '/dev/null');
|
---|
430 | if fRc is True:
|
---|
431 | reporter.log("Initial writer: " + str(oStdOut.getInitWriter()));
|
---|
432 | reporter.log("Rewriter: " + str(oStdOut.getRewriter()));
|
---|
433 | reporter.log("Initial reader: " + str(oStdOut.getReader()));
|
---|
434 | reporter.log("Re-reader: " + str(oStdOut.getRereader()));
|
---|
435 | reporter.log("Reverse reader: " + str(oStdOut.getReverseReader()));
|
---|
436 | reporter.log("Stride reader: " + str(oStdOut.getStrideReader()));
|
---|
437 | reporter.log("Random reader: " + str(oStdOut.getRandomReader()));
|
---|
438 | reporter.log("Mixed Workload: " + str(oStdOut.getMixedWorkload()));
|
---|
439 | reporter.log("Random writer: " + str(oStdOut.getRandomWriter()));
|
---|
440 | reporter.log("pwrite Writer: " + str(oStdOut.getPWrite()));
|
---|
441 | reporter.log("pread Reader: " + str(oStdOut.getPRead()));
|
---|
442 | reporter.testDone();
|
---|
443 | else:
|
---|
444 | reporter.testDone(fSkipped = True);
|
---|
445 |
|
---|
446 | reporter.testStart('fio');
|
---|
447 | if fRc and 'fio' in self.asTests:
|
---|
448 | oFioWrapper = FioWrapper('64k', '2g', '32', '/mnt');
|
---|
449 | fRc = self.txsUploadString(oSession, oTxsSession, oFioWrapper.getConfig(), '${SCRATCH}/aio-test');
|
---|
450 | fRc = fRc and self.txsRunTestRedirectStd(oTxsSession, '2G', 3600000,
|
---|
451 | '/usr/bin/fio', ('fio', '${SCRATCH}/aio-test'),
|
---|
452 | (), '', '/dev/null', oFioWrapper, '/dev/null', '/dev/null');
|
---|
453 | else:
|
---|
454 | reporter.testDone(fSkipped = True);
|
---|
455 |
|
---|
456 | reporter.testDone(not fRc);
|
---|
457 | return fRc;
|
---|
458 |
|
---|
459 | def test1OneCfg(self, sVmName, eStorageController, sDiskFormat, sDiskPath, cCpus, fHwVirt, fNestedPaging):
|
---|
460 | """
|
---|
461 | Runs the specified VM thru test #1.
|
---|
462 |
|
---|
463 | Returns a success indicator on the general test execution. This is not
|
---|
464 | the actual test result.
|
---|
465 | """
|
---|
466 | oVM = self.getVmByName(sVmName);
|
---|
467 |
|
---|
468 | # Reconfigure the VM
|
---|
469 | fRc = True;
|
---|
470 | oSession = self.openSession(oVM);
|
---|
471 | if oSession is not None:
|
---|
472 | # Attach HD
|
---|
473 | fRc = oSession.ensureControllerAttached(_ControllerTypeToName(eStorageController));
|
---|
474 | fRc = fRc and oSession.setStorageControllerType(eStorageController, _ControllerTypeToName(eStorageController));
|
---|
475 |
|
---|
476 | if sDiskFormat == "iSCSI":
|
---|
477 | listNames = [];
|
---|
478 | listValues = [];
|
---|
479 | listValues = sDiskPath.split('|');
|
---|
480 | listNames.append('TargetAddress');
|
---|
481 | listNames.append('TargetName');
|
---|
482 | listNames.append('LUN');
|
---|
483 |
|
---|
484 | if self.fpApiVer >= 5.0:
|
---|
485 | oHd = oSession.oVBox.createMedium(sDiskFormat, sDiskPath, vboxcon.AccessMode_ReadWrite, \
|
---|
486 | vboxcon.DeviceType_HardDisk);
|
---|
487 | else:
|
---|
488 | oHd = oSession.oVBox.createHardDisk(sDiskFormat, sDiskPath);
|
---|
489 | oHd.type = vboxcon.MediumType_Normal;
|
---|
490 | oHd.setProperties(listNames, listValues);
|
---|
491 |
|
---|
492 | # Attach it.
|
---|
493 | if fRc is True:
|
---|
494 | try:
|
---|
495 | if oSession.fpApiVer >= 4.0:
|
---|
496 | oSession.o.machine.attachDevice(_ControllerTypeToName(eStorageController), \
|
---|
497 | 1, 0, vboxcon.DeviceType_HardDisk, oHd);
|
---|
498 | else:
|
---|
499 | oSession.o.machine.attachDevice(_ControllerTypeToName(eStorageController), \
|
---|
500 | 1, 0, vboxcon.DeviceType_HardDisk, oHd.id);
|
---|
501 | except:
|
---|
502 | reporter.errorXcpt('attachDevice("%s",%s,%s,HardDisk,"%s") failed on "%s"' \
|
---|
503 | % (_ControllerTypeToName(eStorageController), 1, 0, oHd.id, oSession.sName) );
|
---|
504 | fRc = False;
|
---|
505 | else:
|
---|
506 | reporter.log('attached "%s" to %s' % (sDiskPath, oSession.sName));
|
---|
507 | else:
|
---|
508 | fRc = fRc and oSession.createAndAttachHd(sDiskPath, sDiskFormat, _ControllerTypeToName(eStorageController), \
|
---|
509 | cb = 10*1024*1024*1024, iPort = 1, fImmutable = False);
|
---|
510 | fRc = fRc and oSession.enableVirtEx(fHwVirt);
|
---|
511 | fRc = fRc and oSession.enableNestedPaging(fNestedPaging);
|
---|
512 | fRc = fRc and oSession.setCpuCount(cCpus);
|
---|
513 | fRc = fRc and oSession.saveSettings();
|
---|
514 | fRc = oSession.close() and fRc and True; # pychecker hack.
|
---|
515 | oSession = None;
|
---|
516 | else:
|
---|
517 | fRc = False;
|
---|
518 |
|
---|
519 | # Start up.
|
---|
520 | if fRc is True:
|
---|
521 | self.logVmInfo(oVM);
|
---|
522 | oSession, oTxsSession = self.startVmAndConnectToTxsViaTcp(sVmName, fCdWait = False, fNatForwardingForTxs = True);
|
---|
523 | if oSession is not None:
|
---|
524 | self.addTask(oSession);
|
---|
525 |
|
---|
526 | # Fudge factor - Allow the guest to finish starting up.
|
---|
527 | self.sleep(5);
|
---|
528 |
|
---|
529 | self.test1RunTestProgs(oSession, oTxsSession, fRc, 'Disk benchmark');
|
---|
530 |
|
---|
531 | # cleanup.
|
---|
532 | self.removeTask(oTxsSession);
|
---|
533 | self.terminateVmBySession(oSession)
|
---|
534 |
|
---|
535 | # Remove disk
|
---|
536 | oSession = self.openSession(oVM);
|
---|
537 | if oSession is not None:
|
---|
538 | try:
|
---|
539 | oSession.o.machine.detachDevice(_ControllerTypeToName(eStorageController), 1, 0);
|
---|
540 |
|
---|
541 | # Remove storage controller if it is not an IDE controller.
|
---|
542 | if eStorageController is not vboxcon.StorageControllerType_PIIX3 \
|
---|
543 | and eStorageController is not vboxcon.StorageControllerType_PIIX4:
|
---|
544 | oSession.o.machine.removeStorageController(_ControllerTypeToName(eStorageController));
|
---|
545 |
|
---|
546 | oSession.saveSettings();
|
---|
547 | self.oVBox.deleteHdByLocation(sDiskPath);
|
---|
548 | oSession.saveSettings();
|
---|
549 | oSession.close();
|
---|
550 | oSession = None;
|
---|
551 | except:
|
---|
552 | reporter.errorXcpt('failed to detach/delete disk %s from storage controller' % (sDiskPath));
|
---|
553 | else:
|
---|
554 | fRc = False;
|
---|
555 | else:
|
---|
556 | fRc = False;
|
---|
557 | return fRc;
|
---|
558 |
|
---|
559 | def test1OneVM(self, sVmName):
|
---|
560 | """
|
---|
561 | Runs one VM thru the various configurations.
|
---|
562 | """
|
---|
563 | reporter.testStart(sVmName);
|
---|
564 | fRc = True;
|
---|
565 | for sStorageCtrl in self.asStorageCtrls:
|
---|
566 | reporter.testStart(sStorageCtrl);
|
---|
567 |
|
---|
568 | if sStorageCtrl == 'AHCI':
|
---|
569 | eStorageCtrl = vboxcon.StorageControllerType_IntelAhci;
|
---|
570 | elif sStorageCtrl == 'IDE':
|
---|
571 | eStorageCtrl = vboxcon.StorageControllerType_PIIX4;
|
---|
572 | elif sStorageCtrl == 'LsiLogicSAS':
|
---|
573 | eStorageCtrl = vboxcon.StorageControllerType_LsiLogicSas;
|
---|
574 | elif sStorageCtrl == 'LsiLogic':
|
---|
575 | eStorageCtrl = vboxcon.StorageControllerType_LsiLogic;
|
---|
576 | elif sStorageCtrl == 'BusLogic':
|
---|
577 | eStorageCtrl = vboxcon.StorageControllerType_BusLogic;
|
---|
578 | else:
|
---|
579 | eStorageCtrl = None;
|
---|
580 |
|
---|
581 | for sDiskFormat in self.asDiskFormats:
|
---|
582 | reporter.testStart('%s' % (sDiskFormat));
|
---|
583 |
|
---|
584 | if sDiskFormat == "iSCSI":
|
---|
585 | asPaths = self.asIscsiTargets;
|
---|
586 | else:
|
---|
587 | asPaths = self.asDirs;
|
---|
588 |
|
---|
589 | for sDir in asPaths:
|
---|
590 | reporter.testStart('%s' % (sDir));
|
---|
591 |
|
---|
592 | if sDiskFormat == "iSCSI":
|
---|
593 | sPath = sDir;
|
---|
594 | else:
|
---|
595 | sPath = sDir + "/test.disk";
|
---|
596 |
|
---|
597 | for cCpus in self.acCpus:
|
---|
598 | if cCpus == 1: reporter.testStart('1 cpu');
|
---|
599 | else: reporter.testStart('%u cpus' % (cCpus));
|
---|
600 |
|
---|
601 | for sVirtMode in self.asVirtModes:
|
---|
602 | if sVirtMode == 'raw' and cCpus > 1:
|
---|
603 | continue;
|
---|
604 | hsVirtModeDesc = {};
|
---|
605 | hsVirtModeDesc['raw'] = 'Raw-mode';
|
---|
606 | hsVirtModeDesc['hwvirt'] = 'HwVirt';
|
---|
607 | hsVirtModeDesc['hwvirt-np'] = 'NestedPaging';
|
---|
608 | reporter.testStart(hsVirtModeDesc[sVirtMode]);
|
---|
609 |
|
---|
610 | fHwVirt = sVirtMode != 'raw';
|
---|
611 | fNestedPaging = sVirtMode == 'hwvirt-np';
|
---|
612 | fRc = self.test1OneCfg(sVmName, eStorageCtrl, sDiskFormat, sPath, \
|
---|
613 | cCpus, fHwVirt, fNestedPaging) and fRc and True; # pychecker hack.
|
---|
614 | reporter.testDone();
|
---|
615 |
|
---|
616 | reporter.testDone();
|
---|
617 | reporter.testDone();
|
---|
618 | reporter.testDone();
|
---|
619 | reporter.testDone();
|
---|
620 | reporter.testDone();
|
---|
621 | return fRc;
|
---|
622 |
|
---|
623 | def test1(self):
|
---|
624 | """
|
---|
625 | Executes test #1.
|
---|
626 | """
|
---|
627 |
|
---|
628 | # Loop thru the test VMs.
|
---|
629 | for sVM in self.asTestVMs:
|
---|
630 | # run test on the VM.
|
---|
631 | if not self.test1OneVM(sVM):
|
---|
632 | fRc = False;
|
---|
633 | else:
|
---|
634 | fRc = True;
|
---|
635 |
|
---|
636 | return fRc;
|
---|
637 |
|
---|
638 |
|
---|
639 |
|
---|
640 | if __name__ == '__main__':
|
---|
641 | sys.exit(tdStorageBenchmark().main(sys.argv));
|
---|
642 |
|
---|