Search in sources :

Example 1 with RecordingListener

use of com.google.copybara.testing.profiler.RecordingListener in project copybara by google.

the class ProfilerTest method setUp.

@Before
public void setUp() throws Exception {
    ticker = new FakeTicker().setAutoIncrementStep(1, TimeUnit.NANOSECONDS);
    profiler = new Profiler(ticker);
    recordingCallback = new RecordingListener();
    // We don't record anything  before start
    try (ProfilerTask ignore = profiler.start("bar")) {
        profiler.simpleTask("foo", 10, 20);
    }
    assertThat(recordingCallback.events).isEmpty();
    profiler.init(ImmutableList.of(recordingCallback));
}
Also used : ProfilerTask(com.google.copybara.profiler.Profiler.ProfilerTask) RecordingListener(com.google.copybara.testing.profiler.RecordingListener) FakeTicker(com.google.common.testing.FakeTicker) Before(org.junit.Before)

Example 2 with RecordingListener

use of com.google.copybara.testing.profiler.RecordingListener in project copybara by google.

the class GitMirrorTest method testMirror.

@Test
public void testMirror() throws Exception {
    RecordingListener recordingCallback = new RecordingListener();
    Profiler profiler = new Profiler(new FakeTicker());
    profiler.init(ImmutableList.of(recordingCallback));
    options.general.withProfiler(profiler);
    Migration mirror = createMirrorObj();
    mirror.run(workdir, ImmutableList.of());
    String orig = originRepo.git(originRepo.getGitDir(), "show-ref").getStdout();
    String dest = destRepo.git(destRepo.getGitDir(), "show-ref").getStdout();
    assertThat(dest).isEqualTo(orig);
    recordingCallback.assertMatchesNext(EventType.START, "//copybara").assertMatchesNext(EventType.START, "//copybara/run/default").assertMatchesNext(EventType.START, "//copybara/run/default/fetch").assertMatchesNext(EventType.END, "//copybara/run/default/fetch").assertMatchesNext(EventType.START, "//copybara/run/default/push").assertMatchesNext(EventType.END, "//copybara/run/default/push").assertMatchesNext(EventType.END, "//copybara/run/default");
}
Also used : Profiler(com.google.copybara.profiler.Profiler) RecordingListener(com.google.copybara.testing.profiler.RecordingListener) Migration(com.google.copybara.config.Migration) FakeTicker(com.google.common.testing.FakeTicker) Test(org.junit.Test)

Aggregations

FakeTicker (com.google.common.testing.FakeTicker)2 RecordingListener (com.google.copybara.testing.profiler.RecordingListener)2 Migration (com.google.copybara.config.Migration)1 Profiler (com.google.copybara.profiler.Profiler)1 ProfilerTask (com.google.copybara.profiler.Profiler.ProfilerTask)1 Before (org.junit.Before)1 Test (org.junit.Test)1