BUG: Lucene.Net.Tests.Index.TestByteSlices.TestBasic(): This test was failing after upgrading to NUnit 3. As it turns out, the test will run the NUnit process out of memory and crash it if VERBOSE is true. So, added a local variable in the test to turn verbosity on manually, and if it is on, decreased the number of iterations by 1/3 to keep it from happening during debugging.
Project: http://git-wip-us.apache.org/repos/asf/lucenenet/repo Commit: http://git-wip-us.apache.org/repos/asf/lucenenet/commit/39e3fa24 Tree: http://git-wip-us.apache.org/repos/asf/lucenenet/tree/39e3fa24 Diff: http://git-wip-us.apache.org/repos/asf/lucenenet/diff/39e3fa24 Branch: refs/heads/api-work Commit: 39e3fa24cf8c0336ec05d76b08a1398daf7fa967 Parents: 72cdeed Author: Shad Storhaug <[email protected]> Authored: Sat Mar 4 20:37:37 2017 +0700 Committer: Shad Storhaug <[email protected]> Committed: Sun Mar 5 17:08:45 2017 +0700 ---------------------------------------------------------------------- src/Lucene.Net.Tests/Index/TestByteSlices.cs | 36 ++++++++++++++++------- 1 file changed, 25 insertions(+), 11 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/lucenenet/blob/39e3fa24/src/Lucene.Net.Tests/Index/TestByteSlices.cs ---------------------------------------------------------------------- diff --git a/src/Lucene.Net.Tests/Index/TestByteSlices.cs b/src/Lucene.Net.Tests/Index/TestByteSlices.cs index 9869364..c5b31ac 100644 --- a/src/Lucene.Net.Tests/Index/TestByteSlices.cs +++ b/src/Lucene.Net.Tests/Index/TestByteSlices.cs @@ -1,11 +1,10 @@ +using Lucene.Net.Attributes; +using Lucene.Net.Randomized.Generators; +using NUnit.Framework; using System; namespace Lucene.Net.Index { - using Attributes; - using Lucene.Net.Randomized.Generators; - using NUnit.Framework; - using ByteBlockPool = Lucene.Net.Util.ByteBlockPool; using LuceneTestCase = Lucene.Net.Util.LuceneTestCase; using RecyclingByteBlockAllocator = Lucene.Net.Util.RecyclingByteBlockAllocator; @@ -33,7 +32,16 @@ namespace Lucene.Net.Index [Test, HasTimeout] public virtual void TestBasic() { - fail("This test is somehow crashing NUnit and causing it not to complete"); + // LUCENENET specific: NUnit will crash with an OOM if we do the full test + // with verbosity enabled. So, making this a manual setting that can be + // turned on if, and only if, needed for debugging. If the setting is turned + // on, we are decresing the number of iterations by 1/3, which seems to + // keep it from crashing. + bool isVerbose = false; + if (!isVerbose) + { + Console.WriteLine("Verbosity disabled to keep NUnit from running out of memory - enable manually"); + } ByteBlockPool pool = new ByteBlockPool(new RecyclingByteBlockAllocator(ByteBlockPool.BYTE_BLOCK_SIZE, Random().Next(100))); @@ -55,7 +63,13 @@ namespace Lucene.Net.Index counters[stream] = 0; } - int num = AtLeast(3000); + // LUCENENET NOTE: Since upgrading to NUnit 3, this test + // will crash if VERBOSE is true because of an OutOfMemoryException. + // This not only keeps this test from finishing, it crashes NUnit + // and no other tests will run. + // So, we need to allocate a smaller size to ensure this + // doesn't happen with verbosity enabled. + int num = isVerbose ? AtLeast(2000) : AtLeast(3000); for (int iter = 0; iter < num; iter++) { int stream; @@ -68,7 +82,7 @@ namespace Lucene.Net.Index stream = Random().Next(NUM_STREAM); } - if (VERBOSE) + if (isVerbose) { Console.WriteLine("write stream=" + stream); } @@ -77,7 +91,7 @@ namespace Lucene.Net.Index { int spot = pool.NewSlice(ByteBlockPool.FIRST_LEVEL_SIZE); starts[stream] = uptos[stream] = spot + pool.ByteOffset; - if (VERBOSE) + if (isVerbose) { Console.WriteLine(" init to " + starts[stream]); } @@ -100,7 +114,7 @@ namespace Lucene.Net.Index for (int j = 0; j < numValue; j++) { - if (VERBOSE) + if (isVerbose) { Console.WriteLine(" write " + (counters[stream] + j)); } @@ -110,7 +124,7 @@ namespace Lucene.Net.Index } counters[stream] += numValue; uptos[stream] = writer.Address; - if (VERBOSE) + if (isVerbose) { Console.WriteLine(" addr now " + uptos[stream]); } @@ -118,7 +132,7 @@ namespace Lucene.Net.Index for (int stream = 0; stream < NUM_STREAM; stream++) { - if (VERBOSE) + if (isVerbose) { Console.WriteLine(" stream=" + stream + " count=" + counters[stream]); }
