Exemple #1
0
  public void testUpdateBaseAndDelta() throws Exception {
    // local root with just a base in it
    makeLocalFile("00005.base.cueball");

    MockFetcher fetcher = new MockFetcher(LOCAL_ROOT, "00006.base.cueball", "00007.delta.cueball");
    MockCueballMerger merger = new MockCueballMerger();
    CueballUpdater updater =
        new CueballUpdater(LOCAL_ROOT, 12, 5, fetcher, merger, new NoCompressionCodec(), 1);

    updater.update(7, null);

    // make sure fetcher got the right args
    assertEquals(5, fetcher.latestLocalVersion);

    // make sure the merger got the right args
    assertEquals(LOCAL_ROOT + "/00006.base.cueball", merger.latestBase);
    assertEquals(
        new HashSet<String>(Arrays.asList(LOCAL_ROOT + "/00007.delta.cueball")), merger.deltas);
    assertEquals(12, merger.keyHashSize);
    assertEquals(5, merger.valueSize);
    assertEquals(LOCAL_ROOT + "/00007.base.cueball", merger.newBasePath);

    // make sure that the mock base created by the merger still exists
    assertTrue(localFileExists("/00007.base.cueball"));
    // old base should be deleted
    assertFalse(localFileExists("/00005.base.cueball"));
    // delta that was fetched should be deleted
    assertFalse(localFileExists(LOCAL_ROOT + "/00006.base.cueball"));
    assertFalse(localFileExists(LOCAL_ROOT + "/00007.delta.cueball"));
  }
Exemple #2
0
  public void testBootstrapWithDeltas() throws Exception {
    // blank local root

    MockFetcher fetcher = new MockFetcher(LOCAL_ROOT, "00000.base.cueball", "00001.delta.cueball");
    MockCueballMerger merger = new MockCueballMerger();
    CueballUpdater updater =
        new CueballUpdater(LOCAL_ROOT, 12, 5, fetcher, merger, new NoCompressionCodec(), 1);

    updater.update(1, Collections.singleton(45));

    // make sure fetcher got the right args
    assertEquals(-1, fetcher.latestLocalVersion);
    assertEquals(Collections.singleton(45), fetcher.excludeVersions);

    // make sure the merger got the right args
    assertEquals(LOCAL_ROOT + "/00000.base.cueball", merger.latestBase);
    assertEquals(
        new HashSet<String>(Arrays.asList(LOCAL_ROOT + "/00001.delta.cueball")), merger.deltas);
    assertEquals(12, merger.keyHashSize);
    assertEquals(5, merger.valueSize);
    assertEquals(LOCAL_ROOT + "/00001.base.cueball", merger.newBasePath);

    // make sure that the mock base created by the merger still exists
    assertTrue(localFileExists("/00001.base.cueball"));
    // old base should be deleted
    assertFalse(localFileExists("/00000.base.cueball"));
    // delta that was fetched should be deleted
    assertFalse(localFileExists(LOCAL_ROOT + "/00001.delta.cueball"));
  }