Skip to content

Commit

Permalink
Debug test failing on remote CI host
Browse files Browse the repository at this point in the history
Debug test failing on remote CI host

Debug test failing on remote CI host

Debug test failing on remote CI host

Debug test failing on remote CI host

Clean up debugging

Increase lines to make it run longer. Test completes sometimes

Consistently use 'LOGGER'

Document change
  • Loading branch information
tszmytka committed Sep 1, 2020
1 parent c3b1645 commit c4ccad5
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 8 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
0.7.3 (Next)
============

* [#202](https://github.com/jenkinsci/ansicolor-plugin/pull/202): Render logs correctly for long running jobs which generate lots of output - [@tszmytka](https://github.com/tszmytka).
* Your contribution here.


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ public final class AnsiColorBuildWrapper extends SimpleBuildWrapper implements S

/**
* Create a new {@link AnsiColorBuildWrapper}.
* @param colorMapName Name of the color map to use
*/
@DataBoundConstructor
public AnsiColorBuildWrapper(String colorMapName) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public final class AnsiColorConsoleLogFilter extends ConsoleLogFilter implements

private static final long serialVersionUID = 1L;

private static final Logger LOG = Logger.getLogger(AnsiColorConsoleLogFilter.class.getName());
private static final Logger LOGGER = Logger.getLogger(AnsiColorConsoleLogFilter.class.getName());

private AnsiColorMap colorMap;
private final Map<String, byte[]> notes;
Expand All @@ -46,14 +46,14 @@ public AnsiColorConsoleLogFilter(AnsiColorMap colorMap) {
pregenerateNote(AnsiAttributeElement.framed());
pregenerateNote(AnsiAttributeElement.overline());
// TODO other cases, and other methods
LOG.log(Level.FINE, "Notes pregenerated for {0}", notes.keySet());
LOGGER.log(Level.FINE, "Notes pregenerated for {0}", notes.keySet());
}

private void pregenerateNote(AnsiAttributeElement element) {
element.emitOpen(html -> pregenerateNote(html));
element.emitClose(html -> pregenerateNote(html));
}

private void pregenerateNote(String html) {
if (!notes.containsKey(html)) {
JenkinsJVM.checkJenkinsJVM();
Expand Down Expand Up @@ -91,7 +91,7 @@ public void emitHtml(@Nonnull String html) {
new SimpleHtmlNote(html).encodeTo(logger);
}
} catch (IOException e) {
LOG.log(Level.WARNING, "Failed to add HTML markup '" + html + "'", e);
LOGGER.log(Level.WARNING, "Failed to add HTML markup '" + html + "'", e);
}
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,15 @@

import java.util.Optional;
import java.util.UUID;
import java.util.logging.Logger;

import static hudson.plugins.ansicolor.action.ActionNote.TAG_ACTION_BEGIN;

/**
* Action for issuing commands to ColorConsoleAnnotator
*/
public class ColorizedAction extends InvisibleAction {
private static final Logger LOGGER = Logger.getLogger(ColorizedAction.class.getName());
private static final String TAG_PIPELINE_INTERNAL = "<span class=\"pipeline-new-node\"";
static final ColorizedAction CONTINUE = new ColorizedAction("", Command.CONTINUE);
static final ColorizedAction IGNORE = new ColorizedAction("", Command.IGNORE);
Expand Down Expand Up @@ -96,7 +98,9 @@ public static ColorizedAction parseAction(MarkupText text, Run<?, ?> run) {
if (line.contains(TAG_PIPELINE_INTERNAL)) {
return IGNORE;
}
if (run.isBuilding()) {
final boolean isBuilding = run.isBuilding();
LOGGER.fine("Run is building: " + isBuilding);
if (isBuilding) {
Optional<ColorizedAction> currentAction = run.getActions(ColorizedAction.class).stream()
.filter(a -> Command.CURRENT.equals(a.getCommand()))
.findFirst();
Expand Down
6 changes: 4 additions & 2 deletions src/test/java/hudson/plugins/ansicolor/AnsiColorStepTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -147,14 +147,16 @@ public void canRenderLongOutputWhileBuildStillRunning() {
public void evaluate() throws Throwable {
final String a1k = JenkinsTestSupport.repeat("a", 1024);
final String script = "ansiColor('xterm') {\n" +
JenkinsTestSupport.repeat("echo '\033[32m" + a1k + "\033[0m'\n", 150) +
"for (i = 0; i < 1000; i++) {" +
"echo '\033[32m" + a1k + "\033[0m'\n" +
"}" +
"}";
final WorkflowJob project = story.j.jenkins.createProject(WorkflowJob.class, "canRenderLongOutputWhileBuildStillRunning");
project.setDefinition(new CpsFlowDefinition(script, true));
QueueTaskFuture<WorkflowRun> runFuture = project.scheduleBuild2(0);
assertNotNull(runFuture);
final WorkflowRun lastBuild = runFuture.waitForStart();
await().pollDelay(Duration.ofSeconds(10)).pollInterval(Duration.ofSeconds(5)).atMost(Duration.ofSeconds(60)).until(() -> {
await().pollInterval(Duration.ofSeconds(5)).atMost(Duration.ofSeconds(150)).until(() -> {
StringWriter writer = new StringWriter();
final int skipInitialStartAction = 3000;
assertTrue(lastBuild.getLogText().writeHtmlTo(skipInitialStartAction, writer) > 0);
Expand Down

0 comments on commit c4ccad5

Please sign in to comment.