Ejemplo n.º 1
0
    def run(self, arglist=None):
        sdkzip = xenrt.TEC().getFile("xe-phase-2/sdk.zip", "sdk.zip")
        if not sdkzip:
            raise xenrt.XRTError("Couldn't find xe-phase-2/sdk.zip")
        nfs = xenrt.NFSDirectory()
        xenrt.command("unzip %s -d %s" % (sdkzip, nfs.path()))
        
        self.guest = self.host.guestFactory()(\
                        xenrt.randomGuestName(),
                        host=self.host,
                        password=xenrt.TEC().lookup("ROOT_PASSWORD_SDK"))
        self.guest.importVM(self.host, "%s/sdk" % (nfs.path()))
        self.guest.paramSet("is-a-template", "true")
        nfs.remove()

        nfs = xenrt.NFSDirectory()
        xenrt.getTestTarball("apiperf", extract=True, directory=nfs.path())
        self.host.createISOSR(nfs.getMountURL("apiperf"))
        self.sr = self.host.parseListForUUID("sr-list",
                                             "name-label",
                                             "Remote ISO Library on: %s" %
                                             (nfs.getMountURL("apiperf")))
        for s in self.host.getSRs(type="iso", local=True):
            self.host.getCLIInstance().execute("sr-scan", "uuid=%s" %(s))
        time.sleep(30)
    
        self.runSubcase("test", "pool0", "Pool", "Pool0")
        self.runSubcase("test", "pool1", "Pool", "Pool1")
        self.runSubcase("test", "xendesktop", "XenDesktop", "XenDesktop")
Ejemplo n.º 2
0
    def run(self, arglist=None):
        sdkzip = xenrt.TEC().getFile("xe-phase-2/sdk.zip", "sdk.zip")
        if not sdkzip:
            raise xenrt.XRTError("Couldn't find xe-phase-2/sdk.zip")
        nfs = xenrt.NFSDirectory()
        xenrt.command("unzip %s -d %s" % (sdkzip, nfs.path()))

        self.guest = self.host.guestFactory()(\
                        xenrt.randomGuestName(),
                        host=self.host,
                        password=xenrt.TEC().lookup("ROOT_PASSWORD_SDK"))
        self.guest.importVM(self.host, "%s/sdk" % (nfs.path()))
        self.guest.paramSet("is-a-template", "true")
        nfs.remove()

        nfs = xenrt.NFSDirectory()
        xenrt.getTestTarball("apiperf", extract=True, directory=nfs.path())
        self.host.createISOSR(nfs.getMountURL("apiperf"))
        self.sr = self.host.parseListForUUID(
            "sr-list", "name-label",
            "Remote ISO Library on: %s" % (nfs.getMountURL("apiperf")))
        for s in self.host.getSRs(type="iso", local=True):
            self.host.getCLIInstance().execute("sr-scan", "uuid=%s" % (s))
        time.sleep(30)

        self.runSubcase("test", "pool0", "Pool", "Pool0")
        self.runSubcase("test", "pool1", "Pool", "Pool1")
        self.runSubcase("test", "xendesktop", "XenDesktop", "XenDesktop")
Ejemplo n.º 3
0
    def installNettestOnGuest(self, guest):
        if guest.xmlrpcFileExists("c:\\netsend.exe"):
            # Assume we've already installed
            return
        d = xenrt.TEC().tempDir()
        xenrt.getTestTarball("nettest",
                             extract=True,
                             copy=False,
                             directory=d)
        path = "nettest"

        for fn in ["netecho.exe", "netsend.exe"]:
            exe = "%s/%s/%s" % (d, path, fn)
            guest.xmlrpcSendFile(exe,
                                 "c:\\%s" % (os.path.basename(exe)),
                                 usehttp=True)
        try:
            guest.xmlrpcExec("netsh firewall set opmode " + \
                             "DISABLE")
        except:
            pass
Ejemplo n.º 4
0
    def installWindows(self, version, build, arch):
        self.windows = True

        if not os.path.exists(
                "%s/%s/%s/autoinstall-%s.zip" %
            (xenrt.TEC().lookup("IMAGES_ROOT"), version, build, arch)):
            if not os.path.exists(
                    "%s/%s/%s/autoinstall-%s.tar" %
                (xenrt.TEC().lookup("IMAGES_ROOT"), version, build, arch)):
                raise xenrt.XRTError("No install files found for %s build %s" %
                                     (version, build))

        if version == "longhorn" or version[0:7] == "vistaee":
            method = "longhorn"
        else:
            method = "normal"
        self.distro = version

        xenrt.TEC().progress("Preparing TFTP...")
        tftp = "%s/xenrt/native" % (xenrt.TEC().lookup("TFTP_BASE"))
        if not os.path.exists(tftp):
            xenrt.sudo("mkdir -p %s" % (tftp))
        xenrt.getTestTarball("native", extract=True)
        xenrt.sudo("rsync -avxl %s/winpe32.wim %s/winpe.wim" %
                   (xenrt.TEC().lookup("IMAGES_ROOT"), tftp))

        # Get a PXE directory to put boot files in.
        xenrt.TEC().progress("Preparing PXE...")
        serport = xenrt.TEC().lookup("SERIAL_CONSOLE_PORT", "0")
        serbaud = xenrt.TEC().lookup("SERIAL_CONSOLE_BAUD", "115200")
        pxe = xenrt.PXEBoot()
        pxe.copyIn("%s/native/pxe/pxeboot.0" % (xenrt.TEC().getWorkdir()))
        xenrt.sudo("rsync -avxl %s/native/pxe/32/BCD %s/BCD" %
                   (xenrt.TEC().getWorkdir(), tftp))
        xenrt.sudo("rsync -avxl %s/native/pxe/boot.sdi %s/boot.sdi" %
                   (xenrt.TEC().getWorkdir(), tftp))
        xenrt.sudo("rsync -avxl %s/native/pxe/bootmgr.exe %s/bootmgr.exe" %
                   (xenrt.TEC().getWorkdir(), tftp))

        # Set the boot files and options for PXE
        pxe.setSerial(serport, serbaud)
        pxe.addEntry("local", boot="local")
        pxecfg = pxe.addEntry("winpe", default=1, boot="linux")
        pxecfg.linuxSetKernel("pxeboot.0")

        xenrt.TEC().progress("Preparing web directory")
        w = xenrt.WebDirectory()

        f = file("%s/native/pe/perun.cmd" % (xenrt.TEC().getWorkdir()), "r")
        perun = f.read()
        f.close()

        if method == "longhorn":
            t = xenrt.TempDirectory()

            xenrt.command("tar xf %s/%s/%s/autoinstall-%s.tar -C %s" %
                          (xenrt.TEC().lookup("IMAGES_ROOT"), version, build,
                           arch, t.path()))

            w.copyIn("%s/install/unattend.xml" % (t.path()))
            perun += "wget %FILES%/unattend.xml\n"

            # Count the number of install.wim fragments.
            catcmd = "cat "
            partpath = "%s/install/install.part" % (t.path())
            numparts = len(glob.glob("%s*" % (partpath)))
            for i in range(1, numparts + 1):
                # Download install.wim fragment.
                perun += "wget %%FILES%%/%s%d\n" % (os.path.basename(partpath),
                                                    i)
                # Make sure fragments get recombined.
                catcmd += "%s%d " % (os.path.basename(partpath), i)
                # Make fragment available over the network.
                w.copyIn("%s%d" % (partpath, i))
            catcmd += "> c:\\win\\sources\\install.wim\n"
            perun += catcmd
            w.copyIn("%s/install/install.zip" % (t.path()), target="win.zip")

            t.remove()

            # 32-bit installs just require the one stage.
            if arch == "x86-32":
                perun += "c:\\win\\sources\\setup.exe /unattend:c:\\unattend.xml"
        else:
            t = xenrt.TempDirectory()

            xenrt.command(
                "unzip %s/%s/%s/autoinstall-%s.zip unattend.txt -d %s" %
                (xenrt.TEC().lookup("IMAGES_ROOT"), version, build, arch,
                 t.path()))
            try:
                xenrt.command(
                    "unzip %s/%s/%s/autoinstall-%s.zip runonce.cmd -d %s" %
                    (xenrt.TEC().lookup("IMAGES_ROOT"), version, build, arch,
                     t.path()))
            except:
                try:
                    xenrt.command(
                        "unzip %s/%s/%s/autoinstall-%s.zip win/i386/runonce.cmd -d %s"
                        % (xenrt.TEC().lookup("IMAGES_ROOT"), version, build,
                           arch, t.path()))
                except:
                    xenrt.command(
                        "unzip %s/%s/%s/autoinstall-%s.zip win/I386/runonce.cmd -d %s"
                        % (xenrt.TEC().lookup("IMAGES_ROOT"), version, build,
                           arch, t.path()))
                xenrt.command("mv %s/win/?386/runonce.cmd %s/runonce.cmd" %
                              (t.path(), t.path()))
            xenrt.command("chmod a+rwx %s/runonce.cmd" % (t.path()))

            perun += """
wget %FILES%/runonce.cmd
wget %FILES%/unattend.txt
bootsect /nt52 c: /force
c:\win\i386\winnt32.exe /makelocalsource /syspart:c: /s:c:\win\i386 /unattend:c:\unattend.txt /cmd:c:\runonce.cmd
wpeutil reboot
"""
            f = file("%s/runonce.cmd" % (t.path()), "r")
            data = f.read()
            f.close()
            # HACK to support Broadcom NICs on those machines that have them.
            if xenrt.TEC().lookup("BROADCOM_POSTINSTALL", False, boolean=True):
                data = string.replace(data, "EXIT", "")
                data = data + 'REG ADD %KEY%\\050 /VE /D "Broadcom Driver" /f\n'
                data = data + 'REG ADD %KEY%\\050 /V 1 /D ' \
                       '"%systemdrive%\\win\\post\\Broadcom\\setup.exe ' \
                       '/s /v/qn" /f\n'
                data = data + "EXIT\n"

            xenrt.TEC().copyToLogDir("%s/runonce.cmd" % (t.path()))
            f = file("%s/runonce.cmd" % (t.path()), "w")
            f.write(data)
            f.close()
            w.copyIn("%s/unattend.txt" % (t.path()))
            w.copyIn("%s/runonce.cmd" % (t.path()))
            w.copyIn("%s/%s/%s/autoinstall-%s.zip" %
                     (xenrt.TEC().lookup("IMAGES_ROOT"), version, build, arch),
                     target="win.zip")
            t.remove()

        # Copy common files.
        w.copyIn("%s/native/pe/makepart.txt" % (xenrt.TEC().getWorkdir()))

        perun_dir = os.path.dirname(xenrt.TEC().lookup("WINPE_START_FILE"))
        if not os.path.exists(perun_dir):
            xenrt.sudo("mkdir -p %s" % (perun_dir))
        # Replace variables in perun.cmd.
        perun = string.replace(perun, "%FILES%", "%s" % (w.getURL("/")))
        f = file("%s/perun.cmd" % (xenrt.TEC().getWorkdir()), "w")
        f.write(perun)
        f.close()
        xenrt.TEC().copyToLogDir("%s/perun.cmd" % (xenrt.TEC().getWorkdir()))
        # Put perun.cmd where WinPE expects it.
        lock = xenrt.resources.CentralResource()
        for i in range(10):
            try:
                lock.acquire("WINPE_START_FILE")
                break
            except:
                if i == 9:
                    raise xenrt.XRTError("Couldn't get lock on WINPE "
                                         "bootstrap file.")
                xenrt.sleep(60)
        xenrt.sudo(
            "cp %s/perun.cmd %s" %
            (xenrt.TEC().getWorkdir(), xenrt.TEC().lookup("WINPE_START_FILE")))

        # Start install.
        xenrt.TEC().progress("Starting installation")
        pxefile = pxe.writeOut(self.machine)
        pfname = os.path.basename(pxefile)
        xenrt.TEC().copyToLogDir(pxefile, target="%s.pxe.txt" % (pfname))
        self.machine.powerctl.cycle()
        xenrt.TEC().progress("Rebooted host to start installation.")

        xenrt.sleep(120)

        lock.release()

        # 64-bit requires a two-stage installation.
        if arch == "x86-64":
            # Wait for first stage to complete.
            xenrt.sleep(360)
            xenrt.TEC().progress("Preparing TFTP for second stage.")
            xenrt.sudo("rsync -avxl %s/native/pxe/64/ %s/" %
                       (xenrt.TEC().getWorkdir(), tftp))
            xenrt.sudo("rsync -avxl %s/winpe64.wim %s/winpe.wim" %
                       (xenrt.TEC().lookup("IMAGES_ROOT"), tftp))
            self.machine.powerctl.cycle()
            xenrt.TEC().progress(
                "Rebooted host into second installation stage.")

        # Wait for PXE boot.
        xenrt.sleep(120)
        pxe.setDefault("local")
        pxe.writeOut(self.machine)

        # Wait for Windows to boot.
        xenrt.TEC().progress("Waiting for host to boot")
        self.waitforxmlrpc(7200)

        w.remove()

        if method == "longhorn":
            self.winRegAdd(
                "HKLM", "SYSTEM\\CurrentControlSet\\Control\\Terminal Server",
                "fDenyTSConnections", "DWORD", 0)
            self.winRegAdd("HKLM", "SYSTEM\\CurrentControlSet\\Control\\Lsa",
                           "LMCompatibilityLevel", "DWORD", 1)

        if not method == "longhorn":
            bootini = self.xmlrpcReadFile("c:\\boot.ini").strip()
            if self.memory:
                bootini += " /MAXMEM=%d" % (self.memory)
            if self.vcpus:
                bootini += " /NUMPROC=%d" % (self.vcpus)
            self.xmlrpcRemoveFile("c:\\boot.ini")
            self.xmlrpcCreateFile("c:\\boot.ini", xmlrpclib.Binary(bootini))
            self.xmlrpcReboot()
            xenrt.sleep(180)
            self.waitforxmlrpc(300)

            self.tailor()
Ejemplo n.º 5
0
    def run(self, arglist=None):

        machine = "RESOURCE_HOST_0"
        if arglist and len(arglist) > 0:
            machine = arglist[0]

        host = xenrt.TEC().registry.hostGet(machine)
        if not host:
            raise xenrt.XRTError("Unable to find host %s in registry" %
                                 (machine))
        self.getLogsFrom(host)

        # Get the test scripts
        testtar = xenrt.TEC().lookup("XENOPS_REGRESSION_TESTS", None)
        if not testtar:
            # Try the same directory as the ISO
            testtar = xenrt.TEC().getFile("xenops-regress.tar.gz",
                                          "xe-phase-1/xenops-regress.tar.gz")
        if not testtar:
            raise xenrt.XRTError("No CLI regression test tarball given")
        xenrt.command("tar -zxf %s -C %s" % (testtar, self.tec.getWorkdir()))
        if os.path.exists("%s/runtest" % (self.tec.getWorkdir())):
            testbin = "runtest"
        else:
            raise xenrt.XRTError("runtest not found in test tarball")

        # Copy test files to the host
        ramdisk = "initrd-1.1-i386.img"
        xenrt.getTestTarball("xm", extract=True)
        sftp = host.sftpClient()
        rdir = host.hostTempDir()
        sftp.copyTreeTo(self.tec.getWorkdir(), rdir)

        # Get dom0 kernel filename
        kver = string.strip(host.execdom0("uname -r"))
        kfile = "/boot/vmlinuz-%s" % (kver)
        if host.execdom0("ls %s" % (kfile), retval="code") != 0:
            raise xenrt.XRTError("Kernel not where expected (%s)" % (kfile))

        # Build a command line to run the regression test on dom0
        cmd = []
        cmd.append("%s/%s" % (rdir, testbin))
        cmd.append(kfile)
        cmd.append("%s/xm/%s" % (rdir, ramdisk))
        cmd.append("%s/log.txt" % (rdir))

        # Run the test
        self.hostToClean = host
        passed = True
        try:
            commands = []
            commands.append("cd %s" % (rdir))
            commands.append("PATH=.:${PATH} %s > output.txt 2> stderr.log" %
                            (string.join(cmd)))
            self.runAsync(host, commands, timeout=3600)
        except:
            traceback.print_exc(file=sys.stderr)
            self.tec.reason("Test exited with error or timed out")
            passed = False
        for f in ('log.txt', 'output.txt', 'stderr.log'):
            try:
                sftp.copyFrom("%s/%s" % (rdir, f),
                              "%s/%s" % (self.tec.getLogdir(), f))
            except:
                pass

        # Check for failures
        resfile = "%s/output.txt" % (self.tec.getLogdir())
        if os.path.exists(resfile):
            f = file(resfile, "r")
            while True:
                line = f.readline()
                if not line:
                    break
                r = re.search(
                    r"^test\s+\d+\[\s*(\d+)\]\s+\(\s*(.+)\):"
                    "\s+([A-Z]+)", line)
                if r:
                    tc = r.group(1)
                    group = string.replace(r.group(2), " ", "_")
                    outcome = r.group(3)
                    if self.outcomes.has_key(outcome):
                        self.testcaseResult(group, tc, self.outcomes[outcome])
                        if self.outcomes[outcome] == xenrt.RESULT_FAIL or \
                               self.outcomes[outcome] == xenrt.RESULT_ERROR:
                            passed = False
                    else:
                        self.tec.warning("Unknown outcome '%s'" % (outcome))
            f.close()
        else:
            passed = False
            self.tec.reason("No output file found")

        if not passed:
            raise xenrt.XRTFailure()
Ejemplo n.º 6
0
    def runViaDaemon(self, remote, arglist):

        # Extract onewin.exe and copy to the VM
        d = xenrt.TEC().tempDir()
        xenrt.getTestTarball("videowin", extract=True, copy=False, directory=d)
        xenrt.command("unzip %s/videowin/videowin.zip VideoWin/OneWin.exe "
                      "-d %s" % (d, d))
        workdir = remote.xmlrpcTempDir()
        remote.xmlrpcSendFile("%s/VideoWin/OneWin.exe" % (d),
                              "%s\\OneWin.exe" % (workdir))

        results = {}
        for iteration in range(9):
            xenrt.TEC().logdelimit("Iteration %u" % (iteration))

            # Run the test on the current video mode
            try:
                remote.xmlrpcRemoveFile("%s\\VideoLog.txt" % (workdir))
            except:
                pass
            try:
                remote.xmlrpcExec("cd %s\n%s\\OneWin.exe RUN" %
                                  (workdir, workdir),
                                  timeout=600)
            except xenrt.XRTFailure, e:
                # Returns non-zero for some reason
                xenrt.TEC().logverbose("OneWin.exe returned non-zero: %s" %
                                       (str(e)))

            # Process results.
            data = str(remote.xmlrpcReadFile("%s\\VideoLog.txt" % (workdir)))
            f = file("%s/VideoLog-%u.txt" %
                     (xenrt.TEC().getLogdir(), iteration), "w")
            f.write(data)
            f.close()

            # Find the header line
            lines = data.splitlines()
            headerindex = None
            headers = []
            for i in range(len(lines)):
                line = lines[i].strip()
                ll = line.split()
                if len(ll) > 0 and ll[0] == "Resolution":
                    headerindex = i
                    headers = ll[1:]
                    break
            if headerindex == None:
                raise xenrt.XRTError("Could not find result header line")

            # Walk through all lines after the header line looking for results
            for i in range(headerindex + 1, len(lines)):
                line = lines[i].strip()
                ll = line.split()
                if len(ll) == len(headers) + 3:
                    resolution = "%sx%sB%s" % (ll[0], ll[1], ll[2])
                    for j in range(len(headers)):
                        h = "%s_%s" % (resolution, headers[j])
                        v = float(ll[j+3])
                        if not results.has_key(h):
                            results[h] = []
                        results[h].append(v)
Ejemplo n.º 7
0
    def installWindows(self, version, build, arch):
        self.windows = True

        if not os.path.exists("%s/%s/%s/autoinstall-%s.zip" % 
            (xenrt.TEC().lookup("IMAGES_ROOT"), version, build, arch)):
            if not os.path.exists("%s/%s/%s/autoinstall-%s.tar" %
                (xenrt.TEC().lookup("IMAGES_ROOT"), version, build, arch)):
                raise xenrt.XRTError("No install files found for %s build %s" % (version, build)) 
 
        if version == "longhorn" or version[0:7] == "vistaee":
            method = "longhorn"
        else:
            method = "normal"
        self.distro = version
        
        xenrt.TEC().progress("Preparing TFTP...")
        tftp = "%s/xenrt/native" % (xenrt.TEC().lookup("TFTP_BASE"))
        if not os.path.exists(tftp):
            xenrt.sudo("mkdir -p %s" % (tftp))
        xenrt.getTestTarball("native", extract=True)
        xenrt.sudo("rsync -avxl %s/winpe32.wim %s/winpe.wim" %
                   (xenrt.TEC().lookup("IMAGES_ROOT"), tftp))

        # Get a PXE directory to put boot files in.
        xenrt.TEC().progress("Preparing PXE...")
        serport = xenrt.TEC().lookup("SERIAL_CONSOLE_PORT", "0")
        serbaud = xenrt.TEC().lookup("SERIAL_CONSOLE_BAUD", "115200")
        pxe = xenrt.PXEBoot()
        pxe.copyIn("%s/native/pxe/pxeboot.0" % (xenrt.TEC().getWorkdir()))
        xenrt.sudo("rsync -avxl %s/native/pxe/32/BCD %s/BCD" % 
                      (xenrt.TEC().getWorkdir(), tftp))
        xenrt.sudo("rsync -avxl %s/native/pxe/boot.sdi %s/boot.sdi" %
                      (xenrt.TEC().getWorkdir(), tftp))
        xenrt.sudo("rsync -avxl %s/native/pxe/bootmgr.exe %s/bootmgr.exe" %
                      (xenrt.TEC().getWorkdir(), tftp))
        
        # Set the boot files and options for PXE
        pxe.setSerial(serport, serbaud)
        pxe.addEntry("local", boot="local")
        pxecfg = pxe.addEntry("winpe", default=1, boot="linux")
        pxecfg.linuxSetKernel("pxeboot.0")

        xenrt.TEC().progress("Preparing web directory")
        w = xenrt.WebDirectory()

        f = file("%s/native/pe/perun.cmd" % (xenrt.TEC().getWorkdir()), "r")
        perun = f.read()
        f.close()    

        if method == "longhorn":
            t = xenrt.TempDirectory()
            
            xenrt.command("tar xf %s/%s/%s/autoinstall-%s.tar -C %s" %
                         (xenrt.TEC().lookup("IMAGES_ROOT"), version, build, arch, t.path()))    
            
            w.copyIn("%s/install/unattend.xml" %
                    (t.path()))
            perun += "wget %FILES%/unattend.xml\n"

            # Count the number of install.wim fragments.
            catcmd = "cat "
            partpath = "%s/install/install.part" % (t.path())
            numparts = len(glob.glob("%s*" % (partpath)))  
            for i in range(1, numparts + 1):
                # Download install.wim fragment.
                perun += "wget %%FILES%%/%s%d\n" % (os.path.basename(partpath), i) 
                # Make sure fragments get recombined.
                catcmd += "%s%d " % (os.path.basename(partpath), i)
                # Make fragment available over the network.
                w.copyIn("%s%d" % (partpath, i))
            catcmd += "> c:\\win\\sources\\install.wim\n"
            perun += catcmd
            w.copyIn("%s/install/install.zip" % (t.path()), target="win.zip")

            t.remove()

            # 32-bit installs just require the one stage.
            if arch == "x86-32":
                perun += "c:\\win\\sources\\setup.exe /unattend:c:\\unattend.xml"
        else:
            t = xenrt.TempDirectory()
            
            xenrt.command("unzip %s/%s/%s/autoinstall-%s.zip unattend.txt -d %s" %
                         (xenrt.TEC().lookup("IMAGES_ROOT"), version, build, arch, t.path()))
            try:
                xenrt.command("unzip %s/%s/%s/autoinstall-%s.zip runonce.cmd -d %s" %
                             (xenrt.TEC().lookup("IMAGES_ROOT"), version, build, arch, t.path()))
            except:
                try:
                    xenrt.command("unzip %s/%s/%s/autoinstall-%s.zip win/i386/runonce.cmd -d %s" %
                                 (xenrt.TEC().lookup("IMAGES_ROOT"), version, build, arch, t.path()))
                except:
                    xenrt.command("unzip %s/%s/%s/autoinstall-%s.zip win/I386/runonce.cmd -d %s" %
                                 (xenrt.TEC().lookup("IMAGES_ROOT"), version, build, arch, t.path()))
                xenrt.command("mv %s/win/?386/runonce.cmd %s/runonce.cmd" %
                              (t.path(), t.path()))
            xenrt.command("chmod a+rwx %s/runonce.cmd" % (t.path())) 

            perun += """
wget %FILES%/runonce.cmd
wget %FILES%/unattend.txt
bootsect /nt52 c: /force
c:\win\i386\winnt32.exe /makelocalsource /syspart:c: /s:c:\win\i386 /unattend:c:\unattend.txt /cmd:c:\runonce.cmd
wpeutil reboot
"""
            f = file("%s/runonce.cmd" % (t.path()), "r")
            data = f.read()
            f.close()
            # HACK to support Broadcom NICs on those machines that have them. 
            if xenrt.TEC().lookup("BROADCOM_POSTINSTALL", False, boolean=True):
                data = string.replace(data, "EXIT", "")
                data = data + 'REG ADD %KEY%\\050 /VE /D "Broadcom Driver" /f\n'
                data = data + 'REG ADD %KEY%\\050 /V 1 /D ' \
                       '"%systemdrive%\\win\\post\\Broadcom\\setup.exe ' \
                       '/s /v/qn" /f\n'
                data = data + "EXIT\n"
 
            xenrt.TEC().copyToLogDir("%s/runonce.cmd" % (t.path()))
            f = file("%s/runonce.cmd" % (t.path()), "w")
            f.write(data)
            f.close()
            w.copyIn("%s/unattend.txt" % (t.path()))
            w.copyIn("%s/runonce.cmd" % (t.path()))
            w.copyIn("%s/%s/%s/autoinstall-%s.zip" % 
                    (xenrt.TEC().lookup("IMAGES_ROOT"), version, build, arch), target="win.zip")
            t.remove()
    
        # Copy common files.
        w.copyIn("%s/native/pe/makepart.txt" % (xenrt.TEC().getWorkdir()))
 
        perun_dir = os.path.dirname(xenrt.TEC().lookup("WINPE_START_FILE"))
        if not os.path.exists(perun_dir):
            xenrt.sudo("mkdir -p %s" % (perun_dir))
        # Replace variables in perun.cmd.
        perun = string.replace(perun, "%FILES%", "%s" % (w.getURL("/")))        
        f = file("%s/perun.cmd" % (xenrt.TEC().getWorkdir()), "w")
        f.write(perun)
        f.close()
        xenrt.TEC().copyToLogDir("%s/perun.cmd" %
                                (xenrt.TEC().getWorkdir()))
        # Put perun.cmd where WinPE expects it.
        lock = xenrt.resources.CentralResource()
        for i in range(10):
            try:
                lock.acquire("WINPE_START_FILE")
                break
            except:
                if i == 9:
                    raise xenrt.XRTError("Couldn't get lock on WINPE "
                                         "bootstrap file.")
                xenrt.sleep(60)
        xenrt.sudo("cp %s/perun.cmd %s" %
                   (xenrt.TEC().getWorkdir(),
                    xenrt.TEC().lookup("WINPE_START_FILE")))

        # Start install.
        xenrt.TEC().progress("Starting installation")
        pxefile = pxe.writeOut(self.machine)
        pfname = os.path.basename(pxefile)
        xenrt.TEC().copyToLogDir(pxefile,target="%s.pxe.txt" % (pfname))
        self.machine.powerctl.cycle()
        xenrt.TEC().progress("Rebooted host to start installation.")

        xenrt.sleep(120)

        lock.release()

        # 64-bit requires a two-stage installation. 
        if arch == "x86-64":
            # Wait for first stage to complete.
            xenrt.sleep(360)
            xenrt.TEC().progress("Preparing TFTP for second stage.")
            xenrt.sudo("rsync -avxl %s/native/pxe/64/ %s/" %
                    (xenrt.TEC().getWorkdir(), tftp))
            xenrt.sudo("rsync -avxl %s/winpe64.wim %s/winpe.wim" %
                    (xenrt.TEC().lookup("IMAGES_ROOT"), tftp))
            self.machine.powerctl.cycle()
            xenrt.TEC().progress("Rebooted host into second installation stage.") 

        # Wait for PXE boot.
        xenrt.sleep(120)
        pxe.setDefault("local")
        pxe.writeOut(self.machine)

        # Wait for Windows to boot.
        xenrt.TEC().progress("Waiting for host to boot")
        self.waitforxmlrpc(7200)

        w.remove()

        if method == "longhorn":
            self.winRegAdd("HKLM", "SYSTEM\\CurrentControlSet\\Control\\Terminal Server", "fDenyTSConnections", "DWORD", 0)
            self.winRegAdd("HKLM", "SYSTEM\\CurrentControlSet\\Control\\Lsa", "LMCompatibilityLevel", "DWORD", 1)

        if not method == "longhorn":
            bootini = self.xmlrpcReadFile("c:\\boot.ini").strip() 
            if self.memory:
                bootini += " /MAXMEM=%d" % (self.memory)
            if self.vcpus:
                bootini += " /NUMPROC=%d" % (self.vcpus)
            self.xmlrpcRemoveFile("c:\\boot.ini") 
            self.xmlrpcCreateFile("c:\\boot.ini", xmlrpclib.Binary(bootini))
            self.xmlrpcReboot()
            xenrt.sleep(180)
            self.waitforxmlrpc(300)

            self.tailor()
Ejemplo n.º 8
0
    def run(self, arglist=None):

        machine = "RESOURCE_HOST_0"
        if arglist and len(arglist) > 0:
            machine = arglist[0]

        host = xenrt.TEC().registry.hostGet(machine)
        if not host:
            raise xenrt.XRTError("Unable to find host %s in registry" %
                                 (machine))
        self.getLogsFrom(host)

        # Get the test scripts
        testtar = xenrt.TEC().lookup("XENOPS_REGRESSION_TESTS", None)
        if not testtar:
            # Try the same directory as the ISO
            testtar = xenrt.TEC().getFile("xenops-regress.tar.gz", 
                                          "xe-phase-1/xenops-regress.tar.gz")
        if not testtar:
            raise xenrt.XRTError("No CLI regression test tarball given")
        xenrt.command("tar -zxf %s -C %s" % (testtar, self.tec.getWorkdir()))
        if os.path.exists("%s/runtest" % (self.tec.getWorkdir())):
            testbin = "runtest"
        else:
            raise xenrt.XRTError("runtest not found in test tarball")

        # Copy test files to the host
        ramdisk = "initrd-1.1-i386.img"
        xenrt.getTestTarball("xm", extract=True)
        sftp = host.sftpClient()
        rdir = host.hostTempDir()
        sftp.copyTreeTo(self.tec.getWorkdir(), rdir)

        # Get dom0 kernel filename
        kver = string.strip(host.execdom0("uname -r"))
        kfile = "/boot/vmlinuz-%s" % (kver)
        if host.execdom0("ls %s" % (kfile), retval="code") != 0:
            raise xenrt.XRTError("Kernel not where expected (%s)" % (kfile))

        # Build a command line to run the regression test on dom0
        cmd = []
        cmd.append("%s/%s" % (rdir, testbin))
        cmd.append(kfile)
        cmd.append("%s/xm/%s" % (rdir, ramdisk))
        cmd.append("%s/log.txt" % (rdir))
        
        # Run the test
        self.hostToClean = host
        passed = True
        try:
            commands = []
            commands.append("cd %s" % (rdir))
            commands.append("PATH=.:${PATH} %s > output.txt 2> stderr.log" %
                            (string.join(cmd)))
            self.runAsync(host, commands, timeout=3600)
        except:
            traceback.print_exc(file=sys.stderr)
            self.tec.reason("Test exited with error or timed out")
            passed = False
        for f in ('log.txt', 'output.txt', 'stderr.log'):
            try:
                sftp.copyFrom("%s/%s" % (rdir, f),
                              "%s/%s" % (self.tec.getLogdir(), f))
            except:
                pass

        # Check for failures
        resfile = "%s/output.txt" % (self.tec.getLogdir())
        if os.path.exists(resfile):
            f = file(resfile, "r")
            while True:
                line = f.readline()
                if not line:
                    break
                r = re.search(r"^test\s+\d+\[\s*(\d+)\]\s+\(\s*(.+)\):"
                              "\s+([A-Z]+)", line)
                if r:
                    tc = r.group(1)
                    group = string.replace(r.group(2), " ", "_")
                    outcome = r.group(3)
                    if self.outcomes.has_key(outcome):
                        self.testcaseResult(group, tc, self.outcomes[outcome])
                        if self.outcomes[outcome] == xenrt.RESULT_FAIL or \
                               self.outcomes[outcome] == xenrt.RESULT_ERROR:
                            passed = False
                    else:
                        self.tec.warning("Unknown outcome '%s'" % (outcome))
            f.close()
        else:
            passed = False
            self.tec.reason("No output file found")

        if not passed:
            raise xenrt.XRTFailure()