def run(self, arglist=None): # Parse arguments vmsperhost = 10 minnumhostsstr = "all" # e.g. "1" for arg in arglist: l = string.split(arg, "=", 1) if l[0] == "vmsperhost": vmsperhost = int(l[1]) elif l[0] == "minnumhosts": minnumhostsstr = l[1] numhosts = len(self.normalHosts) if minnumhostsstr == "all": minnumhosts = numhosts else: minnumhosts = int(minnumhostsstr) # Repeat until you've just got the master while numhosts >= minnumhosts: xenrt.TEC().comment("Starting test run with numhosts=%d" % numhosts) # Create numhosts * 10 MPS VMs numvms = numhosts * vmsperhost xenrt.TEC().logverbose("vmsperhost=%s so numvms=%d" % (vmsperhost, numvms)) clones = self.createMPSVMs(numvms, self.goldvm) self.configureAllVMs() stem = "%d-perhost-%d-hosts" % (vmsperhost, numhosts) bootwatcherLogfile = libperf.createLogName("bootwatcher-%s" % stem) starterLogfile = libperf.createLogName("starter-%s" % stem) xenrt.TEC().comment( "bootwatcher logfile for %d hosts (running on %s), %d VMs per host: %s" % (numhosts, self.hostname, vmsperhost, bootwatcherLogfile)) xenrt.TEC().comment( "starter logfile for %d hosts (running on %s), %d VMs per host: %s" % (numhosts, self.hostname, vmsperhost, starterLogfile)) # Time starting them self.timeStartVMs(numhosts, clones, starterLogfile, bootwatcherLogfile) if numhosts > minnumhosts: # Destroy them self.destroyVMs(clones) # Disable a host self.disableASlave() xenrt.TEC().comment( "Number of hosts is now %d and minimum is %d" % (numhosts, minnumhosts)) numhosts = numhosts - 1
def run(self, arglist=None): # Parse arguments vmsperhost = 10 minnumhostsstr = "all" # e.g. "1" for arg in arglist: l = string.split(arg, "=", 1) if l[0] == "vmsperhost": vmsperhost = int(l[1]) elif l[0] == "minnumhosts": minnumhostsstr = l[1] numhosts = len(self.normalHosts) if minnumhostsstr == "all": minnumhosts = numhosts else: minnumhosts = int(minnumhostsstr) # Repeat until you've just got the master while numhosts >= minnumhosts: xenrt.TEC().comment("Starting test run with numhosts=%d" % numhosts) # Create numhosts * 10 MPS VMs numvms = numhosts * vmsperhost xenrt.TEC().logverbose("vmsperhost=%s so numvms=%d" % (vmsperhost, numvms)) clones = self.createMPSVMs(numvms, self.goldvm) self.configureAllVMs() stem = "%d-perhost-%d-hosts" % (vmsperhost, numhosts) bootwatcherLogfile = libperf.createLogName("bootwatcher-%s" % stem) starterLogfile = libperf.createLogName("starter-%s" % stem) xenrt.TEC().comment( "bootwatcher logfile for %d hosts (running on %s), %d VMs per host: %s" % (numhosts, self.hostname, vmsperhost, bootwatcherLogfile) ) xenrt.TEC().comment( "starter logfile for %d hosts (running on %s), %d VMs per host: %s" % (numhosts, self.hostname, vmsperhost, starterLogfile) ) # Time starting them self.timeStartVMs(numhosts, clones, starterLogfile, bootwatcherLogfile) if numhosts > minnumhosts: # Destroy them self.destroyVMs(clones) # Disable a host self.disableASlave() xenrt.TEC().comment("Number of hosts is now %d and minimum is %d" % (numhosts, minnumhosts)) numhosts = numhosts - 1
def run(self, arglist=None): # Set up log files bootwatcherLogfile = libperf.createLogName("bootwatcher") starterLogfile = libperf.createLogName("starter") xenrt.TEC().comment("bootwatcher logfile: %s" % bootwatcherLogfile) xenrt.TEC().comment("starter logfile: %s" % starterLogfile) self.sampleDom0State(0) for i in range(0, self.numvms): vm = self.clones[i] # Start the VM # TODO: BootWatcher will count already-booted VMs, not just those in the list of VMs to watch. self.timeStartVMs(1, [vm], starterLogfile, bootwatcherLogfile) # Sample dom0 state self.sampleDom0State(i+1)
def run(self, arglist=None): # Set up log files bootwatcherLogfile = libperf.createLogName("bootwatcher") starterLogfile = libperf.createLogName("starter") xenrt.TEC().comment("bootwatcher logfile: %s" % bootwatcherLogfile) xenrt.TEC().comment("starter logfile: %s" % starterLogfile) self.sampleDom0State(0) for i in range(0, self.numvms): vm = self.clones[i] # Start the VM # TODO: BootWatcher will count already-booted VMs, not just those in the list of VMs to watch. self.timeStartVMs(1, [vm], starterLogfile, bootwatcherLogfile) # Sample dom0 state self.sampleDom0State(i + 1)
def run(self, arglist=None): uuid = self.goldvm.getUUID() # Now repeatedly clone the VM clonerLogfile = libperf.createLogName("cloner") xenrt.TEC().comment("cloner logfile: %s" % clonerLogfile) t = libperf.Cloner(self, self.host, self.goldvm, self.numclones, clonerLogfile) t.start() t.join()
def run(self, arglist=None): # Start and boot the gold VM xenrt.TEC().logverbose("Booting the gold VM...") bootwatcherLogfile = libperf.createLogName("bootwatcher") starterLogfile = libperf.createLogName("starter") self.timeStartVMs(1, [self.goldvm], starterLogfile, bootwatcherLogfile) # Snapshot the gold VM xenrt.TEC().logverbose("Snapshotting the gold VM...") output = self.host.execdom0("time xe vm-snapshot uuid=%s new-name-label=snapshot" % self.goldvm.uuid) snaptime = libperf.parseTimeOutput(output) line = "%f" % snaptime self.log("vmsnapshot", line) # Install n VMs from the snapshot xenrt.TEC().logverbose("Installing from the snapshot...") output = self.host.execdom0("for ((i=0; i<=%d; i++)); do time xe vm-install new-name-label=vm$i template-name-label=snapshot; done" % self.numvms) xenrt.TEC().logverbose("output: %s" % output) self.outputTimings(output, "vminstall")
def run(self, arglist=None): # Create the clones, recording how long it takes to do so self.clones = self.createMPSVMs(self.numdesktops, self.goldvm) self.configureAllVMs() # Set up log files for REQ226 bootwatcherLogfile = libperf.createLogName("bootwatcher") starterLogfile = libperf.createLogName("starter") shutdownwatcherLogfile = libperf.createLogName("shutdownwatcher") xenrt.TEC().comment("bootwatcher logfile: %s" % bootwatcherLogfile) xenrt.TEC().comment("starter logfile: %s" % starterLogfile) xenrt.TEC().comment("shutdownwatcher logfile: %s" % shutdownwatcherLogfile) # Begin to collect stats from NetApp, for REQ246,248 self.startNetAppStatGather() # Start watching for shutdowns sdw = ShutdownWatcher(self, len(self.clones), shutdownwatcherLogfile) sdw.start() xenrt.TEC().logverbose("started shutdownwatcher") # Now start the VMs, for REQ226 numthreads = len(self.normalHosts) self.timeStartVMs( numthreads, self.clones, starterLogfile, bootwatcherLogfile, awaitParam=None) # awaitParam=None -> don't use a BootWatcher # Wait for all the VMs to shut down # TODO this is broken sdw.join() xenrt.TEC().logverbose("shutdownwatcher has completed") if sdw.error: raise xenrt.XRTError("shutdownwatcher completed with error") # Now gather the final stats from the NetApp, for REQ246,248 stats = self.finishNetAppStatGather() netappLogFile = libperf.createLogName("netapp") libperf.outputToResultsFile(netappLogFile, stats)
def run(self, arglist=None): # Create the clones, recording how long it takes to do so self.clones = self.createMPSVMs(self.numdesktops, self.goldvm) self.configureAllVMs() # Set up log files for REQ226 bootwatcherLogfile = libperf.createLogName("bootwatcher") starterLogfile = libperf.createLogName("starter") xenrt.TEC().comment("bootwatcher logfile: %s" % bootwatcherLogfile) xenrt.TEC().comment("starter logfile: %s" % starterLogfile) # Begin to collect stats from NetApp, for REQ246,248 self.startNetAppStatGather() # Now start the VMs, for REQ226 numthreads = len(self.normalHosts) self.timeStartVMs(numthreads, self.clones, starterLogfile, bootwatcherLogfile) # Now gather the final stats from the NetApp, for REQ246,248 stats = self.finishNetAppStatGather() netappLogFile = libperf.createLogName("netapp") libperf.outputToResultsFile(netappLogFile, stats)
def run(self, arglist=None): # Start and boot the gold VM xenrt.TEC().logverbose("Booting the gold VM...") bootwatcherLogfile = libperf.createLogName("bootwatcher") starterLogfile = libperf.createLogName("starter") self.timeStartVMs(1, [self.goldvm], starterLogfile, bootwatcherLogfile) # Snapshot the gold VM xenrt.TEC().logverbose("Snapshotting the gold VM...") output = self.host.execdom0( "time xe vm-snapshot uuid=%s new-name-label=snapshot" % self.goldvm.uuid) snaptime = libperf.parseTimeOutput(output) line = "%f" % snaptime self.log("vmsnapshot", line) # Install n VMs from the snapshot xenrt.TEC().logverbose("Installing from the snapshot...") output = self.host.execdom0( "for ((i=0; i<=%d; i++)); do time xe vm-install new-name-label=vm$i template-name-label=snapshot; done" % self.numvms) xenrt.TEC().logverbose("output: %s" % output) self.outputTimings(output, "vminstall")
def run(self, arglist=None): # Create the clones, recording how long it takes to do so self.clones = self.createMPSVMs(self.numdesktops, self.goldvm) self.configureAllVMs() # Set up log files for REQ226 bootwatcherLogfile = libperf.createLogName("bootwatcher") starterLogfile = libperf.createLogName("starter") shutdownwatcherLogfile = libperf.createLogName("shutdownwatcher") xenrt.TEC().comment("bootwatcher logfile: %s" % bootwatcherLogfile) xenrt.TEC().comment("starter logfile: %s" % starterLogfile) xenrt.TEC().comment("shutdownwatcher logfile: %s" % shutdownwatcherLogfile) # Begin to collect stats from NetApp, for REQ246,248 self.startNetAppStatGather() # Start watching for shutdowns sdw = ShutdownWatcher(self, len(self.clones), shutdownwatcherLogfile) sdw.start() xenrt.TEC().logverbose("started shutdownwatcher") # Now start the VMs, for REQ226 numthreads = len(self.normalHosts) self.timeStartVMs(numthreads, self.clones, starterLogfile, bootwatcherLogfile, awaitParam=None) # awaitParam=None -> don't use a BootWatcher # Wait for all the VMs to shut down # TODO this is broken sdw.join() xenrt.TEC().logverbose("shutdownwatcher has completed") if sdw.error: raise xenrt.XRTError("shutdownwatcher completed with error") # Now gather the final stats from the NetApp, for REQ246,248 stats = self.finishNetAppStatGather() netappLogFile = libperf.createLogName("netapp") libperf.outputToResultsFile(netappLogFile, stats)
def run(self, arglist=None): self.vm = self.prepareVM() # Create a logfile for the downtimes migrateLogfile = libperf.createLogName("downtime") xenrt.TEC().comment("downtime logfile: %s" % migrateLogfile) libperf.outputToResultsFile(migrateLogfile, "# iter pingable running total-duration") for i in range(0, self.numiters): xenrt.TEC().logverbose("migration iteration %d of %d" % (i, self.numiters)) timesStr = self.timeMigrate() line = "%d %s" % (i, timesStr) libperf.outputToResultsFile(migrateLogfile, line)
def run(self, arglist=None): self.xenhost = self.host.getIP() xenrt.TEC().logverbose("hostname is [%s]" % self.xenhost) # Restart the 'Citrix Pool Management service' on the DDC. This clears out any previous state about which hosts were in which pools. if self.useXenDesktop: self.restartPoolManagementService(self.ddc) # Clean up if self.startwithcleanslate: xenrt.TEC().logverbose("Deleting all existing desktop groups") self.deleteAllDesktopGroups() rundirpath = None # Register the VMs in a new desktop group with the DDC groupname = "xenrt%s" % self.randomid try: if self.useXenDesktop: xenrt.TEC().logverbose("Registering VMs with DDC in desktop group %s" % groupname) self.registerVMsWithDDC(groupname, self.clones) hostobjs = [self.tec.gec.registry.hostGet(h) for h in self.normalHosts] # Use the master for the host for the launchers launcherhostobj = hostobjs.pop(0) xenrt.TEC().logverbose("Nominated host %s as the launcher host" % launcherhostobj.getName()) numthreads = self.numhostsfordesktops # Select the relevant number of hosts for desktops hostobjsfordesktops = hostobjs[0:self.numhostsfordesktops] hostnamesfordesktops = [h.getName() for h in hostobjsfordesktops] xenrt.TEC().logverbose("Names of hosts for desktop VMs are %s" % hostnamesfordesktops) # Now spin up the VMs xenrt.TEC().logverbose("Starting VMs") bootwatcherLogfile = libperf.createLogName("bootwatcher") starterLogfile = libperf.createLogName("starter") self.timeStartVMs(numthreads, self.clones, starterLogfile, bootwatcherLogfile, queueHosts=hostnamesfordesktops, awaitParam="PV_drivers_version", awaitKey="major") # Now make some launcher VMs numlaunchers = int(math.ceil(self.numdesktops / self.vmsperlauncher)) xenrt.TEC().logverbose("VMs per launcher is %d; number of desktops is %d; hence using %d launcher VMs" % (self.vmsperlauncher, self.numdesktops, numlaunchers)) launchers = [] for i in range(0, numlaunchers): launchername = "mylauncher%d" % i xenrt.TEC().logverbose("Making launcher VM %d on host %s..." % (i, launcherhostobj.getName())) # TODO could import the first and then clone the rest? launchervmobj = self.makeLauncherVM(launchername, useICA=self.useXenDesktop, host=launcherhostobj) launchers.append(launchervmobj) # Create a 'run' directory. The returned path is valid on self.guest. rundirpath = self.createFreshResultsDir() # Now tell the launcher to start ICA sessions to the VMs. # The VMs then log in and LoginVSI kicks in. # (We assume that by this stage the VMs' VDAs have registered with the DDC.) refbasedir = self.mountRefBase(self.guest.execguest) # Begin to collect stats from NetApp, for REQ247,249 self.startNetAppStatGather() for i in range(0, self.numdesktops): launcherindex = i % numlaunchers if self.useXenDesktop: user = "******" % (i+1) xenrt.TEC().logverbose("Logging in to desktop group %s with user %s on launcher %d" % (groupname, user, launcherindex)) self.logInToVMsWfica(refbasedir, launchers[launcherindex], groupname, user, "xenroot!!1!") else: # Get the IP address of the ith desktop VM xenrt.TEC().logverbose("Finding IP of %dth desktop VM..." % i) # We need to know the host that the ith desktop VM is running on # TODO Temporary hack: assume it's the second host in self.normalHosts! h = self.normalHosts[1] xenrt.TEC().logverbose("host is [%s]" % h) vmuuid = self.clones[i].getUUID() ip = self.getVMIP(h, vmuuid) xenrt.TEC().logverbose("IP of %dth VM is %s" % (i, ip)) xenrt.TEC().logverbose("Logging in to %dth VM with on launcher %d" % (i, launcherindex)) self.logInToVMsRdesktop(refbasedir, launchers[launcherindex], ip, "Administrator", xenrt.TEC().lookup(["WINDOWS_INSTALL_ISOS", "ADMINISTRATOR_PASSWORD"])) xenrt.TEC().logverbose("Started all %d sessions!" % self.numdesktops) # Wait for the sessions to complete latestTime = time.time() + 50*60 # allow 50 mins for all sessions to complete for i in range(1, self.numdesktops+1): xenrt.TEC().logverbose("Waiting for the %dth session of %d to complete..." % (i, self.numdesktops)) self.waitForResultsToAppear(rundirpath, i, self.numreadings, latestTime) xenrt.TEC().logverbose("All %d sessions have completed (or timed out)!" % self.numdesktops) # Now gather the final stats from the NetApp, for REQ247,249 stats = self.finishNetAppStatGather() netappLogFile = libperf.createLogName("netapp") libperf.outputToResultsFile(netappLogFile, stats) xenrt.TEC().logverbose("All good.") finally: xenrt.TEC().logverbose("FINALLY") if not rundirpath is None: # Get the results. xenrt.TEC().logverbose("Copying logs from %s..." % rundirpath) self.copyRunDirToLogs(rundirpath) if self.useXenDesktop: # Clean up if self.cleanup: xenrt.TEC().logverbose("Deleting desktop group %s" % groupname) self.deleteDesktopGroup(groupname)
def log(self, filename, msg): """Logs to a file and console""" xenrt.TEC().logverbose(msg) if filename is not None: libperf.outputToResultsFile(libperf.createLogName(filename), msg)