You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by dp...@apache.org on 2019/08/12 11:06:31 UTC

[ignite-teamcity-bot] branch master updated: YAGNI

This is an automated email from the ASF dual-hosted git repository.

dpavlov pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ignite-teamcity-bot.git


The following commit(s) were added to refs/heads/master by this push:
     new 9c93dd7  YAGNI
9c93dd7 is described below

commit 9c93dd758eeba1e4bf76b14b1f647a732fe446b8
Author: Dmitriy Pavlov <dp...@apache.org>
AuthorDate: Mon Aug 12 14:06:20 2019 +0300

    YAGNI
---
 .../ignite/ci/web/rest/GetChainResultsAsHtml.java  | 339 ---------------------
 ignite-tc-helper-web/src/main/webapp/tracked.html  | 181 -----------
 2 files changed, 520 deletions(-)

diff --git a/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/web/rest/GetChainResultsAsHtml.java b/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/web/rest/GetChainResultsAsHtml.java
deleted file mode 100644
index db6360f..0000000
--- a/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/web/rest/GetChainResultsAsHtml.java
+++ /dev/null
@@ -1,339 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.ci.web.rest;
-
-import com.google.common.base.Strings;
-import java.util.Collections;
-import java.util.List;
-import javax.servlet.ServletContext;
-import javax.servlet.http.HttpServletRequest;
-import javax.ws.rs.GET;
-import javax.ws.rs.Path;
-import javax.ws.rs.Produces;
-import javax.ws.rs.QueryParam;
-import javax.ws.rs.core.Context;
-
-import com.google.inject.Injector;
-import org.apache.ignite.tcbot.engine.chain.BuildChainProcessor;
-import org.apache.ignite.tcservice.ITeamcity;
-import org.apache.ignite.tcbot.engine.chain.FullChainRunCtx;
-import org.apache.ignite.tcbot.engine.chain.LatestRebuildMode;
-import org.apache.ignite.tcbot.engine.chain.ProcessLogsMode;
-import org.apache.ignite.tcbot.persistence.IStringCompactor;
-import org.apache.ignite.tcignited.ITeamcityIgnited;
-import org.apache.ignite.tcignited.ITeamcityIgnitedProvider;
-import org.apache.ignite.tcignited.SyncMode;
-import org.apache.ignite.ci.user.ITcBotUserCreds;
-import org.apache.ignite.tcbot.common.util.FutureUtil;
-import org.apache.ignite.ci.web.CtxListener;
-import org.apache.ignite.tcbot.engine.ui.DsChainUi;
-import org.apache.ignite.tcbot.engine.ui.DsSuiteUi;
-import org.apache.ignite.tcbot.engine.ui.DsTestFailureUi;
-import org.apache.ignite.tcbot.engine.ui.DsTestHistoryUi;
-
-import static java.lang.Float.parseFloat;
-import static javax.ws.rs.core.MediaType.TEXT_HTML;
-import static org.apache.ignite.internal.util.lang.GridFunc.isEmpty;
-
-/**
- *
- */
-@Path("chainResults")
-public class GetChainResultsAsHtml {
-    /** Servlet Context. */
-    @Context
-    private ServletContext ctx;
-
-    /** Current Request. */
-    @Context
-    private HttpServletRequest req;
-    
-    //test here http://localhost:8080/rest/chainResults/html?serverId=public&buildId=1086222
-    public void showChainOnServersResults(StringBuilder res, Integer buildId, String srvCode) {
-        //todo solve report auth problem
-        final Injector injector = CtxListener.getInjector(ctx);
-        final BuildChainProcessor buildChainProcessor = injector.getInstance(BuildChainProcessor.class);
-
-        String failRateBranch = ITeamcity.DEFAULT;
-
-        ITcBotUserCreds creds = ITcBotUserCreds.get(req);
-        ITeamcityIgnited tcIgn = injector.getInstance(ITeamcityIgnitedProvider.class).server(srvCode, creds);
-
-        final FullChainRunCtx ctx = buildChainProcessor.loadFullChainContext(
-                tcIgn,
-            Collections.singletonList(buildId),
-            LatestRebuildMode.NONE,
-            ProcessLogsMode.SUITE_NOT_COMPLETE,
-            false,
-            failRateBranch,
-            SyncMode.RELOAD_QUEUED,
-            null,
-            null);
-
-        DsChainUi status = new DsChainUi(srvCode, tcIgn.serverCode(), ctx.branchName());
-
-        ctx.getRunningUpdates().forEach(FutureUtil::getResultSilent);
-
-        status.chainName = ctx.suiteName();
-
-        IStringCompactor c = injector.getInstance(IStringCompactor.class);
-        status.initFromContext(tcIgn, ctx, failRateBranch, c, false, null, null, -1, null, false, false);
-
-        res.append(showChainAtServerData(status));
-
-    }
-
-    @GET
-    @Produces(TEXT_HTML)
-    @Path("html")
-    public String getChainRes(@QueryParam("serverId") String serverId, @QueryParam("buildId") Integer buildId) {
-        StringBuilder builder = new StringBuilder();
-        builder.append("<html>\n");
-        builder.append("<head>\n");
-        builder.append("    <title>Ignite Teamcity - current failures</title>");
-        builder.append(" <script src=\"https://code.jquery.com/jquery-1.12.4.js\"></script>\n");
-        builder.append("    <script src=\"https://code.jquery.com/ui/1.12.1/jquery-ui.js\"></script>\n");
-        builder.append("\n");
-        builder.append("    <link rel=\"icon\" href=\"https://pbs.twimg.com/profile_images/568493154500747264/xTBxO73F.png\">\n");
-        builder.append("    <link rel=\"stylesheet\" href=\"https://code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css\">");
-
-        builder.append("<style>");
-        builder.append("body {\n");
-        builder.append(" \tfont-family: Arial;\n");
-        builder.append(" \tfont-size: 12px;\n");
-        builder.append(" \tfont-style: normal;\n");
-        builder.append(" \tfont-variant: normal;\n");
-        builder.append(" \tfont-weight: 500;\n");
-        builder.append("}");
-        builder.append("</style>");
-
-        builder.append("</head>");
-        builder.append("<body>\n");
-        builder.append("<script>\n");
-        builder.append("$(document).ready(function() {\n");
-        builder.append("    $( document ).tooltip();\n");
-        builder.append("     \n");
-        builder.append("}); \n");
-        builder.append("</script>\n");
-        builder.append("\n");
-        showChainOnServersResults(builder, buildId, serverId)      ;
-
-        builder.append("\n");
-        builder.append("</body>\n");
-        builder.append("</html>");
-
-        return builder.toString();
-    }
-
-
-
-    private boolean isDefinedAndFilled(Object failures) {
-        return failures!=null;
-    }
-
-    private String showChainAtServerData(DsChainUi server) {
-        String res = "";
-        String altTxt = "";
-
-        if(!isEmpty(server.durationPrintable))
-            altTxt += "duration: " + server.durationPrintable;
-
-        res += "<b><a href='" + server.webToHist + "'>" + Strings.nullToEmpty(server.serverId);
-
-        if (isDefinedAndFilled(server.chainName))
-            res += " " + server.chainName;
-
-        res += "</a> ";
-        res += "[";
-        res += " <a href='" + server.webToBuild + "' title='" + altTxt + "'>";
-        res += "tests " + server.failedTests + " suites " + server.failedToFinish + "";
-        res += " </a>";
-        res += "]";
-        res += "</b><br><br>";
-
-        StringBuilder resBuilder = new StringBuilder(res);
-        for (DsSuiteUi suite : server.suites) {
-            resBuilder.append(showSuiteData(suite));
-        }
-        res = resBuilder.toString();
-
-        return res;
-    }
-
-    private String showSuiteData(DsSuiteUi suite) {
-        String res = "";
-        String altTxt = "duration: " + suite.durationPrintable;
-        res += "&nbsp; ";
-
-        String failRateText = "";
-        if (isDefinedAndFilled(suite.failures) && isDefinedAndFilled(suite.runs) && isDefinedAndFilled(suite.failureRate)) {
-            altTxt += "; " + suite.failures + " fails / " + suite.runs + " runs in all tracked branches in helper DB";
-            failRateText += "(fail rate " + suite.failureRate + "%)";
-            altTxt += "; " + failRateText;
-        }
-        String color = failureRateToColor(suite.failureRate);
-        res += " <span style='border-color: " + color + "; width:6px; height:6px; display: inline-block; border-width: 4px; color: black; border-style: solid;' title='" + failRateText + "'></span> ";
-
-        res += "<a href='" + suite.webToHist + "'>" + suite.name + "</a> " +
-            "[ " + "<a href='" + suite.webToBuild + "' title='" + altTxt + "'> " + "tests " + suite.failedTests + " " + suite.result + "</a> ]";
-
-        if(isDefinedAndFilled(suite.runningBuildCount) && suite.runningBuildCount!=0) {
-            res+=" <img src='https://image.flaticon.com/icons/png/128/2/2745.png' width=12px height=12px> ";
-            res+=" " + suite.runningBuildCount + " running";
-        }
-        if(isDefinedAndFilled(suite.queuedBuildCount) && suite.queuedBuildCount!=0) {
-            res+=" <img src='https://d30y9cdsu7xlg0.cloudfront.net/png/273613-200.png' width=12px height=12px> ";
-            res+="" + suite.queuedBuildCount + " queued";
-        }
-
-        /* //no triggering support in static version
-        if(isDefinedAndFilled(suite.serverId) && isDefinedAndFilled(suite.suiteId) && isDefinedAndFilled(suite.branchName)) {
-            res+=" <a href='javascript:void(0);' ";
-            res+=" onClick='triggerBuild(\"" + suite.serverId + "\", \"" + suite.suiteId + "\", \""+suite.branchName+"\")' ";
-            res+=" title='trigger build'";
-            res+=" >run</a> ";
-        }
-        */
-        res+=" <br>";
-
-        List<DsTestFailureUi> failures = suite.testFailures;
-        StringBuilder resBuilder = new StringBuilder(res);
-        for (DsTestFailureUi next : failures)
-            resBuilder.append(showTestFailData(next));
-        res = resBuilder.toString();
-        
-        if(isDefinedAndFilled(suite.webUrlThreadDump)) {
-            res += "&nbsp; &nbsp; <a href='" + suite.webUrlThreadDump + "'>";
-            res += "<img src='https://cdn2.iconfinder.com/data/icons/metro-uinvert-dock/256/Services.png' width=12px height=12px> ";
-            res += "Thread Dump</a>";
-            res += " <br>";
-        }
-
-        res += " <br>";
-        return res;
-    }
-
-    private boolean isDefinedAndFilled(String id) {
-        return !Strings.isNullOrEmpty(id);
-    }
-
-
-    private String showTestFailData(DsTestFailureUi testFail) {
-        String res = "";
-        res += "&nbsp; &nbsp; ";
-
-        boolean haveIssue = isDefinedAndFilled(testFail.webIssueUrl) && isDefinedAndFilled(testFail.webIssueText);
-
-        String color = (isDefinedAndFilled(testFail.histBaseBranch) && isDefinedAndFilled(testFail.histBaseBranch.recent))
-            ? failureRateToColor(testFail.histBaseBranch.recent.failureRate)
-            : "white";
-
-        boolean investigated = testFail.investigated;
-        if(investigated) {
-            res += "<img src='https://d30y9cdsu7xlg0.cloudfront.net/png/324212-200.png' width=8px height=8px> ";
-            res += "<span style='opacity: 0.75'> ";
-        }
-
-        res += " <span style='background-color: " + color + "; width:7px; height:7px; display: inline-block; border-width: 1px; border-color: black; border-style: solid; '></span> ";
-
-        if (haveIssue) {
-            res += "<a href='" + testFail.webIssueUrl + "'>";
-            res += testFail.webIssueText;
-            res += "</a>";
-            res += ": ";
-        }
-        ;
-
-        res += testFail.name;
-
-        boolean haveWeb = isDefinedAndFilled(testFail.webUrl);
-        String histContent = "";
-
-        DsTestHistoryUi hist;
-
-        if(isDefinedAndFilled(testFail.histBaseBranch))
-            hist = testFail.histBaseBranch;
-        else
-            hist = null;
-
-        if (hist!=null) {
-            String testFailTitle = "";
-
-            if(isDefinedAndFilled(hist.recent))
-                testFailTitle = "recent rate: " + hist.recent.failures + " fails / " + hist.recent.runs + " runs" ;
-
-            histContent += " <span title='" +testFailTitle + "'>";
-
-            if (isDefinedAndFilled(hist.recent) && isDefinedAndFilled(hist.recent.failureRate))
-                histContent += "(fail rate " + hist.recent.failureRate + "%)";
-            else
-                histContent += "(fails: " + hist.recent.failures + "/" + hist.recent.runs + ")";
-
-            if(isDefinedAndFilled(testFail.histCurBranch)) {
-                //todo presence of this indicates that PR is checked, need to draw latest
-            }
-
-            histContent += "</span>";
-        } else if (haveWeb)
-            histContent += " (test history)";
-
-        if (haveWeb)
-            res += "<a href='" + testFail.webUrl + "'>";
-        res += histContent;
-        if (haveWeb)
-            res += "</a>";
-
-
-        if(investigated)
-            res += "</span> ";
-
-        res += " <br>";
-        return res;
-    }
-
-
-    private String failureRateToColor(String failureRate) {
-        float redSaturation = 255;
-        float greenSaturation = 0;
-        float blueSaturation = 0;
-
-        float colorCorrect = 0;
-        if (isDefinedAndFilled(failureRate))
-            colorCorrect = parseFloat(failureRate.replace(",", "."));
-
-        if (colorCorrect < 50) {
-            redSaturation = 255;
-            greenSaturation += colorCorrect * 5;
-        }
-        else {
-            greenSaturation = 255 - (colorCorrect - 50) * 5;
-            redSaturation = 255 - (colorCorrect - 50) * 5;
-        }
-        return rgbToHex(redSaturation, greenSaturation, blueSaturation);
-    }
-
-    private String componentToHex(float c) {
-        int cInt = (int)c;
-        String cStr = Integer.toHexString(cInt > 255 ? 255 : cInt);
-        return Strings.padStart(cStr, 2, '0');
-    }
-
-    private String rgbToHex(float r, float g, float b) {
-        return "#" + componentToHex(r) + componentToHex(g) + componentToHex(b);
-    }
-}
diff --git a/ignite-tc-helper-web/src/main/webapp/tracked.html b/ignite-tc-helper-web/src/main/webapp/tracked.html
deleted file mode 100644
index 3203e9b..0000000
--- a/ignite-tc-helper-web/src/main/webapp/tracked.html
+++ /dev/null
@@ -1,181 +0,0 @@
-<html>
-<head>
-    <title>Apache Ignite Teamcity Bot - Tracked branch - Detailed status of failures</title>
-    <link rel="icon" href="img/leaf-icon-png-7066.png">
-
-    <script src="https://code.jquery.com/jquery-1.12.4.js"></script>
-    <script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
-
-    <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
-    <!-- production version, optimized for size and speed -->
-    <!--<script src="https://cdn.jsdelivr.net/npm/vue"></script>-->
-
-    <script src="https://cdn.jsdelivr.net/npm/vuetify/dist/vuetify.js"></script>
-   <link href="https://fonts.googleapis.com/css?family=Roboto:100,300,400,500,700,900|Material+Icons" rel="stylesheet">
-
-    <link href="https://cdn.jsdelivr.net/npm/vuetify/dist/vuetify.min.css" rel="stylesheet">
-
-    <link rel="stylesheet" href="https://code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
-    <link rel="stylesheet" href="css/style-1.5.css">
-
-    <script src="js/common-1.6.js"></script>
-</head>
-<body>
-<script>
-    var g_shownDataHashCodeHex = "";
-    let gVue;
-
-    $(document).ready(function() {
-        $.getScript("js/testfails-2.2.js", function(data, textStatus, jqxhr){ });
-
-        $( document ).tooltip();
-        showQueryForm();
-
-        $.ajax({ url: "/rest/branches/version",  success: showVersionInfo, error: showErrInLoadStatus });
-    });
-
-    function showQueryForm() {
-        gVue = new Vue({
-            el: '#vueQueryForm',
-            data: {
-                baseBranchSelected: ''
-            },
-            methods: {
-                formChanged: function () {
-                    $("#divFailures").html(parmsForRest());
-                }
-            }
-        });
-    }
-
-
-    function parmsForRest() {
-        var curReqParms = "";
-        var branch = findGetParameter("branch");
-        if (branch != null) {
-            curReqParms += "?branch=" + branch;
-        }
-
-        if (gVue.$data.baseBranchSelected != null) {
-            curReqParms += "?baseBranch=" +  gVue.$data.baseBranchSelected;
-        }
-
-        var checkAllLogs = findGetParameter("checkAllLogs");
-        if (checkAllLogs != null) {
-            curReqParms += "&checkAllLogs=" + checkAllLogs;
-        }
-
-        var trustedTests = findGetParameter("trustedTests");
-        if (trustedTests != null) {
-            curReqParms += "&trustedTests=" + trustedTests;
-        }
-
-        return curReqParms;
-    }
-
-    function checkForUpdate() {
-        var curFailuresUrl = "rest/tracked/updates" + parmsForRest();
-
-        $.ajax({
-            url: curFailuresUrl,
-            success: function (result) {
-                if (g_shownDataHashCodeHex !== "" && isDefinedAndFilled(result.hashCodeHex)) {
-                    if (g_shownDataHashCodeHex === result.hashCodeHex) {
-                        var fastCheckNeeded = isDefinedAndFilled(result.runningUpdates) && result.runningUpdates > 0;
-                        var ms = fastCheckNeeded ? 3000 : 30000;
-
-                        setTimeout(checkForUpdate, ms);
-
-                        $("#loadStatus").html("");
-                    } else {
-                        loadData(); // data changed, show new
-                    }
-                } else {
-                    loadData();
-                }
-            },
-            error: showErrInLoadStatus
-        });
-    }
-
-    function loadData() {
-        var curFailuresUrl = "rest/tracked/results" + parmsForRest();
-
-        $("#loadStatus").html("<img src='https://www.wallies.com/filebin/images/loading_apple.gif' width=20px height=20px> Please wait");
-        setTimeout(loadPartialData, 3000);
-
-        $.ajax({
-            url: curFailuresUrl,
-            success: function (result) {
-                if (isDefinedAndFilled(result.runningUpdates) && result.runningUpdates > 0) {
-                    setTimeout(checkForUpdate, 3000);
-
-                    $("#loadStatus").html("<img src='https://www.wallies.com/filebin/images/loading_apple.gif' width=20px height=20px> Updating");
-                } else {
-                    $("#loadStatus").html("");
-                }
-                showData(result);
-                g_shownDataHashCodeHex = isDefinedAndFilled(result.hashCodeHex) ? result.hashCodeHex : "";
-            },
-            error: showErrInLoadStatus
-        });
-    }
-
-    function loadPartialData() {
-        var curFailuresUrl = "rest/tracked/resultsNoSync" + parmsForRest();
-
-        if (g_shownDataHashCodeHex !== "") {
-            return;
-        }
-        $.ajax({
-            url: curFailuresUrl,
-            success: function (result) {
-                if (g_shownDataHashCodeHex !== "") {
-                    return;
-                }
-
-                var validResult = true;
-                for (var i = 0; i < result.servers.length; i++) {
-                    var server = result.servers[i];
-
-                    if (isDefinedAndFilled(server.buildNotFound) && server.buildNotFound) {
-                        validResult = false;
-                        break;
-                    }
-                }
-                if (validResult)
-                    showData(result);
-
-                setTimeout(loadPartialData, 3000);
-            },
-            error: showErrInLoadStatus
-        });
-    }
-
-    function showData(result) {
-        //var txtUrl = "rest/tracked/results/txt" + parmsForRest();
-
-        $("#divFailures").html(showChainOnServersResults(result));
-        //        + " <a href='"+ txtUrl + "'>txt</a>");
-    }
-
-</script>
-
-<div id="loadStatus"></div>
-<div id="vueQueryForm" class="h-25">
-    <v-app id="queryForm" class="h-25">
-        <select v-model="baseBranchSelected" @change="formChanged">
-            <option disabled value="">Please select one</option>
-            <option>A</option>
-            <option>B</option>
-            <option>C</option>
-        </select>
-        <span>Base branch: {{ baseBranchSelected }}</span>
-    </v-app>
-</div>
-<div id="divFailures"></div>
-
-<div id="version"></div>
-<div style="visibility:hidden;"><div id="triggerConfirm" title="Trigger Confirmation"></div><div id="triggerDialog" title="Trigger Result"></div></div>
-</body>
-</html>
\ No newline at end of file