Skip to content

Commit

Permalink
FIXME Implemented very basic linking to the diff tool
Browse files Browse the repository at this point in the history
  • Loading branch information
judovana committed Jun 3, 2024
1 parent f8e07a9 commit 9010f80
Show file tree
Hide file tree
Showing 6 changed files with 76 additions and 23 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package io.jenkins.plugins.report.jtreg.main.comparator;

import io.jenkins.plugins.report.jtreg.BuildSummaryParser;
import io.jenkins.plugins.report.jtreg.CommonOptions;
import io.jenkins.plugins.report.jtreg.ConfigFinder;
import io.jenkins.plugins.report.jtreg.utils.StackTraceTools;
import io.jenkins.plugins.report.jtreg.formatters.JtregPluginServicesCell;
Expand Down Expand Up @@ -101,7 +102,7 @@ public static void compareTraces(Map<String, ArrayList<String>> failedMap, Optio
String jobId = Builds.getBuildNumber(new File(jobBuilds.get(column-1)));
String id = "comapre-" + test + "-" + buildName + "-" + jobId;
List<JtregPluginServicesLinkWithTooltip> maybeSeveralComaprisons = new ArrayList<>();
maybeSeveralComaprisons.add(new JtregPluginServicesLinkWithTooltip(stringToPut, null, id, createTooltip(test, buildName, jobId, column, id, options.getJenkinsUrl()), true));
maybeSeveralComaprisons.add(new JtregPluginServicesLinkWithTooltip(stringToPut, null, id, createTooltip(test, buildName, jobId, test, column, id, options.getJenkinsUrl(), options.getDiffUrl()), true));
//you can add more links simply by
//maybeSeveralComaprisons.add(new JtregPluginServicesLinkWithTooltip("X2", "test", null, getLinksTooltip(), true));
//maybeSeveralComaprisons.add(new JtregPluginServicesLinkWithTooltip("X3", "test", null, getLinksTooltip(), true));
Expand All @@ -113,7 +114,7 @@ public static void compareTraces(Map<String, ArrayList<String>> failedMap, Optio
}

// TODO delete, just for debug logging

Check warning on line 116 in report-jtreg-comparator/src/main/java/io/jenkins/plugins/report/jtreg/main/comparator/StackTraceCompare.java

View check run for this annotation

ci.jenkins.io / Open Tasks Scanner

TODO

NORMAL: delete, just for debug logging
System.err.println("Test " + (i - 1) + "/" + failedTests.size() + " - " + (int)((i - 1)/(double)failedTests.size() * 100) + "%");
System.err.println("Test " + (i - 1) + "/" + failedTests.size() + " - " + (int) ((i - 1) / (double) failedTests.size() * 100) + "%");

i++;
}
Expand All @@ -122,15 +123,30 @@ public static void compareTraces(Map<String, ArrayList<String>> failedMap, Optio
options.getFormatter().printTable(table, failedTests.size() + 1, jobBuilds.size() + 1);
}

private static List<JtregPluginServicesLinkWithTooltip> createTooltip(String result, String buildName, String buildId, int column, String id, String url) {
List<JtregPluginServicesLinkWithTooltip> list = VirtualJobsResults.createTooltip(result, buildName, buildId, column, id, url);
private static List<JtregPluginServicesLinkWithTooltip> createTooltip(String result, String buildName, String buildId, String test, int column, String id, String jenkinsUrl, String comapratorUrl) {
List<JtregPluginServicesLinkWithTooltip> list = VirtualJobsResults.createTooltip(result, buildName, buildId, column, id, jenkinsUrl);
list.add(new JtregPluginServicesLinkWithTooltip("*** comapre links ***"));
list.add(new JtregPluginServicesLinkWithTooltip(" * use this as base", "some link", null));
list.add(new JtregPluginServicesLinkWithTooltip(" * show diff agaisnt base", "some otjer link", null));
list.add(new JtregPluginServicesLinkWithTooltip(" * show diff in different setup", "other link", null));
list.add(new JtregPluginServicesLinkWithTooltip(" * show diff against self", getSelfDiffLink(buildName, buildId, test, comapratorUrl)));
list.add(new JtregPluginServicesLinkWithTooltip(" * show diff against base", "other link", null));
list.add(new JtregPluginServicesLinkWithTooltip(" * show diff against right one", "other link", null));
list.add(new JtregPluginServicesLinkWithTooltip(" * show diff against left one", "other link", null));
list.add(new JtregPluginServicesLinkWithTooltip(" * use this as base (not yet working)", "must reconstruct parameters map, and add/replace ++--set-referential+build:id. May be good idea to append anchor of #test-job-id (where #==%23", null));
return list;
}

private static String getSelfDiffLink(String buildName, String buildId, String test, String comapratorUrl) {
return getDiffLink(buildName, buildId, buildName, buildId, test, comapratorUrl);
}

private static String getDiffLink(String buildName1, String buildId1, String buildName2, String buildId2, String test, String comapratorUrl) {
return comapratorUrl + "?generated-part=&custom-part=" +
"++--formatting+html" +
"++--diff-format+sidebyside" +
"++--trace-from+" + buildName1 + "%3A"/*:*/ + buildId1 +
"++--trace-to+" + buildName2 + "%3A"/*:*/ + buildId2 +
"++--exact-tests+" + test.replaceAll("#", "%23");
}

private static int getTraceSimilarity(String one, String two) {
// TODO:
// - try the second, memory efficient algorithm (maybe give the user a choice?)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,37 @@ public void setJenkinsUrl(String jenkinsUrl) {
this.jenkinsUrl = jenkinsUrl;
}

/**
* FIXME; this is terribly hackish an incredibnly wrong

Check warning on line 80 in report-jtreg-lib/src/main/java/io/jenkins/plugins/report/jtreg/CommonOptions.java

View check run for this annotation

ci.jenkins.io / Open Tasks Scanner

FIXME

HIGH: ; this is terribly hackish an incredibnly wrong
* But considering the nature of our CGI wrapper, th "self" url is not bubblibng down
* unless it would be passed in similarly as jenkins url.
* <p>
* Already port is out of scope here:(
*
* @return nonsense
*/
public String getSelfUrl() {
final String wrongGuessedDefaultPort = "9090";
if (jenkinsUrl != null) {
if (jenkinsUrl.contains(":")) {
return jenkinsUrl.replaceAll(":8080.*", ":" + wrongGuessedDefaultPort);
} else {
return jenkinsUrl + ":" + wrongGuessedDefaultPort;
}
} else {
return "http://localhost:" + wrongGuessedDefaultPort;
}
}

public String getDiffUrl() {
return getSelfUrl() + Constants.DIFF_BACKEND;
}

public String getComparatorUrl() {
return getSelfUrl() + Constants.COMPARATOR_BACKEND;
}


public enum Side {
Head, HeadEach, Tail, TailEach
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,20 @@ final public class Constants {
public static final String REPORT_JSON = "report.json";
public static final String REPORT_TESTS_LIST_JSON = "tests-list.json";
public static final String IRRELEVANT_GLOB_STRING = "report-{runtime,devtools,compiler}.xml.gz";

public static final String LIST_BACKEND = "/list.html";
public static final String COMPARATOR_BACKEND = "/comp.html";
public static final String DIFF_BACKEND = "/diff.html";
public static final double VAGUE_QUERY_THRESHOLD = 0.5;
public static final int VAGUE_QUERY_LENGTH_THRESHOLD = 4;
public static final String COMPARATOR_TABLE_CSS =
"<style>\n" +
".tooltip {\n" +
" position: relative;\n" +
" display: inline-block;\n" +
"}\n" +
".tooltip .tooltiptext {\n" +
" visibility: hidden;\n" +
"<style>\n" +
".tooltip {\n" +
" position: relative;\n" +
" display: inline-block;\n" +
"}\n" +
".tooltip .tooltiptext {\n" +
" visibility: hidden;\n" +
" width: 240px;\n" +
" background-color: grey;\n" +
" color: #fff;\n" +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@

import com.sun.net.httpserver.HttpServer;

import io.jenkins.plugins.report.jtreg.Constants;
import io.jenkins.plugins.report.jtreg.main.web.ComapreContextExecutingHandler;
import io.jenkins.plugins.report.jtreg.main.web.ListContextExecutingHandler;
import io.jenkins.plugins.report.jtreg.main.web.DiffContextExecutingHandler;
Expand Down Expand Up @@ -58,9 +59,9 @@ public static void main(String... args) throws IOException {
help();
throw new RuntimeException("0,1,3 or 4 args expected. Is " + args.length);
}
String b1 = "/list.html";
String b2 = "/comp.html";
String b3 = "/diff.html";
String b1 = Constants.LIST_BACKEND;
String b2 = Constants.COMPARATOR_BACKEND;
String b3 = Constants.DIFF_BACKEND;
HttpServer hs = HttpServer.create(new InetSocketAddress(port), 0);
hs.createContext(b1, new ListContextExecutingHandler(
new File(file1)));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,21 +23,22 @@
*/
package io.jenkins.plugins.report.jtreg.model;

import io.jenkins.plugins.report.jtreg.Constants;
import io.jenkins.plugins.report.jtreg.JenkinsReportJckGlobalConfig;

public final class UrlsProviderPlugin implements UrlsProvider {

@Override
public String getListServer() {
return JenkinsReportJckGlobalConfig.getGlobalDiffUrl() + "/list.html";
return JenkinsReportJckGlobalConfig.getGlobalDiffUrl() + Constants.LIST_BACKEND;
}
@Override
public String getCompServer() {
return JenkinsReportJckGlobalConfig.getGlobalDiffUrl() + "/comp.html";
return JenkinsReportJckGlobalConfig.getGlobalDiffUrl() + Constants.COMPARATOR_BACKEND;
}

@Override
public String getDiffServer() {
return JenkinsReportJckGlobalConfig.getGlobalDiffUrl() + "/diff.html";
return JenkinsReportJckGlobalConfig.getGlobalDiffUrl() + Constants.DIFF_BACKEND;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,17 @@ public void getMatchedComparatorLinksGroupsTest() {
new UrlsProvider() {
@Override
public String getListServer() {
return "http://mylocal/list.html";
return "http://mylocal" + Constants.LIST_BACKEND;
}

@Override
public String getCompServer() {
return "http://mylocal/comp.html";
return "http://mylocal" + Constants.COMPARATOR_BACKEND;
}

@Override
public String getDiffServer() {
return "http://mylocal/diff.html";
return "http://mylocal" + Constants.DIFF_BACKEND;
}
});

Expand Down

0 comments on commit 9010f80

Please sign in to comment.