Skip to content

Commit

Permalink
Merge pull request #9 from takipi/feature/OOE-19
Browse files Browse the repository at this point in the history
OOE-19 Update Bamboo Plugin with Show All Errors and Removing Increas…
  • Loading branch information
ccaspanello authored May 11, 2020
2 parents 59141c0 + 3b85dd9 commit 399bb72
Show file tree
Hide file tree
Showing 14 changed files with 25 additions and 1,651 deletions.
30 changes: 12 additions & 18 deletions src/main/java/com/overops/plugins/bamboo/TaskType.java
Original file line number Diff line number Diff line change
Expand Up @@ -73,15 +73,19 @@ public TaskResult execute(@NotNull TaskContext context) throws TaskException {
try {
logger.addBuildLogEntry("[" + Utils.getArtifactId() + " v" + Utils.getVersion() + "]");

boolean showAllEvents = Boolean.parseBoolean(context.getConfigurationMap().get(Const.SHOW_ALL_EVENTS));
boolean isDebug = Boolean.parseBoolean(context.getConfigurationMap().get(Const.DEBUG));
PrintStream printStream = isDebug ? new BambooPrintWriter(System.out, logger) : null;

QualityReport reportModel = overOpsService.runQualityReport(endPoint, apiKey, query, Requestor.BAMBOO, printStream, isDebug);

context.getBuildContext().getBuildResult().getCustomBuildData().put("overOpsReport", objectMapper.writeValueAsString(reportModel.getHtmlParts()));
context.getBuildContext().getBuildResult().getCustomBuildData().put("overOpsReport", objectMapper.writeValueAsString(reportModel.getHtmlParts(showAllEvents)));
context.getBuildContext().getBuildResult().getCustomBuildData().put("isOverOpsStep", "true");

if (reportModel.getStatusCode() == ReportStatus.FAILED) {
if ((reportModel.getExceptionDetails() != null) && Boolean.parseBoolean(context.getConfigurationMap().get(Const.PASS_BUILD_ON_QR_EXCEPTION))) {
return resultBuilder.success().build();
}
return resultBuilder.failed().build();
} else {
return resultBuilder.success().build();
Expand Down Expand Up @@ -132,23 +136,13 @@ private QualityReportParams getQualityReportParams(ConfigurationMap params) {
qrp.setCriticalExceptionTypes("");
}

if (Boolean.parseBoolean(params.get(Const.CHECK_INCREASING_ERRORS))) {
qrp.setActiveTimespan(params.get(Const.ACTIVE_TIMESPAN));
qrp.setBaselineTimespan(params.get(Const.BASELINE_TIMESPAN));
qrp.setMinVolumeThreshold(NumberUtils.toInt(params.get(Const.MIN_VOLUME_THRESHOLD), 0));
qrp.setMinErrorRateThreshold(NumberUtils.toDouble(params.get(Const.MIN_RATE_THRESHOLD), 0));
qrp.setRegressionDelta(NumberUtils.toDouble(params.get(Const.REGRESSION_DELTA), 0));
qrp.setCriticalRegressionDelta(NumberUtils.toDouble(params.get(Const.CRITICAL_REGRESSION_THRESHOLD), 0));
qrp.setApplySeasonality(Boolean.parseBoolean(params.get(Const.APPLY_SEASONALITY)));
} else {
qrp.setActiveTimespan("0");
qrp.setBaselineTimespan("0");
qrp.setMinVolumeThreshold(0);
qrp.setMinErrorRateThreshold(0);
qrp.setRegressionDelta(0);
qrp.setCriticalRegressionDelta(0);
qrp.setApplySeasonality(false);
}
qrp.setActiveTimespan("0");
qrp.setBaselineTimespan("0");
qrp.setMinVolumeThreshold(0);
qrp.setMinErrorRateThreshold(0);
qrp.setRegressionDelta(0);
qrp.setCriticalRegressionDelta(0);
qrp.setApplySeasonality(false);

qrp.setDebug(Boolean.parseBoolean(params.get(Const.DEBUG)));
return qrp;
Expand Down
13 changes: 3 additions & 10 deletions src/main/java/com/overops/plugins/bamboo/configuration/Const.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ public class Const {
public static final String REGEX_FILTER = "regexFilter";
public static final String TOP_ERROR_COUNT = "topErrorCount";
public static final String MARK_UNSTABLE = "markUnstable";
public static final String SHOW_ALL_EVENTS = "showAllEvents";
public static final String PASS_BUILD_ON_QR_EXCEPTION = "passOnQRException";


public static final String CHECK_NEW_ERRORS = "checkNewErrors";
public static final String CHECK_RESURFACED_ERRORS = "checkResurfacedErrors";
Expand All @@ -34,18 +37,8 @@ public class Const {
public static final String CHECK_CRITICAL_ERRORS = "checkCriticalErrors";
public static final String CRITICAL_EXCEPTION_TYPES = "criticalExceptionTypes";

public static final String CHECK_INCREASING_ERRORS = "checkIncreasingErrors";
public static final String ACTIVE_TIMESPAN = "activeTimespan";
public static final String BASELINE_TIMESPAN = "baselineTimespan";
public static final String MIN_VOLUME_THRESHOLD = "minVolumeThreshold";
public static final String MIN_RATE_THRESHOLD = "minRateThreshold";
public static final String REGRESSION_DELTA = "regressionDelta";
public static final String CRITICAL_REGRESSION_THRESHOLD = "criticalRegressionThreshold";
public static final String APPLY_SEASONALITY = "applySeasonality";

public static final String DEBUG = "debug";


// default values
public static final String DEFAULT_API_URL = "https://api.overops.com/";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ public void populateContextForEdit(Map<String, Object> context, TaskDefinition t
context.put(Const.REGEX_FILTER, config.get(Const.REGEX_FILTER));
context.put(Const.TOP_ERROR_COUNT, config.get(Const.TOP_ERROR_COUNT));
context.put(Const.MARK_UNSTABLE, config.get(Const.MARK_UNSTABLE));
context.put(Const.SHOW_ALL_EVENTS, config.get(Const.SHOW_ALL_EVENTS));
context.put(Const.PASS_BUILD_ON_QR_EXCEPTION, config.get(Const.PASS_BUILD_ON_QR_EXCEPTION));

// new and resurfaced quality gates
context.put(Const.CHECK_NEW_ERRORS, config.get(Const.CHECK_NEW_ERRORS));
Expand All @@ -61,16 +63,6 @@ public void populateContextForEdit(Map<String, Object> context, TaskDefinition t
context.put(Const.CHECK_CRITICAL_ERRORS, config.get(Const.CHECK_CRITICAL_ERRORS));
context.put(Const.CRITICAL_EXCEPTION_TYPES, config.get(Const.CRITICAL_EXCEPTION_TYPES));

// increasing errors quality gate
context.put(Const.CHECK_INCREASING_ERRORS, config.get(Const.CHECK_INCREASING_ERRORS));
context.put(Const.ACTIVE_TIMESPAN, config.get(Const.ACTIVE_TIMESPAN));
context.put(Const.BASELINE_TIMESPAN, config.get(Const.BASELINE_TIMESPAN));
context.put(Const.MIN_VOLUME_THRESHOLD, config.get(Const.MIN_VOLUME_THRESHOLD));
context.put(Const.MIN_RATE_THRESHOLD, config.get(Const.MIN_RATE_THRESHOLD));
context.put(Const.REGRESSION_DELTA, config.get(Const.REGRESSION_DELTA));
context.put(Const.CRITICAL_REGRESSION_THRESHOLD, config.get(Const.CRITICAL_REGRESSION_THRESHOLD));
context.put(Const.APPLY_SEASONALITY, config.get(Const.APPLY_SEASONALITY));

// advanced settings
context.put(Const.DEBUG, config.get(Const.DEBUG));
}
Expand All @@ -90,6 +82,8 @@ public Map<String, String> generateTaskConfigMap(ActionParametersMap params, Tas
config.put(Const.REGEX_FILTER, params.getString(Const.REGEX_FILTER));
config.put(Const.TOP_ERROR_COUNT, params.getString(Const.TOP_ERROR_COUNT));
config.put(Const.MARK_UNSTABLE, params.getString(Const.MARK_UNSTABLE));
config.put(Const.SHOW_ALL_EVENTS, params.getString(Const.SHOW_ALL_EVENTS));
config.put(Const.PASS_BUILD_ON_QR_EXCEPTION, params.getString(Const.PASS_BUILD_ON_QR_EXCEPTION));

// new and resurfaced quality gates
config.put(Const.CHECK_NEW_ERRORS, params.getString(Const.CHECK_NEW_ERRORS));
Expand All @@ -107,16 +101,6 @@ public Map<String, String> generateTaskConfigMap(ActionParametersMap params, Tas
config.put(Const.CHECK_CRITICAL_ERRORS, params.getString(Const.CHECK_CRITICAL_ERRORS));
config.put(Const.CRITICAL_EXCEPTION_TYPES, params.getString(Const.CRITICAL_EXCEPTION_TYPES));

// increasing errors quality gate
config.put(Const.CHECK_INCREASING_ERRORS, params.getString(Const.CHECK_INCREASING_ERRORS));
config.put(Const.ACTIVE_TIMESPAN, params.getString(Const.ACTIVE_TIMESPAN).toLowerCase()); // D,H,M -> d,h,m
config.put(Const.BASELINE_TIMESPAN, params.getString(Const.BASELINE_TIMESPAN).toLowerCase());
config.put(Const.MIN_VOLUME_THRESHOLD, params.getString(Const.MIN_VOLUME_THRESHOLD));
config.put(Const.MIN_RATE_THRESHOLD, params.getString(Const.MIN_RATE_THRESHOLD));
config.put(Const.REGRESSION_DELTA, params.getString(Const.REGRESSION_DELTA));
config.put(Const.CRITICAL_REGRESSION_THRESHOLD, params.getString(Const.CRITICAL_REGRESSION_THRESHOLD));
config.put(Const.APPLY_SEASONALITY, params.getString(Const.APPLY_SEASONALITY));

// advanced settings
config.put(Const.DEBUG, params.getString(Const.DEBUG));

Expand Down Expand Up @@ -144,13 +128,6 @@ public void validate(ActionParametersMap params, ErrorCollection errorCollection
// validate critical errors
validString(Const.CRITICAL_EXCEPTION_TYPES, Const.CHECK_CRITICAL_ERRORS);

// validate increasing errors
validTimeWindow(Const.ACTIVE_TIMESPAN, Const.CHECK_INCREASING_ERRORS);
validTimeWindow(Const.BASELINE_TIMESPAN, Const.CHECK_INCREASING_ERRORS);
validNumber(Const.MIN_VOLUME_THRESHOLD, Const.CHECK_INCREASING_ERRORS);
validRange(Const.MIN_RATE_THRESHOLD, Const.CHECK_INCREASING_ERRORS);
validRange(Const.REGRESSION_DELTA, Const.CHECK_INCREASING_ERRORS);
validRange(Const.CRITICAL_REGRESSION_THRESHOLD, Const.CHECK_INCREASING_ERRORS);
}

// must be a number
Expand Down

This file was deleted.

Loading

0 comments on commit 399bb72

Please sign in to comment.