# -*- coding: utf-8 -*-
# $Id$
"""
VirtualBox Validation Kit - Networking benchmark #1.
"""
__copyright__ = \
"""
Copyright (C) 2010-2014 Oracle Corporation
This file is part of VirtualBox Open Source Edition (OSE), as
available from http://www.virtualbox.org. This file is free software;
General Public License (GPL) as published by the Free Software
Foundation, in version 2 as it comes in the "COPYING" file of the
VirtualBox OSE distribution. VirtualBox OSE is distributed in the
hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
The contents of this file may alternatively be used under the terms
of the Common Development and Distribution License Version 1.0
(CDDL) only, as it comes in the "COPYING.CDDL" file of the
VirtualBox OSE distribution, in which case the provisions of the
CDDL are applicable instead of those of the GPL.
You may elect to license modified versions of this file under the
terms and conditions of either the GPL or the CDDL or both.
"""
# Standard Python imports.
import os;
import socket
import sys;
# Only the main script needs to modify the path.
try: __file__
g_ksValidationKitDir = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))));
# Validation Kit imports.
"""
Networking benchmark #1.
"""
self.sRemoteName = None;
self.sGuestName = None;
self.oGuestToGuestVM = None;
self.oGuestToGuestSess = None;
self.oGuestToGuestTxs = None;
except: pass;
#
# Overridden methods.
#
reporter.log(' Default: %s' % (':'.join(str(cb) for cb in self.acbLatencyPktsDef))); # pychecker bug?
reporter.log(' Default: %s' % (':'.join(str(cb) for cb in self.acbThroughputPktsDef))); # pychecker bug?
reporter.log(' Shorthand for: --virt-modes hwvirt --cpu-counts 1 --secs-per-run 5 --latency-sizes 32');
return rc;
iArg += 1;
if iArg >= len(asArgs): raise base.InvalidOption('The "--remote-host" takes an IP address or a hostname');
iArg += 1;
if iArg >= len(asArgs): raise base.InvalidOption('The "--local-host" takes an IP address or a hostname');
iArg += 1;
if iArg >= len(asArgs): raise base.InvalidOption('The "--guest-host" takes an IP address or a hostname');
iArg += 1;
if iArg >= len(asArgs): raise base.InvalidOption('The "--virt-modes" takes a colon separated list of modes');
for s in self.asVirtModes:
if s not in self.asVirtModesDef:
iArg += 1;
if iArg >= len(asArgs): raise base.InvalidOption('The "--cpu-counts" takes a colon separated list of cpu counts');
try: c = int(s);
iArg += 1;
if iArg >= len(asArgs): raise base.InvalidOption('The "--nic-types" takes a colon separated list of NIC types');
iArg += 1;
raise base.InvalidOption('The "--nic-attachment" value "%s" is not supported. Valid values are: bridged, nat' \
% (self.sNicAttachment));
iArg += 1;
if iArg >= len(asArgs): raise base.InvalidOption('The "--setups" takes a colon separated list of setups');
if s not in self.asSetupsDef:
iArg += 1;
except: raise base.InvalidOption('The "--secs-per-run" value "%s" is not an integer' % (self.cSecsRun,));
raise base.InvalidOption('The "--secs-per-run" value "%s" is zero or negative.' % (self.cSecsRun,));
iArg += 1;
if iArg >= len(asArgs): raise base.InvalidOption('The "--tests" takes a colon separated list of tests');
if s not in self.asTestsDef:
iArg += 1;
if iArg >= len(asArgs): raise base.InvalidOption('The "--latency-sizes" takes a colon separated list of sizes');
self.acbLatencyPkts = [];
if cb <= 0: raise base.InvalidOption('The "--latency-sizes" value "%s" is zero or negative' % (s,));
iArg += 1;
if iArg >= len(asArgs): raise base.InvalidOption('The "--throughput-sizes" takes a colon separated list of sizes');
self.acbThroughputPkts = [];
if cb <= 0: raise base.InvalidOption('The "--throughput-sizes" value "%s" is zero or negative' % (s,));
iArg += 1;
if s not in self.asTestVMsDef:
iArg += 1;
if s not in self.asTestVMsDef:
else:
return iArg + 1;
# Remove skipped VMs from the test list.
except: pass;
# Resolve any names we've been given.
else:
# Construct the resource list the first time it's queried.
# Some stupid trickery to guess the location of the iso. ## fixme - testsuite unzip ++
sVBoxValidationKit_iso = os.path.abspath(os.path.join(os.path.dirname(__file__), '../../VBoxValidationKit.iso'));
sVBoxValidationKit_iso = os.path.abspath(os.path.join(os.path.dirname(__file__), '../../VBoxTestSuite.iso'));
break;
break;
# Make sure vboxapi has been imported so we can use the constants.
if not self.importVBoxApi():
return False;
# Guest to Guest VM.
oVM = self.createTestVM('tst-guest2guest', 0, '3.0/tcp/rhel5.vdi', sKind = 'RedHat', fIoApic = True, \
if oVM is None:
return False;
#
# Configure the VMs we're going to use.
#
# Linux VMs
if oVM is None:
return False;
if oVM is None:
return False;
oVM = self.createTestVM('tst-sles11', 1, '3.0/tcp/sles11.vdi', sKind = 'OpenSUSE', fIoApic = True, \
if oVM is None:
return False;
if oVM is None:
return False;
if oVM is None:
return False;
if oVM is None:
return False;
# Windows VMs
if oVM is None:
return False;
oVM = self.createTestVM('tst-win2k3ent-64', 1, '3.0/tcp/win2k3ent-64.vdi', sKind = 'Windows2003_64', \
if oVM is None:
return False;
if oVM is None:
return False;
# Solaris VMs
if oVM is None:
return False;
if oVM is None:
return False;
return True;
"""
Execute the testcase.
"""
return fRc;
#
# Test execution helpers.
#
"""
Runs all the test programs against one 'server' machine.
"""
if not fRc:
break;
else:
('NetPerf', '--client', sAddr, '--interval', self.cSecsRun, '--len', cbPkt, '--mode', 'throughput'));
if not fRc:
break;
else:
else:
else:
## @todo tbench.
else:
return fRc;
"""
Runs the specified VM thru test #1.
Returns a success indicator on the general test execution. This is not
the actual test result.
"""
# Reconfigure the VM
if oSession is not None:
oSession = None;
else:
# Start up.
if oSession is not None:
# Fudge factor - Allow the guest to finish starting up.
# Benchmark #1 - guest <-> host.
# Benchmark #2 - guest <-> host.
# Benchmark #3 - guest <-> guest.
# cleanup.
else:
return fRc;
def test1OneVM(self, sVmName, asSkipNicTypes = (), asSupVirtModes = None, rSupCpus = range(1, 256)):
"""
Runs one VM thru the various configurations.
"""
if asSupVirtModes is None:
if sNicType in asSkipNicTypes:
continue;
if sNicType == 'E1000':
elif sNicType == 'PCNet':
elif sNicType == 'Virtio':
else:
eNicType = None;
continue;
continue;
if sVirtMode not in asSupVirtModes:
continue;
hsVirtModeDesc = {};
fRc = self.test1OneCfg(sVmName, eNicType, cCpus, fHwVirt, fNestedPaging) and fRc and True; # pychecker hack.
return fRc;
"""
Executes test #1.
"""
# Start the VM for the guest to guest testing, if required.
self.oGuestToGuestSess, self.oGuestToGuestTxs = self.startVmAndConnectToTxsViaTcp('tst-guest2guest', fCdWait = True);
if self.oGuestToGuestSess is None:
return False;
# Start the test servers on it.
# Loop thru the test VMs.
if fRc:
# figure args.
asSkipNicTypes = [];
asSupVirtModes = None;
# run test on the VM.
# Kill the guest to guest VM and clean up the state.
if self.oGuestToGuestSess is not None:
self.oGuestToGuestSess = None;
self.oGuestToGuestTxs = None;
return fRc;
if __name__ == '__main__':