Пример #1
0
 def notifyAllRead(self, suites):
     self.text = ""
     self.text += "\n".join(map(self.appInfo, suites)) + "\n"
     self.text += "Command line     : " + plugins.commandLineString(
         sys.argv) + "\n\n"
     self.text += "Start time       : " + plugins.startTimeString() + "\n"
     self.updateView()
Пример #2
0
 def performOnCurrent(self):
     for test in self.getRerunMarkedTests():
         rerunNumber = test.stateInGui.briefText.split()[-1]
         pattern = os.path.join(
             os.getenv("TEXTTEST_TMP"), "*." + rerunNumber + "_from_" +
             plugins.startTimeString().replace(":", "") + "*")
         dirs = glob(pattern)
         if len(dirs) == 1:
             rerunDir = dirs[0]
             appDir = os.path.join(rerunDir,
                                   test.app.name + test.app.versionSuffix())
             if not os.path.isdir(appDir):
                 allAppDirs = glob(
                     os.path.join(rerunDir, test.app.name + "*"))
                 if len(allAppDirs) > 0:
                     allAppVersions = [
                         d.replace(
                             os.path.join(rerunDir, test.app.name + "."),
                             "") for d in allAppDirs
                     ]
                     raise plugins.TextTestError(
                         "Cannot load data for rerun, version '" +
                         test.app.getFullVersion() +
                         "' could not be found, only version(s) '" +
                         ", ".join(allAppVersions) + "'")
             if self.loadFrom(test, appDir):
                 continue
         raise plugins.TextTestError(
             "Cannot load data for rerun, test " + test.name +
             " has not yet completed or has been deleted in rerun " +
             rerunNumber)
Пример #3
0
    def generatePage(self, dataFinder, appsWithVersions, fileToUrl):
        jobLink = ""
        creationDate = testoverview.TitleWithDateStamp("").__str__().strip()
        if os.getenv("JENKINS_URL") and os.getenv("JOB_NAME") and os.getenv(
                "BUILD_NUMBER"):
            jobPath = os.path.join(os.getenv("JENKINS_URL"), "job",
                                   os.getenv("JOB_NAME"),
                                   os.getenv("BUILD_NUMBER"))
            if jobPath:
                jobLink = "<br>(built by Jenkins job '" + os.getenv("JOB_NAME") + "', " + "<a href='" + \
                    jobPath + "'> " + "build number " + os.getenv("BUILD_NUMBER") + "</a>" + ")"

        summaryPageTimeStamp = dataFinder.summaryPageName + "." + plugins.startTimeString(
            self.timeFormat)
        with open(summaryPageTimeStamp, "w") as f:
            versionOrder = ["default"]
            appOrder = []
            mostRecentInfo = dataFinder.getMostRecentDateAndTags()
            mostRecentTags = [i[1] for i in mostRecentInfo]
            self.diag.info("Most recent results are from " +
                           repr(mostRecentTags))
            cssColours = []
            for line in open(dataFinder.getTemplateFile()):
                if "<title>" in line:
                    f.write(line)
                elif "historical_report_colours" in line:
                    f.write(self.adjustLineForColours(line, dataFinder))
                else:
                    f.write(line)
                if "td.cell_" in line:
                    cssColours.append(line.rsplit("_", 1)[-1].split()[0])
                if "App order=" in line:
                    appOrder += self.extractOrder(line)
                if "Version order=" in line:
                    versionOrder += self.extractOrder(line)
                if "<h1" in line:
                    f.write("<h3 align=\"center\">(from " +
                            self.getRecentTagText(mostRecentInfo) + ")</h3>\n")
                if "Insert table here" in line:
                    self.insertSummaryTable(f, dataFinder, mostRecentInfo,
                                            appsWithVersions, appOrder,
                                            versionOrder, cssColours)
                if "Insert footer here" in line:
                    f.write(creationDate + (jobLink if jobLink else ""))

        fileNames = self.getSortedFileNames(dataFinder.summaryPageName)
        self.linkOrCopy(fileNames[-1][1], dataFinder.summaryPageName)
        self.cleanOldest(fileNames)

        plugins.log.info("wrote: '" + summaryPageTimeStamp + "'")
        if fileToUrl:
            url = convertToUrl(dataFinder.summaryPageName, fileToUrl)
            plugins.log.info("(URL is " + url + ")")
Пример #4
0
    def __init__(self, optionMap, allApps):
        includeSite, includePersonal = optionMap.configPathOptions()
        self.readGtkRCFiles(includeSite, includePersonal)
        self.dynamic = not optionMap.has_key("gx")
        self.initialApps = self.storeInitial(allApps)
        self.interactiveActionHandler = InteractiveActionHandler(
            self.dynamic, allApps, optionMap)
        self.setUpGlobals(allApps, includePersonal)
        self.shortcutBarGUI = ShortcutBarGUI(includeSite, includePersonal)
        plugins.Responder.__init__(self)
        plugins.Observable.__init__(self)
        testCount = int(optionMap.get("count", 0))
        initialStatus = "TextTest started at " + plugins.localtime() + "."
        # This is perhaps not an ideal design, throwing up the application creation dialog from the middle of a constructor.
        # Would possibly be better to move this, and all the code below, to a later call
        # At the moment that would be setObservers, not fantastic as a side-effect there either
        # Perhaps an entirely new call would be needed? [GB 20130524]
        if len(allApps) == 0:
            newApp, initialStatus = self.createNewApplication(optionMap)
            allApps.append(newApp)

        self.statusMonitor = statusviews.StatusMonitorGUI(initialStatus)
        self.textInfoGUI = textinfo.TextInfoGUI(self.dynamic)
        runName = optionMap.get("name", "").replace("<time>",
                                                    plugins.startTimeString())
        reconnect = optionMap.has_key("reconnect")
        self.runInfoGUI = textinfo.RunInfoGUI(self.dynamic, runName, reconnect)
        self.testRunInfoGUI = textinfo.TestRunInfoGUI(self.dynamic, reconnect)
        self.progressMonitor = statusviews.TestProgressMonitor(
            self.dynamic, testCount)
        self.progressBarGUI = statusviews.ProgressBarGUI(
            self.dynamic, testCount)
        self.idleManager = IdleHandlerManager()
        uiManager = gtk.UIManager()
        self.defaultActionGUIs, self.actionTabGUIs = self.interactiveActionHandler.getPluginGUIs(
            uiManager)
        self.menuBarGUI, self.toolBarGUI, testPopupGUI, testFilePopupGUI, appFilePopupGUI = self.createMenuAndToolBarGUIs(
            uiManager, includeSite, includePersonal)
        self.testColumnGUI = testtree.TestColumnGUI(self.dynamic, testCount)
        self.testTreeGUI = testtree.TestTreeGUI(self.dynamic, allApps,
                                                testPopupGUI,
                                                self.testColumnGUI)
        self.testFileGUI = filetrees.TestFileGUI(self.dynamic,
                                                 testFilePopupGUI)
        self.appFileGUI = filetrees.ApplicationFileGUI(self.dynamic, allApps,
                                                       appFilePopupGUI)
        self.rightWindowGUI = self.createRightWindowGUI()

        self.topWindowGUI = self.createTopWindowGUI(allApps, runName,
                                                    optionMap.get("rerun"))
Пример #5
0
    def takeOwnership(self, conn, instances, maxCapacity):
        myTag = getUserName() + "_" + plugins.startTimeString()
        otherOwners = set()
        tryOwnInstances, fallbackInstances = self.tryAddTag(
            conn, instances, maxCapacity, myTag, otherOwners)

        if not tryOwnInstances:
            return [], sorted(otherOwners)

        currTryInstances = tryOwnInstances
        ownInstances = []
        lostCapacity = 0
        time.sleep(
            0.5)  # add and check too close together makes racing more likely
        for _ in range(20):
            newInsts = conn.get_only_instances(instance_ids=currTryInstances)
            currTryInstances = []
            for inst in newInsts:
                owner = inst.tags.get(self.userTagName, "")
                if owner == myTag:
                    ownInstances.append(inst)
                elif owner:
                    # There's a race condition, somebody else grabbed it first, we drop it
                    otherOwners.add(owner.split("_")[0])
                    lostCapacity += self.getCores(inst, 1)
                else:
                    currTryInstances.append(inst.id)
            if currTryInstances:
                time.sleep(0.1)
            else:
                break

        def getOrigOrder(inst):
            return tryOwnInstances.index(inst.id)

        ownInstances.sort(key=getOrigOrder)

        if lostCapacity:
            fallbackInstances, fallbackOwners = self.takeOwnership(
                conn, fallbackInstances, lostCapacity)
            ownInstances += fallbackInstances
            otherOwners.update(fallbackOwners)

        return ownInstances, sorted(otherOwners)
Пример #6
0
 def setWindowTitle(self):
     guiText = "dynamic" if self.dynamic else "static"
     trailer = " - TextTest " + guiText + " GUI"
     if self.name:
         title = self.name
         if self.rerunId:
             title += " (rerun " + self.rerunId + ")"
     elif self.dynamic:
         appNameDesc = self.dynamicAppNameTitle()
         checkoutTitle = self.getCheckoutTitle()
         title = appNameDesc + " tests" + checkoutTitle
         if self.rerunId:
             title += " (rerun " + self.rerunId + ")"
         else:
             title += " (started at " + plugins.startTimeString() + ")"
     else:
         appNameDesc = self.staticAppNameTitle()
         basicTitle = "test management"
         if len(appNameDesc) > 0:
             title = appNameDesc + " " + basicTitle
         else:
             title = basicTitle.capitalize()
     self.topWindow.set_title(title + trailer)