Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test review Core I-J #926

Merged
merged 76 commits into from
Mar 21, 2024
Merged
Show file tree
Hide file tree
Changes from 68 commits
Commits
Show all changes
76 commits
Select commit Hold shift + click to select a range
4013a39
Test review of TestIndexableField
paulirwin Feb 26, 2024
f3d26a3
Test review of TestIndexCommit
paulirwin Feb 26, 2024
10e76b9
Test review of TestIndexFileDeleter
paulirwin Feb 26, 2024
a06a660
Test review of TestIndexReaderClose
paulirwin Feb 26, 2024
9c83fbc
Test review of TestIndexWriterCommit
paulirwin Feb 26, 2024
8ee8c6d
Test review of TestIndexWriterConfig
paulirwin Mar 3, 2024
cac2362
Test review of TestIndexWriterDelete
paulirwin Mar 5, 2024
ada9e66
Test review of TestIndexWriterExceptions
paulirwin Mar 7, 2024
714a57d
Test review of TestIndexWriterForceMerge, plus fix static copied methods
paulirwin Mar 8, 2024
e5389c8
Test review of TestIndexWriterLockRelease
paulirwin Mar 8, 2024
be5b832
Test review of TestIndexWriterMergePolicy, and unify IndexWriterConfi…
paulirwin Mar 8, 2024
4429965
Test review of TestIndexWriterMerging
paulirwin Mar 8, 2024
2495e3d
Test review of TestIndexWriterOnDiskFull
paulirwin Mar 8, 2024
abc9da0
Test review of TestIndexWriterOnJRECrash
paulirwin Mar 8, 2024
bf07f88
Test review of TestIndexWriterOutOfFileDescriptors, and clean up cond…
paulirwin Mar 8, 2024
994c3a6
Test review of TestIndexWriterUnicode
paulirwin Mar 8, 2024
5e3aab7
Test review of TestIndexWriterWithThreads
paulirwin Mar 8, 2024
7740520
Fix region removal of CreateIndexNoClose
paulirwin Mar 8, 2024
bdf7c68
Test review of TestIntBlockPool
paulirwin Mar 8, 2024
c5dbc09
Test review of TestLazyProxSkipping
paulirwin Mar 8, 2024
e7240ce
Test review of TestLogMergePolicy
paulirwin Mar 8, 2024
606e5e0
Test review of TestLongPostings
paulirwin Mar 8, 2024
2c9c783
Test review of TestMaxTermFrequency
paulirwin Mar 8, 2024
4704c50
Test review of TestMixedCodecs
paulirwin Mar 8, 2024
d1c9990
Test review of TestMixedDocValuesUpdates
paulirwin Mar 8, 2024
c21a280
Test review of TestMultiDocValues
paulirwin Mar 8, 2024
0e9a187
Test review of TestMultiFields
paulirwin Mar 8, 2024
ebca50c
Test review of TestMultiLevelSkipList
paulirwin Mar 8, 2024
823a94d
Test review of TestNeverDelete
paulirwin Mar 8, 2024
39dc3d0
Test review of TestNorms
paulirwin Mar 9, 2024
9845b19
Test review of TestNRTReaderWithThreads
paulirwin Mar 9, 2024
ad18ef0
Test review of TestNRTThreads
paulirwin Mar 9, 2024
129f67b
Test review of TestNumericDocValuesUpdates
paulirwin Mar 9, 2024
2996ed9
Test review of TestOmitNorms
paulirwin Mar 9, 2024
14ccf01
Test review of TestOmitPositions
paulirwin Mar 9, 2024
733834b
Test review of TestOmitTf
paulirwin Mar 9, 2024
93ab197
Test review of TestParallelAtomicReader
paulirwin Mar 9, 2024
41a01c3
Test review of TestParallelCompositeReader
paulirwin Mar 10, 2024
69246d5
Test review of TestParallelReaderEmptyIndex
paulirwin Mar 10, 2024
36addaa
Test review of TestPayloads
paulirwin Mar 10, 2024
171d420
Test review of TestPerSegmentDeletes
paulirwin Mar 10, 2024
64df147
Test review of TestPersistentSnapshotDeletionPolicy
paulirwin Mar 10, 2024
f029231
Test review of TestPostingsOffsets
paulirwin Mar 10, 2024
cd8e057
Replace int.MinValue with MergeTrigger.NONE
paulirwin Mar 10, 2024
ab67dbb
Test review of TestReaderClosed
paulirwin Mar 10, 2024
c86c513
Test review of TestRollingUpdates
paulirwin Mar 10, 2024
faadc67
Test review of TestSameTokenSamePosition
paulirwin Mar 10, 2024
b9c047b
Test review of TestSegmentMerger
paulirwin Mar 10, 2024
7498e9e
Test review of TestSegmentReader
paulirwin Mar 10, 2024
ccbb96e
Test review of TestSegmentTermDocs
paulirwin Mar 10, 2024
74d4272
Test review of TestSizeBoundedForceMerge
paulirwin Mar 10, 2024
ce0c5b8
Test review of TestSnapshotDeletionPolicy; revert SetUp change on Tes…
paulirwin Mar 10, 2024
7ffae7f
Test review of TestStoredFieldsFormat
paulirwin Mar 10, 2024
7d675dd
Test review of TestStressAdvance
paulirwin Mar 10, 2024
836e38e
Test review of TestStressIndexing
paulirwin Mar 11, 2024
578184f
Test review of TestStressIndexing2
paulirwin Mar 11, 2024
0e8f58f
Test review of TestStressNRT
paulirwin Mar 11, 2024
d793adf
Test review of TestSumDocFreq
paulirwin Mar 11, 2024
4461cc3
Test review of TestTermdocPerf
paulirwin Mar 11, 2024
52bd7d4
Test review of TestTermsEnum
paulirwin Mar 11, 2024
c8cfc0c
Test review of TestTermsEnum2
paulirwin Mar 11, 2024
05e33c1
Test review of TestTermVectorsFormat
paulirwin Mar 11, 2024
5e98324
Test review of TestTermVectorsReader
paulirwin Mar 11, 2024
81e3ec7
Test review of TestTermVectorsWriter
paulirwin Mar 11, 2024
c8c1f15
Test review of TestThreadedForceMerge
paulirwin Mar 11, 2024
bd2c945
Test review of TestTransactionRollback
paulirwin Mar 11, 2024
0da3d2b
Test review of TestTransactions
paulirwin Mar 11, 2024
d41501f
Test review of TestUniqueTermCount
paulirwin Mar 11, 2024
80673c3
Misc cleanup from PR review
paulirwin Mar 13, 2024
59db9c9
Make IOUtils.CHARSET_UTF_8 not use a BOM; remove obsolete attribute
paulirwin Mar 13, 2024
1c43b7f
Remove using aliases from TestIndexWriterReader
paulirwin Mar 13, 2024
f8def01
Add comment explaining MergeTrigger.NONE use
paulirwin Mar 13, 2024
9be0d3e
Use invariant culture for Convert.ToString in TestStressNRT
paulirwin Mar 13, 2024
2967e0c
Make MergeTrigger.NONE be 0, add back previously commented-out assert…
paulirwin Mar 13, 2024
98a99bc
Add missing usings in TestIndexWriterReader
paulirwin Mar 14, 2024
5f7137a
Update TestTermsEnum to better match Java code, with fix for MakeIndex
paulirwin Mar 16, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/Lucene.Net.TestFramework/Index/MockRandomMergePolicy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,8 @@ public override MergeSpecification FindForcedMerges(SegmentInfos segmentInfos, i

public override MergeSpecification FindForcedDeletesMerges(SegmentInfos segmentInfos)
{
// LUCENENET specific - just use int.MinValue to indicate "null"
return FindMerges((MergeTrigger)int.MinValue, segmentInfos);
// LUCENENET specific - use NONE instead of null
return FindMerges(MergeTrigger.NONE, segmentInfos);
}

protected override void Dispose(bool disposing)
Expand All @@ -130,4 +130,4 @@ public override bool UseCompoundFile(SegmentInfos infos, SegmentCommitInfo merge
return random.Next(5) != 1;
}
}
}
}
20 changes: 7 additions & 13 deletions src/Lucene.Net.Tests/Index/TestIndexCommit.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ public virtual void TestEqualsHashCode()
// LUCENE-2417: equals and hashCode() impl was inconsistent
Directory dir = NewDirectory();

IndexCommit ic1 = new IndexCommitAnonymousClass(this, dir);
IndexCommit ic1 = new IndexCommitAnonymousClass(dir);

IndexCommit ic2 = new IndexCommitAnonymousClass2(this, dir);
IndexCommit ic2 = new IndexCommitAnonymousClass2(dir);

Assert.AreEqual(ic1, ic2);
Assert.AreEqual(ic1.GetHashCode(), ic2.GetHashCode(), "hash codes are not equals");
Expand All @@ -44,13 +44,10 @@ public virtual void TestEqualsHashCode()

private sealed class IndexCommitAnonymousClass : IndexCommit
{
private readonly TestIndexCommit outerInstance;
private readonly Directory dir;

private Directory dir;

public IndexCommitAnonymousClass(TestIndexCommit outerInstance, Directory dir)
public IndexCommitAnonymousClass(Directory dir)
{
this.outerInstance = outerInstance;
this.dir = dir;
}

Expand All @@ -75,13 +72,10 @@ public override void Delete()

private sealed class IndexCommitAnonymousClass2 : IndexCommit
{
private readonly TestIndexCommit outerInstance;

private Directory dir;
private readonly Directory dir;

public IndexCommitAnonymousClass2(TestIndexCommit outerInstance, Directory dir)
public IndexCommitAnonymousClass2(Directory dir)
{
this.outerInstance = outerInstance;
this.dir = dir;
}

Expand All @@ -104,4 +98,4 @@ public override void Delete()
public override int SegmentCount => 2;
}
}
}
}
19 changes: 14 additions & 5 deletions src/Lucene.Net.Tests/Index/TestIndexFileDeleter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,12 @@ public virtual void TestDeleteLeftoverFiles()
mergePolicy.NoCFSRatio = 1.0;
mergePolicy.MaxCFSSegmentSizeMB = double.PositiveInfinity;

IndexWriter writer = new IndexWriter(dir, NewIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(Random)).SetMaxBufferedDocs(10).SetMergePolicy(mergePolicy).SetUseCompoundFile(true));
IndexWriter writer = new IndexWriter(
dir,
NewIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(Random)).
SetMaxBufferedDocs(10).
SetMergePolicy(mergePolicy).SetUseCompoundFile(true)
);

int i;
for (i = 0; i < 35; i++)
Expand All @@ -75,7 +80,11 @@ public virtual void TestDeleteLeftoverFiles()
writer.Dispose();

// Delete one doc so we get a .del file:
writer = new IndexWriter(dir, NewIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(Random)).SetMergePolicy(NoMergePolicy.NO_COMPOUND_FILES).SetUseCompoundFile(true));
writer = new IndexWriter(
dir,
NewIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(Random)).
SetMergePolicy(NoMergePolicy.NO_COMPOUND_FILES).SetUseCompoundFile(true)
);
Term searchTerm = new Term("id", "7");
writer.DeleteDocuments(searchTerm);
writer.Dispose();
Expand Down Expand Up @@ -157,7 +166,7 @@ private static ISet<string> DifFiles(string[] files1, string[] files2)
{
set2.Add(files2[x]);
}
IEnumerator<string> i1 = set1.GetEnumerator();
using IEnumerator<string> i1 = set1.GetEnumerator();
while (i1.MoveNext())
{
string o = i1.Current;
Expand All @@ -166,7 +175,7 @@ private static ISet<string> DifFiles(string[] files1, string[] files2)
extra.Add(o);
}
}
IEnumerator<string> i2 = set2.GetEnumerator();
using IEnumerator<string> i2 = set2.GetEnumerator();
while (i2.MoveNext())
{
string o = i2.Current;
Expand Down Expand Up @@ -217,4 +226,4 @@ private void AddDoc(IndexWriter writer, int id)
writer.AddDocument(doc);
}
}
}
}
17 changes: 7 additions & 10 deletions src/Lucene.Net.Tests/Index/TestIndexReaderClose.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public class TestIndexReaderClose : LuceneTestCase
[Test]
public virtual void TestCloseUnderException()
{
int iters = 1000 + 1 + Random.nextInt(20);
int iters = 1000 + 1 + Random.Next(20);
for (int j = 0; j < iters; j++)
{
Directory dir = NewDirectory();
Expand All @@ -46,7 +46,7 @@ public virtual void TestCloseUnderException()
DirectoryReader open = DirectoryReader.Open(dir);
bool throwOnClose = !Rarely();
AtomicReader wrap = SlowCompositeReaderWrapper.Wrap(open);
FilterAtomicReader reader = new FilterAtomicReaderAnonymousClass(this, wrap, throwOnClose);
FilterAtomicReader reader = new FilterAtomicReaderAnonymousClass(wrap, throwOnClose);
//IList<IReaderDisposedListener> listeners = new JCG.List<IReaderDisposedListener>(); // LUCENENET: This list is unused (and was unused in Java)
int listenerCount = Random.Next(20);
AtomicInt32 count = new AtomicInt32();
Expand Down Expand Up @@ -87,7 +87,7 @@ public virtual void TestCloseUnderException()

try
{
var aaa = reader.Fields;
_ = reader.Fields;
Assert.Fail("we are closed");
}
catch (Exception ex) when (ex.IsAlreadyClosedException())
Expand All @@ -106,14 +106,11 @@ public virtual void TestCloseUnderException()

private sealed class FilterAtomicReaderAnonymousClass : FilterAtomicReader
{
private readonly TestIndexReaderClose outerInstance;
private readonly bool throwOnClose;

private bool throwOnClose;

public FilterAtomicReaderAnonymousClass(TestIndexReaderClose outerInstance, AtomicReader wrap, bool throwOnClose)
public FilterAtomicReaderAnonymousClass(AtomicReader wrap, bool throwOnClose)
: base(wrap)
{
this.outerInstance = outerInstance;
this.throwOnClose = throwOnClose;
}

Expand All @@ -129,7 +126,7 @@ protected internal override void DoClose()

private sealed class CountListener : IReaderDisposedListener
{
internal readonly AtomicInt32 count;
private readonly AtomicInt32 count;

public CountListener(AtomicInt32 count)
{
Expand All @@ -150,4 +147,4 @@ public void OnDispose(IndexReader reader)
}
}
}
}
}
13 changes: 6 additions & 7 deletions src/Lucene.Net.Tests/Index/TestIndexWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,8 @@ namespace Lucene.Net.Index
[TestFixture]
public class TestIndexWriter : LuceneTestCase
{
private static readonly FieldType storedTextType = new FieldType(TextField.TYPE_NOT_STORED);

#if FEATURE_INDEXWRITER_TESTS
private static readonly FieldType storedTextType = new FieldType(TextField.TYPE_NOT_STORED);

[Test]
public virtual void TestDocCount()
Expand Down Expand Up @@ -155,11 +154,11 @@ public virtual void TestDocCount()

/// <summary>
/// LUCENENET specific
/// Changed from internal static method to private to remove
/// Changed from internal method to private to remove
/// inter-dependencies between TestIndexWriter*.cs, TestAddIndexes.cs
/// and TestDeletionPolicy.cs tests
/// </summary>
private void AddDoc(IndexWriter writer)
private static void AddDoc(IndexWriter writer)
{
Document doc = new Document();
doc.Add(NewTextField("content", "aaa", Field.Store.NO));
Expand All @@ -168,11 +167,11 @@ private void AddDoc(IndexWriter writer)

/// <summary>
/// LUCENENET specific
/// Changed from internal static method to private to remove
/// Changed from internal method to private to remove
/// inter-dependencies between TestIndexWriter*.cs, TestAddIndexes.cs
/// and TestDeletionPolicy.cs tests
/// </summary>
private void AddDocWithIndex(IndexWriter writer, int index)
private static void AddDocWithIndex(IndexWriter writer, int index)
{
Document doc = new Document();
doc.Add(NewField("content", "aaa " + index, storedTextType));
Expand Down Expand Up @@ -2935,4 +2934,4 @@ public virtual void TestClosingNRTReaderDoesNotCorruptYourIndex()
}
#endif
}
}
}
Loading
Loading