Search in sources :

Example 11 with BuckEvent

use of com.facebook.buck.event.BuckEvent in project buck by facebook.

the class UnskippedRulesTrackerTest method assertNoNewEvents.

private void assertNoNewEvents() throws InterruptedException {
    // BuckEventBus is asynchronous so it is not enough to check that the events queue is empty.
    // Instead, post a fake event and check that there were no pending events before it.
    BuckEvent sentinel = new FakeEvent();
    eventBus.post(sentinel);
    assertThat("An event was received but no event was expected", events.take(), is(sameInstance(sentinel)));
}
Also used : BuckEvent(com.facebook.buck.event.BuckEvent) AbstractBuckEvent(com.facebook.buck.event.AbstractBuckEvent)

Example 12 with BuckEvent

use of com.facebook.buck.event.BuckEvent in project buck by facebook.

the class UnskippedRulesTrackerTest method setUp.

@Before
public void setUp() {
    BuildRuleResolver resolver = new BuildRuleResolver(TargetGraph.EMPTY, new DefaultTargetNodeToBuildRuleTransformer());
    SourcePathRuleFinder ruleFinder = new SourcePathRuleFinder(resolver);
    sourcePathResolver = new SourcePathResolver(ruleFinder);
    ListeningExecutorService executor = listeningDecorator(MostExecutors.newMultiThreadExecutor("UnskippedRulesTracker", 7));
    RuleDepsCache depsCache = new RuleDepsCache(executor, resolver);
    unskippedRulesTracker = new UnskippedRulesTracker(depsCache, resolver, executor);
    eventBus = new BuckEventBus(new FakeClock(1), new BuildId());
    eventBus.register(new Object() {

        @Subscribe
        public void onUnskippedRuleCountUpdated(BuckEvent event) {
            events.add(event);
        }
    });
    ruleH = resolver.addToIndex(createRule("//:h"));
    ruleG = resolver.addToIndex(createRule("//:g"));
    ruleF = resolver.addToIndex(createRule("//:f"));
    ruleE = resolver.addToIndex(createRule("//:e", ImmutableSet.of(ruleG, ruleH)));
    ruleD = resolver.addToIndex(createRule("//:d", ImmutableSet.of(ruleG), ImmutableSet.of(ruleF)));
    ruleC = resolver.addToIndex(createRule("//:c", ImmutableSet.of(ruleD, ruleE)));
    ruleB = resolver.addToIndex(createRule("//:b", ImmutableSet.of(), ImmutableSet.of(ruleD)));
    ruleA = resolver.addToIndex(createRule("//:a", ImmutableSet.of(ruleD)));
}
Also used : BuckEventBus(com.facebook.buck.event.BuckEventBus) FakeClock(com.facebook.buck.timing.FakeClock) Subscribe(com.google.common.eventbus.Subscribe) BuckEvent(com.facebook.buck.event.BuckEvent) AbstractBuckEvent(com.facebook.buck.event.AbstractBuckEvent) BuildId(com.facebook.buck.model.BuildId) ListeningExecutorService(com.google.common.util.concurrent.ListeningExecutorService) Before(org.junit.Before)

Example 13 with BuckEvent

use of com.facebook.buck.event.BuckEvent in project buck by facebook.

the class BuckEventOrdererTest method testPreservesInsertionOrderForSameTimestamp.

@Test
public void testPreservesInsertionOrderForSameTimestamp() {
    BuckEvent first = createUniqueEvent(0, TimeUnit.MILLISECONDS, THREAD_ONE);
    BuckEvent second = createUniqueEvent(0, TimeUnit.MILLISECONDS, THREAD_ONE);
    BuckEvent third = createUniqueEvent(0, TimeUnit.MILLISECONDS, THREAD_ONE);
    try (BuckEventOrderer<BuckEvent> orderer = new BuckEventOrderer<>(addToSerializedEventsFunction, MAX_SKEW, TimeUnit.MILLISECONDS)) {
        orderer.add(first);
        orderer.add(second);
        orderer.add(third);
    }
    assertThat(serializedEvents, Matchers.contains(first, second, third));
}
Also used : BuckEvent(com.facebook.buck.event.BuckEvent) AbstractBuckEvent(com.facebook.buck.event.AbstractBuckEvent) Test(org.junit.Test)

Example 14 with BuckEvent

use of com.facebook.buck.event.BuckEvent in project buck by facebook.

the class BuckEventOrdererTest method testPreservesInsertionOrderForSameTimestampWithReorder.

@Test
public void testPreservesInsertionOrderForSameTimestampWithReorder() {
    BuckEvent first = createUniqueEvent(1, TimeUnit.MILLISECONDS, THREAD_ONE);
    BuckEvent second = createUniqueEvent(2, TimeUnit.MILLISECONDS, THREAD_ONE);
    BuckEvent third = createUniqueEvent(2, TimeUnit.MILLISECONDS, THREAD_ONE);
    BuckEvent fourth = createUniqueEvent(2, TimeUnit.MILLISECONDS, THREAD_ONE);
    try (BuckEventOrderer<BuckEvent> orderer = new BuckEventOrderer<>(addToSerializedEventsFunction, MAX_SKEW, TimeUnit.MILLISECONDS)) {
        orderer.add(second);
        orderer.add(third);
        orderer.add(fourth);
        orderer.add(first);
    }
    assertThat(serializedEvents, Matchers.contains(first, second, third, fourth));
}
Also used : BuckEvent(com.facebook.buck.event.BuckEvent) AbstractBuckEvent(com.facebook.buck.event.AbstractBuckEvent) Test(org.junit.Test)

Example 15 with BuckEvent

use of com.facebook.buck.event.BuckEvent in project buck by facebook.

the class BuckEventOrdererTest method testPreservesInsertionOrderForSameTimestampWithReverseReorder.

@Test
public void testPreservesInsertionOrderForSameTimestampWithReverseReorder() {
    BuckEvent first = createUniqueEvent(0, TimeUnit.MILLISECONDS, THREAD_ONE);
    BuckEvent second = createUniqueEvent(0, TimeUnit.MILLISECONDS, THREAD_ONE);
    BuckEvent third = createUniqueEvent(0, TimeUnit.MILLISECONDS, THREAD_ONE);
    BuckEvent fourth = createUniqueEvent(5, TimeUnit.MILLISECONDS, THREAD_ONE);
    try (BuckEventOrderer<BuckEvent> orderer = new BuckEventOrderer<>(addToSerializedEventsFunction, MAX_SKEW, TimeUnit.MILLISECONDS)) {
        orderer.add(fourth);
        orderer.add(first);
        orderer.add(second);
        orderer.add(third);
    }
    assertThat(serializedEvents, Matchers.contains(first, second, third, fourth));
}
Also used : BuckEvent(com.facebook.buck.event.BuckEvent) AbstractBuckEvent(com.facebook.buck.event.AbstractBuckEvent) Test(org.junit.Test)

Aggregations

BuckEvent (com.facebook.buck.event.BuckEvent)19 Test (org.junit.Test)16 AbstractBuckEvent (com.facebook.buck.event.AbstractBuckEvent)12 BuckEventBus (com.facebook.buck.event.BuckEventBus)5 ConsoleEvent (com.facebook.buck.event.ConsoleEvent)4 Subscribe (com.google.common.eventbus.Subscribe)4 FakeBuckEventListener (com.facebook.buck.event.FakeBuckEventListener)3 ExecutionContext (com.facebook.buck.step.ExecutionContext)3 TestExecutionContext (com.facebook.buck.step.TestExecutionContext)3 FakeClock (com.facebook.buck.timing.FakeClock)3 WatchmanStatusEvent (com.facebook.buck.event.WatchmanStatusEvent)2 BuildId (com.facebook.buck.model.BuildId)2 EventBus (com.google.common.eventbus.EventBus)2 ListeningExecutorService (com.google.common.util.concurrent.ListeningExecutorService)2 FakeWatchmanClient (com.facebook.buck.io.FakeWatchmanClient)1 LazyPath (com.facebook.buck.io.LazyPath)1 WatchmanCursor (com.facebook.buck.io.WatchmanCursor)1 RuleKey (com.facebook.buck.rules.RuleKey)1 HttpResponse (com.facebook.buck.slb.HttpResponse)1 HttpService (com.facebook.buck.slb.HttpService)1