use of com.facebook.buck.event.BuckEventBus in project buck by facebook.
the class SuperConsoleEventBusListenerTest method testAutoSparseUpdates.
@Test
public void testAutoSparseUpdates() {
Clock fakeClock = new IncrementingFakeClock(TimeUnit.SECONDS.toNanos(1));
BuckEventBus eventBus = BuckEventBusFactory.newInstance(fakeClock);
SuperConsoleEventBusListener listener = createSuperConsole(fakeClock, eventBus);
AutoSparseStateEvents.SparseRefreshStarted sparseRefreshStarted = new AutoSparseStateEvents.SparseRefreshStarted();
eventBus.postWithoutConfiguring(configureTestEventAtTime(sparseRefreshStarted, 0L, TimeUnit.MILLISECONDS, /* threadId */
0L));
validateConsole(listener, 0L, ImmutableList.of("[+] REFRESHING SPARSE CHECKOUT...0.0s"));
eventBus.postWithoutConfiguring(configureTestEventAtTime(new AutoSparseStateEvents.SparseRefreshFinished(sparseRefreshStarted), 0L, TimeUnit.MILLISECONDS, /* threadId */
0L));
validateConsole(listener, 0L, ImmutableList.of("[-] REFRESHING SPARSE CHECKOUT...FINISHED 0.0s"));
// starting a new refresh resets the message
sparseRefreshStarted = new AutoSparseStateEvents.SparseRefreshStarted();
eventBus.postWithoutConfiguring(configureTestEventAtTime(sparseRefreshStarted, 0L, TimeUnit.MILLISECONDS, /* threadId */
0L));
validateConsole(listener, 0L, ImmutableList.of("[+] REFRESHING SPARSE CHECKOUT...0.0s"));
eventBus.postWithoutConfiguring(configureTestEventAtTime(new AutoSparseStateEvents.SparseRefreshFinished(sparseRefreshStarted), 0L, TimeUnit.MILLISECONDS, /* threadId */
0L));
validateConsole(listener, 0L, ImmutableList.of("[-] REFRESHING SPARSE CHECKOUT...FINISHED 0.0s"));
}
use of com.facebook.buck.event.BuckEventBus in project buck by facebook.
the class SuperConsoleEventBusListenerTest method renderLinesWithLineLimit.
@Test
public void renderLinesWithLineLimit() throws IOException {
Clock fakeClock = new IncrementingFakeClock(TimeUnit.SECONDS.toNanos(1));
BuckEventBus eventBus = BuckEventBusFactory.newInstance(fakeClock);
try (SuperConsoleEventBusListener listener = createSuperConsole(fakeClock, eventBus)) {
FakeThreadStateRenderer fakeRenderer = new FakeThreadStateRenderer(ImmutableList.of(2L, 1L, 4L, 8L, 5L));
ImmutableList.Builder<String> lines;
ImmutableList<String> fullOutput = ImmutableList.of(" |=> Status of thread 2", " |=> Status of thread 1", " |=> Status of thread 4", " |=> Status of thread 8", " |=> Status of thread 5");
compareOutput(listener, fakeRenderer, fullOutput, 10000);
compareOutput(listener, fakeRenderer, fullOutput, 10000);
compareOutput(listener, fakeRenderer, fullOutput, 6);
compareOutput(listener, fakeRenderer, fullOutput, 5);
lines = ImmutableList.builder();
listener.renderLines(fakeRenderer, lines, 4, false);
assertThat(lines.build(), equalTo(ImmutableList.of(" |=> Status of thread 2", " |=> Status of thread 1", " |=> Status of thread 4", " |=> 2 MORE THREADS: t8 t5")));
assertThat(fakeRenderer.lastSortWasByTime(), is(true));
lines = ImmutableList.builder();
listener.renderLines(fakeRenderer, lines, 2, false);
assertThat(lines.build(), equalTo(ImmutableList.of(" |=> Status of thread 2", " |=> 4 MORE THREADS: t1 t4 t8 t5")));
assertThat(fakeRenderer.lastSortWasByTime(), is(true));
lines = ImmutableList.builder();
listener.renderLines(fakeRenderer, lines, 1, false);
assertThat(lines.build(), equalTo(ImmutableList.of(" |=> 5 THREADS: t2 t1 t4 t8 t5")));
assertThat(fakeRenderer.lastSortWasByTime(), is(true));
}
}
use of com.facebook.buck.event.BuckEventBus in project buck by facebook.
the class SuperConsoleEventBusListenerTest method testParsingStatus.
@Test
public void testParsingStatus() {
Clock fakeClock = new IncrementingFakeClock(TimeUnit.SECONDS.toNanos(1));
BuckEventBus eventBus = BuckEventBusFactory.newInstance(fakeClock);
SuperConsoleEventBusListener listener = createSuperConsole(fakeClock, eventBus);
// new daemon instance & action graph cache miss
eventBus.post(DaemonEvent.newDaemonInstance());
assertEquals(NEW_DAEMON_INSTANCE_MSG, listener.getParsingStatus());
eventBus.post(ActionGraphEvent.Cache.miss(/* cacheWasEmpty */
true));
assertEquals(NEW_DAEMON_INSTANCE_MSG, listener.getParsingStatus());
// overflow scenario
String overflowMessage = "and if you go chasing rabbits";
eventBus.post(WatchmanStatusEvent.overflow(overflowMessage));
assertEquals(createParsingMessage(EMOJI_SNAIL, overflowMessage), listener.getParsingStatus());
// file added scenario
eventBus.post(WatchmanStatusEvent.fileCreation("and you know you're going to fall"));
assertEquals(createParsingMessage(EMOJI_SNAIL, "File added"), listener.getParsingStatus());
// file removed scenario
eventBus.post(WatchmanStatusEvent.fileDeletion("Tell 'em a hookah-smoking"));
assertEquals(createParsingMessage(EMOJI_SNAIL, "File removed"), listener.getParsingStatus());
// symlink invalidation scenario
eventBus.post(ParsingEvent.symlinkInvalidation("caterpillar has given you the call"));
assertEquals(createParsingMessage(EMOJI_WHALE, "Symlink caused cache invalidation"), listener.getParsingStatus());
// environmental change scenario
eventBus.post(ParsingEvent.environmentalChange("WHITE_RABBIT=1"));
assertEquals(createParsingMessage(EMOJI_SNAIL, "Environment variable changes: WHITE_RABBIT=1"), listener.getParsingStatus());
// action graph cache hit scenario
eventBus.post(ActionGraphEvent.Cache.hit());
assertEquals(createParsingMessage(EMOJI_BUNNY, ""), listener.getParsingStatus());
}
use of com.facebook.buck.event.BuckEventBus 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.event.BuckEventBus in project buck by facebook.
the class SuperConsoleEventBusListenerTest method testProjectGeneration.
@Test
public void testProjectGeneration() {
Clock fakeClock = new IncrementingFakeClock(TimeUnit.SECONDS.toNanos(1));
BuckEventBus eventBus = BuckEventBusFactory.newInstance(fakeClock);
SuperConsoleEventBusListener listener = createSuperConsole(fakeClock, eventBus);
eventBus.postWithoutConfiguring(configureTestEventAtTime(ProjectGenerationEvent.started(), 0L, TimeUnit.MILLISECONDS, /* threadId */
0L));
validateConsole(listener, 0L, ImmutableList.of("[+] GENERATING PROJECT...0.0s"));
eventBus.postWithoutConfiguring(configureTestEventAtTime(new ProjectGenerationEvent.Finished(), 0L, TimeUnit.MILLISECONDS, 0L));
validateConsole(listener, 0L, ImmutableList.of("[-] GENERATING PROJECT...FINISHED 0.0s"));
}
Aggregations