Ejemplo n.º 1
0
    def renderPageBody(self):
        mm = self.testManager.machine_management

        if self.options.get("amiLogs"):
            ami,hash = self.options.get("amiLogs").split("_")
            url = mm.amiConfigLogUrl(ami,hash)
            if url:
                raise cherrypy.HTTPRedirect(url)
            else:
                return HtmlGeneration.card("No logs available")

        if self.options.get("amiSetupScript"):
            ami,hash = self.options.get("amiSetupScript").split("_")
            url = mm.amiConfigLogUrl(ami,hash, "InstallScript")
            if url:
                raise cherrypy.HTTPRedirect(url)
            else:
                return HtmlGeneration.card("No script available")

        osConfigs = set(
            list(mm.windowsOsConfigsAvailable) + 
            list(mm.windowsOsConfigsBeingCreated) + 
            list(mm.invalidWindowsOsConfigs)
            )

        grid = [["BaseAmi", "Hash", "Status", "", ""]]

        for osConfig in sorted(osConfigs, key=lambda c: (c.ami, c.setupHash)):
            ami,contentHash = osConfig.ami, osConfig.setupHash

            status = (
                "OK" if osConfig in mm.windowsOsConfigsAvailable else 
                "In progress" if osConfig in mm.windowsOsConfigsBeingCreated else 
                "Invalid"
                )

            if status in ("OK", "Invalid"):
                logsButton = HtmlGeneration.Link(
                    self.withOptions(amiLogs=ami+"_"+contentHash).urlString(), 
                    "Logs",
                    is_button=True,
                    button_style='btn-primary btn-xs'
                    ).render()
            else:
                logsButton = ""

            scriptButton = HtmlGeneration.Link(
                self.withOptions(amiSetupScript=ami+"_"+contentHash).urlString(), 
                "Setup Script",
                is_button=True,
                button_style='btn-primary btn-xs'
                ).render()

            grid.append([ami,contentHash,status, logsButton, scriptButton])
            
        return HtmlGeneration.grid(grid)
Ejemplo n.º 2
0
 def cancelTestRunButton(self, testRunId):
     return HtmlGeneration.Link(
         self.address + "/cancelTestRun?" + urllib.urlencode({"testRunId":testRunId, "redirect": self.redirect()}),
         "cancel", 
         is_button=True,
         button_style=self.disable_if_cant_write('btn-primary btn-xs')
         )        
Ejemplo n.º 3
0
 def testLogsButton(self, testId):
     return HtmlGeneration.Link(
         self.testLogsUrl(testId),
         "LOGS", 
         is_button=True,
         button_style=self.disable_if_cant_write('btn-primary btn-xs')
         )
Ejemplo n.º 4
0
 def deleteTestRunButton(self, testId):
     return HtmlGeneration.Link(
         self.deleteTestRunUrl(testId),
         "CLEAR", 
         is_button=True,
         button_style=self.disable_if_cant_write('btn-primary btn-xs')
         )
Ejemplo n.º 5
0
 def shutdownDeploymentLink(self, d):
     return HtmlGeneration.Link("/shutdownDeployment?deploymentId=" +
                                d._identity,
                                "shutdown",
                                is_button=True,
                                new_tab=True,
                                button_style='btn-primary btn-xs')
Ejemplo n.º 6
0
 def connectDeploymentLink(self, d):
     return HtmlGeneration.Link("/terminalForDeployment?deploymentId=" +
                                d._identity,
                                "connect",
                                is_button=True,
                                new_tab=True,
                                button_style='btn-primary btn-xs')
Ejemplo n.º 7
0
 def reload_link(self):
     return HtmlGeneration.Link(
         "/reloadSource?" + 
             urllib.urlencode({'redirect': self.redirect()}),
         '<span class="octicon octicon-sync" aria-hidden="true" style="horizontal-align:center"></span>',
         is_button=True,
         button_style='btn-outline-primary btn-xs'
         )
Ejemplo n.º 8
0
 def toggleBranchUnderTestLink(self, branch):
     icon = "octicon-triangle-right"
     hover_text = "%s testing this branch" % ("Pause" if branch.isUnderTest else "Start")
     button_style = "btn-xs " + ("btn-primary active" if branch.isUnderTest else "btn-outline-dark")
     
     return HtmlGeneration.Link(
         "/toggleBranchUnderTest?" + 
             urllib.urlencode({'repo': branch.repo.name, 'branchname':branch.branchname, 'redirect': self.redirect()}),
         '<span class="octicon %s" aria-hidden="true" style="horizontal-align:center"></span>' % icon,
         is_button=True,
         button_style=self.disable_if_cant_write(button_style),
         hover_text=hover_text
         )
Ejemplo n.º 9
0
    def renderCommitTestDefinitionsInfo(self):
        raw_text, extension = self.testManager.getRawTestFileForCommit(
            self.commit)

        post_text = HtmlGeneration.Link(
            self.withOptions(action="force_reparse").urlString(),
            "Force Test Reparse",
            is_button=True,
            button_style=self.renderer.disable_if_cant_write(
                'btn-primary btn-xs mt-4')).render()

        if raw_text:
            return card(
                '<pre class="language-yaml"><code class="line-numbers">%s</code></pre>'
                % cgi.escape(raw_text)) + post_text
        else:
            return card("No test definitions found") + post_text
Ejemplo n.º 10
0
    def configurationView(self):
        if self.repo.branchCreateTemplates is None:
            self.repo.branchCreateTemplates = []

        if self.options.get('action', None) == "new_template":
            self.repo.branchCreateTemplates = list(self.repo.branchCreateTemplates) + [
                self.database.BranchCreateTemplate.New()
                ]

            return HtmlGeneration.Redirect(self.withOptions(action=None).urlString())
        if self.options.get('action', None) == "update_template":
            template = self.database.BranchCreateTemplate(str(self.options.get("identity")))
            assert template.exists() and template in self.repo.branchCreateTemplates

            template.globsToInclude = [str(x) for x in self.options.get("include_pats").split("\n")]
            template.globsToExclude = [str(x) for x in self.options.get("exclude_pats").split("\n")]
            template.suffix = str(self.options.get("suffix"))
            template.branchToCopyFrom = str(self.options.get("branch"))
            template.def_to_replace = str(self.options.get("def_to_replace"))
            template.disableOtherAutos = bool(self.options.get("disableOtherAutos"))
            template.autoprioritizeBranch = bool(self.options.get("autoprioritizeBranch"))
            template.deleteOnUnderlyingRemoval = bool(self.options.get("deleteOnUnderlyingRemoval"))

            return HtmlGeneration.Redirect(self.withOptions(action=None).urlString())
        
        result = ""

        for template in self.repo.branchCreateTemplates:
            result += card(self.renderTemplateUpdateForm(template))

        result += card(
            HtmlGeneration.Link(
                self.withOptions(action='new_template').urlString(),
                "Create new Branch Template",
                is_button=True,
                button_style=self.renderer.disable_if_cant_write('btn-primary btn-xs'),
                hover_text="Create a new branch-creation template."
                ).render()
            )

        return result        
Ejemplo n.º 11
0
    def toggleCommitUnderTestLink(self):
        commit = self.commit

        actual_priority = commit.userPriority > 0

        icon = "octicon-triangle-right"
        hover_text = "%s tests for this commit" % (
            "Enable" if not actual_priority else "Disable")
        button_style = "btn-xs " + ("btn-primary active"
                                    if actual_priority else "btn-outline-dark")

        return HtmlGeneration.Link(
            "/toggleCommitUnderTest?" +
            urllib.urlencode({
                'reponame': commit.repo.name,
                'hash': commit.hash,
                'redirect': self.redirect()
            }),
            '<span class="octicon %s" aria-hidden="true"></span>' % icon,
            is_button=True,
            button_style=self.renderer.disable_if_cant_write(button_style),
            hover_text=hover_text)
Ejemplo n.º 12
0
 def small_clear_button(self, url, label=None):
     label = label or "clear"
     return HtmlGeneration.Link(url,
                                label,
                                is_button=True,
                                button_style=self.disable_if_cant_write('btn-primary btn-xs'))
Ejemplo n.º 13
0
    def renderTestSuitesSummary(self, builds=False):
        commit = self.commit

        tests = self.allTests()

        if builds:
            tests = [
                t for t in tests if t.testDefinitionSummary.type == "Build"
                and self.shouldIncludeTest(t)
            ]
        else:
            tests = [
                t for t in tests if t.testDefinitionSummary.type == "Test"
                and self.shouldIncludeTest(t)
            ]

        if not tests:
            if commit.data.noTestsFound:
                return card("Commit defined no test definition file.")

            raw_text, extension = self.testManager.getRawTestFileForCommit(
                commit)
            if not raw_text:
                return card(
                    "Commit defined no tests because the test-definitions file is empty."
                )
            elif commit.data.testDefinitionsError:
                return card(
                    "<div>Commit defined no tests or builds. Maybe look at the test definitions? Error was</div><pre><code>%s</code></pre>"
                    % commit.data.testDefinitionsError)
            else:
                if self.projectFilter and self.configFilter:
                    return card(
                        "Commit defined no %s for project '%s' and configuration '%s'."
                        % ("builds" if builds else "tests", self.projectFilter,
                           self.configFilter))
                if self.projectFilter:
                    return card(
                        "Commit defined no %s for project '%s'." %
                        ("builds" if builds else "tests", self.projectFilter))
                if self.configFilter:
                    return card(
                        "Commit defined no %s for configuration %s." %
                        ("builds" if builds else "tests", self.configFilter))
                return card("Commit defined no %s." %
                            ("builds" if builds else "tests"))

        tests = sorted(tests, key=lambda test: test.testDefinitionSummary.name)

        if builds:
            grid = [[
                "BUILD", "HASH", "", "PROJECT", "CONFIGURATION", "STATUS",
                "STAGE", "RUNS", "RUNTIME", "", "DEPENDENCIES"
            ]]
        else:
            grid = [[
                "SUITE", "HASH", "", "PROJECT", "CONFIGURATION", "STATUS",
                "RUNS", "TARGET_RUNS", "TEST_CT", "FAILURE_CT", "AVG_RUNTIME",
                "", "DEPENDENCIES"
            ]]

        if self.options.get("show_disabled"):
            grid[0].append("Disabled")
            grid[0].append("Calculated Priority")

        for t in tests:
            row = []

            row.append(self.contextFor(t).renderLink(includeCommit=False))
            row.append(t.hash[:8])
            row.append(
                HtmlGeneration.Link(
                    self.contextFor(t).bootTestOrEnvUrl(),
                    "BOOT",
                    is_button=True,
                    new_tab=True,
                    button_style=self.renderer.disable_if_cant_write(
                        'btn-primary btn-xs')))

            row.append(t.testDefinitionSummary.project)
            row.append(t.testDefinitionSummary.configuration)

            row.append(
                TestSummaryRenderer.TestSummaryRenderer(
                    [t], "", ignoreIndividualTests=True).renderSummary())

            all_tests = list(
                self.testManager.database.TestRun.lookupAll(test=t))
            all_noncanceled_tests = [
                testRun for testRun in all_tests if not testRun.canceled
            ]
            all_running_tests = [
                testRun for testRun in all_noncanceled_tests
                if testRun.endTimestamp == 0.0
            ]
            finished_tests = [
                testRun for testRun in all_noncanceled_tests
                if testRun.endTimestamp > 0.0
            ]

            if builds:
                if not all_running_tests or not t.testDefinitionSummary.artifacts:
                    row.append("")
                else:
                    completed = len(all_running_tests[0].artifactsCompleted)
                    row.append(
                        "%s / %s" %
                        (completed, len(t.testDefinitionSummary.artifacts)) +
                        ([
                            " (" + x + ")"
                            for x in t.testDefinitionSummary.artifacts
                        ] + [""])[completed])

            row.append(str(t.totalRuns))

            if not builds:
                row.append(self.renderIncreaseSuiteTargetCount(t))

            if t.totalRuns:
                if not builds:
                    if t.totalRuns == 1:
                        #don't want to convert these to floats
                        row.append("%d" % t.totalTestCount)
                        row.append("%d" % t.totalFailedTestCount)
                    else:
                        row.append(str(t.totalTestCount / float(t.totalRuns)))
                        row.append(
                            str(t.totalFailedTestCount / float(t.totalRuns)))

                if finished_tests:
                    row.append(
                        HtmlGeneration.secondsUpToString(
                            sum([
                                testRun.endTimestamp - testRun.startedTimestamp
                                for testRun in finished_tests
                            ]) / len(finished_tests)))
                else:
                    row.append("")
            else:
                if not builds:
                    row.append("")
                    row.append("")

                if all_noncanceled_tests:
                    row.append(
                        HtmlGeneration.secondsUpToString(
                            sum([
                                time.time() - testRun.startedTimestamp
                                for testRun in all_noncanceled_tests
                            ]) / len(all_noncanceled_tests)) + " so far")
                else:
                    row.append("")

            runButtons = []

            for testRun in all_noncanceled_tests[:5]:
                runButtons.append(
                    self.renderer.testLogsButton(testRun._identity).render())
            if len(all_noncanceled_tests) > 5:
                runButtons.append(" and %s more" %
                                  (len(all_noncanceled_tests) - 5))

            row.append(" ".join(runButtons))
            row.append(self.testDependencySummary(t))

            if self.options.get("show_disabled"):
                row.append(
                    "Disabled" if t.testDefinitionSummary.disabled else "")
                row.append(str(t.calculatedPriority))

            grid.append(row)

        return HtmlGeneration.grid(grid)