Ejemplo n.º 1
0
  @Test
  public void existingStateTest() throws Exception {
    Paths paths = ConfigGenerator.testPaths();
    Config config = ConfigGenerator.testConfig();
    FileTableWriter.Task writerTask =
        new FileTableWriter.Task(
            1, 1, paths, config, tuples.iterator(), tuples.size(), null, Throttle.MAX);
    writerTask.run();

    DBState state = new DBInitializer(config, new Metrics(config)).initialize();
    Assert.assertEquals("Should be 1 table", 1, state.tables().count());
    Assert.assertEquals("Should be 100 as the max snapshot id", 100, state.snapshots().currentId());
  }
Ejemplo n.º 2
0
 @Test
 public void defaultStateTest() throws Exception {
   Config config = ConfigGenerator.testConfig();
   DBState state = new DBInitializer(config, new Metrics(config)).initialize();
   Assert.assertTrue("No tables", state.tables().count() == 0);
   Assert.assertEquals("No Max Snapshot Id", 0, state.snapshots().currentId());
 }
Ejemplo n.º 3
0
  @Test
  public void existingStateLogTest() throws Exception {
    Paths paths = ConfigGenerator.testPaths();
    Config config = ConfigGenerator.testConfig();
    FileTableWriter.Task writerTask =
        new FileTableWriter.Task(
            1, 1, paths, config, tuples.iterator(), tuples.size(), null, Throttle.MAX);
    writerTask.run();

    CommitLogWriter log = CommitLogWriter.open(2, paths);
    List<Tuple> moreTestTuples = generateMoreTestRecords(101);
    for (Tuple tuple : moreTestTuples) {
      log.append(tuple, false);
    }

    log.close();

    DBState state = new DBInitializer(config, new Metrics(config)).initialize();
    Assert.assertEquals("Should be 2 tables", 2, state.tables().count());
    Assert.assertEquals("Should be 200 as the max snapshot id", 200, state.snapshots().currentId());
  }