use of com.facebook.buck.distributed.thrift.LogRecord in project buck by facebook.
the class SuperConsoleEventBusListenerTest method testSimpleDistBuildWithProgress.
@Test
public void testSimpleDistBuildWithProgress() throws IOException {
Clock fakeClock = new IncrementingFakeClock(TimeUnit.SECONDS.toNanos(1));
BuckEventBus eventBus = BuckEventBusFactory.newInstance(fakeClock);
SuperConsoleEventBusListener listener = createSuperConsole(fakeClock, eventBus);
BuildTarget fakeTarget = BuildTargetFactory.newInstance("//banana:stand");
BuildTarget cachedTarget = BuildTargetFactory.newInstance("//chicken:dance");
ImmutableSet<BuildTarget> buildTargets = ImmutableSet.of(fakeTarget, cachedTarget);
Iterable<String> buildArgs = Iterables.transform(buildTargets, Object::toString);
ProgressEstimator e = new ProgressEstimator(getStorageForTest(), eventBus, ObjectMappers.newDefaultInstance());
listener.setProgressEstimator(e);
eventBus.register(listener);
ProjectBuildFileParseEvents.Started parseEventStarted = new ProjectBuildFileParseEvents.Started();
eventBus.postWithoutConfiguring(configureTestEventAtTime(parseEventStarted, 0L, TimeUnit.MILLISECONDS, /* threadId */
0L));
validateConsole(listener, 0L, ImmutableList.of("[+] PARSING BUCK FILES...0.0s"));
validateConsole(listener, 100L, ImmutableList.of("[+] PARSING BUCK FILES...0.1s"));
eventBus.postWithoutConfiguring(configureTestEventAtTime(new ProjectBuildFileParseEvents.Finished(parseEventStarted), 200L, TimeUnit.MILLISECONDS, /* threadId */
0L));
validateConsole(listener, 200L, ImmutableList.of("[-] PARSING BUCK FILES...FINISHED 0.2s"));
// trigger a distributed build instead of a local build
BuildEvent.Started buildEventStarted = BuildEvent.started(buildArgs, true);
eventBus.postWithoutConfiguring(configureTestEventAtTime(buildEventStarted, 200L, TimeUnit.MILLISECONDS, /* threadId */
0L));
ParseEvent.Started parseStarted = ParseEvent.started(buildTargets);
eventBus.postWithoutConfiguring(configureTestEventAtTime(parseStarted, 200L, TimeUnit.MILLISECONDS, /* threadId */
0L));
validateConsole(listener, 300L, ImmutableList.of("[+] PROCESSING BUCK FILES...0.1s"));
eventBus.postWithoutConfiguring(configureTestEventAtTime(ParseEvent.finished(parseStarted, Optional.empty()), 300L, TimeUnit.MILLISECONDS, /* threadId */
0L));
ActionGraphEvent.Started actionGraphStarted = ActionGraphEvent.started();
eventBus.postWithoutConfiguring(configureTestEventAtTime(actionGraphStarted, 300L, TimeUnit.MILLISECONDS, /* threadId */
0L));
eventBus.postWithoutConfiguring(configureTestEventAtTime(ActionGraphEvent.finished(actionGraphStarted), 400L, TimeUnit.MILLISECONDS, /* threadId */
0L));
final String parsingLine = "[-] PROCESSING BUCK FILES...FINISHED 0.2s";
validateConsole(listener, 540L, ImmutableList.of(parsingLine, DOWNLOAD_STRING, "[+] DISTBUILD STATUS: INIT...", "[+] BUILDING...0.1s [0%]"));
eventBus.postWithoutConfiguring(configureTestEventAtTime(new DistBuildStatusEvent(DistBuildStatus.builder().setStatus(BuildStatus.QUEUED).setMessage("step 1").setETAMillis(2000).setLogBook(Optional.empty()).build()), 800L, TimeUnit.MILLISECONDS, /* threadId */
0L));
validateConsole(listener, 900L, ImmutableList.of(parsingLine, DOWNLOAD_STRING, "[+] DISTBUILD STATUS: QUEUED... ETA: 2.0s (step 1)", "[+] BUILDING...0.5s [29%]"));
LinkedList<LogRecord> debugLogs = new LinkedList<LogRecord>();
LogRecord log = new LogRecord();
log.setName("buck-client");
log.setTimestampMillis(0);
debugLogs.add(log);
final String distDebugLine = "Distributed build debug info:";
final String logLine1 = "[1970-01-01 00:00:00.000] buck-client";
eventBus.postWithoutConfiguring(configureTestEventAtTime(new DistBuildStatusEvent(DistBuildStatus.builder().setStatus(BuildStatus.BUILDING).setMessage("step 2").setETAMillis(1800).setLogBook(debugLogs).build()), 1000L, TimeUnit.MILLISECONDS, /* threadId */
0L));
validateConsole(listener, 1100L, ImmutableList.of(distDebugLine, logLine1, parsingLine, DOWNLOAD_STRING, "[+] DISTBUILD STATUS: BUILDING... ETA: 1.8s (step 2)", "[+] BUILDING...0.7s [50%]"));
log = new LogRecord();
log.setName("buck-frontend");
log.setTimestampMillis(100);
debugLogs.add(log);
final String logLine2 = "[1970-01-01 00:00:00.100] buck-frontend";
eventBus.postWithoutConfiguring(configureTestEventAtTime(new DistBuildStatusEvent(DistBuildStatus.builder().setStatus(BuildStatus.BUILDING).setMessage("step 2").setETAMillis(1600).setLogBook(debugLogs).build()), 1200L, TimeUnit.MILLISECONDS, /* threadId */
0L));
validateConsole(listener, 1300L, ImmutableList.of(distDebugLine, logLine1, logLine2, parsingLine, DOWNLOAD_STRING, "[+] DISTBUILD STATUS: BUILDING... ETA: 1.6s (step 2)", "[+] BUILDING...0.9s [64%]"));
log = new LogRecord();
log.setName("build_slave_start");
log.setTimestampMillis(200);
debugLogs.add(log);
final String logLine3 = "[1970-01-01 00:00:00.200] build_slave_start";
log = new LogRecord();
log.setName("build_slave_end");
log.setTimestampMillis(300);
debugLogs.add(log);
final String logLine4 = "[1970-01-01 00:00:00.300] build_slave_end";
eventBus.postWithoutConfiguring(configureTestEventAtTime(new DistBuildStatusEvent(DistBuildStatus.builder().setStatus(BuildStatus.FINISHED_SUCCESSFULLY).setMessage("step 3").setETAMillis(0).setLogBook(debugLogs).build()), 1400L, TimeUnit.MILLISECONDS, /* threadId */
0L));
final String distbuildLine = "[-] DISTBUILD STATUS: FINISHED_SUCCESSFULLY... (step 3)";
validateConsole(listener, 1500L, ImmutableList.of(distDebugLine, logLine1, logLine2, logLine3, logLine4, parsingLine, DOWNLOAD_STRING, distbuildLine, "[+] BUILDING...1.1s [100%]"));
eventBus.postWithoutConfiguring(configureTestEventAtTime(BuildEvent.finished(buildEventStarted, 0), 1600L, TimeUnit.MILLISECONDS, /* threadId */
0L));
final String buildingLine = "[-] BUILDING...FINISHED 1.2s [100%]";
validateConsole(listener, 1600L, ImmutableList.of(distDebugLine, logLine1, logLine2, logLine3, logLine4, parsingLine, FINISHED_DOWNLOAD_STRING, distbuildLine, buildingLine));
eventBus.postWithoutConfiguring(configureTestEventAtTime(ConsoleEvent.severe(SEVERE_MESSAGE), 1700L, TimeUnit.MILLISECONDS, /* threadId */
0L));
validateConsoleWithLogLines(listener, 1750L, ImmutableList.of(distDebugLine, logLine1, logLine2, logLine3, logLine4, parsingLine, FINISHED_DOWNLOAD_STRING, distbuildLine, buildingLine), ImmutableList.of(SEVERE_MESSAGE));
}
use of com.facebook.buck.distributed.thrift.LogRecord in project buck by facebook.
the class SuperConsoleEventBusListener method getDistBuildDebugInfo.
private void getDistBuildDebugInfo(ImmutableList.Builder<String> lines) {
// create a local reference to avoid inconsistencies
Optional<DistBuildStatus> distBuildStatus = this.distBuildStatus;
if (distBuildStatus.isPresent() && distBuildStatus.get().getLogBook().isPresent()) {
lines.add(ansi.asWarningText("Distributed build debug info:"));
for (LogRecord log : distBuildStatus.get().getLogBook().get()) {
String dateString = dateFormat.format(new Date(log.getTimestampMillis()));
lines.add(ansi.asWarningText(dateString + " " + log.getName()));
}
anyWarningsPrinted.set(true);
}
}
Aggregations