diff --git a/src/main/java/hudson/plugins/performance/PerformancePublisher.java b/src/main/java/hudson/plugins/performance/PerformancePublisher.java index 29162976..eeccda24 100644 --- a/src/main/java/hudson/plugins/performance/PerformancePublisher.java +++ b/src/main/java/hudson/plugins/performance/PerformancePublisher.java @@ -1,6 +1,11 @@ package hudson.plugins.performance; -import java.io.*; +import java.io.BufferedWriter; +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.OutputStreamWriter; +import java.io.PrintStream; import java.nio.charset.StandardCharsets; import java.util.ArrayList; import java.util.Arrays; @@ -13,14 +18,13 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; -import edu.umd.cs.findbugs.annotations.NonNull; - import org.jenkinsci.Symbol; import org.kohsuke.accmod.Restricted; import org.kohsuke.accmod.restrictions.NoExternalUse; import org.kohsuke.stapler.DataBoundConstructor; import org.kohsuke.stapler.DataBoundSetter; +import edu.umd.cs.findbugs.annotations.NonNull; import hudson.EnvVars; import hudson.Extension; import hudson.FilePath; @@ -202,8 +206,8 @@ public PerformancePublisher(String sourceDataFiles, boolean modeThroughput, boolean showTrendGraphs, /** - * Deprecated. Now use for support previous pipeline jobs. - */ + * Deprecated. Now use for support previous pipeline jobs. + */ List parsers) { this.parsers = parsers; this.sourceDataFiles = sourceDataFiles; @@ -280,10 +284,10 @@ protected static List locatePerformanceReports(FilePath workspace, Str throws IOException, InterruptedException { // First use ant-style pattern - /* - * try { FilePath[] ret = workspace.list(includes); if (ret.length > 0) { - * return Arrays.asList(ret); } - */ + /* + * try { FilePath[] ret = workspace.list(includes); if (ret.length > 0) { + * return Arrays.asList(ret); } + */ // Agoley : Possible fix, if we specify more than one result file pattern try { String[] parts = includes.split("\\s*[;:,]+\\s*"); @@ -470,7 +474,7 @@ private Collection locatePerformanceReports(Run run, Fi return Collections.emptyList(); } - logger.println("Performance: " + parser.getReportName() + " copying reports to master, files '" + files+"'"); + logger.println("Performance: " + parser.getReportName() + " copying reports to master, files '" + files + "'"); List localReports = copyReportsToMaster(run, logger, files, parser.getDescriptor().getDisplayName()); logger.println("Performance: " + parser.getReportName() + " parsing local reports '" + localReports + "'"); @@ -491,7 +495,7 @@ private void prepareParsers(Collection performanceRepor } protected List getBuildUriReports(Run build, FilePath workspace, TaskListener listener, - List parsers, boolean locatePerformanceReports) + List parsers, boolean locatePerformanceReports) throws IOException, InterruptedException { List uriReports = new ArrayList<>(); @@ -632,6 +636,7 @@ private String appendStandardResultsStatsToXml(Collection rep xmlSB.append("").append(report.getMin()).append("\n\t"); xmlSB.append("").append(report.getMedian()).append("\n\t"); xmlSB.append("").append(report.get90Line()).append("\n\t"); + xmlSB.append("").append(report.get95Line()).append("\n\t"); xmlSB.append("").append(report.getMax()).append("\n\t"); xmlSB.append("").append(report.getHttpCode()).append("\n\t"); xmlSB.append("").append(report.errorPercent()).append("\n"); @@ -644,7 +649,7 @@ private String appendStandardResultsStatsToXml(Collection rep // write report in xml, when checked Error Threshold comparison private void writeErrorThresholdReportInXML(Run run, PerformanceReport performanceReport) throws IOException { File xmlDirectory = createArchiveDirectoryIfMissing(run); - + String glob = performanceReport.getReportFileName(); String[] arr = glob.split("/"); @@ -685,6 +690,10 @@ private String appendStatsToXml(List reports) { percentileBuffer.append("\t\t").append(uriReport.get90Line()).append("\n"); percentileBuffer.append("\t\n"); + percentileBuffer.append("\t<").append(uriReport.getStaplerUri()).append(">\n"); + percentileBuffer.append("\t\t").append(uriReport.get95Line()).append("\n"); + percentileBuffer.append("\t\n"); + } averageBuffer.append("\n"); @@ -745,7 +754,7 @@ public void compareWithRelativeThreshold(Run run, FilePath workspace, Task maxUriColumnWidth = Math.max(report.getStaplerUri().length(), maxUriColumnWidth); } - printInfoAboutCompareBasedOn(logger, "%-"+maxUriColumnWidth+"s%20s%20s%20s%20s"); + printInfoAboutCompareBasedOn(logger, "%-" + maxUriColumnWidth + "s%20s%20s%20s%20s"); compareUriReports(run, currentUriReports, @@ -756,7 +765,7 @@ public void compareWithRelativeThreshold(Run run, FilePath workspace, Task (averageBuffer = new StringBuilder("\n")), (medianBuffer = new StringBuilder("\n")), (percentileBuffer = new StringBuilder("\n")), - "%1$-"+maxUriColumnWidth+"s%2$20d%3$20d%4$20.0f%5$19.2f%%" + "%1$-" + maxUriColumnWidth + "s%2$20d%3$20d%4$20.0f%5$19.2f%%" ); // close xml tags @@ -827,7 +836,7 @@ private void calculateBuildStatus(Run run, PrintStream logger, String stap } private double calculateDiffInPercents(double value1, double value2) { - return Math.round(SafeMaths.safeDivide(value1 * 100, value2) * 100) / 100d; + return Math.round(SafeMaths.safeDivide(value1 * 100, value2) * 100) / 100d; } private boolean calculateRelativeFailedThresholdNegative(double relativeDiffPercent) { @@ -859,24 +868,24 @@ private double calculateRelativeDiffInPercent(UriReport currentReport, UriReport relativeDiffPercent = calculateDiffInPercents(relativeDiff, reportForComparison.getAverage()); logger.println(String.format(logFormat, reportForComparison.getStaplerUri(), - reportForComparison.getAverage(), currentReport.getAverage(), - relativeDiff, relativeDiffPercent)); + reportForComparison.getAverage(), currentReport.getAverage(), + relativeDiff, relativeDiffPercent)); } else if (configType.equalsIgnoreCase("MRT")) { relativeDiff = (double) currentReport.getMedian() - reportForComparison.getMedian(); relativeDiffPercent = calculateDiffInPercents(relativeDiff, reportForComparison.getMedian()); logger.println(String.format(logFormat, reportForComparison.getStaplerUri(), - reportForComparison.getMedian(), currentReport.getMedian(), - relativeDiff, relativeDiffPercent)); + reportForComparison.getMedian(), currentReport.getMedian(), + relativeDiff, relativeDiffPercent)); } else if (configType.equalsIgnoreCase("PRT")) { relativeDiff = (double) currentReport.get90Line() - reportForComparison.get90Line(); relativeDiffPercent = calculateDiffInPercents(relativeDiff, reportForComparison.get90Line()); logger.println(String.format(logFormat, reportForComparison.getStaplerUri(), - reportForComparison.get90Line(), currentReport.get90Line(), - relativeDiff, relativeDiffPercent)); + reportForComparison.get90Line(), currentReport.get90Line(), + relativeDiff, relativeDiffPercent)); } return relativeDiffPercent; } @@ -928,7 +937,7 @@ private void writeRelativeThresholdReportInXML(Run run, StringBuilder aver private File createArchiveDirectoryIfMissing(Run run) { File xmlDirectory = new File(run.getRootDir(), ARCHIVE_DIRECTORY); if (!xmlDirectory.exists() && !xmlDirectory.mkdirs()) { - throw new IllegalStateException("Could not create archive directory "+xmlDirectory.getAbsolutePath()); + throw new IllegalStateException("Could not create archive directory " + xmlDirectory.getAbsolutePath()); } return xmlDirectory; } @@ -1015,15 +1024,15 @@ private void printInfoAboutCompareBasedOn(PrintStream logger, String logFormat) if (configType.equalsIgnoreCase("ART")) { logger.println("Average response time\n\n"); logger.println(String.format(logFormat, - "URI", "PrevBuildURIAvg", "CurrentBuildURIAvg", "RelativeDiff", "RelativeDiff(%)")); + "URI", "PrevBuildURIAvg", "CurrentBuildURIAvg", "RelativeDiff", "RelativeDiff(%)")); } else if (configType.equalsIgnoreCase("MRT")) { logger.println("Median response time\n\n"); logger.println(String.format(logFormat, - "URI", "PrevBuildURIMed", "CurrentBuildURIMed", "RelativeDiff", "RelativeDiff(%)")); + "URI", "PrevBuildURIMed", "CurrentBuildURIMed", "RelativeDiff", "RelativeDiff(%)")); } else if (configType.equalsIgnoreCase("PRT")) { logger.println("90 Percentile response time\n\n"); logger.println(String.format(logFormat, - "URI", "PrevBuildURI90%", "CurrentBuildURI90%", "RelativeDiff", "RelativeDiff(%)")); + "URI", "PrevBuildURI90%", "CurrentBuildURI90%", "RelativeDiff", "RelativeDiff(%)")); } } @@ -1047,16 +1056,16 @@ public void evaluateInExpertMode(Run run, FilePath workspace, TaskListener */ ConstraintReport cr = new ConstraintReport(ceList, run.getParent().getBuilds().iterator().next(), persistConstraintLog); logger.print(cr.getLoggerMsg()); - /* - * Determine build result - */ + /* + * Determine build result + */ run.setResult(cr.getBuildResult()); - /* - * Write JUnit report back to workspace, for other post-build actions to pick up - */ + /* + * Write JUnit report back to workspace, for other post-build actions to pick up + */ if (junitOutput != null && !junitOutput.isEmpty()) { - listener.getLogger().println("Performance: Generating JUnit output: "+junitOutput); + listener.getLogger().println("Performance: Generating JUnit output: " + junitOutput); FilePath output = new FilePath(workspace, junitOutput); FilePath parent = output.getParent(); if (parent != null) { @@ -1170,7 +1179,6 @@ public static File[] getPerformanceReportDirectory(Run build, String parse * Gets the Build object entered in the text box "Compare with nth Build" * * @param build, listener - * * @return build object */ diff --git a/src/main/java/hudson/plugins/performance/actions/PerformanceProjectAction.java b/src/main/java/hudson/plugins/performance/actions/PerformanceProjectAction.java index 1d183e08..61dbde1c 100644 --- a/src/main/java/hudson/plugins/performance/actions/PerformanceProjectAction.java +++ b/src/main/java/hudson/plugins/performance/actions/PerformanceProjectAction.java @@ -1,28 +1,20 @@ package hudson.plugins.performance.actions; -import hudson.FilePath; -import hudson.model.AbstractBuild; -import hudson.model.AbstractProject; -import hudson.model.Action; -import hudson.model.Job; -import hudson.model.Run; -import hudson.plugins.performance.Messages; -import hudson.plugins.performance.PerformancePublisher; -import hudson.plugins.performance.PerformanceReportMap; -import hudson.plugins.performance.data.PerformanceReportPosition; -import hudson.plugins.performance.data.ReportValueSelector; -import hudson.plugins.performance.details.GraphConfigurationDetail; -import hudson.plugins.performance.details.TestSuiteReportDetail; -import hudson.plugins.performance.details.TrendReportDetail; -import hudson.plugins.performance.reports.PerformanceReport; -import hudson.plugins.performance.reports.UriReport; -import hudson.plugins.performance.reports.ThroughputReport; -import hudson.util.ChartUtil; -import hudson.util.ChartUtil.NumberOnlyBuildLabel; -import hudson.util.ColorPalette; -import hudson.util.DataSetBuilder; -import hudson.util.Graph; -import hudson.util.ShiftedCategoryAxis; +import java.awt.BasicStroke; +import java.awt.Color; +import java.io.File; +import java.io.IOException; +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Collections; +import java.util.GregorianCalendar; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.logging.Level; +import java.util.logging.Logger; + import org.jfree.chart.ChartFactory; import org.jfree.chart.JFreeChart; import org.jfree.chart.axis.CategoryAxis; @@ -47,16 +39,29 @@ import org.kohsuke.stapler.StaplerResponse; import edu.umd.cs.findbugs.annotations.NonNull; - -import java.awt.*; -import java.io.File; -import java.io.IOException; -import java.text.ParseException; -import java.text.SimpleDateFormat; -import java.util.*; -import java.util.List; -import java.util.logging.Level; -import java.util.logging.Logger; +import hudson.FilePath; +import hudson.model.AbstractBuild; +import hudson.model.AbstractProject; +import hudson.model.Action; +import hudson.model.Job; +import hudson.model.Run; +import hudson.plugins.performance.Messages; +import hudson.plugins.performance.PerformancePublisher; +import hudson.plugins.performance.PerformanceReportMap; +import hudson.plugins.performance.data.PerformanceReportPosition; +import hudson.plugins.performance.data.ReportValueSelector; +import hudson.plugins.performance.details.GraphConfigurationDetail; +import hudson.plugins.performance.details.TestSuiteReportDetail; +import hudson.plugins.performance.details.TrendReportDetail; +import hudson.plugins.performance.reports.PerformanceReport; +import hudson.plugins.performance.reports.ThroughputReport; +import hudson.plugins.performance.reports.UriReport; +import hudson.util.ChartUtil; +import hudson.util.ChartUtil.NumberOnlyBuildLabel; +import hudson.util.ColorPalette; +import hudson.util.DataSetBuilder; +import hudson.util.Graph; +import hudson.util.ShiftedCategoryAxis; public class PerformanceProjectAction implements Action { @@ -535,6 +540,8 @@ public void doRespondingTimeGraph(StaplerRequest request, StaplerResponse respon Messages.ProjectAction_Average(), label); dataSetBuilderAverage.add(performanceReport.get90Line(), Messages.ProjectAction_Line90(), label); + dataSetBuilderAverage.add(performanceReport.get95Line(), + Messages.ProjectAction_Line95(), label); } nbBuildsToAnalyze--; } diff --git a/src/main/java/hudson/plugins/performance/constraints/AbstractConstraint.java b/src/main/java/hudson/plugins/performance/constraints/AbstractConstraint.java index d5a49f1e..2037df1a 100644 --- a/src/main/java/hudson/plugins/performance/constraints/AbstractConstraint.java +++ b/src/main/java/hudson/plugins/performance/constraints/AbstractConstraint.java @@ -123,6 +123,8 @@ protected double checkMetredValueforUriReport(Metric meteredValue, UriReport ur) return (double) ur.getAverage(); case LINE90: return (double) ur.get90Line(); + case LINE95: + return (double) ur.get95Line(); case MEDIAN: return (double) ur.getMedian(); case MINIMUM: @@ -149,6 +151,8 @@ protected double checkMetredValueforPerfReport(Metric meteredValue, PerformanceR return (double) pr.getAverage(); case LINE90: return (double) pr.get90Line(); + case LINE95: + return (double) pr.get95Line(); case MEDIAN: return (double) pr.getMedian(); case MINIMUM: @@ -214,7 +218,7 @@ protected void checkForDefectiveParams(List> builds) throws } public enum Metric { - AVERAGE("Average", false), MEDIAN("Median", false), LINE90("90% Line", false), MAXIMUM("Maximum", false), MINIMUM("Minimum", false), ERRORPRC("Error %", false); + AVERAGE("Average", false), MEDIAN("Median", false), LINE90("90% Line", false), LINE95("95% Line", false), MAXIMUM("Maximum", false), MINIMUM("Minimum", false), ERRORPRC("Error %", false); private final String text; private final boolean isSelected; diff --git a/src/main/java/hudson/plugins/performance/data/TaurusFinalStats.java b/src/main/java/hudson/plugins/performance/data/TaurusFinalStats.java index f606c49d..ffb8efb1 100644 --- a/src/main/java/hudson/plugins/performance/data/TaurusFinalStats.java +++ b/src/main/java/hudson/plugins/performance/data/TaurusFinalStats.java @@ -18,6 +18,7 @@ public class TaurusFinalStats implements Serializable { private double perc0; private double perc50; private double perc90; + private double perc95; private double perc100; private Double testDuration; @@ -77,10 +78,18 @@ public double getPerc90() { return perc90; } + public double getPerc95() { + return perc95; + } + public void setPerc90(double perc90) { this.perc90 = perc90; } + public void setPerc95(double perc95) { + this.perc95 = perc95; + } + public double getPerc0() { return perc0; } diff --git a/src/main/java/hudson/plugins/performance/parsers/TaurusParser.java b/src/main/java/hudson/plugins/performance/parsers/TaurusParser.java index 8d286d0d..8cb6b7ca 100644 --- a/src/main/java/hudson/plugins/performance/parsers/TaurusParser.java +++ b/src/main/java/hudson/plugins/performance/parsers/TaurusParser.java @@ -1,20 +1,18 @@ package hudson.plugins.performance.parsers; -import java.io.File; - -import javax.xml.parsers.DocumentBuilder; -import javax.xml.parsers.DocumentBuilderFactory; - +import hudson.Extension; +import hudson.plugins.performance.data.TaurusFinalStats; +import hudson.plugins.performance.descriptors.PerformanceReportParserDescriptor; +import hudson.plugins.performance.reports.PerformanceReport; import org.kohsuke.stapler.DataBoundConstructor; import org.w3c.dom.Document; import org.w3c.dom.Element; import org.w3c.dom.Node; import org.w3c.dom.NodeList; -import hudson.Extension; -import hudson.plugins.performance.data.TaurusFinalStats; -import hudson.plugins.performance.descriptors.PerformanceReportParserDescriptor; -import hudson.plugins.performance.reports.PerformanceReport; +import javax.xml.parsers.DocumentBuilder; +import javax.xml.parsers.DocumentBuilderFactory; +import java.io.File; /** * Parser for Taurus @@ -32,7 +30,7 @@ public String getDisplayName() { public TaurusParser(String glob, String percentiles) { super(glob, percentiles, PerformanceReport.INCLUDE_ALL); } - + @DataBoundConstructor public TaurusParser(String glob, String percentiles, String filterRegex) { super(glob, percentiles, filterRegex); @@ -105,13 +103,14 @@ private TaurusFinalStats getTaurusFinalStats(Element group) { for (int i = 0; i < perc.getLength(); i++) { Node nNode = perc.item(i); String attributeParam = ((Element) nNode).getAttribute("param"); - double valueInMs; - valueInMs = Double.parseDouble(((Element) nNode).getAttribute("value")) * 1000; + Double valueInMs = Double.valueOf(((Element) nNode).getAttribute("value")) * 1000; if ("50.0".equals(attributeParam)) { report.setPerc50(valueInMs); // to ms } else if ("90.0".equals(attributeParam)) { report.setPerc90(valueInMs); // to ms + } else if ("95.0".equals(attributeParam)) { + report.setPerc95(valueInMs); // to ms } else if ("0.0".equals(attributeParam)) { report.setPerc0(valueInMs); // to ms } else if ("100.0".equals(attributeParam)) { diff --git a/src/main/java/hudson/plugins/performance/reports/AbstractReport.java b/src/main/java/hudson/plugins/performance/reports/AbstractReport.java index 5da531d9..5ce2b05b 100644 --- a/src/main/java/hudson/plugins/performance/reports/AbstractReport.java +++ b/src/main/java/hudson/plugins/performance/reports/AbstractReport.java @@ -1,5 +1,9 @@ package hudson.plugins.performance.reports; +import hudson.plugins.performance.data.HttpSample; +import org.apache.commons.lang.StringUtils; +import org.kohsuke.stapler.Stapler; + import java.text.DecimalFormat; import java.text.DecimalFormatSymbols; import java.util.ArrayList; @@ -10,21 +14,17 @@ import java.util.logging.Level; import java.util.logging.Logger; -import org.apache.commons.lang.StringUtils; -import org.kohsuke.stapler.Stapler; - -import hudson.plugins.performance.data.HttpSample; - /** - * Abstract class for classes with samplesCount, error, mean, average, 90 line, min and max attributes + * Abstract class for classes with samplesCount, error, mean, average, 90 line, 95 line, min and max attributes */ public abstract class AbstractReport { public static final Logger LOGGER = Logger.getLogger(AbstractReport.class.getName()); public static final double ZERO_PERCENT = 0; public static final double ONE_HUNDRED_PERCENT = 100; public static final double NINETY_PERCENT = 90; + public static final double NINETY_FIVE_PERCENT = 95; public static final double FIFTY_PERCENT = 50; - public static final String DEFAULT_PERCENTILES = "0,50,90,100"; + public static final String DEFAULT_PERCENTILES = "0,50,90,95,100"; protected final ThreadLocal percentFormat; protected final ThreadLocal dataFormat; // three decimals @@ -113,6 +113,12 @@ public String get90LineFormated() { return dataFormat.get().format(get90Line()); } + public abstract long get95Line(); + + public String get95LineFormated() { + return dataFormat.get().format(get95Line()); + } + public abstract long getMax(); public String getMaxFormated() { @@ -131,6 +137,8 @@ public String getMaxFormated() { public abstract long get90LineDiff(); + public abstract long get95LineDiff(); + public abstract double getErrorPercentDiff(); public abstract String getLastBuildHttpCodeIfChanged(); diff --git a/src/main/java/hudson/plugins/performance/reports/PerformanceReport.java b/src/main/java/hudson/plugins/performance/reports/PerformanceReport.java index 797b5fc4..2e86f12e 100644 --- a/src/main/java/hudson/plugins/performance/reports/PerformanceReport.java +++ b/src/main/java/hudson/plugins/performance/reports/PerformanceReport.java @@ -1,5 +1,15 @@ package hudson.plugins.performance.reports; +import hudson.model.Run; +import hudson.plugins.performance.Messages; +import hudson.plugins.performance.PerformanceReportMap; +import hudson.plugins.performance.actions.PerformanceBuildAction; +import hudson.plugins.performance.data.HttpSample; +import hudson.plugins.performance.data.TaurusFinalStats; +import hudson.plugins.performance.parsers.PerformanceReportParser; +import hudson.plugins.performance.tools.SafeMaths; +import org.apache.commons.lang.StringUtils; + import java.io.IOException; import java.io.Serializable; import java.util.ArrayList; @@ -10,17 +20,6 @@ import java.util.logging.Level; import java.util.regex.Pattern; -import org.apache.commons.lang.StringUtils; - -import hudson.model.Run; -import hudson.plugins.performance.Messages; -import hudson.plugins.performance.PerformanceReportMap; -import hudson.plugins.performance.actions.PerformanceBuildAction; -import hudson.plugins.performance.data.HttpSample; -import hudson.plugins.performance.data.TaurusFinalStats; -import hudson.plugins.performance.parsers.PerformanceReportParser; -import hudson.plugins.performance.tools.SafeMaths; - /** * Represents a single performance report, which consists of multiple * {@link UriReport}s for different URLs that was tested. @@ -92,6 +91,7 @@ public class PerformanceReport extends AbstractReport implements Serializable, private Long perc0; private Long perc50; private Long perc90; + private Long perc95; private Long perc100; private Long throughput; @@ -109,9 +109,9 @@ public PerformanceReport() { public PerformanceReport(String percentiles, String filterRegex) { this.percentiles = percentiles; this.filterRegex = filterRegex; - if (filterRegex!=null && filterRegex.trim().length()>0) { + if (filterRegex != null && filterRegex.trim().length() > 0) { this.filterRegexPattern = Pattern.compile(filterRegex); - } + } } public PerformanceReport(String defaultPercentiles) { @@ -134,6 +134,7 @@ public Object readResolve() { checkPercentileAndSet(0.0, perc0); checkPercentileAndSet(50.0, perc50); checkPercentileAndSet(90.0, perc90); + checkPercentileAndSet(95.0, perc95); checkPercentileAndSet(100.0, perc100); if (StringUtils.isBlank(percentiles)) { this.percentiles = DEFAULT_PERCENTILES; @@ -154,7 +155,7 @@ public void addSample(HttpSample pHttpSample) { + "name properly for each http sample: skipping sample"); return; } - if(!isIncluded(uri)) { + if (!isIncluded(uri)) { return; } String staplerUri = PerformanceReport.asStaplerURI(uri); @@ -201,7 +202,7 @@ public void addSample(TaurusFinalStats sample, boolean isSummaryReport) { + "name properly for each http sample: skipping sample"); return; } - + if (!isIncluded(uri)) { return; } @@ -218,22 +219,24 @@ public void addSample(TaurusFinalStats sample, boolean isSummaryReport) { average = (long) sample.getAverageResponseTime(); perc50 = (long) sample.getPerc50(); perc90 = (long) sample.getPerc90(); + perc95 = (long) sample.getPerc95(); perc0 = (long) sample.getPerc0(); perc100 = (long) sample.getPerc100(); this.percentilesValues.put(0.0, (long) sample.getPerc0()); this.percentilesValues.put(50.0, (long) sample.getPerc50()); this.percentilesValues.put(90.0, (long) sample.getPerc90()); + this.percentilesValues.put(95.0, (long) sample.getPerc95()); this.percentilesValues.put(100.0, (long) sample.getPerc100()); calculateDiffPercentiles(); isCalculatedPercentilesValues = true; - long durationSec = (long) Math.ceil((float)totalDuration / 1000); + long durationSec = (long) Math.ceil((float) totalDuration / 1000); if (durationSec < 1) { LOGGER.log(Level.INFO, String.format("Performance test had a duration of only %d second(s), please check your configuration.", durationSec)); } throughput = (testDuration == null) ? sample.getThroughput() : - (long)SafeMaths.safeDivide(sampleCount, durationSec); + (long) SafeMaths.safeDivide(sampleCount, durationSec); } else { String staplerUri = PerformanceReport.asStaplerURI(uri); synchronized (uriReportMap) { @@ -286,7 +289,7 @@ public double errorPercent() { public long getAverage() { if (average == null) { - average = (samplesCount == 0) ? 0 : (long)SafeMaths.safeDivide(totalDuration, samplesCount); + average = (samplesCount == 0) ? 0 : (long) SafeMaths.safeDivide(totalDuration, samplesCount); } return average; } @@ -372,6 +375,13 @@ public long get90Line() { return perc90; } + public long get95Line() { + if (perc95 == null) { + perc95 = getDurationAt(NINETY_FIVE_PERCENT); + } + return perc95; + } + public long getMedian() { if (perc50 == null) { perc50 = getDurationAt(FIFTY_PERCENT); @@ -481,6 +491,13 @@ public long get90LineDiff() { return get90Line() - lastBuildReport.get90Line(); } + public long get95LineDiff() { + if (lastBuildReport == null) { + return 0; + } + return get95Line() - lastBuildReport.get95Line(); + } + public double getErrorPercentDiff() { if (lastBuildReport == null) { return 0; diff --git a/src/main/java/hudson/plugins/performance/reports/UriReport.java b/src/main/java/hudson/plugins/performance/reports/UriReport.java index d8c23282..9522cb9e 100644 --- a/src/main/java/hudson/plugins/performance/reports/UriReport.java +++ b/src/main/java/hudson/plugins/performance/reports/UriReport.java @@ -124,6 +124,7 @@ public class UriReport extends AbstractReport implements Serializable, ModelObje private Long perc0; private Long perc50; private Long perc90; + private Long perc95; private Long perc100; @Deprecated private Long throughput; @@ -137,6 +138,7 @@ public Object readResolve() { checkPercentileAndSet(0.0, perc0); checkPercentileAndSet(50.0, perc50); checkPercentileAndSet(90.0, perc90); + checkPercentileAndSet(95.0, perc95); checkPercentileAndSet(100.0, perc100); if (StringUtils.isBlank(percentiles)) { this.percentiles = DEFAULT_PERCENTILES; @@ -168,7 +170,7 @@ public void addHttpSample(HttpSample sample) { summarizerSize += sample.getSummarizerSamples(); summarizerErrors += sample.getSummarizerErrors(); sizeInKb += sample.getSizeInKb(); - + if (start == null || sample.getDate().before(start)) { start = sample.getDate(); } @@ -179,17 +181,18 @@ public void addHttpSample(HttpSample sample) { } - public void setFromTaurusFinalStats(TaurusFinalStats report) { average = (long) report.getAverageResponseTime(); perc0 = (long) report.getPerc0(); perc50 = (long) report.getPerc50(); perc90 = (long) report.getPerc90(); + perc95 = (long) report.getPerc95(); perc100 = (long) report.getPerc100(); this.percentilesValues.put(0.0, (long) report.getPerc0()); this.percentilesValues.put(50.0, (long) report.getPerc50()); this.percentilesValues.put(90.0, (long) report.getPerc90()); + this.percentilesValues.put(95.0, (long) report.getPerc95()); this.percentilesValues.put(100.0, (long) report.getPerc100()); calculateDiffPercentiles(); isCalculatedPercentilesValues = true; @@ -233,7 +236,7 @@ public double errorPercent() { public long getAverage() { if (average == null) { int samplesCount = samplesCount(); - average = (samplesCount == 0) ? 0 : (long)SafeMaths.safeDivide(totalDuration, samplesCount); + average = (samplesCount == 0) ? 0 : (long) SafeMaths.safeDivide(totalDuration, samplesCount); } return average; } @@ -296,6 +299,13 @@ public long get90Line() { return perc90; } + public long get95Line() { + if (perc95 == null) { + perc95 = getDurationAt(NINETY_FIVE_PERCENT); + } + return perc95; + } + public String getHttpCode() { return StringUtils.join(httpCodes, ','); } @@ -428,6 +438,13 @@ public long get90LineDiff() { return get90Line() - lastBuildUriReport.get90Line(); } + public long get95LineDiff() { + if (lastBuildUriReport == null) { + return 0; + } + return get95Line() - lastBuildUriReport.get95Line(); + } + public double getErrorPercentDiff() { if (lastBuildUriReport == null) { return 0; @@ -512,7 +529,7 @@ public void doPercentileGraph(StaplerRequest request, StaplerResponse response) totalNoOfSamples++; // count number of sample occurrences with the same response time value: responseTimesHistogram.put(sample.duration, - responseTimesHistogram.containsKey(sample.duration) ? responseTimesHistogram.get(sample.duration)+1 : 1); + responseTimesHistogram.containsKey(sample.duration) ? responseTimesHistogram.get(sample.duration) + 1 : 1); } } } @@ -522,7 +539,7 @@ public void doPercentileGraph(StaplerRequest request, StaplerResponse response) for (Map.Entry responseTimeOccurrence : responseTimesHistogram.entrySet()) { cumulativeTotal += responseTimeOccurrence.getValue(); - percentiles.addOrUpdate((double) 100.0*cumulativeTotal/totalNoOfSamples, (double) responseTimeOccurrence.getKey()); // float value will result in smoother curve + percentiles.addOrUpdate((double) 100.0 * cumulativeTotal / totalNoOfSamples, (double) responseTimeOccurrence.getKey()); // float value will result in smoother curve } new Graph(-1, 400, 200) { @@ -541,7 +558,7 @@ public void doThroughputGraph(StaplerRequest request, StaplerResponse response) Minute timeBucket = new Minute(sample.date); // count number of samples in the same time bucket throughputIntervals.put(timeBucket, - throughputIntervals.containsKey(timeBucket) ? throughputIntervals.get(timeBucket)+1: 1); + throughputIntervals.containsKey(timeBucket) ? throughputIntervals.get(timeBucket) + 1 : 1); } } } @@ -665,18 +682,18 @@ public boolean hasSamples() { public double getAverageSizeInKb() { return SafeMaths.roundTwoDecimals(SafeMaths.safeDivide(sizeInKb, samplesCount())); } - + public double getTotalTrafficInKb() { return SafeMaths.roundTwoDecimals(sizeInKb); } - + public double getAverageSizeInKbDiff() { if (lastBuildUriReport == null) { return 0; } return SafeMaths.roundTwoDecimals(getAverageSizeInKb() - lastBuildUriReport.getAverageSizeInKb()); } - + public double getTotalTrafficInKbDiff() { if (lastBuildUriReport == null) { return 0; diff --git a/src/main/resources/hudson/plugins/performance/Messages.properties b/src/main/resources/hudson/plugins/performance/Messages.properties index fa190f4e..142b7a92 100644 --- a/src/main/resources/hudson/plugins/performance/Messages.properties +++ b/src/main/resources/hudson/plugins/performance/Messages.properties @@ -10,15 +10,15 @@ ProjectAction.AverageKB=average kb ProjectAction.Average=average ProjectAction.Median=median ProjectAction.Line90=90% line -ProjectAction.PercentageOfFailedTests = Percentage of failed tests +ProjectAction.Line95=95% line +ProjectAction.PercentageOfFailedTests=Percentage of failed tests BuildAction.DisplayName=Performance Report ProjectAction.DisplayName=Performance Trend Publisher.DisplayName=Publish Performance test result report Report.DisplayName=Performance CsvParser.validation.MissingFields=Missing required fields -CsvParser.validation.delimiterEmpty=Delimier can't be empty +CsvParser.validation.delimiterEmpty=Delimiter can't be empty CsvParser.validation.patternEmpty=Pattern is required - GraphConfigurationDetail.DisplayName=Configure TrendReportDetail.DisplayName=Trend report TrendReportDetail.ResponseTime=Response Time (ms) diff --git a/src/main/resources/hudson/plugins/performance/Messages_es.properties b/src/main/resources/hudson/plugins/performance/Messages_es.properties index c0397c39..05d42ab4 100644 --- a/src/main/resources/hudson/plugins/performance/Messages_es.properties +++ b/src/main/resources/hudson/plugins/performance/Messages_es.properties @@ -6,12 +6,12 @@ ProjectAction.Minimum=m ProjectAction.Average=media ProjectAction.Median=mediana ProjectAction.Line90=Línea 90% +ProjectAction.Line95=Línea 95% ProjectAction.TotalTrafficKB=total kb ProjectAction.AverageKB=average kb BuildAction.DisplayName=Informe de Rendimiento ProjectAction.DisplayName=Tendencia de Rendimiento Publisher.DisplayName=Publicar informes de tests de rendimiento Report.DisplayName=Rendimiento - GraphConfigurationDetail.DisplayName=Configurar TrendReportDetail.DisplayName=Informe de tendencia diff --git a/src/main/resources/hudson/plugins/performance/PerformancePublisher/config.jelly b/src/main/resources/hudson/plugins/performance/PerformancePublisher/config.jelly index cfb7a09c..55937ea6 100644 --- a/src/main/resources/hudson/plugins/performance/PerformancePublisher/config.jelly +++ b/src/main/resources/hudson/plugins/performance/PerformancePublisher/config.jelly @@ -141,7 +141,7 @@ - + diff --git a/src/main/resources/hudson/plugins/performance/tags/captionLine_es.properties b/src/main/resources/hudson/plugins/performance/tags/captionLine_es.properties index 28e4f82e..a492a6b1 100644 --- a/src/main/resources/hudson/plugins/performance/tags/captionLine_es.properties +++ b/src/main/resources/hudson/plugins/performance/tags/captionLine_es.properties @@ -4,6 +4,7 @@ samples\ diff=Diferencia peticiones Median=Mediana Median\ diff=Variaci\u00f3n de la mediana Line90=L\u00ednea 90% +Line95=L\u00ednea 95% Average=Media Average\ diff=Variaci\u00f3n de la media URI=URI diff --git a/src/test/java/hudson/plugins/performance/BaselineComparisonTest.java b/src/test/java/hudson/plugins/performance/BaselineComparisonTest.java index 80bd56c2..a9543154 100644 --- a/src/test/java/hudson/plugins/performance/BaselineComparisonTest.java +++ b/src/test/java/hudson/plugins/performance/BaselineComparisonTest.java @@ -78,6 +78,7 @@ private void prepareReportForBuild(int num, int baseline, Map build, TaskListener listener, PerformanceR assertEquals(Long.valueOf(50), percentilesValues.get(0.0)); assertEquals(Long.valueOf(51), percentilesValues.get(50.0)); assertEquals(Long.valueOf(52), percentilesValues.get(90.0)); + assertEquals(Long.valueOf(52), percentilesValues.get(95.0)); assertEquals(Long.valueOf(53), percentilesValues.get(100.0)); assertEquals(Long.valueOf(20), percentilesDiffValues.get(0.0)); assertEquals(Long.valueOf(20), percentilesDiffValues.get(50.0)); assertEquals(Long.valueOf(20), percentilesDiffValues.get(90.0)); + assertEquals(Long.valueOf(20), percentilesDiffValues.get(95.0)); assertEquals(Long.valueOf(20), percentilesDiffValues.get(100.0)); } @@ -137,11 +140,13 @@ protected void parseReports(Run build, TaskListener listener, PerformanceR assertEquals(Long.valueOf(40), percentilesValues.get(0.0)); assertEquals(Long.valueOf(41), percentilesValues.get(50.0)); assertEquals(Long.valueOf(42), percentilesValues.get(90.0)); + assertEquals(Long.valueOf(42), percentilesValues.get(95.0)); assertEquals(Long.valueOf(43), percentilesValues.get(100.0)); assertEquals(Long.valueOf(10), percentilesDiffValues.get(0.0)); assertEquals(Long.valueOf(10), percentilesDiffValues.get(50.0)); assertEquals(Long.valueOf(10), percentilesDiffValues.get(90.0)); + assertEquals(Long.valueOf(10), percentilesDiffValues.get(95.0)); assertEquals(Long.valueOf(10), percentilesDiffValues.get(100.0)); } @@ -167,11 +172,13 @@ protected void parseReports(Run build, TaskListener listener, PerformanceR assertEquals(Long.valueOf(30), percentilesValues.get(0.0)); assertEquals(Long.valueOf(31), percentilesValues.get(50.0)); assertEquals(Long.valueOf(32), percentilesValues.get(90.0)); + assertEquals(Long.valueOf(32), percentilesValues.get(95.0)); assertEquals(Long.valueOf(33), percentilesValues.get(100.0)); assertEquals(Long.valueOf(0), percentilesDiffValues.get(0.0)); assertEquals(Long.valueOf(0), percentilesDiffValues.get(50.0)); assertEquals(Long.valueOf(0), percentilesDiffValues.get(90.0)); + assertEquals(Long.valueOf(0), percentilesDiffValues.get(95.0)); assertEquals(Long.valueOf(0), percentilesDiffValues.get(100.0)); } } diff --git a/src/test/java/hudson/plugins/performance/PerformancePublisherTest.java b/src/test/java/hudson/plugins/performance/PerformancePublisherTest.java index 3d9d5137..faa0debb 100644 --- a/src/test/java/hudson/plugins/performance/PerformancePublisherTest.java +++ b/src/test/java/hudson/plugins/performance/PerformancePublisherTest.java @@ -147,6 +147,7 @@ public boolean perform(AbstractBuild build, "\t501\n" + "\t598\n" + "\t14720\n" + + "\t14720\n" + "\t15902\n" + "\t200\n" + "\t0.0\n" + @@ -158,6 +159,7 @@ public boolean perform(AbstractBuild build, "\t58\n" + "\t63\n" + "\t278\n" + + "\t278\n" + "\t1017\n" + "\t200\n" + "\t0.0\n" + diff --git a/src/test/java/hudson/plugins/performance/actions/PerformanceProjectActionGraphTest.java b/src/test/java/hudson/plugins/performance/actions/PerformanceProjectActionGraphTest.java index 10dc4d9d..70228e33 100644 --- a/src/test/java/hudson/plugins/performance/actions/PerformanceProjectActionGraphTest.java +++ b/src/test/java/hudson/plugins/performance/actions/PerformanceProjectActionGraphTest.java @@ -1,13 +1,12 @@ package hudson.plugins.performance.actions; -import static org.junit.Assert.assertArrayEquals; -import static org.mockito.Mockito.when; - -import java.util.Collections; -import java.util.List; - import edu.umd.cs.findbugs.annotations.NonNull; - +import hudson.model.AbstractProject; +import hudson.model.Run; +import hudson.plugins.performance.AbstractGraphGenerationTest; +import hudson.plugins.performance.PerformancePublisher; +import hudson.plugins.performance.reports.PerformanceReport; +import hudson.util.RunList; import org.jfree.chart.JFreeChart; import org.jfree.data.category.CategoryDataset; import org.junit.Before; @@ -15,12 +14,11 @@ import org.junit.runner.RunWith; import org.mockito.junit.MockitoJUnitRunner; -import hudson.model.AbstractProject; -import hudson.model.Run; -import hudson.plugins.performance.AbstractGraphGenerationTest; -import hudson.plugins.performance.PerformancePublisher; -import hudson.plugins.performance.reports.PerformanceReport; -import hudson.util.RunList; +import java.util.Collections; +import java.util.List; + +import static org.junit.Assert.assertArrayEquals; +import static org.mockito.Mockito.when; @RunWith(MockitoJUnitRunner.Silent.class) public class PerformanceProjectActionGraphTest extends AbstractGraphGenerationTest { @@ -72,7 +70,7 @@ public void testErrorsGraph() throws Exception { public void testRespondingTimeGraph() throws Exception { setGraphType(PerformancePublisher.MRT); target.doRespondingTimeGraph(request, response); - assertArrayEquals(new Number[]{14720L, 4142L, 501L}, toArray(target.dataset)); + assertArrayEquals(new Number[]{14720L, 14720L, 4142L, 501L}, toArray(target.dataset)); } @Test diff --git a/src/test/java/hudson/plugins/performance/constraints/ConstraintCheckerTest.java b/src/test/java/hudson/plugins/performance/constraints/ConstraintCheckerTest.java index b3a4ddbe..9a37b36d 100644 --- a/src/test/java/hudson/plugins/performance/constraints/ConstraintCheckerTest.java +++ b/src/test/java/hudson/plugins/performance/constraints/ConstraintCheckerTest.java @@ -162,6 +162,7 @@ public class ConstraintCheckerTest { AbsoluteConstraint ac3; AbsoluteConstraint ac4; AbsoluteConstraint ac5; + AbsoluteConstraint ac6; PreviousResultsBlock rb0; PreviousResultsBlock rb1; PreviousResultsBlock rb2; @@ -176,6 +177,7 @@ public class ConstraintCheckerTest { RelativeConstraint rc4; RelativeConstraint rc5; RelativeConstraint rc6; + RelativeConstraint rc7; /** * TestCase1 HappyPath - Testing every combination of constraints against some @@ -203,17 +205,19 @@ public void happyPathForAbsoluteConstraints() constraints.add(ac3); constraints.add(ac4); constraints.add(ac5); + constraints.add(ac6); ArrayList result = new ArrayList(); result = constraintChecker.checkAllConstraints(constraints); - assertEquals(6, result.size()); + assertEquals(7, result.size()); assertEquals(ac0, result.get(0).getAbstractConstraint()); assertEquals(ac1, result.get(1).getAbstractConstraint()); assertEquals(ac2, result.get(2).getAbstractConstraint()); assertEquals(ac3, result.get(3).getAbstractConstraint()); assertEquals(ac4, result.get(4).getAbstractConstraint()); assertEquals(ac5, result.get(5).getAbstractConstraint()); + assertEquals(ac6, result.get(6).getAbstractConstraint()); assertTrue(result.get(0).getAbstractConstraint().getSuccess()); assertTrue(result.get(4).getAbstractConstraint().getSuccess()); @@ -236,11 +240,12 @@ public void happyPathForRelativeConstraints() constraints.add(rc4); constraints.add(rc5); constraints.add(rc6); + constraints.add(rc7); ArrayList result = new ArrayList(); result = constraintChecker.checkAllConstraints(constraints); - assertEquals(7, result.size()); + assertEquals(8, result.size()); assertEquals(rc0, result.get(0).getAbstractConstraint()); assertEquals(rc1, result.get(1).getAbstractConstraint()); assertEquals(rc2, result.get(2).getAbstractConstraint()); @@ -248,6 +253,7 @@ public void happyPathForRelativeConstraints() assertEquals(rc4, result.get(4).getAbstractConstraint()); assertEquals(rc5, result.get(5).getAbstractConstraint()); assertEquals(rc6, result.get(6).getAbstractConstraint()); + assertEquals(rc7, result.get(7).getAbstractConstraint()); assertTrue(result.get(0).getAbstractConstraint().getSuccess()); assertTrue(result.get(4).getAbstractConstraint().getSuccess()); @@ -270,17 +276,19 @@ public void happyPathForMixedConstraints() constraints.add(ac3); constraints.add(ac4); constraints.add(ac5); + constraints.add(rc7); ArrayList result = new ArrayList(); result = constraintChecker.checkAllConstraints(constraints); - assertEquals(6, result.size()); + assertEquals(7, result.size()); assertEquals(rc0, result.get(0).getAbstractConstraint()); assertEquals(rc1, result.get(1).getAbstractConstraint()); assertEquals(rc2, result.get(2).getAbstractConstraint()); assertEquals(ac3, result.get(3).getAbstractConstraint()); assertEquals(ac4, result.get(4).getAbstractConstraint()); assertEquals(ac5, result.get(5).getAbstractConstraint()); + assertEquals(rc7, result.get(6).getAbstractConstraint()); assertTrue(result.get(0).getAbstractConstraint().getSuccess()); assertTrue(result.get(2).getAbstractConstraint().getSuccess()); @@ -321,6 +329,8 @@ public void setUp() { ac5 = new AbsoluteConstraint(Metric.MINIMUM, Operator.NOT_LESS, "testResult1.xml", Escalation.ERROR, false, ob2, 100L); ac5.setSpecifiedTestCase(false); + ac6 = new AbsoluteConstraint(Metric.LINE95, Operator.NOT_GREATER, "testResult0.xml", Escalation.WARNING, false, ob0, + 100L); rb0 = new PreviousResultsBlock("true", "3", "", ""); rb1 = new PreviousResultsBlock("true", "*", "", ""); @@ -346,6 +356,8 @@ public void setUp() { rc5.setSpecifiedTestCase(false); rc6 = new RelativeConstraint(Metric.AVERAGE, Operator.NOT_GREATER, "testResult0.xml", Escalation.INFORMATION, false, ob0, rb0, 10); // same as rc0 but against baseline build + rc7 = new RelativeConstraint(Metric.LINE95, Operator.NOT_GREATER, "testResult0.xml", Escalation.WARNING, false, ob0, + rb2, 10); abstractBuildsList.add(abstractBuild0); abstractBuildsList.add(abstractBuild1); @@ -476,188 +488,236 @@ public void setUp() { when(uriReport0_0_0.getAverage()).thenReturn((long) 10); when(uriReport0_0_0.errorPercent()).thenReturn((double) 10); when(uriReport0_0_0.get90Line()).thenReturn((long) 10); + when(uriReport0_0_0.get95Line()).thenReturn((long) 10); when(uriReport0_0_0.getMax()).thenReturn((long) 10); when(uriReport0_0_0.getMedian()).thenReturn((long) 10); when(uriReport0_0_0.getMin()).thenReturn((long) 10); + when(uriReport0_0_0.get95Line()).thenReturn((long) 10); when(uriReport0_0_1.getUri()).thenReturn("testUri1"); when(uriReport0_0_1.getAverage()).thenReturn((long) 10); when(uriReport0_0_1.errorPercent()).thenReturn((double) 10); when(uriReport0_0_1.get90Line()).thenReturn((long) 10); + when(uriReport0_0_1.get95Line()).thenReturn((long) 10); when(uriReport0_0_1.getMax()).thenReturn((long) 10); when(uriReport0_0_1.getMedian()).thenReturn((long) 10); when(uriReport0_0_1.getMin()).thenReturn((long) 10); + when(uriReport0_0_1.get95Line()).thenReturn((long) 10); when(uriReport0_1_0.getUri()).thenReturn("testUri0"); when(uriReport0_1_0.getAverage()).thenReturn((long) 10); when(uriReport0_1_0.errorPercent()).thenReturn((double) 10); when(uriReport0_1_0.get90Line()).thenReturn((long) 10); + when(uriReport0_1_0.get95Line()).thenReturn((long) 10); when(uriReport0_1_0.getMax()).thenReturn((long) 10); when(uriReport0_1_0.getMedian()).thenReturn((long) 10); when(uriReport0_1_0.getMin()).thenReturn((long) 10); + when(uriReport0_1_0.get95Line()).thenReturn((long) 10); when(uriReport0_1_1.getUri()).thenReturn("testUri1"); when(uriReport0_1_1.getAverage()).thenReturn((long) 10); when(uriReport0_1_1.errorPercent()).thenReturn((double) 10); when(uriReport0_1_1.get90Line()).thenReturn((long) 10); + when(uriReport0_1_1.get95Line()).thenReturn((long) 10); when(uriReport0_1_1.getMax()).thenReturn((long) 10); when(uriReport0_1_1.getMedian()).thenReturn((long) 10); when(uriReport0_1_1.getMin()).thenReturn((long) 10); + when(uriReport0_1_1.get95Line()).thenReturn((long) 10); when(uriReport1_0_0.getUri()).thenReturn("testUri0"); when(uriReport1_0_0.getAverage()).thenReturn((long) 10); when(uriReport1_0_0.errorPercent()).thenReturn((double) 10); when(uriReport1_0_0.get90Line()).thenReturn((long) 10); + when(uriReport1_0_0.get95Line()).thenReturn((long) 10); when(uriReport1_0_0.getMax()).thenReturn((long) 10); when(uriReport1_0_0.getMedian()).thenReturn((long) 10); when(uriReport1_0_0.getMin()).thenReturn((long) 10); + when(uriReport1_0_0.get95Line()).thenReturn((long) 10); when(uriReport1_0_1.getUri()).thenReturn("testUri1"); when(uriReport1_0_1.getAverage()).thenReturn((long) 10); when(uriReport1_0_1.errorPercent()).thenReturn((double) 10); when(uriReport1_0_1.get90Line()).thenReturn((long) 10); + when(uriReport1_0_1.get95Line()).thenReturn((long) 10); when(uriReport1_0_1.getMax()).thenReturn((long) 10); when(uriReport1_0_1.getMedian()).thenReturn((long) 10); when(uriReport1_0_1.getMin()).thenReturn((long) 10); + when(uriReport1_0_1.get95Line()).thenReturn((long) 10); when(uriReport1_1_0.getUri()).thenReturn("testUri0"); when(uriReport1_1_0.getAverage()).thenReturn((long) 10); when(uriReport1_1_0.errorPercent()).thenReturn((double) 10); when(uriReport1_1_0.get90Line()).thenReturn((long) 10); + when(uriReport1_1_0.get95Line()).thenReturn((long) 10); when(uriReport1_1_0.getMax()).thenReturn((long) 10); when(uriReport1_1_0.getMedian()).thenReturn((long) 10); when(uriReport1_1_0.getMin()).thenReturn((long) 10); + when(uriReport1_1_0.get95Line()).thenReturn((long) 10); when(uriReport1_1_1.getUri()).thenReturn("testUri1"); when(uriReport1_1_1.getAverage()).thenReturn((long) 10); when(uriReport1_1_1.errorPercent()).thenReturn((double) 10); when(uriReport1_1_1.get90Line()).thenReturn((long) 10); + when(uriReport1_1_1.get95Line()).thenReturn((long) 10); when(uriReport1_1_1.getMax()).thenReturn((long) 10); when(uriReport1_1_1.getMedian()).thenReturn((long) 10); when(uriReport1_1_1.getMin()).thenReturn((long) 10); + when(uriReport1_1_1.get95Line()).thenReturn((long) 10); when(uriReport2_0_0.getUri()).thenReturn("testUri0"); when(uriReport2_0_0.getAverage()).thenReturn((long) 10); when(uriReport2_0_0.errorPercent()).thenReturn((double) 10); when(uriReport2_0_0.get90Line()).thenReturn((long) 10); + when(uriReport2_0_0.get95Line()).thenReturn((long) 10); when(uriReport2_0_0.getMax()).thenReturn((long) 10); when(uriReport2_0_0.getMedian()).thenReturn((long) 10); when(uriReport2_0_0.getMin()).thenReturn((long) 10); + when(uriReport2_0_0.get95Line()).thenReturn((long) 10); when(uriReport2_0_1.getUri()).thenReturn("testUri1"); when(uriReport2_0_1.getAverage()).thenReturn((long) 10); when(uriReport2_0_1.errorPercent()).thenReturn((double) 10); when(uriReport2_0_1.get90Line()).thenReturn((long) 10); + when(uriReport2_0_1.get95Line()).thenReturn((long) 10); when(uriReport2_0_1.getMax()).thenReturn((long) 10); when(uriReport2_0_1.getMedian()).thenReturn((long) 10); when(uriReport2_0_1.getMin()).thenReturn((long) 10); + when(uriReport2_0_1.get95Line()).thenReturn((long) 10); when(uriReport2_1_0.getUri()).thenReturn("testUri0"); when(uriReport2_1_0.getAverage()).thenReturn((long) 10); when(uriReport2_1_0.errorPercent()).thenReturn((double) 10); when(uriReport2_1_0.get90Line()).thenReturn((long) 10); + when(uriReport2_1_0.get95Line()).thenReturn((long) 10); when(uriReport2_1_0.getMax()).thenReturn((long) 10); when(uriReport2_1_0.getMedian()).thenReturn((long) 10); when(uriReport2_1_0.getMin()).thenReturn((long) 10); + when(uriReport2_1_0.get95Line()).thenReturn((long) 10); when(uriReport2_1_1.getUri()).thenReturn("testUri1"); when(uriReport2_1_1.getAverage()).thenReturn((long) 10); when(uriReport2_1_1.errorPercent()).thenReturn((double) 10); when(uriReport2_1_1.get90Line()).thenReturn((long) 10); + when(uriReport2_1_1.get95Line()).thenReturn((long) 10); when(uriReport2_1_1.getMax()).thenReturn((long) 10); when(uriReport2_1_1.getMedian()).thenReturn((long) 10); when(uriReport2_1_1.getMin()).thenReturn((long) 10); + when(uriReport2_1_1.get95Line()).thenReturn((long) 10); when(uriReport3_0_0.getUri()).thenReturn("testUri0"); when(uriReport3_0_0.getAverage()).thenReturn((long) 10); when(uriReport3_0_0.errorPercent()).thenReturn((double) 10); when(uriReport3_0_0.get90Line()).thenReturn((long) 10); + when(uriReport3_0_0.get95Line()).thenReturn((long) 10); when(uriReport3_0_0.getMax()).thenReturn((long) 10); when(uriReport3_0_0.getMedian()).thenReturn((long) 10); when(uriReport3_0_0.getMin()).thenReturn((long) 10); + when(uriReport3_0_0.get95Line()).thenReturn((long) 10); when(uriReport3_0_1.getUri()).thenReturn("testUri1"); when(uriReport3_0_1.getAverage()).thenReturn((long) 10); when(uriReport3_0_1.errorPercent()).thenReturn((double) 10); when(uriReport3_0_1.get90Line()).thenReturn((long) 10); + when(uriReport3_0_1.get95Line()).thenReturn((long) 10); when(uriReport3_0_1.getMax()).thenReturn((long) 10); when(uriReport3_0_1.getMedian()).thenReturn((long) 10); when(uriReport3_0_1.getMin()).thenReturn((long) 10); + when(uriReport3_0_1.get95Line()).thenReturn((long) 10); when(uriReport3_1_0.getUri()).thenReturn("testUri0"); when(uriReport3_1_0.getAverage()).thenReturn((long) 10); when(uriReport3_1_0.errorPercent()).thenReturn((double) 10); when(uriReport3_1_0.get90Line()).thenReturn((long) 10); + when(uriReport3_1_0.get95Line()).thenReturn((long) 10); when(uriReport3_1_0.getMax()).thenReturn((long) 10); when(uriReport3_1_0.getMedian()).thenReturn((long) 10); when(uriReport3_1_0.getMin()).thenReturn((long) 10); + when(uriReport3_1_0.get95Line()).thenReturn((long) 10); when(uriReport3_1_1.getUri()).thenReturn("testUri1"); when(uriReport3_1_1.getAverage()).thenReturn((long) 10); when(uriReport3_1_1.errorPercent()).thenReturn((double) 10); when(uriReport3_1_1.get90Line()).thenReturn((long) 10); + when(uriReport3_1_1.get95Line()).thenReturn((long) 10); when(uriReport3_1_1.getMax()).thenReturn((long) 10); when(uriReport3_1_1.getMedian()).thenReturn((long) 10); when(uriReport3_1_1.getMin()).thenReturn((long) 10); + when(uriReport3_1_1.get95Line()).thenReturn((long) 10); - /* - * Mocking behaviour of performance Reports - */ + /* + * Mocking behaviour of performance Reports + */ when(performanceReport0_0.getAverage()).thenReturn((long) 10); when(performanceReport0_0.errorPercent()).thenReturn((double) 10); when(performanceReport0_0.get90Line()).thenReturn((long) 10); + when(performanceReport0_0.get95Line()).thenReturn((long) 10); when(performanceReport0_0.getMax()).thenReturn((long) 10); when(performanceReport0_0.getMedian()).thenReturn((long) 10); when(performanceReport0_0.getMin()).thenReturn((long) 10); + when(performanceReport0_0.get95Line()).thenReturn((long) 10); when(performanceReport0_1.getAverage()).thenReturn((long) 10); when(performanceReport0_1.errorPercent()).thenReturn((double) 10); when(performanceReport0_1.get90Line()).thenReturn((long) 10); + when(performanceReport0_1.get95Line()).thenReturn((long) 10); when(performanceReport0_1.getMax()).thenReturn((long) 10); when(performanceReport0_1.getMedian()).thenReturn((long) 10); when(performanceReport0_1.getMin()).thenReturn((long) 10); + when(performanceReport0_1.get95Line()).thenReturn((long) 10); when(performanceReport1_0.getAverage()).thenReturn((long) 10); when(performanceReport1_0.errorPercent()).thenReturn((double) 10); when(performanceReport1_0.get90Line()).thenReturn((long) 10); + when(performanceReport1_0.get95Line()).thenReturn((long) 10); when(performanceReport1_0.getMax()).thenReturn((long) 10); when(performanceReport1_0.getMedian()).thenReturn((long) 10); when(performanceReport1_0.getMin()).thenReturn((long) 10); + when(performanceReport1_0.get95Line()).thenReturn((long) 10); when(performanceReport1_1.getAverage()).thenReturn((long) 10); when(performanceReport1_1.errorPercent()).thenReturn((double) 10); when(performanceReport1_1.get90Line()).thenReturn((long) 10); + when(performanceReport1_1.get95Line()).thenReturn((long) 10); when(performanceReport1_1.getMax()).thenReturn((long) 10); when(performanceReport1_1.getMedian()).thenReturn((long) 10); when(performanceReport1_1.getMin()).thenReturn((long) 10); + when(performanceReport1_1.get95Line()).thenReturn((long) 10); when(performanceReport2_0.getAverage()).thenReturn((long) 10); when(performanceReport2_0.errorPercent()).thenReturn((double) 10); when(performanceReport2_0.get90Line()).thenReturn((long) 10); + when(performanceReport2_0.get95Line()).thenReturn((long) 10); when(performanceReport2_0.getMax()).thenReturn((long) 10); when(performanceReport2_0.getMedian()).thenReturn((long) 10); when(performanceReport2_0.getMin()).thenReturn((long) 10); + when(performanceReport2_0.get95Line()).thenReturn((long) 10); when(performanceReport2_1.getAverage()).thenReturn((long) 10); when(performanceReport2_1.errorPercent()).thenReturn((double) 10); when(performanceReport2_1.get90Line()).thenReturn((long) 10); + when(performanceReport2_1.get95Line()).thenReturn((long) 10); when(performanceReport2_1.getMax()).thenReturn((long) 10); when(performanceReport2_1.getMedian()).thenReturn((long) 10); when(performanceReport2_1.getMin()).thenReturn((long) 10); + when(performanceReport2_1.get95Line()).thenReturn((long) 10); when(performanceReport3_0.getAverage()).thenReturn((long) 10); when(performanceReport3_0.errorPercent()).thenReturn((double) 10); when(performanceReport3_0.get90Line()).thenReturn((long) 10); + when(performanceReport3_0.get95Line()).thenReturn((long) 10); when(performanceReport3_0.getMax()).thenReturn((long) 10); when(performanceReport3_0.getMedian()).thenReturn((long) 10); when(performanceReport3_0.getMin()).thenReturn((long) 10); + when(performanceReport3_0.get95Line()).thenReturn((long) 10); when(performanceReport3_1.getAverage()).thenReturn((long) 10); when(performanceReport3_1.errorPercent()).thenReturn((double) 10); when(performanceReport3_1.get90Line()).thenReturn((long) 10); + when(performanceReport3_1.get95Line()).thenReturn((long) 10); when(performanceReport3_1.getMax()).thenReturn((long) 10); when(performanceReport3_1.getMedian()).thenReturn((long) 10); when(performanceReport3_1.getMin()).thenReturn((long) 10); + when(performanceReport3_1.get95Line()).thenReturn((long) 10); } @Test @@ -682,17 +742,19 @@ public void generateJunitOutput() throws Exception { constraints.add(ac3); constraints.add(ac4); constraints.add(ac5); + constraints.add(rc7); ArrayList result = new ArrayList(); result = constraintChecker.checkAllConstraints(constraints); - + List expectedList = Arrays.asList( - "\n\n", - "\n\n", - "\n\n", - "\n\n", - "\n\n", - "\n Measured value for Minimum: 10 milliseconds\n\n" + "\n\n", + "\n\n", + "\n\n", + "\n\n", + "\n\n", + "\n Measured value for Minimum: 10 milliseconds\n\n", + "\n\n" ); Iterator expected = expectedList.iterator(); diff --git a/src/test/java/hudson/plugins/performance/parsers/AbstractParserTest.java b/src/test/java/hudson/plugins/performance/parsers/AbstractParserTest.java index 30200d96..d30b1c7f 100644 --- a/src/test/java/hudson/plugins/performance/parsers/AbstractParserTest.java +++ b/src/test/java/hudson/plugins/performance/parsers/AbstractParserTest.java @@ -6,7 +6,8 @@ import java.io.File; import java.util.Map; -import static org.junit.Assert.*; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; public class AbstractParserTest { @@ -31,14 +32,16 @@ public void testUploadOldReport() throws Exception { PerformanceReport report = AbstractParser.loadSerializedReport(new File(reportFilePath)); assertNotNull(report); Map percentilesValues = report.getPercentilesValues(); - assertEquals(4, percentilesValues.size()); + assertEquals(5, percentilesValues.size()); assertEquals(Long.valueOf(320), percentilesValues.get(50d)); assertEquals(Long.valueOf(449), percentilesValues.get(90d)); + assertEquals(Long.valueOf(455), percentilesValues.get(95d)); assertEquals(Long.valueOf(100), percentilesValues.get(0d)); assertEquals(Long.valueOf(468), percentilesValues.get(100d)); assertEquals(320, report.getMedian()); assertEquals(449, report.get90Line()); + assertEquals(455, report.get95Line()); assertEquals(100, report.getMin()); assertEquals(468, report.getMax()); diff --git a/src/test/java/hudson/plugins/performance/parsers/TaurusParserTest.java b/src/test/java/hudson/plugins/performance/parsers/TaurusParserTest.java index 37c24081..39e6aa21 100644 --- a/src/test/java/hudson/plugins/performance/parsers/TaurusParserTest.java +++ b/src/test/java/hudson/plugins/performance/parsers/TaurusParserTest.java @@ -49,6 +49,7 @@ private void checkUriReport1(UriReport report) { assertEquals("Check min", 0.15600 * 1000, report.getMin(), DELTA); assertEquals("Check median", 0.84300 * 1000, report.getMedian(), DELTA); assertEquals("Check line 90", 1.29300 * 1000, report.get90Line(), DELTA); + assertEquals("Check line 95", 1.42000 * 1000, report.get95Line(), DELTA); assertEquals("Check max", 1.71800 * 1000, report.getMax(), DELTA); assertEquals("Check average", (long) (0.80638 * 1000), report.getAverage()); assertEquals("Check samples count", 326 + 11, report.samplesCount(), DELTA); @@ -60,6 +61,7 @@ private void checkUriReport2(UriReport report) { assertEquals("Check min", 0.06400 * 1000, report.getMin(), DELTA); assertEquals("Check median", 0.07200 * 1000, report.getMedian(), DELTA); assertEquals("Check line 90", 0.18900 * 1000, report.get90Line(), DELTA); + assertEquals("Check line 95", 0.20400 * 1000, report.get95Line(), DELTA); assertEquals("Check max", 0.52200 * 1000, report.getMax(), DELTA); assertEquals("Check average", (long) (0.11568 * 1000), report.getAverage()); assertEquals("Check samples count", 340, report.samplesCount(), DELTA); @@ -71,6 +73,7 @@ private void checkPerformanceReport(PerformanceReport report) { assertEquals("Check min", 0.06400 * 1000, report.getMin(), DELTA); assertEquals("Check median", 0.18700 * 1000, report.getMedian(), DELTA); assertEquals("Check line 90", 1.15800 * 1000, report.get90Line(), DELTA); + assertEquals("Check line 95", 1.29300 * 1000, report.get95Line(), DELTA); assertEquals("Check max", 1.71800 * 1000, report.getMax(), DELTA); assertEquals("Check average", (long) (0.45950 * 1000), report.getAverage()); assertEquals("Check samples count", 666 + 11, report.samplesCount(), DELTA); @@ -81,7 +84,8 @@ private void checkReportDiff(PerformanceReport report) { // Check summary values assertEquals("Check diff median", -14.0, report.getMedianDiff(), DELTA); assertEquals("Check diff average", -400, report.getAverageDiff()); - assertEquals("Check diff line 90", 213, report.get90LineDiff()); + assertEquals("Check diff line 90", 213, report.get90LineDiff()); + assertEquals("Check diff line 95", 348, report.get95LineDiff()); assertEquals("Check diff samples count", 232, report.getSamplesCountDiff()); } diff --git a/src/test/java/hudson/plugins/performance/reports/PerformanceReportTest.java b/src/test/java/hudson/plugins/performance/reports/PerformanceReportTest.java index 45712d30..56dd875d 100644 --- a/src/test/java/hudson/plugins/performance/reports/PerformanceReportTest.java +++ b/src/test/java/hudson/plugins/performance/reports/PerformanceReportTest.java @@ -27,7 +27,7 @@ import hudson.util.StreamTaskListener; public class PerformanceReportTest { - public static final String DEFAULT_PERCENTILES = "0,50,90,100"; + public static final String DEFAULT_PERCENTILES = "0,50,90,95,100"; private PerformanceReport performanceReport; @@ -192,12 +192,24 @@ public void testCanGetCorrect90LineValue() throws IOException, URISyntaxExceptio assertEquals(9L, performanceReport.get90Line()); } + @Test + public void testCanGetCorrect95LineValue() throws IOException, URISyntaxException { + PerformanceReport performanceReport = parseOneJMeter(new File(getClass().getResource("/JMeterResultsTenSamples.jtl").toURI())); + assertEquals(9L, performanceReport.get95Line()); + } + @Test public void testCanGetCorrect90LineValueWithThreeSamples() throws IOException, URISyntaxException { PerformanceReport performanceReport = parseOneJMeter(new File(getClass().getResource("/JMeterResultsThreeSamples.jtl").toURI())); assertEquals(2L, performanceReport.get90Line()); } + @Test + public void testCanGetCorrect95LineValueWithThreeSamples() throws IOException, URISyntaxException { + PerformanceReport performanceReport = parseOneJMeter(new File(getClass().getResource("/JMeterResultsThreeSamples.jtl").toURI())); + assertEquals(2L, performanceReport.get95Line()); + } + @Test public void testCanGetCorrectMaxValueWithThreeSamples() throws IOException, URISyntaxException { PerformanceReport performanceReport = parseOneJMeter(new File(getClass().getResource("/JMeterResultsThreeSamples.jtl").toURI())); diff --git a/src/test/resources/TaurusPreviousBuildReport.xml b/src/test/resources/TaurusPreviousBuildReport.xml index d48bd03e..b345c5ca 100644 --- a/src/test/resources/TaurusPreviousBuildReport.xml +++ b/src/test/resources/TaurusPreviousBuildReport.xml @@ -1,230 +1,242 @@ - https://test_url.com/summary - - - avg_ct - 0 - - - stdev_rt - 3.16982 - - - avg_lt - 0.79907 - - - rc/200 - 440 - - - rc/503 - 3 - - - rc/ConnectException - 2 - - - bytes - 4594038 - - - perc/95.0 - 3.61700 - - - perc/0.0 - 0.05800 - - - perc/99.9 - 15.69500 - - - perc/90.0 - 0.94500 - - - perc/100.0 - 15.69500 - - - perc/99.0 - 15.61000 - - - perc/50.0 - 0.20100 - - - succ - 440 - - - throughput - 445 - - - concurrency - 9 - - - avg_rt - 0.85988 - - - fail - 5 - - - - - avg_ct - 0 - - - stdev_rt - 0.10286 - - - avg_lt - 0.10228 - - - rc/200 - 224 - - - bytes - 1764229 - - - perc/95.0 - 0.18400 - - - perc/0.0 - 0.05800 - - - perc/99.9 - 0.28500 - - - perc/90.0 - 0.16700 - - - perc/100.0 - 0.28500 - - - perc/99.0 - 0.26900 - - - perc/50.0 - 0.06600 - - - succ - 224 - - - throughput - 224 - - - concurrency - 16 - - - avg_rt - 0.10234 - - - fail - 0 - - - - - avg_ct - 0 - - - stdev_rt - 3.38245 - - - avg_lt - 1.50533 - - - rc/200 - 216 - - - rc/503 - 3 - - - rc/ConnectException - 2 - - - bytes - 2829809 - - - perc/95.0 - 7.68900 - - - perc/0.0 - 0.16200 - - - perc/99.9 - 15.69500 - - - perc/90.0 - 3.61700 - - - perc/100.0 - 15.69500 - - - perc/99.0 - 15.64300 - - - perc/50.0 - 0.66900 - - - succ - 216 - - - throughput - 221 - - - concurrency - 9 - - - avg_rt - 1.62770 - - - fail - 5 - - + https://test_url.com/summary + + + avg_ct + 0 + + + stdev_rt + 3.16982 + + + avg_lt + 0.79907 + + + rc/200 + 440 + + + rc/503 + 3 + + + rc/ConnectException + 2 + + + bytes + 4594038 + + + perc/95.0 + 3.61700 + + + perc/0.0 + 0.05800 + + + perc/99.9 + 15.69500 + + + perc/90.0 + 0.94500 + + + perc/95.0 + 0.94500 + + + perc/100.0 + 15.69500 + + + perc/99.0 + 15.61000 + + + perc/50.0 + 0.20100 + + + succ + 440 + + + throughput + 445 + + + concurrency + 9 + + + avg_rt + 0.85988 + + + fail + 5 + + + + + avg_ct + 0 + + + stdev_rt + 0.10286 + + + avg_lt + 0.10228 + + + rc/200 + 224 + + + bytes + 1764229 + + + perc/95.0 + 0.18400 + + + perc/0.0 + 0.05800 + + + perc/99.9 + 0.28500 + + + perc/90.0 + 0.16700 + + + perc/95.0 + 0.16700 + + + perc/100.0 + 0.28500 + + + perc/99.0 + 0.26900 + + + perc/50.0 + 0.06600 + + + succ + 224 + + + throughput + 224 + + + concurrency + 16 + + + avg_rt + 0.10234 + + + fail + 0 + + + + + avg_ct + 0 + + + stdev_rt + 3.38245 + + + avg_lt + 1.50533 + + + rc/200 + 216 + + + rc/503 + 3 + + + rc/ConnectException + 2 + + + bytes + 2829809 + + + perc/95.0 + 7.68900 + + + perc/0.0 + 0.16200 + + + perc/99.9 + 15.69500 + + + perc/90.0 + 3.61700 + + + perc/95.0 + 3.61700 + + + perc/100.0 + 15.69500 + + + perc/99.0 + 15.64300 + + + perc/50.0 + 0.66900 + + + succ + 216 + + + throughput + 221 + + + concurrency + 9 + + + avg_rt + 1.62770 + + + fail + 5 + +