public virtual void TestTotalBytesSize()
{
Directory d = NewDirectory();
if (d is MockDirectoryWrapper)
{
((MockDirectoryWrapper)d).Throttling = MockDirectoryWrapper.Throttling_e.NEVER;
}
IndexWriterConfig iwc = NewIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(Random()));
iwc.SetMaxBufferedDocs(5);
iwc.SetMergeScheduler(new TrackingCMS());
if (TestUtil.GetPostingsFormat("id").Equals("SimpleText"))
{
// no
iwc.SetCodec(TestUtil.AlwaysPostingsFormat(new Lucene41PostingsFormat()));
}
RandomIndexWriter w = new RandomIndexWriter(Random(), d, iwc);
for (int i = 0; i < 1000; i++)
{
Document doc = new Document();
doc.Add(new StringField("id", "" + i, Field.Store.NO));
w.AddDocument(doc);
if (Random().NextBoolean())
{
w.DeleteDocuments(new Term("id", "" + Random().Next(i + 1)));
}
}
Assert.IsTrue(((TrackingCMS)w.w.Config.MergeScheduler).TotMergedBytes != 0);
w.Dispose();
d.Dispose();
}