public virtual void TestAddIndexesWithThreads()
        {
            int NUM_ITER = TEST_NIGHTLY ? 15 : 5;
            const int NUM_COPY = 3;
            CommitAndAddIndexes c = new CommitAndAddIndexes(this, NUM_COPY);
            c.LaunchThreads(NUM_ITER);

            for (int i = 0; i < 100; i++)
            {
                AddDoc(c.Writer2);
            }

            c.JoinThreads();

            int expectedNumDocs = 100 + NUM_COPY * (4 * NUM_ITER / 5) * RunAddIndexesThreads.NUM_THREADS * RunAddIndexesThreads.NUM_INIT_DOCS;
            Assert.AreEqual(expectedNumDocs, c.Writer2.NumDocs(), "expected num docs don't match - failures: " + Environment.NewLine
                + string.Join(Environment.NewLine, c.Failures.Select(x => x.ToString())));

            c.Close(true);

            Assert.IsTrue(c.Failures.Count == 0, "found unexpected failures: " + c.Failures);

            IndexReader reader = DirectoryReader.Open(c.Dir2);
            Assert.AreEqual(expectedNumDocs, reader.NumDocs);
            reader.Dispose();

            c.CloseDir();
        }
Beispiel #2
0
		public virtual void  TestAddIndexesWithThreads()
		{
			
			int NUM_ITER = 12;
			int NUM_COPY = 3;
			CommitAndAddIndexes c = new CommitAndAddIndexes(this, NUM_COPY);
			c.LaunchThreads(NUM_ITER);
			
			for (int i = 0; i < 100; i++)
				AddDoc(c.writer2);
			
			c.JoinThreads();
			
			Assert.AreEqual(100 + NUM_COPY * (3 * NUM_ITER / 4) * Lucene.Net.Index.TestIndexWriter.CommitAndAddIndexes.NUM_THREADS * Lucene.Net.Index.TestIndexWriter.CommitAndAddIndexes.NUM_INIT_DOCS, c.writer2.NumDocs());
			
			c.Close(true);
			
			Assert.IsTrue(c.failures.Count == 0);
			
			_TestUtil.CheckIndex(c.dir2);
			
			IndexReader reader = IndexReader.Open(c.dir2);
			Assert.AreEqual(100 + NUM_COPY * (3 * NUM_ITER / 4) * Lucene.Net.Index.TestIndexWriter.CommitAndAddIndexes.NUM_THREADS * Lucene.Net.Index.TestIndexWriter.CommitAndAddIndexes.NUM_INIT_DOCS, reader.NumDocs());
			reader.Close();
			
			c.CloseDir();
		}