From 9c3dd889fed06a15ed7a608a79cd1f18c89a4362 Mon Sep 17 00:00:00 2001 From: Jiri Vanek Date: Thu, 30 Nov 2023 14:49:01 +0100 Subject: [PATCH 1/2] Fixed bug, when `web ui` links weremissing href --- .../jtreg/main/comparator/FailedTests.java | 2 +- .../report/jtreg/main/diff/CompareBuilds.java | 2 +- .../report/jtreg/BuildReportExtended.java | 2 +- .../report/jtreg/BuildSummaryParser.java | 2 +- .../jtreg/model/SuiteTestsWithResults.java | 17 ++++++++++- .../report/jtreg/model/SuitesWithResults.java | 5 ++++ .../report/jtreg/model/UrlsProvider.java | 10 +++++++ .../jtreg/BuildReportExtendedPlugin.java | 25 +++++++++------- .../BuildReportExtendedPluginFactory.java | 8 ++++- .../jtreg/BuildSummaryParserPlugin.java | 20 ++----------- ...ltsPlugin.java => UrlsProviderPlugin.java} | 29 ++++-------------- .../jtreg/BuildReportExtendedPluginTest.java | 30 ++++++++++--------- 12 files changed, 80 insertions(+), 72 deletions(-) create mode 100644 report-jtreg-lib/src/main/java/io/jenkins/plugins/report/jtreg/model/UrlsProvider.java rename report-jtreg/src/main/java/io/jenkins/plugins/report/jtreg/model/{SuiteTestsWithResultsPlugin.java => UrlsProviderPlugin.java} (65%) diff --git a/report-jtreg-comparator/src/main/java/io/jenkins/plugins/report/jtreg/main/comparator/FailedTests.java b/report-jtreg-comparator/src/main/java/io/jenkins/plugins/report/jtreg/main/comparator/FailedTests.java index 24f263b1..260ee6d9 100644 --- a/report-jtreg-comparator/src/main/java/io/jenkins/plugins/report/jtreg/main/comparator/FailedTests.java +++ b/report-jtreg-comparator/src/main/java/io/jenkins/plugins/report/jtreg/main/comparator/FailedTests.java @@ -14,7 +14,7 @@ public class FailedTests { private static ArrayList getBuildFailedTests(File build, String exactTestsRegex, Formatter formatter) throws Exception { ArrayList failedTests = new ArrayList<>(); - BuildSummaryParser bs = new BuildSummaryParser(Arrays.asList("jck", "jtreg")); + BuildSummaryParser bs = new BuildSummaryParser(Arrays.asList("jck", "jtreg"), null); BuildReportExtended bex = bs.parseBuildReportExtended(new RunWrapperFromDir(build), null); SuitesWithResults swr = bex.getAllTests(); diff --git a/report-jtreg-diff/src/main/java/io/jenkins/plugins/report/jtreg/main/diff/CompareBuilds.java b/report-jtreg-diff/src/main/java/io/jenkins/plugins/report/jtreg/main/diff/CompareBuilds.java index f66e628f..fff59604 100644 --- a/report-jtreg-diff/src/main/java/io/jenkins/plugins/report/jtreg/main/diff/CompareBuilds.java +++ b/report-jtreg-diff/src/main/java/io/jenkins/plugins/report/jtreg/main/diff/CompareBuilds.java @@ -78,7 +78,7 @@ private void workImpl() throws IOException, Exception { if (i < options.getDirsToWork().size() - 1) { oldOne = options.getDirsToWork().get(i + 1); } - BuildSummaryParser bs = new BuildSummaryParser(Arrays.asList("jck", "jtreg")); + BuildSummaryParser bs = new BuildSummaryParser(Arrays.asList("jck", "jtreg"), null); BuildReport br = bs.parseJobReports(newOne); if (options.isInfo()) { diff --git a/report-jtreg-lib/src/main/java/io/jenkins/plugins/report/jtreg/BuildReportExtended.java b/report-jtreg-lib/src/main/java/io/jenkins/plugins/report/jtreg/BuildReportExtended.java index b522baa9..c40b0b5b 100644 --- a/report-jtreg-lib/src/main/java/io/jenkins/plugins/report/jtreg/BuildReportExtended.java +++ b/report-jtreg-lib/src/main/java/io/jenkins/plugins/report/jtreg/BuildReportExtended.java @@ -39,7 +39,7 @@ public class BuildReportExtended extends BuildReport { private final int total; private final int notRun; private final SuitesWithResults allTests; - private final String job; + protected final String job; public BuildReportExtended(int buildNumber, String buildName, int passed, int failed, int error, List suites, List addedSuites, List removedSuites, List testChanges, int total, int notRun, SuitesWithResults allTests, String job) { diff --git a/report-jtreg-lib/src/main/java/io/jenkins/plugins/report/jtreg/BuildSummaryParser.java b/report-jtreg-lib/src/main/java/io/jenkins/plugins/report/jtreg/BuildSummaryParser.java index 2b6b5ff9..f5e075b5 100644 --- a/report-jtreg-lib/src/main/java/io/jenkins/plugins/report/jtreg/BuildSummaryParser.java +++ b/report-jtreg-lib/src/main/java/io/jenkins/plugins/report/jtreg/BuildSummaryParser.java @@ -50,7 +50,7 @@ public class BuildSummaryParser { protected final Set prefixes = new HashSet<>(); protected BuildReportExtendedFactory buildReportExtendedFactory; - public BuildSummaryParser(Collection prefixes) { + public BuildSummaryParser(Collection prefixes, UrlsProvider urlsProvider) { if (prefixes == null || prefixes.isEmpty()) { throw new IllegalArgumentException("Prefixes cannot be null or empty"); } diff --git a/report-jtreg-lib/src/main/java/io/jenkins/plugins/report/jtreg/model/SuiteTestsWithResults.java b/report-jtreg-lib/src/main/java/io/jenkins/plugins/report/jtreg/model/SuiteTestsWithResults.java index c85f4576..2e67681e 100644 --- a/report-jtreg-lib/src/main/java/io/jenkins/plugins/report/jtreg/model/SuiteTestsWithResults.java +++ b/report-jtreg-lib/src/main/java/io/jenkins/plugins/report/jtreg/model/SuiteTestsWithResults.java @@ -24,7 +24,6 @@ package io.jenkins.plugins.report.jtreg.model; import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; -//import io.jenkins.plugins.report.jtreg.JenkinsReportJckGlobalConfig; import java.util.ArrayList; import java.util.List; @@ -34,6 +33,7 @@ public class SuiteTestsWithResults implements java.io.Serializable { private static final int MAX = 1000; private final String name; + private UrlsProvider urlsProvider; @SuppressFBWarnings(value = "SE_BAD_FIELD", justification = "should be internal implementation only, and thus ArrayList and that is serialisable") private final List tests; @@ -78,6 +78,21 @@ public String getSentence() { } } + + public void setUrlsProvider(UrlsProvider urlsProvider) { + this.urlsProvider = urlsProvider; + } + + private String getDiffUrlStub() { + return urlsProvider.getDiffServer() + "?generated-part=+-view%3Dall-tests+++-view%3Dinfo-summary+++-view%3Dinfo-summary" + + "-suites+++-output" + + "%3Dhtml++&custom-part=";//+job+number //eg as above; + } + + public String getLink() { + return getDiffUrlStub() + job + "+" + id; + } + public static class StringWithResult { private final String testName; diff --git a/report-jtreg-lib/src/main/java/io/jenkins/plugins/report/jtreg/model/SuitesWithResults.java b/report-jtreg-lib/src/main/java/io/jenkins/plugins/report/jtreg/model/SuitesWithResults.java index 8798c05a..a5e73c37 100644 --- a/report-jtreg-lib/src/main/java/io/jenkins/plugins/report/jtreg/model/SuitesWithResults.java +++ b/report-jtreg-lib/src/main/java/io/jenkins/plugins/report/jtreg/model/SuitesWithResults.java @@ -69,4 +69,9 @@ public List getAllTestsAndSuites() { return Collections.unmodifiableList(suitests); } + public void setUrlProviser(UrlsProvider urlsProvider) { + for(SuiteTestsWithResults suite: suitests) { + suite.setUrlsProvider(urlsProvider); + } + } } diff --git a/report-jtreg-lib/src/main/java/io/jenkins/plugins/report/jtreg/model/UrlsProvider.java b/report-jtreg-lib/src/main/java/io/jenkins/plugins/report/jtreg/model/UrlsProvider.java new file mode 100644 index 00000000..6abdc00b --- /dev/null +++ b/report-jtreg-lib/src/main/java/io/jenkins/plugins/report/jtreg/model/UrlsProvider.java @@ -0,0 +1,10 @@ +package io.jenkins.plugins.report.jtreg.model; + +import java.io.Serializable; + +public interface UrlsProvider extends Serializable { + + String getDiffServer(); + String getCompServer(); + +} diff --git a/report-jtreg/src/main/java/io/jenkins/plugins/report/jtreg/BuildReportExtendedPlugin.java b/report-jtreg/src/main/java/io/jenkins/plugins/report/jtreg/BuildReportExtendedPlugin.java index 42ac3c61..b2ab4c83 100644 --- a/report-jtreg/src/main/java/io/jenkins/plugins/report/jtreg/BuildReportExtendedPlugin.java +++ b/report-jtreg/src/main/java/io/jenkins/plugins/report/jtreg/BuildReportExtendedPlugin.java @@ -33,12 +33,15 @@ import java.util.regex.Pattern; public class BuildReportExtendedPlugin extends BuildReportExtended { - private final String job; + + private final UrlsProvider urlsProvider; public BuildReportExtendedPlugin(int buildNumber, String buildName, int passed, int failed, int error, List suites, - List addedSuites, List removedSuites, List testChanges, int total, int notRun, SuitesWithResults allTests, String job) { + List addedSuites, List removedSuites, List testChanges, int total, + int notRun, SuitesWithResults allTests, String job, UrlsProvider urlProvider) { super(buildNumber, buildName, passed, failed, error, suites, addedSuites, removedSuites, testChanges, total, notRun, allTests, job); - this.job = job; + this.urlsProvider = urlProvider; + allTests.setUrlProviser(urlsProvider); } public List getMatchedComparatorLinksGroups() { @@ -110,8 +113,8 @@ private String parseQueryToText(String spliterator, String query) { return converted; } - private static String getDiffUrlStub(){ - return SuiteTestsWithResultsPlugin.getDiffServer() + "?generated-part=+-view%3Ddiff-list+++-view%3Ddiff-summary+++-view%3Ddiff-summary-suites+++-view%3Dinfo-problems+++-view%3Dinfo-summary+++-output%3Dhtml++-fill++&custom-part=";//+job+numbers //eg as above; + private String getDiffUrlStub(){ + return urlsProvider.getDiffServer() + "?generated-part=+-view%3Ddiff-list+++-view%3Ddiff-summary+++-view%3Ddiff-summary-suites+++-view%3Dinfo-problems+++-view%3Dinfo-summary+++-output%3Dhtml++-fill++&custom-part=";//+job+numbers //eg as above; } public String getLinkDiff() { @@ -126,12 +129,12 @@ private int lowestBuildForFil() { } } - private static String getTracesUrlStub() { - return SuiteTestsWithResultsPlugin.getDiffServer() + "?generated-part=+-view%3Dinfo+++-output%3Dhtml++&custom-part=";//+job+numbers //eg as above; + private String getTracesUrlStub() { + return urlsProvider.getDiffServer() + "?generated-part=+-view%3Dinfo+++-output%3Dhtml++&custom-part=";//+job+numbers //eg as above; } - public static String getCompUrlStub() { - return SuiteTestsWithResultsPlugin.getCompServer() + "?generated-part=&custom-part="; + public String getCompUrlStub() { + return urlsProvider.getCompServer() + "?generated-part=&custom-part="; } public String getLinkTraces() { @@ -142,8 +145,8 @@ public boolean isDiffTool() { return JenkinsReportJckGlobalConfig.isGlobalDiffUrl(); } - private static String createDiffUrl() { - return SuiteTestsWithResultsPlugin.getDiffServer() + "?generated-part=+-view%3Dall-tests+++-output%3Dhtml++-fill++"; + private String createDiffUrl() { + return urlsProvider.getDiffServer() + "?generated-part=+-view%3Dall-tests+++-output%3Dhtml++-fill++"; } public String getTrackingUrl(Test test) { diff --git a/report-jtreg/src/main/java/io/jenkins/plugins/report/jtreg/BuildReportExtendedPluginFactory.java b/report-jtreg/src/main/java/io/jenkins/plugins/report/jtreg/BuildReportExtendedPluginFactory.java index 8f084a14..69792a89 100644 --- a/report-jtreg/src/main/java/io/jenkins/plugins/report/jtreg/BuildReportExtendedPluginFactory.java +++ b/report-jtreg/src/main/java/io/jenkins/plugins/report/jtreg/BuildReportExtendedPluginFactory.java @@ -3,15 +3,21 @@ import io.jenkins.plugins.report.jtreg.model.Suite; import io.jenkins.plugins.report.jtreg.model.SuiteTestChanges; import io.jenkins.plugins.report.jtreg.model.SuitesWithResults; +import io.jenkins.plugins.report.jtreg.model.UrlsProvider; +import io.jenkins.plugins.report.jtreg.model.UrlsProviderPlugin; import java.util.List; public class BuildReportExtendedPluginFactory extends BuildReportExtendedFactory { + + private static final UrlsProvider urlsProvider= new UrlsProviderPlugin(); + @Override public BuildReportExtended createBuildReportExtended(int buildNumber, String buildName, int passed, int failed, int error, List suites, List addedSuites, List removedSuites, List testChanges, int total, int notRun, SuitesWithResults allTests, String job) { - return new BuildReportExtendedPlugin(buildNumber, buildName, passed, failed, error, suites, addedSuites, removedSuites, testChanges, total, notRun, allTests, job); + return new BuildReportExtendedPlugin(buildNumber, buildName, passed, failed, error, suites, addedSuites, removedSuites, + testChanges, total, notRun, allTests, job, urlsProvider); } } diff --git a/report-jtreg/src/main/java/io/jenkins/plugins/report/jtreg/BuildSummaryParserPlugin.java b/report-jtreg/src/main/java/io/jenkins/plugins/report/jtreg/BuildSummaryParserPlugin.java index ad0b8c45..8e5ecbaf 100644 --- a/report-jtreg/src/main/java/io/jenkins/plugins/report/jtreg/BuildSummaryParserPlugin.java +++ b/report-jtreg/src/main/java/io/jenkins/plugins/report/jtreg/BuildSummaryParserPlugin.java @@ -23,9 +23,6 @@ */ package io.jenkins.plugins.report.jtreg; -import com.google.gson.Gson; -import com.google.gson.reflect.TypeToken; - import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; import hudson.model.AbstractBuild; import hudson.model.AbstractProject; @@ -34,29 +31,16 @@ import hudson.model.Run; import io.jenkins.plugins.report.jtreg.model.*; -import java.io.BufferedInputStream; -import java.io.File; -import java.io.FileInputStream; -import java.io.InputStreamReader; -import java.io.Reader; -import java.nio.charset.StandardCharsets; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; -import java.util.HashSet; import java.util.List; -import java.util.Map; -import java.util.Objects; -import java.util.Set; -import java.util.stream.Collectors; - -import io.jenkins.plugins.report.jtreg.wrappers.RunWrapper; -import io.jenkins.plugins.report.jtreg.wrappers.RunWrapperFromDir; import io.jenkins.plugins.report.jtreg.wrappers.RunWrapperFromRun; import hudson.util.RunList; public class BuildSummaryParserPlugin extends BuildSummaryParser { + private static final UrlsProvider urlsProvider= new UrlsProviderPlugin(); private static interface ListProvider { String getList(); @@ -66,7 +50,7 @@ private static interface ListProvider { private final AbstractReportPublisher settings; public BuildSummaryParserPlugin(Collection prefixes, AbstractReportPublisher settings) { - super(prefixes); + super(prefixes, urlsProvider); this.prefixes.addAll(prefixes); this.settings = settings; this.buildReportExtendedFactory = new BuildReportExtendedPluginFactory(); diff --git a/report-jtreg/src/main/java/io/jenkins/plugins/report/jtreg/model/SuiteTestsWithResultsPlugin.java b/report-jtreg/src/main/java/io/jenkins/plugins/report/jtreg/model/UrlsProviderPlugin.java similarity index 65% rename from report-jtreg/src/main/java/io/jenkins/plugins/report/jtreg/model/SuiteTestsWithResultsPlugin.java rename to report-jtreg/src/main/java/io/jenkins/plugins/report/jtreg/model/UrlsProviderPlugin.java index 9b500205..c659d1b4 100644 --- a/report-jtreg/src/main/java/io/jenkins/plugins/report/jtreg/model/SuiteTestsWithResultsPlugin.java +++ b/report-jtreg/src/main/java/io/jenkins/plugins/report/jtreg/model/UrlsProviderPlugin.java @@ -25,31 +25,14 @@ import io.jenkins.plugins.report.jtreg.JenkinsReportJckGlobalConfig; -import java.util.List; +public final class UrlsProviderPlugin implements UrlsProvider { -public class SuiteTestsWithResultsPlugin extends SuiteTestsWithResults { - - public static String getDiffServer() { + @Override + public String getDiffServer() { return JenkinsReportJckGlobalConfig.getGlobalDiffUrl() + "/diff.html"; } - public static String getCompServer() { + @Override + public String getCompServer() { return JenkinsReportJckGlobalConfig.getGlobalDiffUrl() + "/comp.html"; } - - private static String getDiffUrlStub() { - return getDiffServer() + "?generated-part=+-view%3Dall-tests+++-view%3Dinfo-summary+++-view%3Dinfo-summary-suites+++-output%3Dhtml++&custom-part=";//+job+number //eg as above; - } - - private final String job; - private final int id; - - public SuiteTestsWithResultsPlugin(String name, List tests, String job, int id) { - super(name, tests, job, id); - this.job = job; - this.id = id; - } - - public String getLink() { - return getDiffUrlStub() + job + "+" + id; - } -} \ No newline at end of file + } \ No newline at end of file diff --git a/report-jtreg/src/test/java/io/jenkins/plugins/report/jtreg/BuildReportExtendedPluginTest.java b/report-jtreg/src/test/java/io/jenkins/plugins/report/jtreg/BuildReportExtendedPluginTest.java index 8c870a82..d643e203 100644 --- a/report-jtreg/src/test/java/io/jenkins/plugins/report/jtreg/BuildReportExtendedPluginTest.java +++ b/report-jtreg/src/test/java/io/jenkins/plugins/report/jtreg/BuildReportExtendedPluginTest.java @@ -4,6 +4,8 @@ import io.jenkins.plugins.report.jtreg.model.SuiteTestChanges; import io.jenkins.plugins.report.jtreg.model.SuiteTestsWithResults; import io.jenkins.plugins.report.jtreg.model.SuitesWithResults; +import io.jenkins.plugins.report.jtreg.model.UrlsProvider; + import org.junit.Assert; import java.util.ArrayList; @@ -11,21 +13,21 @@ public class BuildReportExtendedPluginTest { @org.junit.Test public void getMatchedComparatorLinksGroupsTest() { - BuildReportExtendedPlugin bre = new BuildReportExtendedPlugin( - 0, - "", - 0, - 0, - 0, - new ArrayList(), - new ArrayList(), - new ArrayList(), - new ArrayList(), - 0, - 0, + BuildReportExtendedPlugin bre = new BuildReportExtendedPlugin(0, "", 0, 0, 0, new ArrayList(), new ArrayList(), + new ArrayList(), new ArrayList(), 0, 0, new SuitesWithResults(new ArrayList()), - "tck-jp17-ojdk17~rpms-el8.aarch64-fastdebug.sdk-el8.aarch64.beaker-x11.defaultgc.fips.lnxagent.jfroff" - ); + "tck-jp17-ojdk17~rpms-el8.aarch64-fastdebug.sdk-el8.aarch64.beaker-x11.defaultgc.fips.lnxagent.jfroff", + new UrlsProvider() { + @Override + public String getDiffServer() { + return "http://mylocal/diff.html"; + } + + @Override + public String getCompServer() { + return "http://mylocal/comp.html"; + } + }); // arguments without any wildcard LinkToComparator ltc = new LinkToComparator("", "[.-]", "--arguments\n--without\n--any\n--wildcard"); From 43d4e9997f4c98b9605d8d7c2277f408dfba0c93 Mon Sep 17 00:00:00 2001 From: Jiri Vanek Date: Thu, 30 Nov 2023 14:54:49 +0100 Subject: [PATCH 2/2] fixed NPE from new global config Note, that I'm not sure if it is fix or workaround. Not, that it misbehaved for me completly - the items added in config could not be removed in 2.434(.1) STS jenkins renamed settings to jtreg as it should be --- .../plugins/report/jtreg/JenkinsReportJckGlobalConfig.java | 5 +++-- .../report/jtreg/JenkinsReportJckGlobalConfig/config.jelly | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/report-jtreg/src/main/java/io/jenkins/plugins/report/jtreg/JenkinsReportJckGlobalConfig.java b/report-jtreg/src/main/java/io/jenkins/plugins/report/jtreg/JenkinsReportJckGlobalConfig.java index 20254098..94b80bcb 100644 --- a/report-jtreg/src/main/java/io/jenkins/plugins/report/jtreg/JenkinsReportJckGlobalConfig.java +++ b/report-jtreg/src/main/java/io/jenkins/plugins/report/jtreg/JenkinsReportJckGlobalConfig.java @@ -7,6 +7,7 @@ import org.kohsuke.stapler.DataBoundSetter; import org.kohsuke.stapler.StaplerRequest; +import java.util.ArrayList; import java.util.List; import java.util.logging.Logger; @@ -18,8 +19,8 @@ public class JenkinsReportJckGlobalConfig extends GlobalConfiguration { private static Logger logger = Logger.getLogger(JenkinsReportJckGlobalConfig.class.getName()); String diffToolUrl; - List comparatorLinksGroups; - List configItems; + List comparatorLinksGroups = new ArrayList<>(); + List configItems = new ArrayList<>(); public static JenkinsReportJckGlobalConfig getInstance() { return GlobalConfiguration.all().get(JenkinsReportJckGlobalConfig.class); diff --git a/report-jtreg/src/main/resources/io/jenkins/plugins/report/jtreg/JenkinsReportJckGlobalConfig/config.jelly b/report-jtreg/src/main/resources/io/jenkins/plugins/report/jtreg/JenkinsReportJckGlobalConfig/config.jelly index 7226094b..e74730f6 100644 --- a/report-jtreg/src/main/resources/io/jenkins/plugins/report/jtreg/JenkinsReportJckGlobalConfig/config.jelly +++ b/report-jtreg/src/main/resources/io/jenkins/plugins/report/jtreg/JenkinsReportJckGlobalConfig/config.jelly @@ -1,6 +1,6 @@ - +