@Test
public void testOnlyOneChunkGroupAndOneMask() throws Exception {

  File file = fsFactory.getFile(FILE_NAME);
  TsFileWriter writer = new TsFileWriter(file);
  writer.registerTimeseries(new Path("d1", "s1"),
      new MeasurementSchema("s1", TSDataType.FLOAT, TSEncoding.RLE));
  writer.registerTimeseries(new Path("d1", "s2"),
      new MeasurementSchema("s2", TSDataType.FLOAT, TSEncoding.RLE));
  writer.write(new TSRecord(1, "d1").addTuple(new FloatDataPoint("s1", 5))
      .addTuple(new FloatDataPoint("s2", 4)));
  writer.write(new TSRecord(2, "d1").addTuple(new FloatDataPoint("s1", 5))
      .addTuple(new FloatDataPoint("s2", 4)));
  writer.flushAllChunkGroups();
  writer.getIOWriter().writeChunkMaskForTest();
  writer.getIOWriter().close();
  RestorableTsFileIOWriter rWriter = new RestorableTsFileIOWriter(file);
  writer = new TsFileWriter(rWriter);
  writer.close();
  assertNotEquals(TsFileIOWriter.magicStringBytes.length, rWriter.getTruncatedSize());
  TsFileSequenceReader reader = new TsFileSequenceReader(FILE_NAME);
  List<ChunkMetadata> chunkMetadataList = reader.getChunkMetadataList(new Path("d1", "s1"));
  assertNotNull(chunkMetadataList);
  chunkMetadataList = reader.getChunkMetadataList(new Path("d1", "s2"));
  assertNotNull(chunkMetadataList);
  reader.close();
  assertTrue(file.delete());
}