Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed links of web ui elements #17

Merged
merged 2 commits into from
Dec 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public class FailedTests {
private static ArrayList<String> getBuildFailedTests(File build, String exactTestsRegex, Formatter formatter) throws Exception {
ArrayList<String> 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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<Suite> suites,
List<String> addedSuites, List<String> removedSuites, List<SuiteTestChanges> testChanges, int total, int notRun, SuitesWithResults allTests, String job) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public class BuildSummaryParser {
protected final Set<String> prefixes = new HashSet<>();
protected BuildReportExtendedFactory buildReportExtendedFactory;

public BuildSummaryParser(Collection<String> prefixes) {
public BuildSummaryParser(Collection<String> prefixes, UrlsProvider urlsProvider) {
if (prefixes == null || prefixes.isEmpty()) {
throw new IllegalArgumentException("Prefixes cannot be null or empty");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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<StringWithResult> tests;
Expand Down Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,4 +69,9 @@ public List<SuiteTestsWithResults> getAllTestsAndSuites() {
return Collections.unmodifiableList(suitests);
}

public void setUrlProviser(UrlsProvider urlsProvider) {
for(SuiteTestsWithResults suite: suitests) {
suite.setUrlsProvider(urlsProvider);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package io.jenkins.plugins.report.jtreg.model;

import java.io.Serializable;

public interface UrlsProvider extends Serializable {

String getDiffServer();
String getCompServer();

}
Original file line number Diff line number Diff line change
Expand Up @@ -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<Suite> suites,
List<String> addedSuites, List<String> removedSuites, List<SuiteTestChanges> testChanges, int total, int notRun, SuitesWithResults allTests, String job) {
List<String> addedSuites, List<String> removedSuites, List<SuiteTestChanges> 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<ComparatorLinksGroup> getMatchedComparatorLinksGroups() {
Expand Down Expand Up @@ -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() {
Expand All @@ -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() {
Expand All @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<Suite> suites, List<String> addedSuites,
List<String> removedSuites, List<SuiteTestChanges> 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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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();
Expand All @@ -66,7 +50,7 @@ private static interface ListProvider {
private final AbstractReportPublisher settings;

public BuildSummaryParserPlugin(Collection<String> prefixes, AbstractReportPublisher settings) {
super(prefixes);
super(prefixes, urlsProvider);
this.prefixes.addAll(prefixes);
this.settings = settings;
this.buildReportExtendedFactory = new BuildReportExtendedPluginFactory();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -18,8 +19,8 @@ public class JenkinsReportJckGlobalConfig extends GlobalConfiguration {
private static Logger logger = Logger.getLogger(JenkinsReportJckGlobalConfig.class.getName());

String diffToolUrl;
List<ComparatorLinksGroup> comparatorLinksGroups;
List<ConfigItem> configItems;
List<ComparatorLinksGroup> comparatorLinksGroups = new ArrayList<>();
List<ConfigItem> configItems = new ArrayList<>();

public static JenkinsReportJckGlobalConfig getInstance() {
return GlobalConfiguration.all().get(JenkinsReportJckGlobalConfig.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<StringWithResult> tests, String job, int id) {
super(name, tests, job, id);
this.job = job;
this.id = id;
}

public String getLink() {
return getDiffUrlStub() + job + "+" + id;
}
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?jelly escape-by-default='true'?>
<j:jelly xmlns:j="jelly:core" xmlns:f="/lib/form">
<f:section title="Jenkins Report Jck Plugin">
<f:section title="Jenkins Report Jtreg Plugin">
<f:entry title="Diff-tool url (eg http://server.my:9090)" field="diffToolUrl">
<f:textbox/>
</f:entry>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,28 +4,30 @@
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;

public class BuildReportExtendedPluginTest {
@org.junit.Test
public void getMatchedComparatorLinksGroupsTest() {
BuildReportExtendedPlugin bre = new BuildReportExtendedPlugin(
0,
"",
0,
0,
0,
new ArrayList<Suite>(),
new ArrayList<String>(),
new ArrayList<String>(),
new ArrayList<SuiteTestChanges>(),
0,
0,
BuildReportExtendedPlugin bre = new BuildReportExtendedPlugin(0, "", 0, 0, 0, new ArrayList<Suite>(), new ArrayList<String>(),
new ArrayList<String>(), new ArrayList<SuiteTestChanges>(), 0, 0,
new SuitesWithResults(new ArrayList<SuiteTestsWithResults>()),
"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");
Expand Down
Loading