Skip to content

Commit 4e8faa4

Browse files
committed
Expect remote code using a TaskListener to flush at the end, and expect flush to be effective.
1 parent 39971d7 commit 4e8faa4

File tree

1 file changed

+1
-12
lines changed

1 file changed

+1
-12
lines changed

src/test/java/org/jenkinsci/plugins/workflow/log/LogStorageTestBase.java

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,7 @@
3737
import java.util.Random;
3838
import java.util.concurrent.Callable;
3939
import java.util.function.BiFunction;
40-
import java.util.logging.Logger;
4140
import jenkins.security.MasterToSlaveCallable;
42-
import org.apache.commons.io.IOUtils;
4341
import org.apache.commons.io.output.NullOutputStream;
4442
import org.apache.commons.io.output.NullWriter;
4543
import org.apache.commons.io.output.WriterOutputStream;
@@ -149,17 +147,7 @@ protected static void close(TaskListener listener) throws Exception {
149147
long stepPos = assertStepLog("1", 0, "step from master\n", true);
150148
VirtualChannel channel = r.createOnlineSlave().getChannel();
151149
channel.call(new RemotePrint("overall from agent", overall));
152-
while (!IOUtils.toString(text().readAll()).contains("overall from agent")) {
153-
// Implementations may be unable to honor the completed flag on remotely printed messages, pending some way to have all affected loggers confirm they have flushed
154-
Logger.getLogger(LogStorageTestBase.class.getName()).info("waiting for remote overall content to appear");
155-
Thread.sleep(1000);
156-
}
157-
// Note that we cannot guarantee ordering of messages if the remote printed declines to flush.
158150
channel.call(new RemotePrint("step from agent", step));
159-
while (!IOUtils.toString(text().readAll()).contains("step from agent")) {
160-
Logger.getLogger(LogStorageTestBase.class.getName()).info("waiting for remote step content to appear");
161-
Thread.sleep(1000);
162-
}
163151
overallPos = assertOverallLog(overallPos, "overall from agent\n<span class=\"pipeline-node-1\">step from agent\n</span>", true);
164152
stepPos = assertStepLog("1", stepPos, "step from agent\n", true);
165153
assertEquals(overallPos, assertOverallLog(overallPos, "", true));
@@ -177,6 +165,7 @@ private static final class RemotePrint extends MasterToSlaveCallable<Void, Excep
177165
}
178166
@Override public Void call() throws Exception {
179167
listener.getLogger().println(message);
168+
listener.getLogger().flush();
180169
return null;
181170
}
182171
}

0 commit comments

Comments
 (0)